:root {
    --primary: #0F766E;
    --primary-light: #14B8A6;
    --primary-dark: #0D5E58;
    --primary-50: #F0FDFA;
    --primary-100: #CCFBF1;
    --accent: #6366F1;
    --accent-light: #818CF8;
    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0F172A;
    --bg-sidebar-hover: #1E293B;
    --bg-sidebar-active: #1E3A5F;
    --text: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-sidebar: #CBD5E1;
    --text-sidebar-active: #FFFFFF;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 270px;
    --header-height: 64px;
    --triage-rosso: #DC2626;
    --triage-arancione: #EA580C;
    --triage-azzurro: #2563EB;
    --triage-verde: #16A34A;
    --triage-bianco: #6B7280;
    --success: #16A34A;
    --warning: #F59E0B;
    --danger: #DC2626;
    --info: #2563EB;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100vh;
}

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo-svg {
    width: 180px;
    height: auto;
    display: block;
}

.logo-icon {
    font-size: 32px;
    color: var(--primary-light);
    background: rgba(20, 184, 166, 0.12);
    padding: 8px;
    border-radius: var(--radius-sm);
}

.logo-text { display: flex; flex-direction: column; }
.logo-title { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -0.3px; }
.logo-subtitle { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 1px; }

.sidebar-close {
    display: none;
    position: absolute;
    top: 20px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-sidebar);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-xs);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 12px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-section { margin-bottom: 20px; }
.nav-section-title {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(148, 163, 184, 0.6);
    padding: 0 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
}

.nav-item .material-symbols-rounded {
    font-size: 20px;
    opacity: 0.8;
}

.nav-item.active .material-symbols-rounded { opacity: 1; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.logout-btn {
    color: var(--text-muted);
    padding: 6px;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
    text-decoration: none;
}
.logout-btn:hover { color: var(--danger); background: rgba(220, 38, 38, 0.1); }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .main-content {
    margin-left: 0;
}

.top-header {
    height: var(--header-height);
    background: var(--bg-sidebar);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    gap: 16px;
    position: relative;
}

.header-left { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.header-center {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    display: flex; align-items: center; pointer-events: none;
}
.header-logo-desktop { height: 32px; width: auto; pointer-events: auto; }
.header-logo-mobile { display: none; height: 28px; width: auto; }
.header-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; flex-shrink: 0; }

.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: #E2E8F0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}
.menu-toggle:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--primary-light);
    color: #FFFFFF;
    transform: scale(1.05);
}
.menu-toggle:active {
    transform: scale(0.95);
}
.menu-toggle .material-symbols-rounded {
    font-size: 22px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
body.sidebar-collapsed .menu-toggle .material-symbols-rounded {
    transform: rotate(180deg);
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: #F1F5F9;
    letter-spacing: -0.3px;
}

.header-datetime, .header-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #CBD5E1;
    background: rgba(255,255,255,0.08);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.1);
}
.header-datetime .material-symbols-rounded,
.header-badge .material-symbols-rounded { font-size: 16px; color: #60A5FA; }

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scrollbar-width: thin;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card.card-teal::before { background: var(--primary); }
.stat-card.card-orange::before { background: var(--warning); }
.stat-card.card-blue::before { background: var(--info); }
.stat-card.card-green::before { background: var(--success); }
.stat-card.card-red::before { background: var(--danger); }

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card-icon .material-symbols-rounded { font-size: 22px; }

.stat-card.card-teal .stat-card-icon { background: var(--primary-50); color: var(--primary); }
.stat-card.card-orange .stat-card-icon { background: #FFF7ED; color: var(--warning); }
.stat-card.card-blue .stat-card-icon { background: #EFF6FF; color: var(--info); }
.stat-card.card-green .stat-card-icon { background: #F0FDF4; color: var(--success); }
.stat-card.card-red .stat-card-icon { background: #FEF2F2; color: var(--danger); }

.stat-card-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    letter-spacing: -1px;
}

.stat-card-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .material-symbols-rounded {
    font-size: 20px;
    color: var(--primary);
}

.card-body { padding: 20px; }
.card-body.no-padding { padding: 0; }

.table-container { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

table tbody tr { transition: background var(--transition); }
table tbody tr:hover { background: var(--primary-50); }
table tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.badge-success { background: #DCFCE7; color: #15803D; }
.badge-warning { background: #FEF3C7; color: #B45309; }
.badge-danger { background: #FEE2E2; color: #B91C1C; }
.badge-info { background: #DBEAFE; color: #1D4ED8; }
.badge-primary { background: var(--primary-100); color: var(--primary-dark); }
.badge-secondary { background: #F1F5F9; color: #475569; }
.badge-dark { background: #1E293B; color: #E2E8F0; }

.triage-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.triage-1 { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.triage-2 { background: #FED7AA; color: #9A3412; border: 1px solid #FDBA74; }
.triage-3 { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }
.triage-4 { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.triage-5 { background: #F3F4F6; color: #374151; border: 1px solid #E5E7EB; }

.triage-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.triage-dot.code-1 { background: var(--triage-rosso); box-shadow: 0 0 6px rgba(220,38,38,0.5); }
.triage-dot.code-2 { background: var(--triage-arancione); box-shadow: 0 0 6px rgba(234,88,12,0.5); }
.triage-dot.code-3 { background: var(--triage-azzurro); box-shadow: 0 0 6px rgba(37,99,235,0.4); }
.triage-dot.code-4 { background: var(--triage-verde); }
.triage-dot.code-5 { background: var(--triage-bianco); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn .material-symbols-rounded { font-size: 18px; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-light); border-color: var(--text-muted); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803D; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: #06b6d4; color: #fff; }
.btn-info:hover { background: #0891b2; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-sm .material-symbols-rounded { font-size: 16px; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-xs);
}

.btn-icon.btn-sm { width: 30px; height: 30px; }

.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}

.form-control {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-card);
    transition: all var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2394A3B8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.form-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
}

.form-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.form-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section-title .material-symbols-rounded {
    font-size: 18px;
    color: var(--primary);
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.dolor-scale {
    display: flex;
    gap: 4px;
    align-items: center;
}

.dolor-level {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-card);
}

.dolor-level:hover { transform: scale(1.1); }
.dolor-level.selected { border-color: currentColor; color: #fff; }
.dolor-level[data-val="0"] { color: var(--success); }
.dolor-level[data-val="1"], .dolor-level[data-val="2"] { color: #65A30D; }
.dolor-level[data-val="3"], .dolor-level[data-val="4"] { color: var(--warning); }
.dolor-level[data-val="5"], .dolor-level[data-val="6"] { color: #EA580C; }
.dolor-level[data-val="7"], .dolor-level[data-val="8"] { color: #DC2626; }
.dolor-level[data-val="9"], .dolor-level[data-val="10"] { color: #991B1B; }
.dolor-level.selected[data-val="0"] { background: var(--success); }
.dolor-level.selected[data-val="1"], .dolor-level.selected[data-val="2"] { background: #65A30D; }
.dolor-level.selected[data-val="3"], .dolor-level.selected[data-val="4"] { background: var(--warning); }
.dolor-level.selected[data-val="5"], .dolor-level.selected[data-val="6"] { background: #EA580C; }
.dolor-level.selected[data-val="7"], .dolor-level.selected[data-val="8"] { background: #DC2626; }
.dolor-level.selected[data-val="9"], .dolor-level.selected[data-val="10"] { background: #991B1B; }

.triage-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.triage-option {
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
    background: var(--bg-card);
}

.triage-option:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.triage-option.selected { border-width: 3px; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.triage-option[data-code="1"].selected { border-color: var(--triage-rosso); background: #FEF2F2; }
.triage-option[data-code="2"].selected { border-color: var(--triage-arancione); background: #FFF7ED; }
.triage-option[data-code="3"].selected { border-color: var(--triage-azzurro); background: #EFF6FF; }
.triage-option[data-code="4"].selected { border-color: var(--triage-verde); background: #F0FDF4; }
.triage-option[data-code="5"].selected { border-color: var(--triage-bianco); background: #F9FAFB; }

.triage-option-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin: 0 auto 8px;
}

.triage-option[data-code="1"] .triage-option-dot { background: var(--triage-rosso); }
.triage-option[data-code="2"] .triage-option-dot { background: var(--triage-arancione); }
.triage-option[data-code="3"] .triage-option-dot { background: var(--triage-azzurro); }
.triage-option[data-code="4"] .triage-option-dot { background: var(--triage-verde); }
.triage-option[data-code="5"] .triage-option-dot { background: var(--triage-bianco); }

.triage-option-name { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.triage-option-label { font-size: 10px; color: var(--text-muted); }

.vital-signs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.vital-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
    border: 1px solid var(--border-light);
}

.vital-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.vital-value { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.2; }
.vital-unit { font-size: 10px; color: var(--text-muted); }

.triage-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.triage-column {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.triage-column-header {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.triage-column[data-code="1"] .triage-column-header { background: #FEE2E2; color: #991B1B; }
.triage-column[data-code="2"] .triage-column-header { background: #FED7AA; color: #9A3412; }
.triage-column[data-code="3"] .triage-column-header { background: #DBEAFE; color: #1E40AF; }
.triage-column[data-code="4"] .triage-column-header { background: #DCFCE7; color: #166534; }
.triage-column[data-code="5"] .triage-column-header { background: #F3F4F6; color: #374151; }

.triage-column-count {
    font-size: 18px;
    font-weight: 800;
}

.triage-column-body {
    padding: 8px;
    min-height: 100px;
    max-height: 400px;
    overflow-y: auto;
}

.triage-patient-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.triage-patient-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow);
}

.triage-patient-name { font-size: 13px; font-weight: 600; color: var(--text); }
.triage-patient-info { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.triage-patient-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.triage-patient-time .material-symbols-rounded { font-size: 14px; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.98);
    transition: all 0.3s ease;
}

.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-xs);
}
.modal-close:hover { color: var(--text); background: var(--bg); }

.modal-body { padding: 20px; }
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-lg { max-width: 900px; }
.modal-fullscreen { max-width: 95vw; width: 95vw; max-height: 95vh; height: 95vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-fullscreen .modal-body { flex: 1; overflow-y: auto; min-height: 0; }
.modal-close-visible {
    background: rgba(255,255,255,0.15) !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    transition: all .2s !important;
}
.modal-close-visible:hover {
    background: rgba(255,255,255,0.3) !important;
    color: #fff !important;
}
.modal-btn-confirm {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .2s;
}
.modal-btn-green { background: linear-gradient(135deg, #059669, #047857); }
.modal-btn-green:hover { background: linear-gradient(135deg, #047857, #065F46); box-shadow: 0 4px 12px rgba(5,150,105,0.3); }
.modal-btn-blue { background: linear-gradient(135deg, #0EA5E9, #0284C7); }
.modal-btn-blue:hover { background: linear-gradient(135deg, #0284C7, #0369A1); box-shadow: 0 4px 12px rgba(14,165,233,0.3); }
.modal-btn-orange { background: linear-gradient(135deg, #F97316, #EA580C); }
.modal-btn-orange:hover { background: linear-gradient(135deg, #EA580C, #C2410C); box-shadow: 0 4px 12px rgba(249,115,22,0.3); }
.modal-btn-red { background: linear-gradient(135deg, #DC2626, #B91C1C); }
.modal-btn-red:hover { background: linear-gradient(135deg, #B91C1C, #991B1B); box-shadow: 0 4px 12px rgba(220,38,38,0.3); }
.modal-btn-print {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all .2s;
}
.modal-btn-print:hover { background: rgba(255,255,255,0.25); }
.modal-section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.modal-section-card {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    padding: 16px;
}
.modal-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid #E2E8F0;
}
.modal-section-title .material-symbols-rounded { font-size: 20px; color: #3B82F6; }
.modal-info-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.5;
}
.modal-info-blue { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF; }
.modal-info-blue .material-symbols-rounded { color: #2563EB; font-size: 22px; flex-shrink: 0; }
.modal-info-red { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }
.modal-info-red .material-symbols-rounded { color: #DC2626; font-size: 22px; flex-shrink: 0; }
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.raccomandazioni-checkboxes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
.racc-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: #334155;
    cursor: pointer;
    transition: background .15s;
    line-height: 1.4;
}
.racc-check:hover { background: #E2E8F0; }
.racc-check input { margin-top: 2px; flex-shrink: 0; accent-color: #3B82F6; }
.farmaci-search-wrap { position: relative; }
.farmaci-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.farmaco-suggestion {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #F1F5F9;
    transition: background .1s;
}
.farmaco-suggestion:hover { background: #EFF6FF; }
.farmaco-suggestion .farmaco-nome { font-weight: 600; color: #1E293B; }
.farmaco-suggestion .farmaco-classe { font-size: 11px; color: #64748B; margin-top: 2px; }
.farmaci-list-added { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.farmaco-added {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    border-radius: 8px;
    font-size: 13px;
}
.farmaco-added .farmaco-info { flex: 1; }
.farmaco-added .farmaco-info strong { color: #166534; }
.farmaco-added .farmaco-posologia {
    flex: 1;
    font-size: 12px;
}
.farmaco-added .farmaco-posologia input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #BBF7D0;
    border-radius: 4px;
    font-size: 12px;
    background: #fff;
}
.farmaco-remove {
    background: none;
    border: none;
    color: #DC2626;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: background .15s;
}
.farmaco-remove:hover { background: #FEE2E2; }
.cartella-body { padding: 0 !important; background: #F1F5F9; }
.cartella-container { max-width: 1000px; margin: 0 auto; padding: 24px; }
.cartella-header-section {
    background: linear-gradient(135deg, #1E293B, #334155);
    color: #fff;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
}
.cartella-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}
.cartella-hospital { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.7; margin-bottom: 4px; }
.cartella-title { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.cartella-patient-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 16px;
}
.cartella-field { font-size: 12px; }
.cartella-field-label { opacity: 0.6; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.cartella-field-value { font-weight: 600; }
.cartella-triage-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
}
.cartella-accesso-info {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 16px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    margin-bottom: 20px;
}
.cartella-accesso-field { font-size: 13px; }
.cartella-accesso-label { font-size: 11px; color: #64748B; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.cartella-accesso-value { font-weight: 600; color: #1E293B; }
.cartella-section {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    margin-bottom: 16px;
    overflow: hidden;
}
.cartella-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 700;
    color: #1E293B;
    border-bottom: 1px solid #E2E8F0;
    background: #F8FAFC;
}
.cartella-section-header .material-symbols-rounded { font-size: 22px; }
.cartella-section-header .section-count {
    margin-left: auto;
    background: #E2E8F0;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    color: #64748B;
}
.cartella-section-body { padding: 16px 18px; }
.cartella-timeline { position: relative; padding-left: 24px; }
.cartella-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #E2E8F0;
}
.cartella-tl-item {
    position: relative;
    padding: 12px 0;
    border-bottom: 1px solid #F1F5F9;
}
.cartella-tl-item:last-child { border-bottom: none; }
.cartella-tl-dot {
    position: absolute;
    left: -20px;
    top: 16px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3B82F6;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #E2E8F0;
}
.cartella-tl-dot.dot-green { background: #22C55E; }
.cartella-tl-dot.dot-orange { background: #F97316; }
.cartella-tl-dot.dot-red { background: #DC2626; }
.cartella-tl-dot.dot-purple { background: #8B5CF6; }
.cartella-tl-time { font-size: 11px; color: #94A3B8; font-weight: 600; }
.cartella-tl-title { font-size: 14px; font-weight: 600; color: #1E293B; margin: 2px 0; }
.cartella-tl-desc { font-size: 13px; color: #475569; line-height: 1.5; }
.cartella-tl-medico { font-size: 12px; color: #64748B; margin-top: 4px; font-style: italic; }
.cartella-vitali-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.cartella-vitale-card {
    text-align: center;
    padding: 6px 10px;
    background: #F8FAFC;
    border-radius: 6px;
    border: 1px solid #E2E8F0;
    min-width: 80px;
    flex: 1 1 auto;
}
.cartella-vitale-icon { font-size: 16px; color: #3B82F6; }
.cartella-vitale-value { font-size: 14px; font-weight: 700; color: #1E293B; margin: 2px 0; line-height: 1.2; }
.cartella-vitale-label { font-size: 10px; color: #64748B; }
.cartella-lab-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin-top: 10px;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.cartella-lab-2col-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 14px;
    border-bottom: 1px solid #F1F5F9;
    font-size: 13px;
}
.cartella-lab-2col-item:nth-child(odd) {
    border-right: 1px solid #F1F5F9;
}
.cartella-lab-2col-name {
    color: #475569;
    font-weight: 500;
}
.cartella-lab-2col-val {
    font-weight: 700;
    color: #1E293B;
    text-align: right;
    min-width: 60px;
}
.cartella-lab-2col-val.lab-pending {
    color: #94A3B8;
    font-weight: 400;
}
.cartella-lab-2col-val.lab-value-abnormal {
    color: #DC2626;
}
.lab-ref-unit {
    font-size: 10px;
    color: #94A3B8;
    font-weight: 400;
}
.lab-ref-range {
    font-size: 10px;
    color: #94A3B8;
    font-weight: 400;
}
.cartella-referto-box {
    margin-top: 10px;
    padding: 12px 16px;
    background: #F0FDF4;
    border-radius: 8px;
    border-left: 4px solid #22C55E;
    font-size: 13px;
    color: #1E293B;
}
.cartella-referto-box .referto-label {
    font-weight: 700;
    color: #166534;
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cartella-diag-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.cartella-diag-images img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #E2E8F0;
    cursor: pointer;
    transition: transform 0.2s;
}
.cartella-diag-images img:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.cartella-diag-medico-info {
    font-size: 12px;
    color: #64748B;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.cartella-diag-desc {
    margin-top: 6px;
    font-size: 13px;
    color: #334155;
    line-height: 1.5;
}
.cartella-lab-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.cartella-lab-table th {
    text-align: left;
    padding: 8px 12px;
    background: #F1F5F9;
    font-weight: 600;
    color: #475569;
    font-size: 11px;
    text-transform: uppercase;
    border-bottom: 2px solid #E2E8F0;
}
.cartella-lab-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #F1F5F9;
}
.cartella-lab-table tr:hover { background: #F8FAFC; }
.lab-value-abnormal { color: #DC2626; font-weight: 700; }
.lab-value-normal { color: #1E293B; }
.cartella-diag-card {
    padding: 14px;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    margin-bottom: 10px;
    background: #FAFBFC;
}
.cartella-diag-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.cartella-diag-title { font-weight: 600; font-size: 14px; color: #1E293B; }
.cartella-diag-stato {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.cartella-diag-stato-completata { background: #DCFCE7; color: #166534; }
.cartella-diag-stato-in_corso { background: #FEF3C7; color: #92400E; }
.cartella-diag-stato-richiesta { background: #E0E7FF; color: #3730A3; }
.cartella-diag-result {
    padding: 10px;
    background: #F0FDF4;
    border-radius: 6px;
    font-size: 13px;
    color: #166534;
    margin-top: 8px;
    border: 1px solid #BBF7D0;
}
.cartella-esito-section {
    background: linear-gradient(135deg, #059669, #047857);
    color: #fff;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 16px;
}
.cartella-esito-title { font-size: 18px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.cartella-esito-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cartella-esito-field .cartella-field-label { opacity: 0.7; }
.cartella-allegati-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}
.cartella-allegato-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
}
.cartella-allegato-card:hover { background: #EFF6FF; border-color: #93C5FD; }
.cartella-footer {
    text-align: center;
    padding: 20px;
    color: #94A3B8;
    font-size: 11px;
    border-top: 1px solid #E2E8F0;
    margin-top: 20px;
}
@media (max-width: 768px) {
    .modal-section-grid { grid-template-columns: 1fr; }
    .form-row-2col { grid-template-columns: 1fr; }
    .raccomandazioni-checkboxes { grid-template-columns: 1fr; }
    .cartella-patient-grid { grid-template-columns: 1fr 1fr; }
    .cartella-accesso-info { grid-template-columns: 1fr 1fr; }
    .cartella-esito-grid { grid-template-columns: 1fr; }

    /* Modal overlay centrato, nessun padding (il padding è sul modal) */
    .modal-overlay { align-items: center; padding: 0; }

    /* Modal non-fullscreen su mobile: larghezza viewport - 24px, scroll nativo sul modal */
    .modal-overlay .modal:not(.modal-fullscreen) {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        max-height: 88dvh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
        border-radius: 12px;
    }

    /* Header: sticky in cima, compatto */
    .modal-overlay .modal:not(.modal-fullscreen) .modal-header {
        position: sticky;
        top: 0;
        z-index: 5;
        padding: 10px 12px;
        align-items: center;
        gap: 6px;
    }
    .modal-overlay .modal:not(.modal-fullscreen) .modal-title {
        font-size: 13px;
        line-height: 1.25;
        flex: 1;
        min-width: 0;
        font-weight: 700;
    }
    .modal-overlay .modal:not(.modal-fullscreen) .modal-title .material-symbols-rounded {
        font-size: 16px;
        flex-shrink: 0;
    }
    .modal-overlay .modal:not(.modal-fullscreen) .modal-close {
        flex-shrink: 0;
    }

    /* Body modal: padding ridotto */
    .modal-overlay .modal:not(.modal-fullscreen) .modal-body {
        padding: 14px;
    }

    /* Footer: sticky in fondo */
    .modal-overlay .modal:not(.modal-fullscreen) .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border-light);
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
        z-index: 5;
    }
    .modal-overlay .modal:not(.modal-fullscreen) .modal-footer .btn {
        flex: 1;
        min-width: 100px;
        justify-content: center;
    }

    /* Fix iOS Safari: datetime-local e date input non sfondano il container */
    input[type="datetime-local"].form-control,
    input[type="date"].form-control,
    input[type="time"].form-control {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        -webkit-appearance: none;
        appearance: none;
    }

    /* Fullscreen modal: occupa tutto il viewport */
    .modal-fullscreen { max-width: 100vw; width: 100vw; max-height: 100dvh; height: 100dvh; max-height: -webkit-fill-available; border-radius: 0; margin: 0; overflow: hidden; padding: 0; }
    .modal-fullscreen .modal-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .modal-fullscreen .modal-header { flex-shrink: 0; padding: 10px 12px; }
    .modal-fullscreen .modal-header .modal-title { font-size: 13px; gap: 6px; }
    .modal-fullscreen .modal-header .modal-title .material-symbols-rounded { font-size: 18px; }
    .modal-fullscreen .modal-header .modal-btn-print span:not(.material-symbols-rounded) { display: none; }
    .modal-fullscreen .modal-header .modal-btn-print { padding: 6px 10px; font-size: 0; }
    .modal-fullscreen .modal-header .modal-btn-print .material-symbols-rounded { font-size: 18px; }
    .modal-fullscreen .modal-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: env(safe-area-inset-bottom, 16px); }

    /* Form grids nel modal: colonna singola su mobile */
    .modal .wizard-form-grid { grid-template-columns: 1fr; }
    .modal .wizard-form-grid-3 { grid-template-columns: 1fr; }

    /* Triage selector nel modal edit: 5 colonne strette */
    #editTriageSelector.triage-selector { grid-template-columns: repeat(5, 1fr); gap: 4px; }
    #editTriageSelector .triage-select-option { padding: 8px 4px; }
    #editTriageSelector .triage-select-name { font-size: 9px; }
    #editTriageSelector .triage-select-label { font-size: 8px; }
    #editTriageSelector .triage-select-dot { width: 16px; height: 16px; margin-bottom: 2px; }
}

.dett-container { padding: 0; }
.dett-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid #E2E8F0;
}
.dett-header-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dett-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dett-stato-badge {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
}
.dett-stato-in_attesa { background: #FEF3C7; color: #92400E; }
.dett-stato-in_visita { background: #DBEAFE; color: #1E40AF; }
.dett-stato-in_diagnostica { background: #E0E7FF; color: #3730A3; }
.dett-stato-in_osservazione { background: #CFFAFE; color: #155E75; }
.dett-stato-dimesso { background: #DCFCE7; color: #166534; }
.dett-stato-ricoverato { background: #FED7AA; color: #9A3412; }
.dett-tabs {
    display: flex;
    gap: 0;
    background: #fff;
    border-bottom: 2px solid #E2E8F0;
    padding: 0 24px;
    overflow-x: auto;
}
.dett-tab {
    padding: 12px 20px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: #64748B;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: all .15s;
}
.dett-tab:hover { color: #1E293B; background: #F8FAFC; }
.dett-tab.active { color: #1E40AF; border-bottom-color: #1E40AF; }
.dett-tab-content { padding: 20px 24px; }
.dett-section {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    padding: 18px;
    margin-bottom: 16px;
}
.dett-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #E2E8F0;
}
.dett-section-title .material-symbols-rounded { font-size: 20px; color: #3B82F6; }
.dett-field-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
.dett-field { margin-bottom: 10px; }
.dett-field-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}
.dett-field-value { font-size: 14px; font-weight: 500; color: #1E293B; }
.dett-input {
    font-size: 13px !important;
    padding: 8px 10px !important;
    border-radius: 6px !important;
}
.dett-save-bar {
    display: flex;
    justify-content: flex-end;
    padding: 16px 0 0;
    border-top: 1px solid #E2E8F0;
    margin-top: 16px;
}
.detail-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: #64748B;
    font-size: 15px;
}
@media (max-width: 768px) {
    .dett-field-grid { grid-template-columns: 1fr 1fr; }
    .dett-header-bar { flex-direction: column; align-items: flex-start; padding: 12px 16px; gap: 8px; }
    .dett-header-actions { width: 100%; }
    .dett-header-actions .btn { flex: 1; justify-content: center; font-size: 11px; padding: 6px 8px; }
    .dett-tabs { padding: 0 8px; gap: 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .dett-tabs::-webkit-scrollbar { display: none; }
    .dett-tab { padding: 10px 12px; font-size: 11px; flex-shrink: 0; }
    .dett-tab-content { padding: 14px 12px; }
    .dett-save-bar { position: sticky; bottom: 0; background: #fff; padding: 12px 16px; margin: 0 -12px; border-top: 1px solid #E2E8F0; z-index: 3; }
    .dett-save-bar .btn { width: 100%; justify-content: center; }
    .dett-section { padding: 14px; }
    .dett-section-title { font-size: 14px; }
}
@media (max-width: 480px) {
    .dett-field-grid { grid-template-columns: 1fr; }
}

@media print {
    body:not(.printing-consegne):not(.printing-cartella) .modal-overlay { position: static !important; background: none !important; }
    body:not(.printing-consegne):not(.printing-cartella) .modal { max-width: 100% !important; width: 100% !important; max-height: none !important; border-radius: 0 !important; box-shadow: none !important; }
    .modal-header, .modal-footer, .modal-close-visible, .modal-btn-print { display: none !important; }
    .cartella-body { overflow: visible !important; }
    .cartella-section { break-inside: avoid; }

    body.printing-cartella {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 11px !important;
    }
    body.printing-cartella * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    body.printing-cartella > *:not(#cartellaPrintContainer) {
        display: none !important;
    }
    body.printing-cartella #cartellaPrintContainer {
        display: block !important;
        position: static !important;
        background: #fff !important;
        overflow: visible !important;
        z-index: auto !important;
        width: 100% !important;
        height: auto !important;
    }
    body.printing-cartella .cartella-container {
        padding: 10px !important;
    }
    body.printing-cartella .cartella-header-section {
        background: #1E293B !important;
        color: #fff !important;
        padding: 12px 16px !important;
        border-radius: 0 !important;
        margin-bottom: 10px !important;
    }
    body.printing-cartella .cartella-header-top {
        margin-bottom: 8px !important;
    }
    body.printing-cartella .cartella-hospital {
        font-size: 10px !important;
    }
    body.printing-cartella .cartella-title {
        font-size: 16px !important;
    }
    body.printing-cartella .cartella-triage-badge {
        padding: 3px 10px !important;
        font-size: 11px !important;
    }
    body.printing-cartella .cartella-patient-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
        font-size: 11px !important;
    }
    body.printing-cartella .cartella-field-label {
        font-size: 8px !important;
    }
    body.printing-cartella .cartella-field-value {
        font-size: 11px !important;
    }
    body.printing-cartella .cartella-section {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        margin-bottom: 8px !important;
        padding: 10px !important;
        border: 1px solid #CBD5E1 !important;
        border-radius: 6px !important;
    }
    body.printing-cartella .cartella-section-header {
        font-size: 12px !important;
        margin-bottom: 6px !important;
        padding-bottom: 4px !important;
    }
    body.printing-cartella .cartella-section-body {
        font-size: 11px !important;
    }
    body.printing-cartella .cartella-accesso-info {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
        margin-bottom: 8px !important;
        font-size: 11px !important;
    }
    body.printing-cartella .cartella-vitali-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }
    body.printing-cartella .cartella-vitale-card {
        padding: 6px !important;
        border: 1px solid #E2E8F0 !important;
        border-radius: 4px !important;
        text-align: center !important;
    }
    body.printing-cartella .cartella-vitale-value {
        font-size: 14px !important;
        font-weight: 700 !important;
    }
    body.printing-cartella .cartella-vitale-label {
        font-size: 9px !important;
    }
    body.printing-cartella .cartella-timeline {
        padding-left: 16px !important;
    }
    body.printing-cartella .cartella-tl-item {
        padding-bottom: 8px !important;
        break-inside: avoid !important;
    }
    body.printing-cartella .cartella-tl-time {
        font-size: 10px !important;
    }
    body.printing-cartella .cartella-tl-title {
        font-size: 11px !important;
    }
    body.printing-cartella .cartella-tl-desc {
        font-size: 10px !important;
    }
    body.printing-cartella .cartella-lab-2col {
        grid-template-columns: 1fr 1fr !important;
        font-size: 10px !important;
    }
    body.printing-cartella .cartella-lab-2col-item {
        padding: 3px 8px !important;
        font-size: 10px !important;
    }
    body.printing-cartella .cartella-referto-box {
        font-size: 10px !important;
        padding: 6px 10px !important;
    }
    body.printing-cartella .cartella-diag-images img {
        width: 60px !important;
        height: 60px !important;
    }
    body.printing-cartella .cartella-diag-card {
        break-inside: avoid !important;
        padding: 8px !important;
        margin-bottom: 6px !important;
        border: 1px solid #E2E8F0 !important;
        border-radius: 4px !important;
    }
    body.printing-cartella .cartella-lab-table {
        font-size: 10px !important;
        width: 100% !important;
        border-collapse: collapse !important;
    }
    body.printing-cartella .cartella-lab-table th,
    body.printing-cartella .cartella-lab-table td {
        padding: 3px 6px !important;
        border: 1px solid #CBD5E1 !important;
    }
    body.printing-cartella .cartella-lab-table th {
        background: #F1F5F9 !important;
        font-weight: 700 !important;
    }
    body.printing-cartella .lab-value-abnormal {
        color: #DC2626 !important;
        font-weight: 700 !important;
    }
    body.printing-cartella .cartella-esito-section {
        break-inside: avoid !important;
        border: 2px solid #059669 !important;
        border-radius: 6px !important;
        padding: 10px !important;
        margin-top: 8px !important;
    }
    body.printing-cartella .cartella-esito-title {
        font-size: 13px !important;
        color: #059669 !important;
    }
    body.printing-cartella .cartella-esito-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }
    body.printing-cartella .cartella-footer {
        font-size: 9px !important;
        text-align: center !important;
        color: #94A3B8 !important;
        margin-top: 12px !important;
        padding-top: 8px !important;
        border-top: 1px solid #E2E8F0 !important;
    }
    body.printing-cartella .cartella-allegati-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
    }
    body.printing-cartella .section-count {
        display: inline-block !important;
    }
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .material-symbols-rounded { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state-text { font-size: 13px; }

.search-box {
    position: relative;
    max-width: 320px;
}

.search-box .material-symbols-rounded {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-muted);
}

.search-box .form-control { padding-left: 36px; }

.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.patient-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.detail-item { margin-bottom: 12px; }
.detail-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.detail-value { font-size: 14px; color: var(--text); font-weight: 500; }

.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-card);
}

.timeline-time { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.timeline-content { font-size: 13px; color: var(--text); }
.timeline-author { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 280px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    padding: 24px;
    position: relative;
    overflow: hidden;
}
.login-video-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.login-container {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.15);
    border: 2px solid transparent;
    position: relative;
}
.login-card::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 22px;
    padding: 3px;
    pointer-events: none;
    background: linear-gradient(
        var(--aura-angle, 0deg),
        #06B6D4, #8B5CF6, #EC4899, #EF4444, #F59E0B, #10B981, #06B6D4
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    animation: auraRotate 4s linear infinite;
}
@property --aura-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}
@keyframes auraRotate {
    to { --aura-angle: 360deg; }
}

.login-banner {
    background: rgba(15, 23, 42, 0.7);
    padding: 36px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px 18px 0 0;
}

.login-banner-logo {
    width: 280px;
    height: auto;
    display: block;
}

.login-body-wrap {
    padding: 32px 40px 40px;
}

.login-title { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -0.5px; }
.login-subtitle { font-size: 13px; color: rgba(255,255,255,0.6); margin-top: 4px; }

.login-body-wrap .form-label { color: rgba(255,255,255,0.85); font-weight: 600; }
.login-form .form-control {
    padding: 11px 14px;
    font-size: 14px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
}
.login-form .form-control::placeholder { color: rgba(255,255,255,0.4); }
.login-form .form-control:focus {
    background: rgba(255,255,255,0.15);
    border-color: rgba(139,92,246,0.6);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.2);
    color: #fff;
}
.login-form .btn { width: 100%; padding: 12px; font-size: 14px; }
.login-body-wrap .text-muted { color: rgba(255,255,255,0.45) !important; }

.login-error {
    background: #FEF2F2;
    color: #B91C1C;
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.unauthorized-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-gap { display: flex; align-items: center; gap: 8px; }
.flex-wrap-gap { display: flex; flex-wrap: wrap; gap: 8px; }

.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }

.pulse-dot {
    animation: pulse 2s infinite;
}

.settings-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.settings-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
    cursor: pointer;
}

.settings-tab:hover {
    background: var(--bg);
    color: var(--text);
}

.settings-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.settings-tab .material-symbols-rounded {
    font-size: 20px;
}

.settings-panel {
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #CBD5E1;
    border-radius: 26px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    left: 3px;
    top: 3px;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

.logo-upload-area {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.logo-preview {
    width: 140px;
    height: 140px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg);
    flex-shrink: 0;
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.logo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.logo-upload-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-actions {
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
    margin-top: 16px;
}

.alert-box {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.alert-success {
    background: #DCFCE7;
    border: 1px solid #BBF7D0;
    color: #166534;
}

.alert-error {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: #991B1B;
}

.sidebar-logo-img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
}

.shift-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.08) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
}

.shift-badge-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.shift-badge-text span:last-child {
    color: #94A3B8 !important;
}

.shift-stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

.shift-stat-item {
    text-align: center;
    padding: 16px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.shift-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.shift-stat-value small {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.shift-stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shift-row-active {
    background: var(--primary-50) !important;
}

.shift-config-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 16px;
}

.shift-config-card {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.shift-config-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.triage-action-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}
.triage-action-bar-center {
    justify-content: center;
}

.btn-nuovo-triage {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    background: linear-gradient(135deg, #DC2626, #B91C1C);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
    text-transform: uppercase;
}

.btn-nuovo-triage:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.45);
    background: linear-gradient(135deg, #EF4444, #DC2626);
}

.btn-nuovo-triage:active {
    transform: translateY(0);
}

.btn-nuovo-triage .material-symbols-rounded {
    font-size: 22px;
    animation: pulse 2s ease-in-out infinite;
}

.triage-priority-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.triage-priority-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 1px solid var(--border-light);
}

.triage-priority-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--triage-color);
}

.triage-priority-indicator {
    height: 4px;
    width: 100%;
}

.triage-priority-content {
    padding: 16px;
    text-align: center;
}

.triage-priority-count {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.triage-priority-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.triage-priority-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.triage-priority-wait {
    font-size: 10px;
    color: var(--text-muted);
    background: var(--border-light);
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}

.triage-priority-immediate {
    background: #FEE2E2;
    color: #DC2626;
    font-weight: 600;
}

.patient-link {
    color: var(--text);
    text-decoration: none;
    transition: color 0.15s;
}
.patient-link:hover {
    color: var(--primary);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #15803D);
    color: #fff;
    border: none;
}
.btn-success:hover {
    background: linear-gradient(135deg, #22C55E, var(--success));
}

.triage-wizard-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
    padding: 0;
}

.triage-wizard-overlay.active {
    display: flex;
}

.triage-wizard {
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.triage-wizard #formTriageWizard {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.triage-wizard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-sidebar);
    color: #fff;
    flex-shrink: 0;
}

.triage-wizard-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.triage-wizard-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.triage-wizard-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
}

.triage-wizard-header-logo {
    display: none;
}

.triage-wizard-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.triage-wizard-close:hover {
    background: rgba(255,255,255,0.2);
}

.triage-wizard-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 0;
}

.wizard-step-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.3s;
    white-space: nowrap;
}

.wizard-step-indicator.active {
    color: var(--primary);
    font-weight: 600;
}

.wizard-step-indicator.completed {
    color: var(--success);
}

.wizard-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border-light);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    transition: all 0.3s;
    flex-shrink: 0;
}

.wizard-step-indicator.active .wizard-step-num {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.3);
}

.wizard-step-indicator.completed .wizard-step-num {
    background: var(--success);
    color: #fff;
}

.wizard-step-line {
    width: 32px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
}

.triage-wizard-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 24px 40px;
    width: 100%;
    min-height: 0;
    box-sizing: border-box;
}

.wizard-panel {
    display: none;
}

.wizard-panel.active {
    display: block;
    animation: fadeSlideIn 0.3s ease;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.wizard-panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.wizard-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.wizard-panel-title .material-symbols-rounded {
    font-size: 26px;
    color: var(--primary);
}

.wizard-panel-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

.wizard-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.wizard-form-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.wizard-section-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 24px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.wizard-section-divider .material-symbols-rounded {
    font-size: 20px;
    color: var(--primary);
}

.wizard-dolor-scale {
    gap: 6px !important;
}

.triage-wizard-footer {
    display: flex;
    align-items: center;
    padding: 16px 40px;
    background: var(--bg-card);
    border-top: 2px solid var(--primary);
    flex-shrink: 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
    z-index: 10;
}
.triage-wizard-footer .btn {
    min-width: 140px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 700;
}

.symptom-categories {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.symptom-search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.symptom-search-box .material-symbols-rounded {
    font-size: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.symptom-search-box .form-control {
    border: none;
    background: transparent;
    padding: 4px 0;
    font-size: 13px;
    box-shadow: none;
}

.symptom-search-box .form-control:focus {
    box-shadow: none;
    border-color: transparent;
}

.symptom-search-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    display: none;
}

.symptom-category-count {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 11px;
}

.symptom-category {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.2s;
}

.symptom-category.open {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.symptom-category-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    cursor: pointer;
    transition: background 0.15s;
}

.symptom-category-header:hover {
    background: var(--border-light);
}

.symptom-category-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.symptom-category-icon .material-symbols-rounded {
    font-size: 22px;
}

.symptom-category-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.symptom-category-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.symptom-chevron {
    color: var(--text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.symptom-category.open .symptom-chevron {
    transform: rotate(180deg);
}

.symptom-category-body {
    display: none;
    padding: 0 18px 18px;
}

.symptom-category.open .symptom-category-body {
    display: block;
}

.trauma-bodymap-container {
    padding: 16px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
    border-radius: 10px;
    border: 1px solid #FDE68A;
}
.trauma-bodymap-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #92400E;
    margin-bottom: 10px;
}
.trauma-bodymap-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
    min-height: 32px;
}
.trauma-no-selection {
    font-size: 12px;
    color: #92400E;
    font-style: italic;
    padding: 6px 12px;
    background: rgba(255,255,255,0.6);
    border-radius: 6px;
    border: 1px dashed #D97706;
}
.trauma-area-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #D97706;
    color: #fff;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    animation: fadeIn 0.2s ease;
}
.trauma-area-remove {
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    padding: 0 0 0 4px;
    line-height: 1;
    opacity: 0.8;
}
.trauma-area-remove:hover { opacity: 1; }
.trauma-bodymap-views {
    display: flex;
    gap: 16px;
    justify-content: center;
}
.trauma-bodymap-view {
    flex: 1;
    max-width: 320px;
}
.trauma-bodymap-label {
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: #92400E;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.trauma-bodymap-img-wrap {
    position: relative;
    border-radius: 10px;
    overflow: visible;
    background: #fff;
    border: 2px solid #E2E8F0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.trauma-bodymap-img-wrap img {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    pointer-events: none;
    border-radius: 10px;
}
.trauma-zone {
    position: absolute;
    border: 2px dashed transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.18s ease;
    z-index: 2;
}
.trauma-zone:hover {
    background: rgba(217, 119, 6, 0.22);
    border-color: rgba(217, 119, 6, 0.6);
    border-style: solid;
    box-shadow: 0 0 10px rgba(217, 119, 6, 0.35);
}
.trauma-zone:hover::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30,30,30,0.92);
    color: #fff;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 99;
    pointer-events: none;
    font-weight: 500;
    letter-spacing: 0.2px;
}
.trauma-zone.selected {
    background: rgba(217, 119, 6, 0.38);
    border-color: #D97706;
    border-style: solid;
    box-shadow: 0 0 14px rgba(217, 119, 6, 0.55), inset 0 0 8px rgba(217,119,6,0.15);
}
.trauma-zone.selected::after {
    content: '\e55e';
    font-family: 'Material Symbols Rounded';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    filter: drop-shadow(0 0 3px #D97706);
}
@media (max-width: 600px) {
    .trauma-bodymap-views {
        flex-direction: column;
        align-items: center;
    }
    .trauma-bodymap-view {
        max-width: 280px;
        width: 100%;
    }
}

.symptom-checklist {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.symptom-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    color: var(--text);
}

.symptom-check:hover {
    background: var(--border-light);
}

.symptom-check input[type="checkbox"] {
    display: none;
}

.symptom-check-box {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s;
}

.symptom-check input:checked + .symptom-check-box {
    background: var(--primary);
    border-color: var(--primary);
}

.symptom-check input:checked + .symptom-check-box::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.symptom-severity {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.symptom-sev-1 { background: #FEE2E2; color: #DC2626; }
.symptom-sev-2 { background: #FED7AA; color: #EA580C; }
.symptom-sev-3 { background: #DBEAFE; color: #2563EB; }
.symptom-sev-4 { background: #DCFCE7; color: #16A34A; }
.symptom-sev-5 { background: #F3F4F6; color: #6B7280; }

.symptom-guideline {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding: 12px 14px;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-radius: var(--radius-xs);
    font-size: 12px;
    color: #1E40AF;
    line-height: 1.5;
}

.symptom-guideline .material-symbols-rounded {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.vitals-wizard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
    margin-left: auto;
    margin-right: auto;
}

.vital-input-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: all 0.2s;
}

.vital-input-card:hover {
    border-color: var(--primary);
}

.vital-input-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
}

.vital-input-icon .material-symbols-rounded {
    font-size: 22px;
}

.vital-input-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.vital-input-wrap {
    position: relative;
}

.vital-input {
    text-align: center;
    font-size: 18px !important;
    font-weight: 600 !important;
    padding-right: 50px !important;
}

.vital-input-unit {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.vital-alarm {
    font-size: 11px;
    margin-top: 6px;
    min-height: 16px;
    font-weight: 600;
}

.vital-alarm.alarm-danger { color: #DC2626; }
.vital-alarm.alarm-warning { color: #EA580C; }
.vital-alarm.alarm-normal { color: #16A34A; }

.vitals-reference-card {
    background: #F0FDFA;
    border: 1px solid #99F6E4;
    border-radius: var(--radius);
    padding: 16px;
}

.vitals-reference-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
}

.vitals-reference-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.triage-suggestion-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow: hidden;
    transition: border-color 0.3s;
}

.triage-suggestion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--border-light);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.triage-suggestion-header .material-symbols-rounded {
    font-size: 20px;
    color: var(--accent);
}

.triage-suggestion-body {
    padding: 16px;
}

.triage-suggestion-code {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.triage-suggestion-code .triage-dot {
    width: 14px;
    height: 14px;
}

.triage-suggestion-reason {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.triage-final-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.triage-final-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.triage-final-option:hover {
    border-color: var(--border);
    background: var(--border-light);
}

.triage-final-option.selected {
    border-color: var(--primary);
    background: var(--primary-50);
}

.triage-final-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
}

.triage-final-info { flex: 1; }

.triage-final-name {
    font-size: 15px;
    font-weight: 700;
}

.triage-final-label {
    font-size: 11px;
    color: var(--text-muted);
}

.triage-final-check {
    color: var(--border);
    transition: all 0.2s;
}

.triage-final-option.selected .triage-final-check {
    color: var(--primary);
}

.wizard-summary-card {
    background: var(--border-light);
    border-radius: var(--radius);
    padding: 18px;
    margin-top: 24px;
}

.wizard-summary-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
}

.wizard-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 13px;
}

.wizard-summary-item {
    display: flex;
    gap: 8px;
}

.wizard-summary-item .sum-label {
    color: var(--text-muted);
    min-width: 100px;
}

.wizard-summary-item .sum-value {
    font-weight: 600;
    color: var(--text);
}

.form-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.scan-btn-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.scan-btn-group .form-group {
    flex: 1;
    min-width: 0;
}
.btn-scan-ts {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    height: 40px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, transform 0.1s;
    align-self: flex-end;
    margin-bottom: 0;
}
.btn-scan-ts:hover {
    background: var(--primary-hover);
}
.btn-scan-ts:active {
    transform: scale(0.97);
}
.btn-scan-ts .material-symbols-rounded {
    font-size: 20px;
}

.wizard-phase-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    border-left: 5px solid;
}
.wizard-phase-banner.phase-1 {
    background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
    border-color: #DC2626;
}
.wizard-phase-banner.phase-2 {
    background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
    border-color: #D97706;
}
.wizard-phase-banner.phase-3 {
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    border-color: #2563EB;
}
.wizard-phase-banner.phase-4 {
    background: linear-gradient(135deg, #F0FDF4 0%, #DCFCE7 100%);
    border-color: #16A34A;
}
.wizard-phase-banner-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255,255,255,0.7);
}
.wizard-phase-banner-icon .material-symbols-rounded {
    font-size: 26px;
}
.phase-1 .wizard-phase-banner-icon { color: #DC2626; }
.phase-2 .wizard-phase-banner-icon { color: #D97706; }
.phase-3 .wizard-phase-banner-icon { color: #2563EB; }
.phase-4 .wizard-phase-banner-icon { color: #16A34A; }
.wizard-phase-banner-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.3px;
}
.phase-1 .wizard-phase-banner-title { color: #991B1B; }
.phase-2 .wizard-phase-banner-title { color: #92400E; }
.phase-3 .wizard-phase-banner-title { color: #1E3A8A; }
.phase-4 .wizard-phase-banner-title { color: #166534; }
.wizard-phase-banner-desc {
    font-size: 13px;
    margin-top: 2px;
    line-height: 1.4;
}
.phase-1 .wizard-phase-banner-desc { color: #B91C1C; }
.phase-2 .wizard-phase-banner-desc { color: #B45309; }
.phase-3 .wizard-phase-banner-desc { color: #1E40AF; }
.phase-4 .wizard-phase-banner-desc { color: #15803D; }

.abcde-section { margin-bottom: 8px; }
.abcde-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin: 0 auto;
}
.abcde-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.abcde-card:hover {
    border-color: var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.abcde-card-letter {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 900;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 1px;
}
.abcde-card-body {
    flex: 1;
    padding: 10px 10px;
    text-align: center;
}
.abcde-card-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}
.abcde-card-desc {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.3;
}
.abcde-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}
.abcde-option {
    cursor: pointer;
    display: flex;
    align-items: center;
}
.abcde-option input[type="radio"] {
    display: none;
}
.abcde-option-label {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 16px;
    font-size: 10px;
    font-weight: 600;
    border: 2px solid transparent;
    transition: all 0.15s;
}
.abcde-option-label.abcde-ok {
    background: #F0FDF4;
    color: #16A34A;
    border-color: #BBF7D0;
}
.abcde-option-label.abcde-warn {
    background: #FFFBEB;
    color: #D97706;
    border-color: #FDE68A;
}
.abcde-option-label.abcde-danger {
    background: #FEF2F2;
    color: #DC2626;
    border-color: #FECACA;
}
.abcde-option input:checked + .abcde-option-label.abcde-ok {
    background: #16A34A;
    color: #fff;
    border-color: #16A34A;
}
.abcde-option input:checked + .abcde-option-label.abcde-warn {
    background: #D97706;
    color: #fff;
    border-color: #D97706;
}
.abcde-option input:checked + .abcde-option-label.abcde-danger {
    background: #DC2626;
    color: #fff;
    border-color: #DC2626;
}

.abcde-emergency-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    margin-top: 14px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    animation: pulseAlert 1.5s ease-in-out infinite;
}
.abcde-emergency-alert.abcde-danger-level {
    background: #FEE2E2;
    color: #991B1B;
    border: 2px solid #DC2626;
}
.abcde-emergency-alert.abcde-warn-level {
    background: #FEF3C7;
    color: #92400E;
    border: 2px solid #D97706;
}
.abcde-emergency-alert .material-symbols-rounded {
    font-size: 28px;
    flex-shrink: 0;
}
@keyframes pulseAlert {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.wong-baker-scale {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 16px 0;
}
.wong-baker-face {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 10px;
    border-radius: var(--radius);
    border: 3px solid transparent;
    transition: all 0.2s;
    width: 110px;
}
.wong-baker-face:hover {
    transform: scale(1.05);
    border-color: var(--border);
    background: var(--border-light);
}
.wong-baker-face.selected {
    border-color: var(--primary);
    background: var(--primary-50);
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(15, 118, 110, 0.2);
}
.wong-baker-svg {
    width: 64px;
    height: 64px;
}
.wong-baker-label {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
}
.wong-baker-desc {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.3;
    min-height: 26px;
}
.wong-baker-value-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}
.wong-baker-value-display .material-symbols-rounded {
    font-size: 22px;
    color: var(--primary);
}

.wizard-summary-section {
    grid-column: 1 / -1;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.wizard-summary-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.wizard-summary-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.wizard-summary-section-title .material-symbols-rounded {
    font-size: 18px;
}

@media (max-width: 640px) {
    .abcde-grid {
        grid-template-columns: 1fr;
    }
    .abcde-card {
        flex-direction: row;
    }
    .abcde-card-letter {
        width: 48px;
        height: auto;
        min-height: 100%;
    }
    .abcde-card-body {
        text-align: left;
    }
    .abcde-options {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .wong-baker-scale {
        gap: 6px;
    }
    .wong-baker-face {
        width: 80px;
        padding: 6px;
    }
    .wong-baker-svg {
        width: 48px;
        height: 48px;
    }
    .wong-baker-label { font-size: 16px; }
    .wong-baker-desc { font-size: 9px; }
    .wizard-phase-banner {
        padding: 12px 14px;
        gap: 12px;
    }
    .wizard-phase-banner-icon {
        width: 40px;
        height: 40px;
    }
    .wizard-phase-banner-icon .material-symbols-rounded { font-size: 22px; }
    .wizard-phase-banner-title { font-size: 14px; }
    .wizard-phase-banner-desc { font-size: 12px; }
}

.camera-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: #000;
    flex-direction: column;
}
.camera-overlay.active {
    display: flex;
}
.camera-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    flex-shrink: 0;
    z-index: 1;
}
.camera-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.camera-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.camera-viewfinder {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.camera-viewfinder video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.camera-guide {
    position: absolute;
    border: 2px dashed rgba(255,255,255,0.6);
    border-radius: 12px;
    width: 85%;
    max-width: 500px;
    aspect-ratio: 1.586;
    pointer-events: none;
}
.camera-guide-label {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.8);
    font-size: 12px;
    white-space: nowrap;
}
.camera-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    background: rgba(0,0,0,0.8);
    flex-shrink: 0;
}
.btn-camera-capture {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid var(--primary);
    cursor: pointer;
    transition: transform 0.15s;
    position: relative;
}
.btn-camera-capture:active {
    transform: scale(0.9);
}
.btn-camera-capture::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: var(--primary);
}
.camera-processing {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.85);
    color: #fff;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 2;
}
.camera-processing.active {
    display: flex;
}
.camera-processing .spin {
    font-size: 40px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 1024px) {
    /* Fix iOS 100vh bug: use dynamic viewport units so browser chrome never clips content */
    body { height: 100dvh; height: -webkit-fill-available; }
    .app-layout { height: 100dvh; min-height: -webkit-fill-available; }
    .main-content { height: 100dvh; min-height: 0; }
    .content-area {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        padding-bottom: max(env(safe-area-inset-bottom, 0px), 80px);
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .main-content { margin-left: 0 !important; }
    body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    .triage-board { grid-template-columns: 1fr 1fr; }
    .patient-detail-grid { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .triage-selector { grid-template-columns: repeat(3, 1fr); }
    .form-row-3, .form-row-4 { grid-template-columns: 1fr 1fr; }
    .shift-stats-grid { grid-template-columns: repeat(3, 1fr); }
    .shift-config-grid { grid-template-columns: 1fr; }
    .triage-priority-row { grid-template-columns: repeat(3, 1fr); }
    .wizard-step-indicator span:not(.wizard-step-num):not(.material-symbols-rounded) { display: none; }
    .abcde-grid { grid-template-columns: repeat(5, 1fr); }
    .wizard-form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
    .vitals-wizard-grid { grid-template-columns: repeat(4, 1fr); }
    .wizard-summary-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .content-area { padding: 16px; padding-bottom: max(env(safe-area-inset-bottom, 0px), 80px); }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .triage-board { grid-template-columns: 1fr; }
    .form-row, .form-row-2 { grid-template-columns: 1fr; }
    .triage-selector { grid-template-columns: repeat(2, 1fr); }
    .vital-signs-grid { grid-template-columns: 1fr 1fr; }
    .header-right { display: none; }
    .header-center { display: none; }
    .header-logo-mobile { display: block; }
    .login-banner { padding: 24px 16px; }
    .login-banner-logo { width: 220px; }
    .login-body-wrap { padding: 24px 20px 28px; }
    .login-container { max-width: 100%; }
    .shift-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .triage-priority-row { grid-template-columns: repeat(5, 1fr); gap: 6px; }
    .triage-priority-content { padding: 8px 4px; }
    .triage-priority-count { font-size: 22px; margin-bottom: 2px; }
    .triage-priority-name { font-size: 9px; margin-bottom: 1px; }
    .triage-priority-label { font-size: 8px; margin-bottom: 3px; }
    .triage-priority-wait { font-size: 7px; padding: 1px 4px; }
    .btn-nuovo-triage { width: 100%; justify-content: center; font-size: 14px; padding: 12px 20px; }
    .triage-wizard { max-width: 100vw; overflow: hidden; }
    .triage-wizard-header { padding: 10px 14px; position: relative; }
    .triage-wizard-header-left { display: none; }
    .triage-wizard-header-logo { display: block; height: 30px; position: absolute; left: 50%; transform: translateX(-50%); }
    .triage-wizard-close { width: 32px; height: 32px; margin-left: auto; }
    .triage-wizard-close .material-symbols-rounded { font-size: 20px; }
    .triage-wizard-progress { padding: 8px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; justify-content: flex-start; }
    .triage-wizard-progress::-webkit-scrollbar { display: none; }
    .wizard-step-indicator { padding: 4px 6px; font-size: 11px; gap: 4px; flex-shrink: 0; }
    .wizard-step-num { width: 22px; height: 22px; font-size: 10px; }
    .wizard-step-line { width: 10px; }
    .triage-wizard-body { padding: 14px 16px; overflow-x: hidden; max-width: 100%; box-sizing: border-box; }
    .wizard-panel { max-width: 100%; overflow-x: hidden; box-sizing: border-box; }
    .wizard-panel-title-row { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
    .wizard-panel-title-row .btn-scan-ts { width: 100%; justify-content: center; }
    .wizard-panel-title { font-size: 17px; gap: 8px; }
    .wizard-panel-title .material-symbols-rounded { font-size: 22px; }
    .wizard-panel-desc { font-size: 12px; margin-bottom: 16px; }
    .wizard-form-grid { grid-template-columns: 1fr; gap: 12px; }
    .wizard-form-grid-3 { grid-template-columns: 1fr; }
    .wizard-form-group { max-width: 100%; }
    .wizard-form-group label { font-size: 12px; }
    .wizard-form-group input,
    .wizard-form-group select,
    .wizard-form-group textarea { font-size: 14px; max-width: 100%; box-sizing: border-box; }
    .wizard-section-divider { font-size: 13px; margin: 16px 0 12px; }
    .dolor-scale, .wizard-dolor-scale { flex-wrap: wrap; gap: 6px !important; }
    .dolor-level { width: 36px; height: 36px; font-size: 13px; }
    .vitals-wizard-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .vital-input-card { padding: 10px; }
    .vital-input-icon { width: 36px; height: 36px; margin-bottom: 6px; }
    .vital-input-icon .material-symbols-rounded { font-size: 18px; }
    .vital-input-label { font-size: 11px; margin-bottom: 4px; }
    .vital-input { font-size: 15px !important; padding-right: 40px !important; }
    .vital-input-unit { font-size: 11px; right: 8px; }
    .vitals-reference-card { padding: 12px; }
    .vitals-reference-title { font-size: 12px; }
    .vitals-reference-grid { grid-template-columns: 1fr 1fr; gap: 4px; font-size: 11px; }
    .wizard-summary-grid { grid-template-columns: 1fr; }
    .wizard-summary-card { padding: 14px; }
    .wizard-summary-title { font-size: 16px; }
    .wizard-summary-item { font-size: 13px; }
    .symptom-categories { max-width: 100%; overflow-x: hidden; }
    .symptom-category-header { padding: 10px 12px; }
    .symptom-category-title { font-size: 13px; }
    .symptom-search-box { max-width: 100%; box-sizing: border-box; }
    .symptom-search-box .form-control { font-size: 13px; }
    .triage-suggestion-card { margin-bottom: 16px; }
    .triage-suggestion-header { font-size: 12px; padding: 10px 12px; }
    .triage-suggestion-body { padding: 12px; }
    .triage-suggestion-code { font-size: 16px; }
    .triage-suggestion-reason { font-size: 12px; }
    .triage-final-selector { gap: 6px; }
    .triage-wizard-footer { padding: 10px 14px; }
    .triage-wizard-footer .btn { min-width: 100px; padding: 10px 16px; font-size: 13px; }
    .patient-filter-form { flex-direction: column; }
    .filter-select { min-width: 100% !important; }
    .patient-table th:nth-child(4), .patient-table td:nth-child(4) { display: none; }
    .detail-tabs { flex-wrap: nowrap; overflow-x: auto; gap: 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
    .detail-tabs::-webkit-scrollbar { display: none; }
    .detail-tab { font-size: 11px; padding: 6px 8px; white-space: nowrap; flex-shrink: 0; }
    .detail-tab .material-symbols-rounded { font-size: 14px; }
    .detail-tab-label { display: none; }
    .patient-detail-row { display: none !important; }
    .patient-table tbody tr[onclick] { cursor: default !important; }
    .detail-info-grid { grid-template-columns: 1fr; gap: 8px; }
    .detail-info-item { padding: 10px 12px; }
    .detail-info-value { font-size: 13px; word-break: break-word; }
    .detail-vitals-row { gap: 6px; }
    .detail-vital-chip { min-width: 60px; padding: 6px 8px; }
    .detail-vital-chip .dv-value { font-size: 14px; }
    .detail-vital-chip .dv-label { font-size: 9px; }
    .detail-vital-chip .dv-unit { font-size: 9px; }
    .detail-meds-list, .detail-family-list { gap: 6px; }
    .detail-med-item, .detail-family-item { padding: 10px 12px; gap: 8px; font-size: 13px; }
    .detail-med-item .material-symbols-rounded, .detail-family-item .material-symbols-rounded { font-size: 18px; }
    .history-timeline { padding-left: 18px; }
    .history-item { padding: 10px 12px; }
    .history-item::before { left: -14px; top: 14px; width: 8px; height: 8px; }
    .history-item-header { flex-direction: column; align-items: flex-start; gap: 4px; }
    .history-item-date { font-size: 11px; }
    .history-item-motivo { font-size: 12px; word-break: break-word; }
    .history-item-result { font-size: 11px; flex-direction: column; gap: 4px; }
    .detail-empty { padding: 20px 12px; font-size: 12px; }
    .detail-empty .material-symbols-rounded { font-size: 28px; }
    .ai-health-header { padding: 12px 10px; flex-direction: column; gap: 8px; }
    .ai-health-title { gap: 8px; }
    .ai-health-title > div > div:first-child { font-size: 14px; }
    .ai-health-title > div > div:last-child { font-size: 11px; }
    .ai-health-title .material-symbols-rounded { font-size: 22px; }
    .ai-health-disclaimer { max-width: 100%; font-size: 10px; padding: 5px 10px; }
    .ai-section { padding: 12px 10px; }
    .ai-section-title { font-size: 13px; gap: 6px; margin-bottom: 8px; }
    .ai-section-title .material-symbols-rounded { font-size: 18px; }
    .ai-urgency-badge { font-size: 12px; padding: 5px 10px; }
    .ai-urgency-desc { font-size: 12px; line-height: 1.5; word-break: break-word; }
    .ai-urgency-time { font-size: 12px; }
    .ai-vital-alerts { gap: 3px; }
    .ai-vital-alert { font-size: 11px; padding: 3px 8px; }
    .ai-redflag-card { padding: 8px 10px; }
    .ai-rf-title { font-size: 12px; }
    .ai-rf-action { font-size: 11px; word-break: break-word; }
    .ai-scenario-card { padding: 10px 12px; margin-bottom: 8px; overflow: hidden; }
    .ai-scenario-header { flex-wrap: wrap; }
    .ai-scenario-title { font-size: 13px; word-break: break-word; overflow-wrap: break-word; }
    .ai-scenario-desc { font-size: 12px; word-break: break-word; overflow-wrap: break-word; }
    .ai-ddx-title { font-size: 12px; }
    .ai-ddx-item { padding: 6px 10px; }
    .ai-ddx-header { flex-wrap: wrap; gap: 4px; }
    .ai-ddx-name { font-size: 12px; }
    .ai-ddx-desc { font-size: 11px; word-break: break-word; }
    .ai-diag-item { padding: 6px 10px; }
    .ai-diag-name { font-size: 12px; }
    .ai-diag-reason { font-size: 11px; word-break: break-word; }
    .ai-diag-urg-badge { float: none; display: inline-block; margin-top: 4px; }
    .ai-diag-group-title { font-size: 12px; }
    .ai-pharma-card { padding: 10px 12px; }
    .ai-pharma-header { flex-direction: column; align-items: flex-start; gap: 4px; }
    .ai-pharma-name { font-size: 13px; }
    .ai-pharma-dose, .ai-pharma-ind { font-size: 11px; word-break: break-word; }
    .ai-pharma-contra { font-size: 10px; }
    .ai-vitals-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .ai-vital-card { padding: 8px 6px; }
    .ai-vital-val { font-size: 16px; }
    .ai-vital-param { font-size: 10px; }
    .ai-vital-range { font-size: 10px; }
    .ai-vital-note { font-size: 10px; }
    .ai-note-card { font-size: 11px; padding: 6px 10px; }
    .ai-guidelines-list { gap: 3px; }
    .ai-guideline-item { font-size: 11px; padding: 3px 6px; word-break: break-word; }
    .ai-protocol-card { padding: 10px 12px; }
    .ai-protocol-header { gap: 8px; margin-bottom: 8px; }
    .ai-protocol-steps { font-size: 12px; padding-left: 18px; line-height: 1.6; }
    .ai-protocol-time-badge { font-size: 11px; }
    .ai-footer { padding: 10px 12px; font-size: 10px; }
    .ai-cases-list { gap: 3px; }
    .ai-case-item { font-size: 11px; padding: 4px 8px; word-break: break-word; }
    .triage-cardiac-alert { border-radius: 8px; margin-bottom: 12px; }
    .triage-cardiac-alert-header { padding: 10px 12px; gap: 8px; }
    .triage-cardiac-alert-title { font-size: 12px; }
    .triage-cardiac-alert-body { padding: 10px 12px; }
    .triage-cardiac-alert-body p { font-size: 11px; }
    .triage-cardiac-action-item { padding: 8px 10px; flex-wrap: wrap; gap: 6px; font-size: 12px; }
    .btn-triage-upload { margin-left: 0; margin-top: 4px; width: 100%; justify-content: center; font-size: 12px; }
    .triage-allegati-header { flex-direction: column; align-items: flex-start; gap: 6px; }
    .btn-triage-add-allegato { width: 100%; justify-content: center; }
    .triage-allegato-card { flex-wrap: wrap; gap: 8px; padding: 10px; }
    .triage-allegato-icon .material-symbols-rounded { font-size: 22px; }
    .triage-allegato-tipo { font-size: 12px; }
    .triage-allegato-meta { font-size: 10px; }
    .triage-allegato-valore { font-size: 11px; }
    .triage-allegato-actions { width: 100%; justify-content: flex-start; gap: 8px; padding-top: 4px; border-top: 1px solid #F1F5F9; }
    .modal-lg { width: 95vw; max-width: 95vw; }
    .triage-selector { grid-template-columns: repeat(2, 1fr); }
}

.patient-tabs-container {
    background: #1E293B;
    overflow: hidden;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.patient-tabs-scroll {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 2px;
    padding: 6px 6px 0 6px;
}
.patient-tabs-scroll::-webkit-scrollbar {
    display: none;
}
.patient-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 10px 10px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    white-space: nowrap;
    border: none;
    border-radius: 10px 10px 0 0;
    transition: all 0.25s cubic-bezier(.4,0,.2,1);
    cursor: pointer;
    flex: 1 1 0;
    min-width: 0;
    background: transparent;
    position: relative;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.patient-tab:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}
.patient-tab.active {
    color: #fff;
    background: var(--tab-gradient);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.15);
    transform: translateY(-2px);
}
.patient-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 15%;
    right: 15%;
    height: 3px;
    background: #fff;
    border-radius: 3px 3px 0 0;
    opacity: 0.7;
}
.patient-tab-icon {
    font-size: 22px !important;
    transition: transform 0.25s;
}
.patient-tab.active .patient-tab-icon {
    transform: scale(1.15);
}
.patient-tab-label {
    font-size: 10px;
    line-height: 1.1;
    letter-spacing: 0.5px;
}
.patient-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: rgba(255,255,255,0.12);
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.7);
    transition: all 0.25s;
}
.patient-tab.active .patient-tab-count {
    background: rgba(255,255,255,0.3);
    color: #fff;
}
.tab-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}
@media (max-width: 640px) {
    .patient-tabs-scroll { gap: 1px; padding: 4px 4px 0 4px; }
    .patient-tab { padding: 10px 6px 8px; font-size: 9px; }
    .patient-tab-icon { font-size: 18px !important; }
    .patient-tab-label { font-size: 8px; }
    .patient-tab-count { min-width: 18px; height: 16px; font-size: 9px; }
}

.patient-list-filters {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color, #E2E8F0);
    background: #F8FAFC;
}
.patient-filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.patient-filter-form .search-box {
    flex: 1;
    min-width: 180px;
}
.filter-select {
    width: auto !important;
    min-width: 140px;
}

.patient-table {
    width: 100%;
}
.patient-row {
    cursor: pointer;
    transition: background 0.15s;
}
.patient-row:hover {
    background: #F1F5F9 !important;
}
.patient-row.expanded {
    background: #EFF6FF !important;
    border-bottom: none;
}
.patient-name-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.motivo-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-countdown {
    min-width: 180px;
}
.countdown-timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    border-radius: 8px;
    min-width: 90px;
}
.countdown-arrival {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted, #94A3B8);
    white-space: nowrap;
}
.countdown-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.countdown-timer .countdown-icon {
    font-size: 14px;
    color: var(--text-muted, #94A3B8);
}
.countdown-value {
    font-size: 15px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    white-space: nowrap;
    line-height: 1.2;
}
.countdown-date {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 2px;
}
.countdown-timer.countdown-ok .countdown-value { color: #16A34A; }
.countdown-timer.countdown-ok .countdown-icon { color: #16A34A; }
.countdown-timer.countdown-warn .countdown-value { color: #EA580C; }
.countdown-timer.countdown-warn .countdown-icon { color: #EA580C; }
.countdown-timer.countdown-danger .countdown-value { color: #DC2626; }
.countdown-timer.countdown-danger .countdown-icon { color: #DC2626; }
.countdown-timer.countdown-danger .countdown-value { animation: pulse-danger 1s infinite; }
.countdown-timer.countdown-expired .countdown-value { color: #DC2626; animation: pulse-danger 1s infinite; }
.countdown-timer.countdown-expired .countdown-icon { color: #DC2626; font-size: 18px; }
.countdown-timer.countdown-expired {
    background: #FEF2F2;
    border: 1px solid #FECACA;
}
.countdown-rivaluta-wrap {
    display: flex;
    justify-content: center;
    margin-top: 2px;
}
.btn-rivaluta-vitali {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #DC2626, #B91C1C);
    border: none;
    border-radius: 6px;
    padding: 3px 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    animation: pulse-danger 1.5s infinite;
    white-space: nowrap;
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn-rivaluta-vitali:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
}
.btn-rivaluta-vitali .material-symbols-rounded {
    font-size: 13px;
}
.countdown-remaining {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.countdown-timer.countdown-ok .countdown-remaining { color: #16A34A; }
.countdown-timer.countdown-warn .countdown-remaining { color: #EA580C; }
.countdown-timer.countdown-danger .countdown-remaining { color: #DC2626; }
.countdown-timer.countdown-expired .countdown-remaining { color: #DC2626; font-weight: 800; }
.btn-action-close {
    color: #DC2626 !important;
    border-color: #FECACA !important;
    background: #FEF2F2 !important;
}
.btn-action-close:hover {
    background: #FEE2E2 !important;
    border-color: #DC2626 !important;
}
.rivaluta-info-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #1E40AF;
}
.rivaluta-info-banner .material-symbols-rounded {
    font-size: 20px;
    color: #3B82F6;
}
.chiusura-warning-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #991B1B;
}
.chiusura-warning-banner .material-symbols-rounded {
    font-size: 22px;
    color: #DC2626;
    margin-top: 1px;
}
.btn-danger {
    background: linear-gradient(135deg, #DC2626, #B91C1C) !important;
    color: #fff !important;
    border: none !important;
}
.btn-danger:hover {
    background: linear-gradient(135deg, #B91C1C, #991B1B) !important;
}

@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-action-take {
    background: #059669 !important;
    color: #fff !important;
}
.btn-action-take:hover {
    background: #047857 !important;
    box-shadow: 0 2px 8px rgba(5,150,105,0.3);
}

.td-actions {
    min-width: 80px;
}
.action-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}
.btn-action {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-action .material-symbols-rounded {
    font-size: 18px;
}
.btn-action-edit { color: #2563EB; }
.btn-action-edit:hover { background: #EFF6FF; border-color: #93C5FD; }
.btn-action-view { color: #0F766E; text-decoration: none; }
.btn-action-view:hover { background: #F0FDFA; border-color: #5EEAD4; }
.btn-action-cartella { color: #4338CA; }
.btn-action-cartella:hover { background: #EEF2FF; border-color: #A5B4FC; }
.btn-action-dimissione { color: #059669; }
.btn-action-dimissione:hover { background: #ECFDF5; border-color: #6EE7B7; }
.btn-action-ricovero { color: #EA580C; }
.btn-action-ricovero:hover { background: #FFF7ED; border-color: #FDBA74; }

.patient-detail-row td {
    padding: 0 !important;
    border-top: none !important;
}
.patient-detail-panel {
    background: linear-gradient(135deg, #F8FAFC 0%, #EFF6FF 100%);
    border-top: 2px solid #3B82F6;
    border-bottom: 2px solid #3B82F6;
    padding: 0;
    animation: slideDown 0.25s ease;
    overflow: hidden;
    overflow-x: hidden;
    max-width: 100%;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
}

@keyframes slideDown {
    from { max-height: 0; opacity: 0; }
    to { max-height: 2000px; opacity: 1; }
}

.detail-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px;
    color: var(--text-muted, #64748B);
    font-size: 14px;
}
.spin {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.detail-content {
    padding: 20px 24px;
}
.detail-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid #E2E8F0;
    padding-bottom: 0;
}
.detail-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #64748B;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 6px 6px 0 0;
    background: transparent;
    border: none;
}
.detail-tab:hover {
    color: #1E40AF;
    background: #EFF6FF;
}
.detail-tab.active {
    color: #1E40AF;
    border-bottom-color: #2563EB;
    background: white;
}
.detail-tab .material-symbols-rounded {
    font-size: 18px;
}
.detail-tab-count {
    background: #E2E8F0;
    color: #475569;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
}
.detail-tab.active .detail-tab-count {
    background: #DBEAFE;
    color: #1E40AF;
}

.detail-tab-panel {
    display: none;
}
.detail-tab-panel.active {
    display: block;
}

.detail-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.detail-info-item {
    background: white;
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid #E2E8F0;
}
.detail-info-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94A3B8;
    margin-bottom: 4px;
}
.detail-info-value {
    font-size: 14px;
    font-weight: 600;
    color: #1E293B;
}

.detail-vitals-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.detail-vital-chip {
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}
.detail-vital-chip .dv-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94A3B8;
}
.detail-vital-chip .dv-value {
    font-size: 16px;
    font-weight: 700;
    color: #0F172A;
}
.detail-vital-chip .dv-unit {
    font-size: 10px;
    color: #94A3B8;
}

.history-timeline {
    position: relative;
    padding-left: 24px;
}
.history-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #CBD5E1;
}
.history-item {
    position: relative;
    margin-bottom: 16px;
    background: white;
    border-radius: 10px;
    padding: 14px 16px;
    border: 1px solid #E2E8F0;
    transition: box-shadow 0.15s;
}
.history-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.history-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 18px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3B82F6;
    border: 2px solid white;
}
.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.history-item-date {
    font-size: 12px;
    font-weight: 600;
    color: #64748B;
}
.history-item-motivo {
    font-size: 13px;
    color: #334155;
    line-height: 1.5;
}
.history-item-result {
    margin-top: 8px;
    font-size: 12px;
    color: #64748B;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.history-item-result span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.detail-empty {
    text-align: center;
    padding: 24px;
    color: #94A3B8;
    font-size: 13px;
}
.detail-empty .material-symbols-rounded {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

.detail-meds-list, .detail-family-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.detail-med-item, .detail-family-item {
    background: white;
    border-radius: 10px;
    padding: 12px 16px;
    border: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.detail-med-item .material-symbols-rounded,
.detail-family-item .material-symbols-rounded {
    font-size: 20px;
    color: #3B82F6;
}

.edit-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #1E293B;
    margin: 16px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.edit-section-title:first-child {
    margin-top: 0;
}
.edit-section-title .material-symbols-rounded {
    font-size: 20px;
    color: #3B82F6;
}

.triage-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}
.triage-select-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: 2px solid #E2E8F0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}
.triage-select-option:hover {
    border-color: var(--tc);
    background: var(--tbg);
}
.triage-select-option input {
    display: none;
}
.triage-select-option input:checked + .triage-select-dot {
    transform: scale(1.3);
    box-shadow: 0 0 0 3px var(--tbg);
}
.triage-select-option:has(input:checked) {
    border-color: var(--tc);
    background: var(--tbg);
    box-shadow: 0 0 0 2px var(--tc);
}
.triage-select-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transition: all 0.15s;
}
.triage-select-name {
    font-size: 13px;
    font-weight: 700;
    color: #1E293B;
}
.triage-select-label {
    font-size: 10px;
    color: #64748B;
}

.modal-lg {
    width: 90vw;
    max-width: 800px;
}

.diag-patients-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.diag-patient-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.diag-patient-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #F8FAFC;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}
.diag-patient-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.diag-patient-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}
.diag-patient-avatar .material-symbols-rounded {
    font-size: 22px;
}
.diag-patient-details {
    min-width: 0;
}
.diag-patient-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.diag-patient-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 3px;
    flex-wrap: wrap;
}
.diag-meta-item {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: var(--text-muted);
}
.diag-meta-item .material-symbols-rounded {
    font-size: 14px;
}
.diag-patient-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.diag-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}
.diag-stat .material-symbols-rounded { font-size: 15px; }
.diag-stat-pending { background: #FEF3C7; color: #92400E; }
.diag-stat-progress { background: #DBEAFE; color: #1E40AF; }
.diag-stat-done { background: #DCFCE7; color: #166534; }
.diag-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 18px;
    font-size: 13px;
    color: var(--text-muted);
}
.diag-empty .material-symbols-rounded { font-size: 18px; }
.diag-requests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px;
    padding: 14px 18px;
}
.diag-request-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    background: #fff;
    transition: box-shadow 0.2s, border-color 0.2s;
    position: relative;
}
.diag-request-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.diag-request-card.req-pending {
    border-left: 4px solid #F59E0B;
}
.diag-request-card.req-progress {
    border-left: 4px solid #3B82F6;
    background: #F0F7FF;
}
.diag-request-card.req-done {
    border-left: 4px solid #22C55E;
    background: #F0FDF4;
    opacity: 0.75;
}
.diag-request-card.req-urgent {
    border-color: #EF4444;
    border-left-color: #EF4444;
    box-shadow: 0 0 0 1px rgba(239,68,68,0.15);
}
.diag-request-card.req-urgent.req-pending {
    animation: urgentPulse 2s ease-in-out infinite;
}
@keyframes urgentPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(239,68,68,0.15); }
    50% { box-shadow: 0 0 0 3px rgba(239,68,68,0.2); }
}
.diag-req-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.diag-req-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.diag-req-icon-wrap .material-symbols-rounded {
    font-size: 20px;
}
.diag-req-title-area {
    flex: 1;
    min-width: 0;
}
.diag-req-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}
.diag-req-cat {
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.diag-req-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.diag-badge-urgent {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 800;
    color: #DC2626;
    background: #FEE2E2;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.diag-badge-urgent .material-symbols-rounded { font-size: 13px; }
.diag-badge-stato {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.diag-badge-stato .material-symbols-rounded { font-size: 13px; }
.diag-badge-richiesta { background: #FEF3C7; color: #92400E; }
.diag-badge-in_corso { background: #DBEAFE; color: #1E40AF; }
.diag-badge-completata { background: #DCFCE7; color: #166534; }
.diag-req-desc {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    padding: 8px 10px;
    background: #F8FAFC;
    border-radius: 6px;
    border: 1px solid #F1F5F9;
}
.diag-req-timeline {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.diag-tl-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.diag-tl-item .material-symbols-rounded {
    font-size: 16px;
    flex-shrink: 0;
}
.diag-tl-user {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: #F1F5F9;
    padding: 2px 8px;
    border-radius: 4px;
}
.diag-req-result, .diag-req-note {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    line-height: 1.4;
}
.diag-req-result {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #D1FAE5;
}
.diag-req-note {
    background: #FFF7ED;
    color: #9A3412;
    border: 1px solid #FED7AA;
}
.diag-req-result .material-symbols-rounded,
.diag-req-note .material-symbols-rounded {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}
.diag-req-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-diag-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.btn-diag-action .material-symbols-rounded { font-size: 16px; }
.btn-diag-take {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: #fff;
}
.btn-diag-take:hover { background: linear-gradient(135deg, #2563EB, #1D4ED8); box-shadow: 0 2px 8px rgba(37,99,235,0.3); }
.btn-diag-complete {
    background: linear-gradient(135deg, #22C55E, #16A34A);
    color: #fff;
}
.btn-diag-complete:hover { background: linear-gradient(135deg, #16A34A, #15803D); box-shadow: 0 2px 8px rgba(22,163,74,0.3); }

.btn-action-diag {
    background: #8B5CF6 !important;
    color: #fff !important;
}
.btn-action-diag:hover {
    background: #7C3AED !important;
}
.diag-form-patient-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #F8FAFC;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    font-size: 14px;
}
.diag-form-patient-info .material-symbols-rounded {
    font-size: 20px;
    color: var(--text-muted);
}

.diag-card-columns {
    display: flex;
    gap: 0;
}
.diag-card-left {
    flex: 1;
    min-width: 0;
}
.diag-card-right {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border-left: 1px solid var(--border);
    background: #F8FAFC;
    flex-shrink: 0;
    justify-content: center;
    min-width: 130px;
}
.btn-diag-col-action {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    color: var(--text-secondary);
    white-space: nowrap;
    width: 100%;
}
.btn-diag-col-action .material-symbols-rounded { font-size: 16px; flex-shrink: 0; }
.btn-diag-col-edit:hover { background: #EFF6FF; color: #2563EB; border-color: #93C5FD; }
.btn-diag-col-dimissione { color: #16A34A; border-color: #86EFAC; background: #F0FDF4; }
.btn-diag-col-dimissione:hover { background: #DCFCE7; border-color: #4ADE80; }
.btn-diag-col-obi { color: #0284C7; border-color: #7DD3FC; background: #F0F9FF; }
.btn-diag-col-obi:hover { background: #E0F2FE; border-color: #38BDF8; }
.btn-diag-col-ricovero { color: #EA580C; border-color: #FDBA74; background: #FFF7ED; }
.btn-diag-col-ricovero:hover { background: #FFEDD5; border-color: #FB923C; }
.btn-diag-col-close { color: #DC2626; border-color: #FCA5A5; background: #FEF2F2; }
.btn-diag-col-close:hover { background: #FEE2E2; border-color: #F87171; }
.diag-collapse-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    transition: color .2s;
    user-select: none;
}
.diag-collapse-toggle:hover { color: var(--primary); }
.diag-collapse-toggle .diag-toggle-icon { font-size: 20px; transition: transform .2s; }
.diag-requests-grid.diag-collapsed {
    display: none !important;
}

@media (max-width: 640px) {
    .diag-requests-grid { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
    .diag-patient-header { flex-direction: column; align-items: flex-start; }
    .diag-req-top { flex-wrap: wrap; }
    .diag-req-badges { margin-top: 6px; width: 100%; }
    .diag-card-columns { flex-direction: column; }
    .diag-card-right {
        flex-direction: row;
        flex-wrap: wrap;
        border-left: none;
        border-top: 1px solid var(--border);
        min-width: 0;
        padding: 8px 12px;
    }
    .btn-diag-col-action { width: auto; flex: 0 0 auto; }
    .btn-diag-col-label { display: none; }
}

.diag-contrasto-toggle {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    padding: 12px 16px; border-radius: 8px; background: #F0F9FF;
    border: 1px solid #BAE6FD; transition: all .2s; user-select: none;
}
.diag-contrasto-toggle:hover { background: #E0F2FE; }
.diag-contrasto-toggle input { display: none; }
.diag-contrasto-slider {
    width: 40px; height: 22px; background: #CBD5E1; border-radius: 11px;
    position: relative; transition: background .2s; flex-shrink: 0;
}
.diag-contrasto-slider::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px; background: #fff; border-radius: 50%;
    transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.diag-contrasto-toggle input:checked + .diag-contrasto-slider {
    background: #3B82F6;
}
.diag-contrasto-toggle input:checked + .diag-contrasto-slider::after {
    transform: translateX(18px);
}
.diag-contrasto-label { font-size: 14px; font-weight: 600; color: var(--text); }

.diag-mdc-alert {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 16px; border-radius: 8px;
    background: #FEF3C7; border: 1px solid #FDE68A;
    margin-top: 10px; animation: fadeIn .3s;
}
.diag-mdc-alert.mdc-warning { background: #FEF3C7; border-color: #FDE68A; }
.diag-mdc-alert.mdc-ok { background: #DCFCE7; border-color: #BBF7D0; }
.diag-mdc-alert-icon { flex-shrink: 0; }
.diag-mdc-alert.mdc-warning .diag-mdc-alert-icon .material-symbols-rounded { color: #D97706; font-size: 24px; }
.diag-mdc-alert.mdc-ok .diag-mdc-alert-icon .material-symbols-rounded { color: #16A34A; font-size: 24px; }
.diag-mdc-alert-content { font-size: 13px; color: var(--text); line-height: 1.5; }
.diag-mdc-alert-content strong { font-size: 14px; display: block; margin-bottom: 2px; }
.diag-mdc-alert-msg { color: var(--text-muted); margin-top: 2px; }

.diag-mdc-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: #DBEAFE; color: #1D4ED8; font-size: 11px; font-weight: 600;
    padding: 4px 10px; border-radius: 6px; margin-top: 8px;
}
.diag-mdc-badge .material-symbols-rounded { font-size: 14px; }

.modal-xl { max-width: 900px; width: 95%; }

.lab-category-header {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 700; color: #5B21B6;
    padding: 10px 0 6px; margin-top: 16px; border-bottom: 2px solid #DDD6FE;
}
.lab-category-header:first-child { margin-top: 0; }
.lab-category-header .material-symbols-rounded { font-size: 20px; }

.lab-entry-table {
    width: 100%; border-collapse: collapse; margin-top: 8px; margin-bottom: 8px;
    font-size: 13px;
}
.lab-entry-table thead th {
    background: #F8FAFC; padding: 8px 10px; text-align: left;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.lab-entry-table tbody td {
    padding: 6px 10px; border-bottom: 1px solid #F1F5F9;
    vertical-align: middle;
}
.lab-esame-name { font-weight: 500; min-width: 200px; }
.lab-value-input {
    width: 90px; padding: 6px 8px; border: 1px solid #D1D5DB;
    border-radius: 6px; font-size: 13px; text-align: right;
    font-family: 'Inter', sans-serif;
}
.lab-value-input:focus {
    outline: none; border-color: #7C3AED; box-shadow: 0 0 0 3px rgba(124,58,237,.1);
}
.lab-unit { color: var(--text-muted); font-size: 12px; }
.lab-range { color: var(--text-muted); font-size: 12px; text-align: center; }
.lab-flag-cell { min-width: 70px; }

.lab-flag {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 700;
}
.flag-normal { background: #DCFCE7; color: #166534; }
.flag-high { background: #FEE2E2; color: #991B1B; }
.flag-low { background: #DBEAFE; color: #1E40AF; }
.flag-critical {
    background: #DC2626; color: #fff;
    animation: criticalPulse 1s infinite;
}
@keyframes criticalPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .7; }
}

.lab-row-creatinina {
    background: #FFF7ED !important;
    border-left: 3px solid #EA580C;
}
.lab-row-creatinina .lab-esame-name { color: #C2410C; font-weight: 700; }
.lab-row-creatinina .lab-value-input { border-color: #EA580C; }

.btn-diag-view, .btn-diag-print, .btn-diag-imaging {
    font-size: 12px !important;
}
.btn-diag-view { background: #DBEAFE !important; color: #1D4ED8 !important; border-color: #93C5FD !important; }
.btn-diag-view:hover { background: #BFDBFE !important; }
.btn-diag-print { background: #F3E8FF !important; color: #7C3AED !important; border-color: #C4B5FD !important; }
.btn-diag-print:hover { background: #EDE9FE !important; }
.btn-diag-imaging { background: #ECFDF5 !important; color: #059669 !important; border-color: #6EE7B7 !important; }
.btn-diag-imaging:hover { background: #D1FAE5 !important; }

.detail-tab-ai {
    background: linear-gradient(135deg, #EEF2FF, #E0E7FF) !important;
    border: 1px solid #A5B4FC !important;
    color: #4338CA !important;
    font-weight: 600 !important;
}
.detail-tab-ai.active {
    background: linear-gradient(135deg, #6366F1, #4F46E5) !important;
    color: #fff !important;
    border-color: #4338CA !important;
}
.detail-tab-ai .material-symbols-rounded { font-size: 16px; }

.ai-health-container { padding: 0; width: 100%; box-sizing: border-box; overflow-x: hidden; }
.ai-health-loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 20px; text-align: center;
}
.ai-health-error {
    display: flex; align-items: center; gap: 8px; padding: 20px;
    color: #DC2626; font-weight: 500; font-size: 14px;
}

.ai-health-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 16px 20px; background: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 100%);
    border-bottom: 1px solid #E0E7FF; border-radius: 8px 8px 0 0;
    flex-wrap: wrap; gap: 12px;
}
.ai-health-title {
    display: flex; align-items: center; gap: 12px;
}
.ai-health-disclaimer {
    font-size: 11px; color: #6366F1; background: #fff;
    padding: 6px 12px; border-radius: 6px; border: 1px solid #C7D2FE;
    font-style: italic; max-width: 340px;
}

.ai-section {
    padding: 16px 20px; border-bottom: 1px solid #F1F5F9; width: 100%; box-sizing: border-box;
}
.ai-section:last-child { border-bottom: none; }
.ai-section-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 700; color: #1E293B; margin-bottom: 12px;
}

.ai-urgency {
    background: #FEFCE8; border-bottom: 1px solid #FDE68A;
}
.ai-urgency-badge {
    display: inline-flex; align-items: center; gap: 6px;
    color: #fff; font-weight: 700; font-size: 14px; padding: 6px 14px;
    border-radius: 6px; letter-spacing: 0.5px; margin-bottom: 8px;
}
.ai-urgency-badge .material-symbols-rounded { font-size: 18px; }
.ai-urgency-desc { font-size: 13px; color: #1E293B; line-height: 1.6; }
.ai-urgency-time {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: #92400E; margin-top: 8px; font-weight: 500;
}
.ai-urgency-time .material-symbols-rounded { font-size: 16px; }

.ai-vital-alerts { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.ai-vital-alert {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: #DC2626; font-weight: 600;
    padding: 4px 10px; background: #FEF2F2; border-radius: 4px; border: 1px solid #FECACA;
}
.ai-vital-alert .material-symbols-rounded { font-size: 16px; }

.ai-redflags { background: #FFF5F5; border-bottom-color: #FECACA; }
.ai-redflag-card {
    padding: 10px 14px; border-radius: 6px; margin-bottom: 8px;
    border: 1px solid #FECACA; background: #FEF2F2;
}
.ai-rf-critical { border-left: 4px solid #DC2626; background: #FEE2E2; }
.ai-rf-high { border-left: 4px solid #F97316; }
.ai-rf-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 700; color: #991B1B;
}
.ai-rf-title .material-symbols-rounded { font-size: 16px; color: #DC2626; }
.ai-rf-action { font-size: 12px; color: #7F1D1D; margin-top: 4px; line-height: 1.5; }

.ai-scenario-card {
    background: #fff; border: 1px solid #E2E8F0; border-radius: 8px;
    padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.ai-scenario-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ai-scenario-title { font-size: 15px; font-weight: 700; color: #1E293B; }
.ai-scenario-desc { font-size: 13px; color: #475569; line-height: 1.6; }

.ai-ddx-title {
    font-size: 13px; font-weight: 700; color: #334155; margin-top: 14px; margin-bottom: 8px;
    padding-top: 10px; border-top: 1px solid #F1F5F9;
}
.ai-ddx-list { display: flex; flex-direction: column; gap: 6px; }
.ai-ddx-item {
    padding: 8px 12px; background: #F8FAFC; border-radius: 6px;
    border: 1px solid #E2E8F0;
}
.ai-ddx-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ai-ddx-name { font-size: 13px; font-weight: 600; color: #1E293B; }
.ai-ddx-desc { font-size: 12px; color: #64748B; margin-top: 4px; line-height: 1.5; }

.ai-prob-badge {
    font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
    text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap;
}
.ai-prob-alta { background: #FEE2E2; color: #991B1B; }
.ai-prob-media { background: #FEF3C7; color: #92400E; }
.ai-prob-bassa { background: #DBEAFE; color: #1E40AF; }

.ai-cases-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 700; color: #6366F1;
    margin-top: 12px; margin-bottom: 6px; padding-top: 10px; border-top: 1px solid #F1F5F9;
}
.ai-cases-list { display: flex; flex-direction: column; gap: 4px; }
.ai-case-item {
    display: flex; align-items: flex-start; gap: 6px;
    font-size: 12px; color: #475569; line-height: 1.5;
    padding: 6px 10px; background: #F5F3FF; border-radius: 4px;
}

.ai-diag-group { margin-bottom: 14px; }
.ai-diag-group-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 700; color: #334155; margin-bottom: 6px;
}
.ai-diag-group-title .material-symbols-rounded { font-size: 18px; color: #0891B2; }
.ai-diag-item {
    padding: 8px 12px; margin-bottom: 4px; border-radius: 6px;
    border: 1px solid #E2E8F0; background: #fff;
}
.ai-diag-name { font-size: 13px; font-weight: 600; color: #1E293B; }
.ai-diag-reason { font-size: 12px; color: #64748B; margin-top: 3px; line-height: 1.4; }
.ai-diag-urg-badge {
    float: right; font-size: 10px; font-weight: 700; padding: 2px 8px;
    border-radius: 10px; text-transform: uppercase; letter-spacing: 0.3px;
}
.ai-diag-urgent .ai-diag-urg-badge, .ai-diag-urg-badge.ai-diag-urgent { background: #FEE2E2; color: #991B1B; }
.ai-diag-conditional .ai-diag-urg-badge, .ai-diag-urg-badge.ai-diag-conditional { background: #FEF3C7; color: #92400E; }
.ai-diag-normal .ai-diag-urg-badge, .ai-diag-urg-badge.ai-diag-normal { background: #DBEAFE; color: #1E40AF; }
.ai-diag-urgent { border-left: 3px solid #DC2626; }
.ai-diag-conditional { border-left: 3px solid #F59E0B; }

.ai-pharma-card {
    padding: 12px 14px; margin-bottom: 8px; border-radius: 6px;
    border: 1px solid #D1FAE5; background: #F0FDF4;
}
.ai-pharma-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
}
.ai-pharma-name { font-size: 14px; font-weight: 700; color: #065F46; }
.ai-pharma-via {
    font-size: 11px; font-weight: 600; color: #059669;
    background: #D1FAE5; padding: 2px 8px; border-radius: 10px;
}
.ai-pharma-dose { font-size: 12px; color: #1E293B; margin-bottom: 3px; }
.ai-pharma-ind { font-size: 12px; color: #475569; margin-bottom: 3px; line-height: 1.4; }
.ai-pharma-contra {
    display: flex; align-items: flex-start; gap: 4px;
    font-size: 11px; color: #DC2626; margin-top: 4px;
    padding: 4px 8px; background: #FEF2F2; border-radius: 4px; line-height: 1.4;
}

.ai-vitals-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; width: 100%;
}
.ai-vital-card {
    padding: 10px 12px; border-radius: 6px; border: 1px solid #E2E8F0;
    text-align: center; background: #fff;
}
.ai-vital-ok { border-color: #86EFAC; background: #F0FDF4; }
.ai-vital-high { border-color: #FCA5A5; background: #FEF2F2; }
.ai-vital-low { border-color: #93C5FD; background: #EFF6FF; }
.ai-vital-param { font-size: 11px; font-weight: 600; color: #64748B; text-transform: uppercase; letter-spacing: 0.3px; }
.ai-vital-val { font-size: 20px; font-weight: 700; color: #1E293B; margin: 4px 0; }
.ai-vital-unit { font-size: 12px; font-weight: 400; color: #94A3B8; }
.ai-vital-range { font-size: 11px; color: #94A3B8; }
.ai-vital-note { font-size: 11px; color: #DC2626; font-weight: 600; margin-top: 4px; }
.ai-vital-ok .ai-vital-val { color: #16A34A; }
.ai-vital-high .ai-vital-val { color: #DC2626; }
.ai-vital-low .ai-vital-val { color: #2563EB; }

.ai-note-card {
    display: flex; align-items: flex-start; gap: 6px;
    padding: 8px 12px; border-radius: 6px; margin-bottom: 6px;
    font-size: 12px; line-height: 1.5; color: #1E293B;
}
.ai-note-medium { background: #FFFBEB; border: 1px solid #FDE68A; }
.ai-note-high { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; font-weight: 500; }
.ai-note-critical { background: #FEE2E2; border: 2px solid #DC2626; color: #7F1D1D; font-weight: 700; }

.ai-guidelines-list { display: flex; flex-direction: column; gap: 4px; }
.ai-guideline-item {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: #0284C7; padding: 4px 8px;
    background: #F0F9FF; border-radius: 4px; font-weight: 500;
}

.ai-protocol-card {
    background: #FAF5FF;
    border: 1px solid #E9D5FF;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.ai-protocol-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.ai-protocol-steps {
    margin: 0 0 12px 0;
    padding-left: 24px;
    font-size: 13px;
    line-height: 1.8;
    color: #334155;
}

.ai-protocol-steps li {
    margin-bottom: 2px;
}

.ai-protocol-steps li::marker {
    color: #7C3AED;
    font-weight: 700;
}

.ai-protocol-times {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.ai-protocol-time-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #7C3AED;
    background: #EDE9FE;
    padding: 4px 10px;
    border-radius: 20px;
}

.ai-protocol-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.ai-footer {
    display: flex; align-items: center; gap: 4px;
    padding: 12px 20px; font-size: 11px; color: #94A3B8;
    background: #F8FAFC; border-top: 1px solid #F1F5F9;
    border-radius: 0 0 8px 8px;
}

.triage-cardiac-alert {
    background: linear-gradient(135deg, #FEF2F2, #FFF7ED);
    border: 2px solid #DC2626;
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
    animation: cardiacPulse 2s ease-in-out infinite;
}

@keyframes cardiacPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.15); }
    50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.08); }
}

.triage-cardiac-alert-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(90deg, #DC2626, #B91C1C);
    color: #FFF;
}

.triage-cardiac-alert-header .material-symbols-rounded {
    font-size: 24px; animation: pulseIcon 1.5s ease-in-out infinite;
}

@keyframes pulseIcon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.triage-cardiac-alert-title { font-weight: 700; font-size: 14px; letter-spacing: 0.02em; }

.triage-cardiac-alert-body { padding: 14px 16px; }
.triage-cardiac-alert-body p { font-size: 12.5px; color: #7C2D12; margin: 0 0 12px; }

.triage-cardiac-actions { display: flex; flex-direction: column; gap: 10px; }

.triage-cardiac-action-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 8px;
    font-size: 13px; transition: background 0.2s;
}

.triage-cardiac-action-item.tca-pending {
    background: #FFF; border: 1.5px dashed #F87171; color: #7C2D12;
}

.triage-cardiac-action-item.tca-done {
    background: #F0FDF4; border: 1.5px solid #86EFAC; color: #166534;
}

.triage-cardiac-action-item > .material-symbols-rounded {
    font-size: 28px; flex-shrink: 0;
}

.tca-pending > .material-symbols-rounded { color: #DC2626; }
.tca-done > .material-symbols-rounded { color: #16A34A; }
.tca-sub { font-size: 11.5px; color: #78716C; }
.tca-done .tca-sub { color: #166534; }

.btn-triage-upload {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 14px; border-radius: 6px;
    background: #DC2626; color: #FFF; font-size: 12px; font-weight: 600;
    border: none; cursor: pointer; margin-left: auto; flex-shrink: 0;
    transition: background 0.2s;
}

.btn-triage-upload:hover { background: #B91C1C; }

.triage-allegati-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}

.btn-triage-add-allegato {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 12px; border-radius: 6px;
    background: #F1F5F9; color: #334155; font-size: 12px; font-weight: 600;
    border: 1px solid #CBD5E1; cursor: pointer; transition: all 0.2s;
}

.btn-triage-add-allegato:hover { background: #E2E8F0; border-color: #94A3B8; }
.btn-triage-add-allegato .material-symbols-rounded { font-size: 16px; }

.triage-allegati-empty {
    display: flex; align-items: center; gap: 8px;
    padding: 14px; color: #94A3B8; font-size: 12.5px;
    background: #F8FAFC; border: 1px dashed #E2E8F0; border-radius: 8px;
}

.triage-allegati-empty .material-symbols-rounded { font-size: 22px; }

.triage-allegato-card {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px; border: 1px solid #E2E8F0; border-radius: 8px;
    background: #FFF; margin-bottom: 8px; transition: border-color 0.2s;
}

.triage-allegato-card:hover { border-color: #94A3B8; }

.triage-allegato-icon { flex-shrink: 0; padding-top: 2px; }
.triage-allegato-icon .material-symbols-rounded { font-size: 28px; }

.triage-allegato-info { flex: 1; min-width: 0; }

.triage-allegato-tipo { font-size: 13px; font-weight: 700; color: #1E293B; }

.triage-allegato-meta { font-size: 11.5px; color: #94A3B8; margin-top: 2px; }

.triage-allegato-valore {
    margin-top: 5px; font-size: 12.5px; padding: 4px 8px;
    border-radius: 5px; display: inline-block;
}

.allegato-esito-pos { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.allegato-esito-neg { background: #F0FDF4; color: #16A34A; border: 1px solid #BBF7D0; }
.allegato-esito-nd { background: #F8FAFC; color: #64748B; border: 1px solid #E2E8F0; }

.triage-allegato-note { font-size: 12px; color: #64748B; margin-top: 4px; font-style: italic; }

.triage-allegato-actions {
    display: flex; gap: 4px; flex-shrink: 0; align-items: flex-start; padding-top: 2px;
}

.btn-allegato-act {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 6px;
    border: 1px solid #E2E8F0; background: #FFF; color: #64748B;
    cursor: pointer; transition: all 0.2s; text-decoration: none;
}

.btn-allegato-act:hover { background: #F1F5F9; color: #1E293B; }
.btn-allegato-act .material-symbols-rounded { font-size: 16px; }

.btn-allegato-preview:hover { color: #2563EB; border-color: #93C5FD; }
.btn-allegato-download:hover { color: #059669; border-color: #6EE7B7; }
.btn-allegato-print:hover { color: #7C3AED; border-color: #C4B5FD; }
.btn-allegato-delete:hover { color: #DC2626; border-color: #FCA5A5; background: #FEF2F2; }

.triage-upload-dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; padding: 28px 16px; border: 2px dashed #CBD5E1; border-radius: 10px;
    background: #F8FAFC; cursor: pointer; transition: all 0.2s; text-align: center;
}

.triage-upload-dropzone:hover, .triage-upload-dropzone.dragover {
    border-color: #2563EB; background: #EFF6FF;
}

.triage-upload-dropzone p { font-size: 13px; color: #64748B; margin: 0; }

.triage-file-preview {
    display: flex; align-items: center; gap: 12px;
    padding: 10px; border: 1px solid #E2E8F0; border-radius: 8px; background: #F8FAFC;
}

.tfp-thumb { flex-shrink: 0; width: 60px; height: 60px; border-radius: 6px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #FFF; border: 1px solid #E2E8F0; }
.tfp-thumb img { max-width: 100%; max-height: 100%; object-fit: cover; }
.tfp-info { flex: 1; }
.tfp-name { font-size: 13px; font-weight: 600; color: #1E293B; word-break: break-all; }
.tfp-size { font-size: 11.5px; color: #94A3B8; margin-top: 2px; }

.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 600px) {
    .form-row-2col { grid-template-columns: 1fr; }
}

/* ===== TURNI (Shifts) Calendar ===== */
.turni-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.turni-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.turni-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.turni-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.turni-category-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}

.turni-cat-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 2px solid transparent;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
    color: var(--text-muted);
    white-space: nowrap;
}
.turni-cat-btn .material-symbols-rounded { font-size: 16px; }

.turni-cat-btn[data-ruolo="medico"] { border-color: #90CAF9; color: #1565C0; background: #E3F2FD; }
.turni-cat-btn[data-ruolo="medico"].active { background: #1565C0; color: #fff; border-color: #1565C0; }
.turni-cat-btn[data-ruolo="medico"]:hover:not(.active) { background: #BBDEFB; color: #0D47A1; border-color: #64B5F6; }

.turni-cat-btn[data-ruolo="infermiere"] { border-color: #A5D6A7; color: #2E7D32; background: #E8F5E9; }
.turni-cat-btn[data-ruolo="infermiere"].active { background: #2E7D32; color: #fff; border-color: #2E7D32; }
.turni-cat-btn[data-ruolo="infermiere"]:hover:not(.active) { background: #C8E6C9; color: #1B5E20; border-color: #81C784; }

.turni-cat-btn[data-ruolo="oss"] { border-color: #FFCC80; color: #E65100; background: #FFF3E0; }
.turni-cat-btn[data-ruolo="oss"].active { background: #E65100; color: #fff; border-color: #E65100; }
.turni-cat-btn[data-ruolo="oss"]:hover:not(.active) { background: #FFE0B2; color: #BF360C; border-color: #FFB74D; }

.turni-cat-btn[data-ruolo="ausiliare"] { border-color: #CE93D8; color: #7B1FA2; background: #F3E5F5; }
.turni-cat-btn[data-ruolo="ausiliare"].active { background: #7B1FA2; color: #fff; border-color: #7B1FA2; }
.turni-cat-btn[data-ruolo="ausiliare"]:hover:not(.active) { background: #E1BEE7; color: #6A1B9A; border-color: #BA68C8; }

.turni-month-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    min-width: 180px;
    text-align: center;
    letter-spacing: -0.3px;
}

.turni-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.turni-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.turni-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.turni-legend-orario {
    font-size: 0.75rem;
    color: #64748B;
    font-weight: 400;
}

.turni-calendar-container {
    overflow: hidden;
    position: relative;
}

.turni-calendar-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 260px);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    -ms-overflow-style: -ms-autohiding-scrollbar;
}

.turni-calendar-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.turni-calendar-table thead th {
    text-align: center;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.turni-user-col.turni-header-corner {
    z-index: 15;
}

.turni-user-col {
    text-align: left !important;
    padding-left: 14px !important;
    width: 190px;
    min-width: 190px;
    max-width: 190px;
    position: sticky;
    left: 0;
    z-index: 12;
    background: var(--bg) !important;
    border-right: 2px solid var(--border);
}

.turni-day-header {
    width: 44px;
    min-width: 44px;
    max-width: 44px;
}

.turni-day-name {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.2;
}

.turni-day-num {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1.3;
}

.turni-today .turni-day-num {
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.turni-day-header.turni-weekend {
    background: #FEF2F2 !important;
}

.turni-day-header.turni-weekend .turni-day-name {
    color: #EF4444;
    font-weight: 800;
}

.turni-day-header.turni-weekend .turni-day-num {
    color: #EF4444;
}

.turni-day-header {
    cursor: pointer;
    transition: background 0.15s;
}

.turni-day-header:hover {
    background: var(--primary-50) !important;
}

.turni-calendar-table tbody td {
    padding: 2px 2px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    vertical-align: middle;
    height: 44px;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    overflow: hidden;
}

.turni-calendar-table thead th {
    border-right: 1px solid var(--border-light);
}

.turni-cell {
    cursor: default;
    transition: background 0.15s;
}

.turni-cell:hover {
    background: var(--primary-50);
}

.turni-user-cell {
    text-align: left !important;
    padding: 5px 10px !important;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 5;
    border-right: 2px solid var(--border);
    width: 190px;
    min-width: 190px;
    max-width: 190px;
}

.turni-user-info {
    display: flex;
    align-items: center;
    gap: 7px;
}

.turni-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.turni-user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.turni-user-role {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}

.cell-area-tag {
    display: block;
    font-size: 7px;
    font-weight: 900;
    letter-spacing: 0.3px;
    line-height: 1;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
    flex-shrink: 0;
}

.cell-note-icon {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    color: #1E40AF;
    font-size: 9px;
    font-weight: 900;
    font-style: italic;
    font-family: Georgia, serif;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    z-index: 2;
    transition: transform 0.15s;
    line-height: 1;
}

.cell-note-icon:hover {
    transform: scale(1.3);
    background: #fff;
}

.cell-reperibilita-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6F00, #FF8F00);
    color: #fff;
    font-size: 9px;
    font-weight: 900;
    font-family: Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4), 0 0 0 1.5px rgba(255,255,255,0.6);
    z-index: 3;
    line-height: 1;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
    animation: repBadgePulse 2s ease-in-out infinite;
}

@keyframes repBadgePulse {
    0%, 100% { box-shadow: 0 1px 4px rgba(0,0,0,0.4), 0 0 0 1.5px rgba(255,255,255,0.6); }
    50% { box-shadow: 0 1px 4px rgba(0,0,0,0.4), 0 0 0 1.5px rgba(255,255,255,0.6), 0 0 6px 2px rgba(255,111,0,0.35); }
}

.reperibilita-legend-dot {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 16px !important;
    height: 16px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #FF6F00, #FF8F00) !important;
    color: #fff;
    font-size: 9px;
    font-weight: 900;
    font-family: Arial, sans-serif;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.reperibilita-toggle {
    background: var(--bg);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: border-color 0.2s, background 0.2s;
}

.reperibilita-toggle:has(input:checked) {
    border-color: #FF6F00;
    background: #FFF3E0;
}

.reperibilita-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.reperibilita-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #FF6F00;
    cursor: pointer;
    flex-shrink: 0;
}

.reperibilita-badge-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6F00, #FF8F00);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    font-family: Arial, sans-serif;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.reperibilita-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.reperibilita-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

.turni-cell {
    position: relative;
}

.turni-user-actions {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
}

.turni-user-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
}

.turni-user-action-btn .material-symbols-rounded {
    font-size: 16px;
    line-height: 1;
}

.turni-btn-generate {
    background: #EEF2FF;
    color: #4F46E5;
}

.turni-btn-generate:hover {
    background: #4F46E5;
    color: #fff;
    box-shadow: 0 2px 6px rgba(79,70,229,0.35);
}

.turni-btn-delete-user {
    background: #FEF2F2;
    color: #DC2626;
}

.turni-btn-delete-user:hover {
    background: #DC2626;
    color: #fff;
    box-shadow: 0 2px 6px rgba(220,38,38,0.35);
}

.turni-cell-filled {
    cursor: pointer;
    transition: opacity 0.15s, box-shadow 0.15s;
}

.turni-cell-filled:hover {
    opacity: 0.85;
    box-shadow: inset 0 0 0 2px rgba(0,0,0,0.15);
}

.turni-cell-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.turni-cell-content .material-symbols-rounded {
    font-size: 16px;
    color: #fff;
    line-height: 1;
    flex-shrink: 0;
}

.turni-cell-content .cell-label {
    font-size: 9px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
    line-height: 1;
    text-transform: uppercase;
    flex-shrink: 0;
}

.turni-cell.turni-today {
    background: rgba(15, 118, 110, 0.05);
}

.turni-summary-col {
    text-align: left !important;
    padding: 4px 8px !important;
    min-width: 100px;
    max-width: 120px;
    background: var(--bg) !important;
    border-left: 2px solid var(--border);
    height: 44px;
    vertical-align: middle;
    overflow: hidden;
}

.turni-summary-col.turni-summary-header {
    font-size: 11px;
    text-align: center !important;
}

.turni-summary-compact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    justify-content: center;
    height: 100%;
}

.turni-summary-badges {
    display: flex;
    gap: 3px;
    flex-wrap: nowrap;
}

.ts-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    white-space: nowrap;
}

.ts-badge b {
    font-size: 10px;
    font-weight: 900;
}

.turni-summary-ore {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1;
}

.turni-summary-ore .material-symbols-rounded {
    font-size: 11px;
    color: var(--text-muted);
}

.day-summary-section {
    border-bottom: 1px solid var(--border-light);
}

.day-summary-section:last-child {
    border-bottom: none;
}

.day-summary-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
}

.day-summary-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}

.day-summary-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    padding: 0 6px;
}

.day-summary-list {
    padding: 8px 16px 8px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.day-summary-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.wa-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
    cursor: pointer;
}
.wa-btn svg {
    display: block;
}
.wa-btn-active {
    background: rgba(37, 211, 102, 0.12);
}
.wa-btn-active svg {
    fill: #25D366;
}
.wa-btn-active:hover {
    background: rgba(37, 211, 102, 0.3);
    transform: scale(1.12);
}
.wa-btn-disabled {
    background: rgba(150, 150, 150, 0.1);
    cursor: default;
    opacity: 0.45;
}
.wa-btn-disabled svg {
    fill: #999;
}

.day-summary-empty {
    padding: 10px 16px 10px 24px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.turni-summary-total {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    padding-top: 3px;
    border-top: 1px solid var(--border-light);
    font-weight: 700;
    font-size: 11px;
    color: var(--primary-dark);
}

.turni-summary-total .material-symbols-rounded {
    font-size: 14px;
}

.sequenza-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sequenza-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: grab;
    transition: box-shadow 0.15s, border-color 0.15s;
    user-select: none;
}

.sequenza-item:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.sequenza-item.dragging {
    opacity: 0.5;
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.sequenza-drag-handle {
    color: var(--text-muted);
    font-size: 18px;
    cursor: grab;
}

.sequenza-step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.sequenza-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.sequenza-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
}

.sequenza-remove:hover {
    color: #EF4444;
    background: #FEE2E2;
}

.turni-tipo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.turni-tipo-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    background: var(--bg-card);
}

.turni-tipo-option input[type="radio"] {
    display: none;
}

.turni-tipo-option .material-symbols-rounded {
    font-size: 20px;
}

/* Normal state: colored border + icon per tipo */
.turni-tipo-option[data-tipo="mattina"]       { border-color: #C62828; color: #C62828; background: #FFEBEE; }
.turni-tipo-option[data-tipo="pomeriggio"]    { border-color: #E65100; color: #E65100; background: #FBE9E7; }
.turni-tipo-option[data-tipo="notte"]         { border-color: #1565C0; color: #1565C0; background: #E3F2FD; }
.turni-tipo-option[data-tipo="smonto"]        { border-color: #2E7D32; color: #2E7D32; background: #E8F5E9; }
.turni-tipo-option[data-tipo="riposo"]        { border-color: #388E3C; color: #388E3C; background: #E8F5E9; }
.turni-tipo-option[data-tipo="riposo_compensativo"] { border-color: #388E3C; color: #388E3C; background: #E8F5E9; }
.turni-tipo-option[data-tipo="ferie"]         { border-color: #00897B; color: #00897B; background: #E0F2F1; }
.turni-tipo-option[data-tipo="permesso"]      { border-color: #7B1FA2; color: #7B1FA2; background: #F3E5F5; }
.turni-tipo-option[data-tipo="malattia"]      { border-color: #B71C1C; color: #B71C1C; background: #FFEBEE; }
.turni-tipo-option[data-tipo="straordinario"] { border-color: #E65100; color: #E65100; background: #FBE9E7; }
.turni-tipo-option[data-tipo="permesso_studio"]        { border-color: #0277BD; color: #0277BD; background: #E1F5FE; }
.turni-tipo-option[data-tipo="congedo_straordinario"]  { border-color: #4527A0; color: #4527A0; background: #EDE7F6; }
.turni-tipo-option[data-tipo="permesso_retribuito"]    { border-color: #00695C; color: #00695C; background: #E0F2F1; }
.turni-tipo-option[data-tipo="legge_104"]              { border-color: #BF360C; color: #BF360C; background: #FBE9E7; }
.turni-tipo-option[data-tipo="congedo_parentale"]      { border-color: #880E4F; color: #880E4F; background: #FCE4EC; }
.turni-tipo-option[data-tipo="aspettativa"]            { border-color: #546E7A; color: #546E7A; background: #ECEFF1; }
.turni-tipo-option[data-tipo="recupero_ore"]           { border-color: #558B2F; color: #558B2F; background: #F1F8E9; }

/* Hover: slight darken via opacity */
.turni-tipo-option:hover { filter: brightness(0.93); }

/* Selected state: pieno colore, testo bianco */
.turni-tipo-option.selected { filter: none; }
.turni-tipo-option[data-tipo="mattina"].selected       { background: #C62828; border-color: #C62828; color: #fff; }
.turni-tipo-option[data-tipo="pomeriggio"].selected    { background: #E65100; border-color: #E65100; color: #fff; }
.turni-tipo-option[data-tipo="notte"].selected         { background: #1565C0; border-color: #1565C0; color: #fff; }
.turni-tipo-option[data-tipo="smonto"].selected        { background: #2E7D32; border-color: #2E7D32; color: #fff; }
.turni-tipo-option[data-tipo="riposo"].selected        { background: #388E3C; border-color: #388E3C; color: #fff; }
.turni-tipo-option[data-tipo="riposo_compensativo"].selected { background: #388E3C; border-color: #388E3C; color: #fff; }
.turni-tipo-option[data-tipo="ferie"].selected         { background: #00897B; border-color: #00897B; color: #fff; }
.turni-tipo-option[data-tipo="permesso"].selected      { background: #7B1FA2; border-color: #7B1FA2; color: #fff; }
.turni-tipo-option[data-tipo="malattia"].selected      { background: #B71C1C; border-color: #B71C1C; color: #fff; }
.turni-tipo-option[data-tipo="straordinario"].selected { background: #E65100; border-color: #E65100; color: #fff; }
.turni-tipo-option[data-tipo="permesso_studio"].selected       { background: #0277BD; border-color: #0277BD; color: #fff; }
.turni-tipo-option[data-tipo="congedo_straordinario"].selected { background: #4527A0; border-color: #4527A0; color: #fff; }
.turni-tipo-option[data-tipo="permesso_retribuito"].selected   { background: #00695C; border-color: #00695C; color: #fff; }
.turni-tipo-option[data-tipo="legge_104"].selected             { background: #BF360C; border-color: #BF360C; color: #fff; }
.turni-tipo-option[data-tipo="congedo_parentale"].selected     { background: #880E4F; border-color: #880E4F; color: #fff; }
.turni-tipo-option[data-tipo="aspettativa"].selected           { background: #546E7A; border-color: #546E7A; color: #fff; }
.turni-tipo-option[data-tipo="recupero_ore"].selected          { background: #558B2F; border-color: #558B2F; color: #fff; }

.genera-users-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
    scrollbar-width: thin;
}

.genera-user-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.15s;
}

.genera-user-item:hover {
    background: var(--bg);
}

.genera-user-item input[type="checkbox"] {
    flex-shrink: 0;
}

.genera-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .turni-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .turni-toolbar-left {
        justify-content: center;
    }
    .turni-toolbar-right {
        justify-content: center;
        flex-wrap: wrap;
    }
    .turni-category-buttons {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
    .turni-cat-btn {
        padding: 5px 10px;
        font-size: 11px;
        flex: 0 1 auto;
    }
    .turni-cat-btn .material-symbols-rounded {
        font-size: 14px;
    }
    .turni-legend {
        gap: 6px 10px;
        justify-content: center;
        flex-wrap: wrap;
        padding: 8px 4px;
    }
    .turni-legend-item {
        font-size: 11px;
    }
    .turni-tipo-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .turni-month-title {
        font-size: 16px;
        min-width: 140px;
    }
    .turni-user-col,
    .turni-user-cell {
        min-width: 140px;
        max-width: 160px;
    }
    .turni-user-avatar {
        width: 26px;
        height: 26px;
        font-size: 9px;
    }
    .turni-user-name {
        font-size: 11px;
        max-width: 90px;
    }
    .turni-day-header {
        width: 44px;
        min-width: 44px;
        max-width: 44px;
    }
    .turni-calendar-table tbody td {
        height: 44px;
        width: 44px;
        min-width: 44px;
        max-width: 44px;
    }
    .turni-shift-chip {
        min-width: 30px;
        height: 28px;
        padding: 0 4px;
    }
    .turni-shift-chip .chip-label {
        font-size: 9px;
    }
    .turni-summary-col {
        min-width: 130px;
        max-width: 150px;
    }
    .sequenza-item {
        padding: 8px 10px;
    }
    .sequenza-label {
        font-size: 13px;
    }
}

.richieste-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.richieste-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.richieste-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.richieste-stat-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 10px; background: #FFF; border: 1px solid #E2E8F0; transition: box-shadow 0.2s; }
.richieste-stat-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.richieste-stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.richieste-stat-icon .material-symbols-rounded { font-size: 22px; color: #FFF; }
.richieste-stat-info { flex: 1; }
.richieste-stat-value { font-size: 22px; font-weight: 800; color: #1E293B; line-height: 1; }
.richieste-stat-label { font-size: 12px; color: #94A3B8; margin-top: 2px; }
.richieste-list { display: flex; flex-direction: column; gap: 10px; }

.richiesta-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid #E2E8F0; border-radius: 10px; background: #FFF; cursor: pointer; transition: all 0.2s; }
.richiesta-card:hover { border-color: #94A3B8; box-shadow: 0 2px 8px rgba(0,0,0,.06); transform: translateY(-1px); }
.richiesta-tipo-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 20px; background: #EFF6FF; color: #3B82F6; }
.richiesta-card-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.richiesta-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.richiesta-card-title-group { flex: 1; min-width: 0; }
.richiesta-card-title { font-size: 14px; font-weight: 700; color: #1E293B; margin: 0 0 4px; }
.richiesta-card-desc { font-size: 12.5px; color: #64748B; line-height: 1.4; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.richiesta-card-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.richiesta-card-tag { padding: 3px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.richiesta-card-meta { font-size: 11.5px; color: #94A3B8; }
.richiesta-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.richiesta-card-footer-left { display: flex; gap: 8px; align-items: center; }

.richieste-grid-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.richieste-grid-table th { padding: 10px 12px; background: #F8FAFC; color: #64748B; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 2px solid #E2E8F0; text-align: left; white-space: nowrap; }
.richieste-grid-table td { padding: 10px 12px; border-bottom: 1px solid #F1F5F9; vertical-align: middle; }
.richieste-grid-table tbody tr:hover { background: #F8FAFC; }
.richiesta-grid-user { display: flex; align-items: center; gap: 10px; }
.richiesta-grid-avatar { width: 34px; height: 34px; border-radius: 8px; background: #EFF6FF; color: #3B82F6; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.richiesta-grid-avatar .material-symbols-rounded { font-size: 18px; }
.richiesta-grid-actions { display: flex; gap: 4px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; }
.btn-icon .material-symbols-rounded { font-size: 18px; }
.richiesta-tipo-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: #EFF6FF; color: #1D4ED8; white-space: nowrap; }
.richiesta-note-row td { padding: 4px 12px 8px !important; border-bottom: 1px solid #E2E8F0 !important; }
.richiesta-note-content { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; color: #64748B; padding: 4px 8px; background: #F8FAFC; border-radius: 4px; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12.5px; }
.text-muted { color: #94A3B8; }
.text-center { text-align: center; }
.table-container { overflow-x: auto; border: 1px solid #E2E8F0; border-radius: 10px; background: #FFF; }

.catalogo-prodotti-list { max-height: 250px; overflow-y: auto; border: 1px solid #E2E8F0; border-radius: 8px; background: #F8FAFC; }
.catalogo-empty { padding: 24px; text-align: center; color: #94A3B8; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.catalogo-cat-header { padding: 6px 12px; background: #EFF6FF; color: #1D4ED8; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid #DBEAFE; position: sticky; top: 0; z-index: 1; }
.catalogo-prodotto-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #F1F5F9; transition: background 0.15s; }
.catalogo-prodotto-item:hover { background: #EFF6FF; }
.catalogo-prodotto-item.selected { background: #DBEAFE; border-left: 3px solid #2563EB; }
.catalogo-prodotto-icon { width: 30px; height: 30px; border-radius: 6px; background: #FFF; border: 1px solid #E2E8F0; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.catalogo-prodotto-icon .material-symbols-rounded { font-size: 16px; color: #3B82F6; }
.catalogo-prodotto-info { flex: 1; min-width: 0; }
.catalogo-prodotto-nome { font-size: 12.5px; font-weight: 600; color: #1E293B; }
.catalogo-prodotto-desc { font-size: 11px; color: #64748B; margin-top: 1px; }
.catalogo-prodotto-um { font-size: 10.5px; font-weight: 600; color: #94A3B8; background: #F1F5F9; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; }
.catalogo-selected-info { padding: 10px 14px; background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: 8px; margin-bottom: 12px; }
.catalogo-selected-badge { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #1E293B; flex-wrap: wrap; }
.catalogo-selected-badge .material-symbols-rounded { font-size: 20px; color: #2563EB; }
.catalogo-um-badge { font-size: 10.5px; font-weight: 600; color: #64748B; background: #F1F5F9; padding: 2px 6px; border-radius: 4px; }

.dettaglio-section { margin-bottom: 16px; }
.dettaglio-section-title { font-size: 13px; font-weight: 700; color: #1E293B; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid #E2E8F0; }
.dettaglio-row { display: flex; gap: 12px; margin-bottom: 8px; }
.dettaglio-label { font-size: 12px; font-weight: 600; color: #64748B; min-width: 100px; flex-shrink: 0; }
.dettaglio-value { font-size: 13px; color: #1E293B; flex: 1; }
.dettaglio-text { font-size: 13px; color: #1E293B; line-height: 1.5; white-space: pre-wrap; background: #F8FAFC; padding: 10px 12px; border-radius: 6px; border: 1px solid #E2E8F0; }
.dettaglio-header-info { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.dettaglio-risposta { background: #F0FDF4; border: 1px solid #BBF7D0; border-radius: 8px; padding: 12px; }

.archivio-layout { display: grid; grid-template-columns: 280px 1fr; gap: 0; min-height: calc(100vh - 160px); border: 1px solid #E2E8F0; border-radius: 10px; overflow: hidden; background: #FFF; }
.archivio-sidebar { background: #F8FAFC; border-right: 1px solid #E2E8F0; display: flex; flex-direction: column; }
.archivio-sidebar-header { padding: 14px 16px; border-bottom: 1px solid #E2E8F0; display: flex; align-items: center; justify-content: space-between; }
.archivio-sidebar-title { font-size: 14px; font-weight: 700; color: #1E293B; display: flex; align-items: center; gap: 6px; }
.archivio-sidebar-title .material-symbols-rounded { font-size: 20px; color: #3B82F6; }
.archivio-tree { flex: 1; overflow-y: auto; padding: 8px; }
.archivio-tree-empty { padding: 20px; text-align: center; color: #94A3B8; font-size: 12.5px; }
.archivio-tree-item { border-radius: 6px; margin-bottom: 2px; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 7px 10px; font-size: 13px; color: #334155; transition: background 0.15s; }
.archivio-tree-item:hover { background: #E2E8F0; }
.archivio-tree-item.active { background: #DBEAFE; color: #1D4ED8; font-weight: 600; }
.archivio-tree-item > div:first-child { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: #334155; transition: background 0.15s; }
.archivio-tree-item > div:first-child:hover { background: #E2E8F0; }
.archivio-tree-item.active > div:first-child { background: #DBEAFE; color: #1D4ED8; font-weight: 600; }
.archivio-tree-toggle { font-size: 18px !important; color: #94A3B8; transition: transform 0.2s; cursor: pointer; }
.archivio-tree-item.expanded > div:first-child .archivio-tree-toggle { transform: rotate(90deg); }
.archivio-tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archivio-tree-actions { display: none; gap: 2px; margin-left: auto; }
.archivio-tree-item:hover .archivio-tree-actions { display: flex; }
.archivio-tree-item > div:first-child:hover .archivio-tree-actions { display: flex; }
.archivio-tree-actions .btn-icon { width: 24px; height: 24px; border: none; background: transparent; cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: #94A3B8; }
.archivio-tree-actions .btn-icon:hover { background: #CBD5E1; color: #1E293B; }
.archivio-tree-children { padding-left: 20px; }

.archivio-main { display: flex; flex-direction: column; }
.archivio-toolbar { padding: 12px 16px; border-bottom: 1px solid #E2E8F0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.archivio-toolbar-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.archivio-search-inline { display: flex; align-items: center; gap: 6px; background: #F1F5F9; border: 1px solid #E2E8F0; border-radius: 8px; padding: 4px 10px; flex: 1; max-width: 320px; min-width: 160px; transition: border-color 0.2s, box-shadow 0.2s; }
.archivio-search-inline:focus-within { border-color: #3B82F6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); background: #fff; }
.archivio-search-input { border: none; background: transparent; outline: none; font-size: 13px; color: #1E293B; width: 100%; font-family: inherit; }
.archivio-search-input::placeholder { color: #94A3B8; }
.archivio-search-clear { border: none; background: none; cursor: pointer; padding: 2px; border-radius: 50%; color: #94A3B8; display: flex; align-items: center; justify-content: center; transition: color 0.15s, background 0.15s; }
.archivio-search-clear:hover { color: #1E293B; background: #E2E8F0; }
.archivio-breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 13px; color: #64748B; flex-wrap: wrap; }
.archivio-breadcrumb-link { color: #3B82F6; cursor: pointer; text-decoration: none; }
.archivio-breadcrumb-link:hover { text-decoration: underline; }
.archivio-breadcrumb-current { color: #1E293B; font-weight: 600; }
.archivio-content { flex: 1; padding: 16px; overflow-y: auto; }
.archivio-view-toggle { display: flex; border: 1px solid #E2E8F0; border-radius: 6px; overflow: hidden; }
.archivio-view-toggle button { border: none; background: #FFF; padding: 5px 10px; cursor: pointer; color: #64748B; display: flex; align-items: center; }
.archivio-view-toggle button.active { background: #EFF6FF; color: #2563EB; }
.archivio-view-toggle button:not(:last-child) { border-right: 1px solid #E2E8F0; }

.archivio-file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.archivio-file-card { display: flex; flex-direction: column; align-items: center; padding: 16px 12px; border: 1px solid #E2E8F0; border-radius: 10px; background: #FFF; cursor: pointer; transition: all 0.2s; text-align: center; }
.archivio-file-card:hover { border-color: #93C5FD; box-shadow: 0 2px 8px rgba(59,130,246,.1); transform: translateY(-2px); }
.archivio-file-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.archivio-file-icon .material-symbols-rounded { font-size: 28px; }
.archivio-file-name { font-size: 12.5px; font-weight: 600; color: #1E293B; word-break: break-all; line-height: 1.3; margin-bottom: 4px; }
.archivio-file-meta { font-size: 11px; color: #94A3B8; }
.archivio-file-info { flex: 1; min-width: 0; }
.archivio-file-actions { display: flex; gap: 4px; margin-top: 8px; }
.archivio-file-actions .btn-sm { padding: 4px 8px; font-size: 11px; }

.archivio-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; color: #94A3B8; text-align: center; }
.archivio-empty-state .material-symbols-rounded { font-size: 48px; margin-bottom: 10px; }

.archivio-dropzone { border: 2px dashed #CBD5E1; border-radius: 10px; padding: 30px; text-align: center; cursor: pointer; transition: all 0.2s; background: #F8FAFC; }
.archivio-dropzone:hover, .archivio-dropzone.dragover { border-color: #3B82F6; background: #EFF6FF; }
.archivio-dropzone .material-symbols-rounded { font-size: 40px; color: #94A3B8; }
.archivio-dropzone p { font-size: 13px; color: #64748B; margin: 8px 0 0; }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 768px) {
    .richieste-stats { grid-template-columns: repeat(2, 1fr); }
    .richieste-toolbar { flex-direction: column; align-items: stretch; }
    .richieste-filters { flex-wrap: wrap; }
    .archivio-layout { grid-template-columns: 1fr; }
    .archivio-sidebar { border-right: none; border-bottom: 1px solid #E2E8F0; max-height: 200px; }
    .archivio-file-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .form-row-2 { grid-template-columns: 1fr; }
    .kb-stats-row { grid-template-columns: 1fr; }
    .kb-toolbar { flex-direction: column; align-items: stretch; }
}

.kb-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kb-stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.kb-stat-card:hover {
    box-shadow: var(--shadow-md);
}

.kb-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kb-stat-icon .material-symbols-rounded {
    font-size: 22px;
}

.kb-stat-info {
    display: flex;
    flex-direction: column;
}

.kb-stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.kb-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.kb-panel {
    animation: fadeIn 0.25s ease;
}

.kb-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.kb-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.kb-search-wrap .material-symbols-rounded {
    position: absolute;
    left: 10px;
    font-size: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.kb-search-wrap .form-control {
    padding-left: 34px;
    width: 220px;
}

.kb-protocollo-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 10px;
    transition: all var(--transition);
}

.kb-protocollo-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.kb-protocollo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.kb-protocollo-info {
    flex: 1;
    min-width: 0;
}

.kb-protocollo-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.kb-protocollo-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.kb-protocollo-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.kb-detail-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.kb-detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.kb-detail-row {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 6px;
}

.kb-detail-row strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.kb-detail-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.kb-detail-title .material-symbols-rounded {
    font-size: 18px;
    color: var(--primary);
}

.kb-detail-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.kb-detail-list li {
    font-size: 13px;
    color: var(--text);
    padding: 4px 0 4px 20px;
    position: relative;
}

.kb-detail-list li::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 12px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

/* =============================================
   Richieste Page - Sections & Tabs
   ============================================= */

.richieste-sections-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.richieste-section-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    border: none;
    background: none;
    position: relative;
}

.richieste-section-tab:hover {
    background: var(--bg);
    color: var(--text);
}

.richieste-section-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.richieste-section-tab .material-symbols-rounded {
    font-size: 20px;
}

.richieste-section-tab .tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-secondary);
    line-height: 1;
}

.richieste-section-tab.active .tab-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.richieste-section {
    display: none;
    animation: fadeIn 0.25s ease;
}

.richieste-section.active {
    display: block;
}

/* =============================================
   Assenze Stats Bar
   ============================================= */

.assenze-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.assenze-stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.assenze-stat-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.assenze-stat-icon .material-symbols-rounded {
    font-size: 20px;
}

.assenze-stat-icon.stat-pending {
    background: #FEF3C7;
    color: #B45309;
}

.assenze-stat-icon.stat-approved {
    background: #DCFCE7;
    color: #15803D;
}

.assenze-stat-icon.stat-rejected {
    background: #FEE2E2;
    color: #B91C1C;
}

.assenze-stat-icon.stat-cancelled {
    background: #F1F5F9;
    color: #475569;
}

.assenze-stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.assenze-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

/* =============================================
   Assenza Card
   ============================================= */

.assenza-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    transition: all var(--transition);
    cursor: pointer;
}

.assenza-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.assenza-card:last-child {
    margin-bottom: 0;
}

.assenza-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.assenza-card-employee {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.assenza-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.assenza-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assenza-card-role {
    font-size: 11px;
    color: var(--text-muted);
}

.assenza-card-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.assenza-card-body {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.assenza-card-dates {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
}

.assenza-card-dates .material-symbols-rounded {
    font-size: 18px;
    color: var(--primary);
    flex-shrink: 0;
}

.assenza-card-dates .date-separator {
    color: var(--text-muted);
    font-size: 12px;
}

.assenza-card-duration {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: var(--primary-50);
    color: var(--primary-dark);
    white-space: nowrap;
}

.assenza-card-duration .material-symbols-rounded {
    font-size: 14px;
}

.assenza-card-motivo {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =============================================
   Assenza Tipo Badge (colored by type)
   ============================================= */

.assenza-tipo-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.assenza-tipo-badge.tipo-ferie {
    background: #D1FAE5;
    color: #065F46;
}

.assenza-tipo-badge.tipo-permesso {
    background: #DBEAFE;
    color: #1D4ED8;
}

.assenza-tipo-badge.tipo-congedo {
    background: #EDE9FE;
    color: #6D28D9;
}

.assenza-tipo-badge.tipo-riposo {
    background: #E0F2FE;
    color: #0369A1;
}

.assenza-tipo-badge.tipo-malattia {
    background: #FEE2E2;
    color: #B91C1C;
}

.assenza-tipo-badge.tipo-maternita,
.assenza-tipo-badge.tipo-paternita {
    background: #FCE7F3;
    color: #BE185D;
}

.assenza-tipo-badge.tipo-lutto {
    background: #F3F4F6;
    color: #374151;
}

.assenza-tipo-badge.tipo-studio {
    background: #FEF3C7;
    color: #B45309;
}

.assenza-tipo-badge.tipo-sindacale {
    background: #FFF7ED;
    color: #C2410C;
}

.assenza-tipo-badge.tipo-altro {
    background: #F1F5F9;
    color: #475569;
}

/* =============================================
   Assenza Stato Badge
   ============================================= */

.assenza-stato-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.assenza-stato-badge.stato-in_attesa {
    background: #FEF3C7;
    color: #B45309;
}

.assenza-stato-badge.stato-approvata {
    background: #DCFCE7;
    color: #15803D;
}

.assenza-stato-badge.stato-rifiutata {
    background: #FEE2E2;
    color: #B91C1C;
}

.assenza-stato-badge.stato-annullata {
    background: #F1F5F9;
    color: #475569;
}

.assenza-stato-badge .material-symbols-rounded {
    font-size: 14px;
}

/* =============================================
   Assenza Sync Indicator
   ============================================= */

.assenza-sync-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.assenza-sync-indicator.synced {
    background: #D1FAE5;
    color: #065F46;
}

.assenza-sync-indicator.not-synced {
    background: #F1F5F9;
    color: #94A3B8;
}

.assenza-sync-indicator .material-symbols-rounded {
    font-size: 14px;
}

/* =============================================
   Mini Calendar
   ============================================= */

.mini-calendar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.mini-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.mini-calendar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    text-transform: capitalize;
}

.mini-calendar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mini-calendar-nav button {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.mini-calendar-nav button:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

.mini-calendar-nav button .material-symbols-rounded {
    font-size: 18px;
}

.mini-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.mini-calendar-weekday {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 0 8px;
}

.mini-calendar-day {
    position: relative;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    padding: 6px 2px;
    border-radius: var(--radius-xs);
    cursor: default;
    transition: all var(--transition);
    line-height: 1;
}

.mini-calendar-day.other-month {
    color: var(--text-muted);
    opacity: 0.4;
}

.mini-calendar-day.today {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    border-radius: 50%;
}

.mini-calendar-day.has-leave {
    position: relative;
}

.mini-calendar-day.has-leave::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary-light);
}

.mini-calendar-day.today.has-leave::after {
    background: #fff;
}

.mini-calendar-day.has-leave.leave-ferie::after {
    background: #10B981;
}

.mini-calendar-day.has-leave.leave-permesso::after {
    background: #3B82F6;
}

.mini-calendar-day.has-leave.leave-congedo::after {
    background: #8B5CF6;
}

.mini-calendar-day.has-leave.leave-malattia::after {
    background: #EF4444;
}

.mini-calendar-day.has-leave.leave-riposo::after {
    background: #0EA5E9;
}

/* =============================================
   Farmacia Quantita Display
   ============================================= */

.farmacia-quantita {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: #FEF3C7;
    color: #B45309;
    white-space: nowrap;
}

.farmacia-quantita .material-symbols-rounded {
    font-size: 14px;
}

/* =============================================
   Richieste Section Filter & Action Bar
   ============================================= */

.richieste-section-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.richieste-section-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.richieste-section-filters .form-control {
    min-width: 140px;
    max-width: 200px;
}

.assenze-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
}

.assenze-list-col {
    min-width: 0;
}

.assenze-calendar-col {
    position: sticky;
    top: 0;
}

.assenze-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.assenze-empty-state .material-symbols-rounded {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.assenze-empty-state p {
    font-size: 14px;
    margin-bottom: 4px;
}

.assenze-empty-state .text-sm {
    font-size: 12px;
}

/* =============================================
   Richieste Page - Responsive
   ============================================= */

@media (max-width: 768px) {
    .richieste-sections-tabs {
        flex-direction: column;
        gap: 2px;
    }

    .richieste-section-tab {
        justify-content: flex-start;
    }

    .assenze-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .assenze-layout {
        grid-template-columns: 1fr;
    }

    .assenze-calendar-col {
        position: static;
        order: -1;
    }

    .assenza-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .assenza-card-body {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .richieste-section-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .richieste-section-filters {
        flex-wrap: wrap;
    }

    .richieste-section-filters .form-control {
        min-width: 100%;
    }

    .mini-calendar {
        padding: 12px;
    }

    .mini-calendar-day {
        padding: 4px 1px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .assenze-stats {
        grid-template-columns: 1fr;
    }

    .assenza-card {
        padding: 12px 14px;
    }

    .assenza-card-badges {
        flex-direction: column;
        align-items: flex-start;
    }
}

.assenze-top-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 900px) {
    .assenze-top-grid { grid-template-columns: 1fr; }
}

.assenze-stats-panel { display: flex; flex-direction: column; gap: 16px; }

.assenza-stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border: 1px solid #E2E8F0;
    min-width: 0;
}
.assenza-stat-card.stat-attesa { border-left: 3px solid #F59E0B; }
.assenza-stat-card.stat-approvata { border-left: 3px solid #10B981; }
.assenza-stat-card.stat-rifiutata { border-left: 3px solid #EF4444; }
.assenza-stat-card.stat-annullata { border-left: 3px solid #94A3B8; }
.assenza-stat-value { font-size: 22px; font-weight: 700; color: #0F172A; }
.assenza-stat-label { font-size: 11px; color: #64748B; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

.assenze-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.assenze-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.assenza-card-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.assenza-card-nome { font-weight: 600; font-size: 14px; color: #0F172A; }
.assenza-card-ruolo { font-size: 12px; color: #64748B; }

.assenza-card-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.assenza-card-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: #E0E7FF;
    display: flex; align-items: center; justify-content: center;
    color: #4F46E5;
    flex-shrink: 0;
}

.assenza-card-body { padding: 0 16px 12px 16px; }
.assenza-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.assenza-duration-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    background: #F1F5F9;
    padding: 3px 10px;
    border-radius: 20px;
}

.assenza-sync-ok {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #059669;
    background: #ECFDF5;
    padding: 3px 10px;
    border-radius: 20px;
}

.assenza-card-motivo {
    font-size: 13px;
    color: #64748B;
    margin-top: 8px;
    line-height: 1.4;
}

.assenza-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-top: 1px solid #F1F5F9;
    font-size: 11px;
    color: #94A3B8;
}
.assenza-card-date-created { font-size: 11px; }
.assenza-card-approver { font-size: 11px; font-weight: 500; }

.assenze-calendar-panel {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #E2E8F0;
    padding: 16px;
}

.mini-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.mini-calendar-title { font-weight: 600; font-size: 15px; color: #0F172A; }

.btn-icon-sm {
    width: 30px; height: 30px;
    border-radius: 6px;
    border: 1px solid #E2E8F0;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-icon-sm:hover { background: #F1F5F9; }
.btn-icon-sm .material-symbols-rounded { font-size: 18px; color: #475569; }

.mini-cal-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #94A3B8;
    margin-bottom: 4px;
}
.mini-cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.mini-cal-day {
    position: relative;
    text-align: center;
    font-size: 13px;
    padding: 6px 2px 10px;
    border-radius: 6px;
    cursor: default;
    color: #334155;
}
.mini-cal-day.empty { visibility: hidden; }
.mini-cal-day.today {
    background: #EEF2FF;
    font-weight: 700;
    color: #4F46E5;
}
.mini-cal-day.has-leave { font-weight: 600; }

.cal-dots {
    display: flex;
    justify-content: center;
    gap: 2px;
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
}
.cal-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    display: inline-block;
}
.cal-dot.dot-ferie { background: #10B981; }
.cal-dot.dot-permesso { background: #3B82F6; }
.cal-dot.dot-congedo { background: #8B5CF6; }
.cal-dot.dot-malattia { background: #EF4444; }
.cal-dot.dot-altro { background: #94A3B8; }

.mini-calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #F1F5F9;
}
.cal-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #64748B;
}

.stato-attesa {
    background: #FEF3C7;
    color: #92400E;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.stato-approvata {
    background: #DCFCE7;
    color: #166534;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.stato-rifiutata {
    background: #FEE2E2;
    color: #991B1B;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.stato-annullata {
    background: #F1F5F9;
    color: #64748B;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tipo-ferie { background: #DCFCE7; color: #166534; }
.tipo-permesso { background: #DBEAFE; color: #1D4ED8; }
.tipo-congedo { background: #EDE9FE; color: #6D28D9; }
.tipo-riposo { background: #E0F2FE; color: #0369A1; }
.tipo-malattia { background: #FEE2E2; color: #991B1B; }
.tipo-altro { background: #F1F5F9; color: #475569; }

/* ===== STAMPA: orientamento landscape per tutto il sistema ===== */
@page { size: A4 landscape; margin: 6mm 7mm; }

.print-container {
    display: none;
}

@media print {

    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }

    body { background: #fff !important; margin: 0; padding: 0; font-size: 10px; }

    body:not(.printing-consegne):not(.printing-cartella) > *:not(.print-container) { display: none !important; }
    body > .print-container { display: block !important; }
    body.printing-consegne > * { display: block !important; }
    body.printing-consegne > .consegne-page { display: block !important; }
    body.printing-consegne .sidebar, body.printing-consegne .topbar, body.printing-consegne .mobile-header, body.printing-consegne .sidebar-overlay { display: none !important; }
    body.printing-consegne .app-layout { display: block !important; }
    body.printing-consegne .main-content { display: block !important; margin: 0 !important; padding: 0 !important; }
    body.printing-consegne .content-body { display: block !important; padding: 0 !important; margin: 0 !important; }

    html, body {
        height: auto !important;
        overflow: visible !important;
    }

    .main-content {
        height: auto !important;
        overflow: visible !important;
        display: block !important;
    }
    .page-content { overflow: visible !important; height: auto !important; }

    .print-page {
        page-break-after: always;
        page-break-inside: avoid;
        padding: 0;
        margin: 0;
    }
    .print-page:last-child { page-break-after: auto; }

    .print-page-header {
        text-align: center;
        margin-bottom: 6px;
        padding-bottom: 4px;
        border-bottom: 2px solid #333;
    }
    .print-title {
        font-size: 16px;
        font-weight: 800;
        color: #111;
        letter-spacing: 0.5px;
    }
    .print-subtitle {
        font-size: 10px;
        color: #666;
        margin-top: 2px;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;
        font-size: 8px;
    }

    .print-table thead th {
        background: #f0f0f0 !important;
        border: 1px solid #999;
        padding: 3px 1px;
        text-align: center;
        font-weight: 700;
        vertical-align: middle;
    }

    .print-user-th {
        width: 110px;
        text-align: left !important;
        padding-left: 4px !important;
        font-size: 8px;
    }

    .print-day-th {
        font-size: 7px;
    }
    .print-day-th.print-weekend {
        background: #e8e8e8 !important;
    }
    .print-day-name {
        font-size: 6px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        color: #555;
        line-height: 1;
    }
    .print-day-num {
        font-size: 10px;
        font-weight: 800;
        line-height: 1.2;
    }

    .print-ore-th {
        width: 72px;
        font-size: 7px;
        white-space: nowrap;
    }

    .print-table tbody td {
        border: 1px solid #bbb;
        padding: 0;
        text-align: center;
        vertical-align: middle;
        height: 22px;
    }

    .print-user-td {
        text-align: left !important;
        padding: 2px 4px !important;
        border-right: 2px solid #888 !important;
    }
    .print-user-name {
        font-size: 7px;
        font-weight: 700;
        color: #111;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100px;
    }
    .print-user-role {
        font-size: 5.5px;
        color: #777;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

    .print-shift-td {
        font-weight: 800;
        font-size: 8px;
        text-align: center;
        vertical-align: middle;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    .print-shift-label {
        line-height: 1;
        font-size: 9px;
        font-weight: 900;
    }
    .print-shift-area {
        font-size: 5.5px;
        font-weight: 700;
        opacity: 0.9;
        line-height: 1;
        margin-top: 1px;
    }

    .print-weekend-cell {
        background: #f5f5f5 !important;
    }

    .print-ore-td {
        font-size: 8px;
        text-align: center;
        border-left: 2px solid #888 !important;
        padding: 2px 3px !important;
        vertical-align: middle !important;
    }
    .print-ore-counts {
        display: flex;
        justify-content: center;
        gap: 2px;
        margin-bottom: 2px;
    }
    .print-ore-badge {
        display: inline-flex;
        align-items: center;
        gap: 1px;
        color: #fff;
        font-size: 6.5px;
        font-weight: 700;
        padding: 1px 3px;
        border-radius: 3px;
        line-height: 1.2;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    .print-ore-badge b {
        font-size: 7.5px;
    }
    .print-ore-total {
        font-size: 8px;
        font-weight: 600;
        color: #1E293B;
        margin-top: 1px;
    }
    .print-ore-total strong {
        font-size: 10px;
    }

    .print-legend {
        display: flex;
        justify-content: center;
        gap: 10px;
        margin-top: 6px;
        padding-top: 4px;
        border-top: 1px solid #ccc;
        flex-wrap: wrap;
    }
    .print-legend-item {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        font-size: 7px;
        font-weight: 600;
        color: #333;
    }
    .print-legend-dot {
        width: 8px;
        height: 8px;
        border-radius: 2px;
        display: inline-block;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
}

.motivo-filter-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #EEF2FF, #E0E7FF);
    border: 1px solid #C7D2FE;
    border-radius: 10px;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}
.motivo-filter-banner-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #3730A3;
    line-height: 1.4;
}
.motivo-filter-banner-left .material-symbols-rounded {
    font-size: 22px;
    color: #6366F1;
    flex-shrink: 0;
}
.motivo-filter-show-all {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: #fff;
    border: 1px solid #C7D2FE;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #4F46E5;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.motivo-filter-show-all:hover {
    background: #EEF2FF;
    border-color: #818CF8;
}
.motivo-filter-show-all .material-symbols-rounded { font-size: 16px; }

.symptom-category.motivo-match {
    border-color: #818CF8;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.15);
}
.symptom-category.motivo-match > .symptom-category-header {
    background: linear-gradient(135deg, #F5F3FF, #EEF2FF);
}

.symptom-check.motivo-highlight {
    background: #EEF2FF;
    border-left: 3px solid #6366F1;
    padding-left: 9px;
    border-radius: 6px;
}

@media (max-width: 600px) {
    .motivo-filter-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .motivo-filter-show-all { align-self: flex-end; }
}

.dashboard-collapsible-section {
    margin-bottom: 24px;
}
.dashboard-collapsible-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.dashboard-collapsible-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-light);
}
.dashboard-collapsible-toggle-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.dashboard-collapsible-toggle-left .material-symbols-rounded {
    font-size: 20px;
    color: var(--primary);
}
.dashboard-collapsible-arrow {
    font-size: 22px;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}
.dashboard-collapsible-section:not(.collapsed) .dashboard-collapsible-arrow {
    transform: rotate(180deg);
}
.dashboard-collapsible-content {
    margin-top: 16px;
    animation: fadeIn 0.25s ease;
}
.dashboard-collapsible-section.collapsed .dashboard-collapsible-content {
    display: none;
}
.dashboard-collapsible-section.collapsed .dashboard-collapsible-toggle {
    border-radius: var(--radius);
    margin-bottom: 0;
}

.selected-symptoms-panel {
    margin-top: 20px;
    margin-bottom: 8px;
}
.selected-symptoms-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
}
.selected-symptoms-header .material-symbols-rounded {
    font-size: 18px;
    color: var(--primary);
}
.selected-symptoms-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}
.selected-symptoms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.selected-symptom-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #EEF2FF;
    border: 1px solid #C7D2FE;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: #3730A3;
    transition: all 0.15s;
    cursor: default;
}
.selected-symptom-tag .symptom-tag-sev {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.selected-symptom-tag .symptom-tag-sev-1 { background: #DC2626; }
.selected-symptom-tag .symptom-tag-sev-2 { background: #EA580C; }
.selected-symptom-tag .symptom-tag-sev-3 { background: #2563EB; }
.selected-symptom-tag .symptom-tag-sev-4 { background: #16A34A; }
.selected-symptom-tag .symptom-tag-sev-5 { background: #6B7280; }
.selected-symptom-tag .symptom-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(79,70,229,0.1);
    color: #4F46E5;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1;
}
.selected-symptom-tag .symptom-tag-remove:hover {
    background: #DC2626;
    color: #fff;
}
.selected-symptoms-empty {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.clinical-questions-panel {
    margin-top: 16px;
    border: 1px solid var(--border, #E2E8F0);
    border-radius: 12px;
    padding: 16px;
    background: var(--card-bg, #F8FAFC);
}
.clinical-questions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #1E293B);
    margin-bottom: 4px;
}
.clinical-questions-header .material-symbols-rounded {
    font-size: 20px;
    color: #8B5CF6;
}
.clinical-questions-desc {
    font-size: 12px;
    color: var(--text-muted, #64748B);
    margin-bottom: 12px;
}
.clinical-symptom-group {
    margin-bottom: 14px;
}
.clinical-symptom-group:last-child {
    margin-bottom: 0;
}
.clinical-symptom-header {
    font-size: 13px;
    font-weight: 700;
    color: #8B5CF6;
    padding: 6px 10px;
    background: rgba(139, 92, 246, 0.08);
    border-radius: 8px;
    margin-bottom: 8px;
}
.clinical-question-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border, #F1F5F9);
    transition: background 0.15s;
}
.clinical-question-item:hover {
    background: rgba(139, 92, 246, 0.03);
}
.clinical-question-item:last-child {
    border-bottom: none;
}
.clinical-question-text {
    font-size: 13.5px;
    color: var(--text-primary, #334155);
    line-height: 1.5;
    font-weight: 500;
}
.cq-translate-bar {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
    padding: 4px 0 2px 0;
}
.cq-flag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 20px;
    padding: 0;
    border: 1.5px solid transparent;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0.6;
}
.cq-flag-btn:hover {
    opacity: 1;
    border-color: #8B5CF6;
    background: rgba(139, 92, 246, 0.06);
    transform: scale(1.15);
}
.cq-flag-btn.active {
    opacity: 1;
    border-color: #8B5CF6;
    background: rgba(139, 92, 246, 0.12);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}
.cq-flag-img {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    object-fit: cover;
}
.cq-play-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1.5px solid var(--border, #E2E8F0);
    border-radius: 50%;
    background: var(--bg, #FFF);
    cursor: pointer;
    color: #8B5CF6;
    margin-left: 4px;
    transition: all 0.2s;
}
.cq-play-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: #8B5CF6;
    transform: scale(1.1);
}
.cq-play-btn .material-symbols-rounded {
    font-size: 18px;
}
.cq-play-btn.speaking {
    background: rgba(139, 92, 246, 0.15);
    border-color: #7C3AED;
    animation: cq-pulse 1s infinite;
}
@keyframes cq-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
}
.cq-lang-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: #FFF;
    background: #8B5CF6;
    padding: 1px 5px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 4px;
    letter-spacing: 0.5px;
}
.clinical-question-input {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.clinical-yesno-group {
    display: flex;
    gap: 8px;
}
.clinical-yesno-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid var(--border, #E2E8F0);
    background: var(--bg, #FFF);
    color: var(--text-secondary, #64748B);
    transition: all 0.2s;
}
.clinical-yesno-btn .material-symbols-rounded {
    font-size: 18px;
}
.clinical-yesno-btn.yes:hover,
.clinical-yesno-btn.yes.selected {
    background: rgba(22, 163, 74, 0.1);
    border-color: #16A34A;
    color: #16A34A;
}
.clinical-yesno-btn.no:hover,
.clinical-yesno-btn.no.selected {
    background: rgba(239, 68, 68, 0.1);
    border-color: #EF4444;
    color: #EF4444;
}
.clinical-options-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.clinical-option-btn {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    border: 2px solid var(--border, #E2E8F0);
    background: var(--bg, #FFF);
    color: var(--text-secondary, #64748B);
    transition: all 0.2s;
    white-space: nowrap;
}
.clinical-option-btn:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
    background: rgba(139, 92, 246, 0.06);
}
.clinical-option-btn.selected {
    background: rgba(139, 92, 246, 0.12);
    border-color: #8B5CF6;
    color: #7C3AED;
    font-weight: 600;
}
.clinical-scale-group {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}
.clinical-scale {
    flex: 1;
    max-width: 250px;
    accent-color: #8B5CF6;
    height: 6px;
}
.clinical-scale-val {
    font-size: 14px;
    font-weight: 700;
    color: #8B5CF6;
    min-width: 36px;
    text-align: center;
}
.clinical-text-input {
    padding: 8px 12px;
    border: 2px solid var(--border, #E2E8F0);
    border-radius: 8px;
    font-size: 13px;
    width: 100%;
    max-width: 400px;
    background: var(--bg, #FFF);
    color: var(--text-primary, #334155);
    transition: border-color 0.2s;
}
.clinical-text-input:focus {
    border-color: #8B5CF6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
.clinical-loading {
    text-align: center;
    padding: 12px;
    font-size: 13px;
    color: var(--text-muted, #64748B);
}

.login-quick-links { display: flex; gap: 8px; margin-top: 12px; }
.btn-consegne-login { display: flex; align-items: center; justify-content: center; gap: 6px; flex: 1; padding: 10px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; color: #FFFFFF; background: rgba(59,130,246,0.5); border: 1px solid rgba(59,130,246,0.6); text-decoration: none; transition: all 0.2s; cursor: pointer; white-space: nowrap; }
.btn-consegne-login:hover { background: rgba(59,130,246,0.25); border-color: rgba(59,130,246,0.5); transform: translateY(-1px); }
.btn-consegne-login .material-symbols-rounded { font-size: 18px; }
@media (max-width: 480px) {
    .login-quick-links { gap: 5px; }
    .btn-consegne-login { padding: 8px 4px; font-size: 10px; gap: 3px; border-radius: 8px; }
    .btn-consegne-login .material-symbols-rounded { font-size: 14px; }
}
/* ── Ferie Vista Tabs (1s/2s/3s) ── */
.ferie-vista-tabs { display: inline-flex; gap: 3px; background: rgba(0,0,0,0.08); border-radius: 10px; padding: 3px; margin-left: 10px; }
.ferie-vista-btn { background: transparent; border: none; border-radius: 7px; padding: 4px 11px; font-size: 12px; font-weight: 600; color: var(--text-muted,#64748B); cursor: pointer; transition: all 0.18s; white-space: nowrap; }
.ferie-vista-btn:hover { background: rgba(16,185,129,0.12); color: #065F46; }
.ferie-vista-btn.active { background: #10B981; color: #fff; box-shadow: 0 1px 4px rgba(16,185,129,0.35); }

/* Varianti colore quick-links login */
.btn-ql-orange { background: rgba(249,115,22,0.55); border-color: rgba(249,115,22,0.7); }
.btn-ql-orange:hover { background: rgba(249,115,22,0.35); border-color: rgba(249,115,22,0.6); }
.btn-ql-blue { background: rgba(59,130,246,0.55); border-color: rgba(59,130,246,0.7); }
.btn-ql-blue:hover { background: rgba(59,130,246,0.35); border-color: rgba(59,130,246,0.6); }
.btn-ql-green { background: linear-gradient(135deg,#10B981,#059669); border-color: #059669; }
.btn-ql-green:hover { background: linear-gradient(135deg,#059669,#047857); border-color: #047857; }
.btn-ql-purple { background: rgba(161,120,0,0.65); border-color: rgba(161,120,0,0.85); }
.btn-ql-purple:hover { background: rgba(161,120,0,0.45); border-color: rgba(161,120,0,0.7); }
.login-flags-single-row { flex-wrap: nowrap !important; gap: 4px !important; }
.login-flags-single-row .lang-flag-btn { padding: 3px !important; }
.login-flags-single-row .lang-flag-btn img { width: 24px !important; height: 18px !important; }

.consegne-pin-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.6); backdrop-filter: blur(4px); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.consegne-pin-modal { background: #FFF; border-radius: 16px; padding: 32px; width: 90%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); text-align: center; }
.consegne-pin-modal h3 { font-size: 18px; font-weight: 700; color: #1E293B; margin: 0 0 6px; }
.consegne-pin-modal p { font-size: 13px; color: #64748B; margin: 0 0 20px; }
.consegne-pin-modal .material-symbols-rounded.pin-icon { font-size: 48px; color: #3B82F6; margin-bottom: 12px; }
.consegne-pin-input { width: 100%; padding: 12px 16px; border: 2px solid #E2E8F0; border-radius: 10px; font-size: 20px; text-align: center; letter-spacing: 6px; outline: none; transition: border-color 0.2s; box-sizing: border-box; }
.consegne-pin-input:focus { border-color: #3B82F6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.consegne-pin-input.pin-error { border-color: #EF4444; animation: pinShake 0.4s; }
@keyframes pinShake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-6px)} 80%{transform:translateX(6px)} }
.consegne-pin-btn { width: 100%; padding: 12px; margin-top: 16px; border: none; border-radius: 10px; background: #3B82F6; color: #FFF; font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.consegne-pin-btn:hover { background: #2563EB; }
.consegne-pin-error-msg { color: #EF4444; font-size: 12px; font-weight: 600; margin-top: 8px; min-height: 18px; }
.consegne-locked .consegne-cell-edit { filter: blur(4px); pointer-events: none; user-select: none; }
.consegne-lock-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 600; color: #92400E; background: #FEF3C7; border: 1px solid #FDE68A; cursor: pointer; transition: all 0.2s; }
.consegne-lock-badge:hover { background: #FDE68A; }
.consegne-lock-badge .material-symbols-rounded { font-size: 16px; }

.consegne-countdown { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 600; color: #065F46; background: #D1FAE5; border: 1px solid #6EE7B7; margin-bottom: 12px; flex-wrap: wrap; }
.consegne-countdown .material-symbols-rounded { font-size: 16px; }
.btn-auto-vitali { display: inline-flex; align-items: center; justify-content: center; padding: 4px; border-radius: 6px; color: #fff; background: linear-gradient(135deg, #6366F1, #8B5CF6); border: none; cursor: pointer; margin-left: 8px; transition: all 0.2s; }
.btn-auto-vitali:hover { background: linear-gradient(135deg, #4F46E5, #7C3AED); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(99,102,241,0.35); }
.btn-auto-vitali:active { transform: translateY(0); }
.btn-auto-vitali .material-symbols-rounded { font-size: 14px; }

.consegne-guest-body { margin: 0; padding: 0; background: #F1F5F9; font-family: 'Inter', sans-serif; overflow-y: auto; min-height: 100vh; }
.consegne-guest { max-width: 1400px; margin: 0 auto; }
.consegne-main-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.consegne-main-tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 10px; font-size: 15px; font-weight: 700; border: 2px solid #E2E8F0; background: #FFF; color: #64748B; cursor: pointer; transition: all 0.2s; }
.consegne-main-tab .material-symbols-rounded { font-size: 22px; }
.consegne-main-tab:hover { border-color: #93C5FD; color: #3B82F6; background: #EFF6FF; }
.consegne-main-tab.active { border-color: #3B82F6; color: #FFF; background: linear-gradient(135deg, #3B82F6, #2563EB); box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
a.consegne-main-tab { text-decoration: none; }
.consegne-tab-logout { border-color: #FCA5A5; color: #DC2626; }
.consegne-tab-logout:hover { border-color: #DC2626; color: #FFF; background: linear-gradient(135deg, #EF4444, #DC2626); box-shadow: 0 4px 12px rgba(220,38,38,0.25); }

.consegne-page { padding: 24px; }
.consegne-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 16px; }
.consegne-header-left { flex: 1; }
.consegne-title { font-size: 24px; font-weight: 700; color: #1E293B; display: flex; align-items: center; gap: 10px; margin: 0; }
.consegne-title .material-symbols-rounded { font-size: 28px; color: #3B82F6; }
.consegne-subtitle { font-size: 13px; color: #64748B; margin: 4px 0 0 38px; }
.consegne-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-consegne-action { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 600; border: 1px solid; cursor: pointer; transition: all 0.2s; }
.btn-consegne-clear { background: #FFF; border-color: #E2E8F0; color: #64748B; }
.btn-consegne-clear:hover { background: #FEF2F2; border-color: #FCA5A5; color: #DC2626; }
.btn-consegne-save { background: #F0FDF4; border-color: #86EFAC; color: #16A34A; }
.btn-consegne-save:hover { background: #DCFCE7; border-color: #4ADE80; }
.btn-consegne-print { background: #3B82F6; border-color: #3B82F6; color: #FFF; }
.btn-consegne-print:hover { background: #2563EB; border-color: #2563EB; }
.btn-consegne-action .material-symbols-rounded { font-size: 18px; }

.consegne-meta-bar { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.consegne-meta-field { display: flex; flex-direction: column; gap: 4px; }
.consegne-meta-field label { font-size: 12px; font-weight: 600; color: #64748B; text-transform: uppercase; letter-spacing: 0.5px; }
.consegne-clock { padding: 8px 14px; border: 1px solid #E2E8F0; border-radius: 8px; font-size: 16px; font-weight: 700; color: #1E293B; background: #FFF; font-variant-numeric: tabular-nums; letter-spacing: 1px; min-width: 90px; text-align: center; }
.consegne-input { padding: 8px 14px; border: 1px solid #E2E8F0; border-radius: 8px; font-size: 14px; color: #1E293B; background: #FFF; outline: none; transition: border-color 0.2s; }
.consegne-input:focus { border-color: #3B82F6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

.consegne-table-wrap { border: 2px solid #1E293B; border-radius: 12px; overflow: hidden; background: #FFF; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.consegne-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.consegne-table thead th { background: linear-gradient(135deg, #1E293B 0%, #334155 100%); color: #FFF; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; padding: 12px 14px; text-align: left; border: none; }
.consegne-table thead th:first-child { border-radius: 0; }
.consegne-table thead th:last-child { border-radius: 0; }
.col-letto { width: 10%; }
.col-paziente { width: 16%; }
.col-diagnosi { width: 22%; }
.col-dieta { width: 12%; }
.col-prestazioni { width: 20%; }
.col-note { width: 20%; }

/* ===== STANZA SEPARATOR ROWS ===== */
.consegne-stanza-row td {
    padding: 0 !important;
    border: none !important;
}
.consegne-stanza-row .stanza-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
    box-sizing: border-box;
}
.consegne-stanza-row .material-symbols-rounded { font-size: 16px; }
/* OBI — azzurro */
.consegne-stanza-row.stanza-obi,
.consegne-stanza-row.stanza-obi td { background: #DBEAFE !important; border-bottom: 2px solid #93C5FD !important; }
.consegne-stanza-row.stanza-obi .stanza-inner { color: #1D4ED8; }
/* Accettazione — verde smeraldo */
.consegne-stanza-row.stanza-acc,
.consegne-stanza-row.stanza-acc td { background: #D1FAE5 !important; border-bottom: 2px solid #6EE7B7 !important; }
.consegne-stanza-row.stanza-acc .stanza-inner { color: #065F46; }
/* Medicina ST* — ambra */
.consegne-stanza-row.stanza-med,
.consegne-stanza-row.stanza-med td { background: #FEF3C7 !important; border-bottom: 2px solid #FCD34D !important; }
.consegne-stanza-row.stanza-med .stanza-inner { color: #92400E; }

.consegne-row td { padding: 0; border-bottom: 1.5px solid #334155; vertical-align: top; }
.consegne-row:hover td { background: #FAFBFF; }
.consegne-row:last-child td { border-bottom: none; }
.consegne-letto-badge { display: inline-flex; align-items: center; justify-content: center; background: #F1F5F9; color: #334155; font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 6px; margin: 8px; white-space: nowrap; }

.consegne-cell-edit { min-height: 38px; padding: 8px 12px; font-size: 13px; color: #1E293B; outline: none; line-height: 1.5; word-break: break-word; cursor: text; transition: background 0.15s; }
.consegne-cell-edit:empty::before { content: attr(data-placeholder); color: #CBD5E1; font-style: italic; pointer-events: none; }
.consegne-cell-edit:focus { background: #FFFBEB; box-shadow: inset 0 0 0 2px #FDE68A; }

.consegne-toast { position: fixed; bottom: 30px; right: 30px; padding: 12px 24px; border-radius: 10px; font-size: 14px; font-weight: 600; color: #FFF; z-index: 9999; transform: translateY(20px); opacity: 0; transition: all 0.3s; }
.consegne-toast.show { transform: translateY(0); opacity: 1; }
.consegne-toast-success { background: #16A34A; }
.consegne-toast-info { background: #3B82F6; }

.consegne-print-header { display: none; }
.consegne-footer-print { display: none; }

.consegne-firma-row { display: flex; justify-content: space-between; gap: 40px; margin-top: 40px; }
.consegne-firma-box { flex: 1; text-align: center; }
.consegne-firma-box span { font-size: 11px; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: 0.5px; }
.consegne-firma-line { margin-top: 30px; border-bottom: 1px solid #1E293B; }

.vitali-table { table-layout: auto; }
.vt-col-letto { width: 7%; }
.vt-col-paz { width: 11%; }
.vt-col-pa { width: 7%; }
.vt-col-sat { width: 5%; }
.vt-col-o2 { width: 28%; }
.vt-col-bpm { width: 5%; }
.vt-col-temp { width: 5%; }
.vt-col-hgt { width: 6%; }
.vt-col-cat { width: 4%; }
.vt-col-diuresi { width: 6%; }
.vt-col-panno { width: 4%; }

.vitali-row td { padding: 4px 4px !important; vertical-align: middle; }
.vt-paz-input { font-size: 12px; font-weight: 600; color: #1E293B; text-align: left !important; padding: 5px 6px !important; }

.consegne-row-saved { animation: rowSavedFlash 0.8s ease; }
.vitali-row.consegne-row-saved { animation: rowSavedFlash 0.8s ease; }
@keyframes rowSavedFlash { 0% { background-color: rgba(34,197,94,0.15); } 100% { background-color: transparent; } }

.vt-input { width: 100%; padding: 5px 6px; border: 1px solid #E2E8F0; border-radius: 6px; font-size: 12px; color: #1E293B; background: #FFF; outline: none; text-align: center; box-sizing: border-box; transition: border-color 0.2s; }
.vt-input:focus { border-color: #3B82F6; box-shadow: 0 0 0 2px rgba(59,130,246,0.1); }

.vt-o2-wrap { display: flex; flex-wrap: wrap; gap: 2px; }
.vt-o2-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 5px; border-radius: 4px; font-size: 9px; font-weight: 600; cursor: pointer; border: 1px solid #E2E8F0; background: #F8FAFC; color: #64748B; transition: all 0.15s; user-select: none; white-space: nowrap; }
.vt-o2-chip:hover { border-color: #93C5FD; background: #EFF6FF; }
.vt-o2-chip input { display: none; }
.vt-o2-chip:has(input:checked) { background: #3B82F6; color: #FFF; border-color: #3B82F6; }

.vt-o2-blu { border-color: #3B82F6; color: #2563EB; background: #EFF6FF; }
.vt-o2-blu:has(input:checked) { background: #2563EB; border-color: #1D4ED8; color: #FFF; }
.vt-o2-giallo { border-color: #EAB308; color: #A16207; background: #FEFCE8; }
.vt-o2-giallo:has(input:checked) { background: #EAB308; border-color: #CA8A04; color: #422006; }
.vt-o2-bianco { border-color: #94A3B8; color: #475569; background: #F8FAFC; }
.vt-o2-bianco:has(input:checked) { background: #E2E8F0; border-color: #94A3B8; color: #1E293B; }
.vt-o2-verde { border-color: #22C55E; color: #15803D; background: #F0FDF4; }
.vt-o2-verde:has(input:checked) { background: #22C55E; border-color: #16A34A; color: #FFF; }
.vt-o2-rosa { border-color: #EC4899; color: #BE185D; background: #FDF2F8; }
.vt-o2-rosa:has(input:checked) { background: #EC4899; border-color: #DB2777; color: #FFF; }
.vt-o2-arancione { border-color: #F97316; color: #C2410C; background: #FFF7ED; }
.vt-o2-arancione:has(input:checked) { background: #F97316; border-color: #EA580C; color: #FFF; }
.vt-o2-rosso { border-color: #EF4444; color: #B91C1C; background: #FEF2F2; }
.vt-o2-rosso:has(input:checked) { background: #EF4444; border-color: #DC2626; color: #FFF; }

.vt-input-wrap { display: flex; align-items: center; gap: 2px; position: relative; }
.vt-input-wrap .vt-input { flex: 1; min-width: 0; text-align: right; padding-right: 4px; }
.vt-unit { font-size: 9px; font-weight: 600; color: #64748B; white-space: nowrap; flex-shrink: 0; }

.vt-yn-check { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 12px; color: #64748B; justify-content: center; }
.vt-yn-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: #3B82F6; cursor: pointer; }
.vt-yn-check span { font-weight: 600; }

#tabStatsContainer {
    width: 100%; box-sizing: border-box; overflow: hidden;
}
.ts-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}
.ts-stat-card {
    display: flex; align-items: center; gap: 12px; background: #FFFFFF; border-radius: 12px;
    padding: 16px 18px; box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    min-width: 0; overflow: hidden; box-sizing: border-box;
}
.ts-stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); }
.ts-stat-icon { flex-shrink: 0; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.ts-stat-icon .material-symbols-rounded { font-size: 28px; }
.ts-stat-body { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.ts-stat-value { font-size: 22px; font-weight: 700; color: #0F172A; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-stat-label { font-size: 11px; color: #64748B; font-weight: 500; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
    box-sizing: border-box;
}
.ts-chart-box {
    background: #FFFFFF; border-radius: 12px;
    padding: 18px; box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    min-width: 0; overflow: hidden; box-sizing: border-box;
}
.ts-chart-title {
    font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 14px;
    padding-bottom: 10px; border-bottom: 1px solid #F1F5F9;
}
.ts-chart-wrap {
    height: 220px; position: relative; width: 100%; box-sizing: border-box;
}
.ts-chart-wrap canvas {
    width: 100% !important; height: 100% !important;
}

@media (min-width: 1200px) {
    .ts-stats-row { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 769px) and (max-width: 1199px) {
    .ts-stats-row { grid-template-columns: repeat(3, 1fr); }
    .ts-stat-value { font-size: 20px; }
}
@media (max-width: 768px) {
    .ts-stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
    .ts-stat-card { padding: 12px 14px; gap: 10px; border-radius: 10px; }
    .ts-stat-value { font-size: 18px; }
    .ts-stat-label { font-size: 10px; }
    .ts-stat-icon .material-symbols-rounded { font-size: 22px; }
    .ts-stat-icon { width: 30px; height: 30px; }
    .ts-charts-row { grid-template-columns: 1fr; gap: 12px; }
    .ts-chart-box { padding: 14px; }
    .ts-chart-wrap { height: 200px; }
}
@media (max-width: 480px) {
    .ts-stats-row { grid-template-columns: 1fr; }
    .ts-stat-card { padding: 12px; }
    .ts-chart-wrap { height: 180px; }
}

.print-only { display: none !important; }

/* ======================================================
   STAMPA CONSEGNE — A4 LANDSCAPE — 2 PAGINE
   Pagina 1: OBI + ACCETTAZIONE
   Pagina 2: ASTANTERIA MEDICINA
   ====================================================== */
@media print {

    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; box-sizing: border-box !important; }

    html, body {
        margin: 0 !important; padding: 0 !important;
        background: #FFF !important;
        width: 100% !important; height: auto !important;
        overflow: visible !important;
        font-family: 'Inter', Arial, sans-serif !important;
        font-size: 9px !important; line-height: 1.3 !important;
        color: #111 !important;
    }

    .sidebar, .topbar, .mobile-header, .sidebar-overlay,
    .consegne-header, .consegne-meta-bar, .no-print,
    .consegne-lock-badge, .consegne-countdown,
    .consegne-toast, .consegne-pin-overlay,
    .app-header, .nav-sidebar { display: none !important; }

    /* Specificità aumentata per battere body.printing-consegne > * (0,1,0,1) */
    body .consegne-toast,
    body .consegne-countdown,
    body .consegne-lock-badge,
    body .consegne-pin-overlay,
    body #pinOverlay,
    body #pinCountdown,
    body #consegneLockBadge { display: none !important; }

    .print-only { display: block !important; }

    .app-layout { display: block !important; width: 100% !important; margin: 0 !important; padding: 0 !important; }
    .main-content { margin: 0 !important; padding: 0 !important; width: 100% !important; height: auto !important; overflow: visible !important; }
    .content-body { padding: 0 !important; margin: 0 !important; width: 100% !important; overflow: visible !important; }
    .consegne-page { padding: 0 !important; margin: 0 !important; max-width: 100% !important; width: 100% !important; }
    .consegne-guest { max-width: 100% !important; width: 100% !important; }
    .consegne-tab-content { display: block !important; width: 100% !important; }

    /* ---- TAB visibility ---- */
    body.printing-vitali #panelConsegne { display: none !important; }
    body.printing-consegne:not(.printing-vitali) #panelVitali { display: none !important; }
    body.printing-vitali #panelVitali { display: block !important; }

    /* ================================================
       INTESTAZIONE STAMPA — comune a tutte le pagine
       ================================================ */
    .consegne-print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        width: 100% !important;
        margin-bottom: 4px;
        padding-bottom: 4px;
        border-bottom: 2.5px solid #1E293B;
    }
    .consegne-print-logo {
        font-size: 11px; font-weight: 800; color: #1E293B; letter-spacing: 0.5px;
        white-space: nowrap;
    }
    .consegne-print-title h2 {
        font-size: 14px; font-weight: 900; color: #1E293B; margin: 0;
        text-transform: uppercase; letter-spacing: 1px; text-align: center;
        white-space: nowrap;
    }
    .consegne-print-meta { text-align: right; }
    .consegne-print-meta-row { font-size: 8.5px; line-height: 1.4; }
    .consegne-print-label { font-weight: 700; color: #475569; }
    .consegne-print-value { color: #1E293B; margin-left: 3px; }

    /* ================================================
       PAGINA 2 CONSEGNE — salto pagina sul wrapper
       ================================================ */
    .consegne-p2-wrapper {
        page-break-before: always !important;
        break-before: page !important;
        display: block !important;
        width: 100% !important;
    }
    .consegne-print-header-med {
        display: flex !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* ================================================
       TABELLA CONSEGNE (Foglio turno)
       ================================================ */
    .consegne-table-wrap {
        border: 1.5px solid #000000 !important; border-radius: 8px !important;
        box-shadow: none !important; overflow: hidden !important;
        width: 100% !important; margin: 0 !important; padding: 0 !important;
    }
    .consegne-table {
        width: 100% !important; border-collapse: collapse !important;
        table-layout: fixed !important; font-size: 9px !important;
        margin: 0 !important;
    }
    .consegne-table thead th {
        background: #1E293B !important; color: #FFF !important;
        padding: 4px 5px !important; font-size: 9px !important;
        font-weight: 700 !important; line-height: 1.2 !important;
        border: 1px solid #000000 !important; text-align: center !important;
        text-transform: uppercase !important; letter-spacing: 0.3px !important;
        white-space: nowrap !important;
    }
    /* Larghezze colonne consegne — ottimizzate per A4 landscape */
    .col-letto      { width: 7% !important; }
    .col-paziente   { width: 16% !important; }
    .col-diagnosi   { width: 22% !important; }
    .col-dieta      { width: 11% !important; }
    .col-prestazioni{ width: 24% !important; }
    .col-note       { width: 20% !important; }

    .consegne-stanza-row td { padding: 0 !important; border: none !important; }
    .consegne-stanza-row .stanza-inner {
        display: flex !important; align-items: center !important; gap: 3px !important;
        padding: 4px 6px !important; font-size: 9px !important; line-height: 1.3 !important;
        font-weight: 800 !important; text-transform: uppercase !important;
        letter-spacing: 0.5px !important; width: 100% !important; box-sizing: border-box !important;
    }
    .consegne-stanza-row.stanza-obi td,
    .consegne-stanza-row.stanza-obi { background: #BFDBFE !important; border-bottom: 1.5px solid #60A5FA !important; }
    .consegne-stanza-row.stanza-obi .stanza-inner { color: #1E3A8A !important; }
    .consegne-stanza-row.stanza-acc td,
    .consegne-stanza-row.stanza-acc { background: #A7F3D0 !important; border-bottom: 1.5px solid #34D399 !important; }
    .consegne-stanza-row.stanza-acc .stanza-inner { color: #064E3B !important; }
    .consegne-stanza-row.stanza-med td,
    .consegne-stanza-row.stanza-med { background: #FDE68A !important; border-bottom: 1.5px solid #F59E0B !important; }
    .consegne-stanza-row.stanza-med .stanza-inner { color: #78350F !important; }
    .consegne-stanza-row .material-symbols-rounded { font-size: 10px !important; vertical-align: middle !important; }

    .consegne-row td {
        border: 0.75px solid #000000 !important;
        padding: 4px 5px !important;
        line-height: 1.35 !important;
        vertical-align: middle !important;
        text-align: center !important;
        overflow: visible !important;
        word-break: break-word !important;
        min-height: 20px !important;
    }
    .consegne-letto-badge {
        font-size: 9px !important; padding: 2px 5px !important;
        margin: 0 !important; background: #E2E8F0 !important;
        color: #1E293B !important; font-weight: 800 !important;
        border-radius: 3px !important; display: inline-block !important;
        white-space: nowrap !important;
    }
    .consegne-cell-edit {
        min-height: 18px; padding: 1px 2px;
        font-size: 9px !important; line-height: 1.35 !important;
        filter: none !important;
        word-wrap: break-word !important; overflow-wrap: break-word !important;
        overflow: visible !important; white-space: pre-wrap !important;
        display: block !important; text-align: center !important;
    }
    .col-paziente .consegne-cell-edit {
        font-weight: 800 !important;
        text-transform: uppercase !important;
    }
    .consegne-cell-edit:empty::before { content: ''; }
    .consegne-cell-empty { background: #F8FAFC !important; }
    .consegne-locked .consegne-cell-edit { filter: none !important; }

    /* ================================================
       TABELLA PARAMETRI VITALI
       ================================================ */
    body.printing-vitali .consegne-print-header { margin-bottom: 4px; padding-bottom: 4px; }

    .vitali-table {
        width: 100% !important; table-layout: fixed !important;
        border-collapse: collapse !important; font-size: 8.5px !important;
    }
    .vitali-table thead th {
        background: #1E293B !important; color: #FFF !important;
        padding: 4px 3px !important; font-size: 8px !important;
        font-weight: 700 !important; line-height: 1.2 !important;
        white-space: nowrap !important; text-align: center !important;
        border: 1px solid #1E293B !important;
    }
    .vitali-row td {
        padding: 4px 3px !important; line-height: 1.3 !important;
        border: 0.75px solid #CBD5E1 !important;
        vertical-align: middle !important; overflow: visible !important;
        word-break: break-word !important;
    }
    /* Larghezze colonne vitali */
    .vt-col-letto   { width: 6% !important; }
    .vt-col-paz     { width: 12% !important; }
    .vt-col-pa      { width: 8% !important; }
    .vt-col-sat     { width: 6% !important; }
    .vt-col-o2      { width: 22% !important; }
    .vt-col-bpm     { width: 6% !important; }
    .vt-col-temp    { width: 6% !important; }
    .vt-col-hgt     { width: 7% !important; }
    .vt-col-cat     { width: 5% !important; }
    .vt-col-diuresi { width: 8% !important; }
    .vt-col-panno   { width: 5% !important; }

    .vt-paz-input {
        font-size: 9px !important; font-weight: 700 !important;
        border: none !important; background: transparent !important; width: 100%;
    }
    .vt-input {
        font-size: 9px !important; padding: 1px 2px !important;
        border: 0.5px solid #CBD5E1 !important; width: 100% !important;
        background: transparent !important; display: block !important;
    }
    .vt-input-wrap { gap: 1px; display: flex !important; align-items: center !important; }
    .vt-unit { font-size: 7px !important; white-space: nowrap; }

    /* O2 terapia: mostra solo il chip selezionato */
    .vt-o2-wrap { gap: 2px; flex-wrap: wrap; display: flex !important; }
    .vt-o2-chip { display: none !important; font-size: 7.5px !important; padding: 1px 4px !important; border-radius: 3px !important; }
    .vt-o2-chip:has(input:checked) { display: inline-flex !important; background: #1E293B !important; color: #FFF !important; font-weight: 700 !important; }
    .vt-o2-chip input { display: none !important; }
    .vt-o2-litri-wrap { display: flex !important; align-items: center; gap: 2px; margin-top: 2px; }
    .vt-o2-litri { font-size: 8.5px !important; font-weight: 700 !important; border: none !important; background: transparent !important; width: auto !important; max-width: 35px !important; }

    .vt-yn-check { font-size: 9px !important; display: flex !important; align-items: center; justify-content: center; }
    .vt-yn-check input[type="checkbox"] { width: 12px !important; height: 12px !important; }
    .vt-yn-check span { display: none !important; }

    body.printing-vitali .consegne-stanza-row td { padding: 0 !important; border: none !important; }
    body.printing-vitali .consegne-letto-badge {
        font-size: 9px !important; padding: 2px 5px !important;
        background: #E2E8F0 !important; font-weight: 800 !important;
    }

    /* PAGINA 2 VITALI — break prima dell'intestazione */
    body.printing-vitali .vitali-print-header2 {
        break-before: page !important; page-break-before: always !important;
        display: flex !important; margin-top: 0 !important; padding-top: 0 !important;
    }
    body.printing-vitali .vitali-page2 {
        border: none !important; box-shadow: none !important;
        break-before: avoid !important;
    }

    /* ================================================
       FOOTER FIRMA
       ================================================ */
    .consegne-footer-print { display: block !important; margin-top: 6px; width: 100%; }
    .consegne-firma-row { display: flex !important; gap: 60px; justify-content: center !important; align-items: flex-end; }
    .consegne-firma-box { flex: 0 0 200px; text-align: center !important; }
    .consegne-firma-box span { font-size: 7.5px; color: #475569; font-weight: 600; display: block; text-align: center !important; text-transform: uppercase; letter-spacing: 0.5px; }
    .consegne-firma-line { margin-top: 14px; border-top: 1px solid #1E293B; width: 100%; }
}

@media (max-width: 768px) {
    .consegne-page { padding: 10px 6px; }
    .consegne-header { flex-direction: column; gap: 10px; }
    .consegne-main-tabs { width: 100%; }
    .consegne-main-tab { flex: 1; padding: 8px 10px; font-size: 12px; justify-content: center; }
    .consegne-main-tab .material-symbols-rounded { font-size: 18px; }
    .consegne-header-actions { width: 100%; }
    .btn-consegne-action { flex: 1; justify-content: center; padding: 8px 6px; font-size: 11px; gap: 4px; }
    .btn-consegne-action .material-symbols-rounded { font-size: 16px; }
    .consegne-meta-bar { flex-direction: row; flex-wrap: wrap; gap: 8px; }
    .consegne-meta-field { flex: 1; min-width: 0; }
    .consegne-input { width: 100%; font-size: 13px; }
    .consegne-clock { font-size: 16px; }
    .consegne-countdown { font-size: 11px; padding: 6px 10px; }

    .consegne-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .consegne-table { min-width: 600px; font-size: 11px; }
    .consegne-table thead th { font-size: 9px; padding: 6px 4px; }
    .consegne-letto-badge { font-size: 9px; padding: 3px 6px; white-space: nowrap; }
    .consegne-cell-edit { font-size: 11px; min-height: 28px; padding: 4px; }
    .consegne-stanza-label { font-size: 11px !important; padding: 4px 8px !important; }

    .vitali-table { min-width: 900px; font-size: 10px; }
    .vitali-table thead th { font-size: 8px; padding: 4px 2px; white-space: nowrap; }
    .vitali-row td { padding: 3px 2px !important; }
    .vt-input { font-size: 11px; padding: 4px 3px; }
    .vt-paz-input { font-size: 11px; }
    .vt-o2-chip { font-size: 7px; padding: 2px 3px; }
    .vt-o2-wrap { gap: 2px; }
    .vt-unit { font-size: 8px; }
    .vt-yn-check { font-size: 10px; }
    .vt-yn-check input[type="checkbox"] { width: 14px; height: 14px; }
}

/* ===================== MAR (Scheda Terapia OBI) ===================== */
.mar-container { padding: 4px 0; }
.mar-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; background: linear-gradient(135deg, #F5F3FF 0%, #EDE9FE 50%, #E0E7FF 100%); border-radius: 14px; margin-bottom: 18px; box-shadow: 0 2px 8px rgba(124,58,237,.08); }
.mar-header-left { display: flex; align-items: center; gap: 12px; }
.mar-title { font-size: 17px; font-weight: 800; color: #1E1B4B; letter-spacing: -.3px; }
.mar-subtitle { font-size: 11px; color: #6D28D9; margin-top: 2px; font-weight: 500; }
.mar-btn-add { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 10px; font-weight: 700; font-size: 13px; background: linear-gradient(135deg, #7C3AED, #6D28D9); color: #fff; border: none; cursor: pointer; transition: all .2s; box-shadow: 0 2px 8px rgba(124,58,237,.2); }
.mar-btn-add:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(124,58,237,.35); }
.mar-empty { text-align: center; padding: 48px 24px; background: linear-gradient(135deg, #F8FAFC, #F1F5F9); border-radius: 14px; border: 2px dashed #CBD5E1; }
.mar-grid-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid #E2E8F0; box-shadow: 0 2px 12px rgba(0,0,0,.04); }
.mar-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mar-table thead tr { background: #1a1a2e !important; }
.mar-table thead { background: none; }
.mar-table th { padding: 16px 14px; font-weight: 900; color: #FFD700; text-align: center; font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; border-bottom: 3px solid #FFD700; background: #1a1a2e; }
.mar-th-farmaco { text-align: left !important; min-width: 220px; color: #fff !important; font-size: 12px !important; }
.mar-th-ora { min-width: 130px; font-size: 16px !important; letter-spacing: 2px !important; color: #FFD700 !important; }
.mar-th-note { min-width: 100px; text-align: left !important; color: #fff !important; font-size: 12px !important; }
.mar-row { transition: background .15s; }
.mar-row:hover { background: #F5F3FF; }
.mar-row:not(:last-child) td { border-bottom: 1px solid #E2E8F0; }
.mar-row-sospesa { opacity: .5; background: #FEF2F2; }
.mar-row-sospesa:hover { background: #FEE2E2; }
.mar-td-farmaco { padding: 12px 14px; vertical-align: middle; background: #FAFAFE; border-right: 2px solid #E2E8F0; }
.mar-farmaco-name { font-weight: 800; font-size: 13px; color: #1E1B4B; letter-spacing: -.2px; }
.mar-farmaco-detail { font-size: 11px; color: #64748B; margin-top: 4px; line-height: 1.4; }
.mar-farmaco-medico { font-size: 10px; color: #94A3B8; margin-top: 3px; font-style: italic; }
.mar-via-badge { display: inline-block; background: linear-gradient(135deg, #EDE9FE, #DDD6FE); color: #5B21B6; padding: 2px 8px; border-radius: 5px; font-weight: 800; font-size: 10px; letter-spacing: .3px; }
.mar-sospesa-badge { display: inline-block; background: linear-gradient(135deg, #FEE2E2, #FECACA); color: #B91C1C; padding: 2px 10px; border-radius: 5px; font-weight: 800; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
.mar-btn-sospendi { display: inline-flex; align-items: center; gap: 3px; padding: 3px 10px; background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; border-radius: 6px; font-size: 10px; font-weight: 700; cursor: pointer; margin-top: 6px; transition: all .15s; }
.mar-btn-sospendi:hover { background: #FEE2E2; transform: translateY(-1px); }
.mar-td-cell { padding: 8px 6px; text-align: center; vertical-align: middle; min-height: 80px; position: relative; border-left: 1px solid #F1F5F9; }
.mar-td-empty { background: #FAFAFE; }
.mar-cell-dash { color: #D1D5DB; font-size: 16px; }
.mar-cell-somministrato { background: linear-gradient(135deg, #F0FDF4, #DCFCE7); }
.mar-cell-non_somministrato, .mar-cell-rifiutato, .mar-cell-sospeso { background: linear-gradient(135deg, #FEF2F2, #FEE2E2); }
.mar-cell-posticipato { background: linear-gradient(135deg, #EFF6FF, #DBEAFE); }

.mar-cell-pending { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; }
.mar-btn-somministra { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 14px; border-radius: 8px; border: 2px solid #86EFAC; background: linear-gradient(135deg, #F0FDF4, #DCFCE7); color: #16A34A; cursor: pointer; transition: all .2s; font-weight: 700; font-size: 12px; }
.mar-btn-somministra .material-symbols-rounded { font-size: 18px; }
.mar-btn-somm-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.mar-btn-somministra:hover { background: linear-gradient(135deg, #22C55E, #16A34A); color: #fff; border-color: #16A34A; transform: scale(1.05); box-shadow: 0 4px 12px rgba(34,197,94,.3); }
.mar-actions-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 130px; }
.mar-act-btn { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; border: 1px solid #E2E8F0; background: #fff; cursor: pointer; transition: all .15s; padding: 0; }
.mar-act-btn .material-symbols-rounded { font-size: 14px; }
.mar-act-btn:hover { transform: scale(1.2); box-shadow: 0 2px 8px rgba(0,0,0,.12); z-index: 2; }
.mar-act-rifiutato { color: #EF4444; } .mar-act-rifiutato:hover { background: #FEE2E2; border-color: #FECACA; }
.mar-act-non-disp { color: #F59E0B; } .mar-act-non-disp:hover { background: #FEF3C7; border-color: #FDE68A; }
.mar-act-controid { color: #DC2626; } .mar-act-controid:hover { background: #FEE2E2; border-color: #FECACA; }
.mar-act-digiuno { color: #EA580C; } .mar-act-digiuno:hover { background: #FFF7ED; border-color: #FED7AA; }
.mar-act-vomito { color: #F97316; } .mar-act-vomito:hover { background: #FFF7ED; border-color: #FED7AA; }
.mar-act-posticipato { color: #3B82F6; } .mar-act-posticipato:hover { background: #EFF6FF; border-color: #BFDBFE; }
.mar-act-sospeso { color: #7C3AED; } .mar-act-sospeso:hover { background: #F5F3FF; border-color: #C4B5FD; }
.mar-act-parametri { color: #DC2626; } .mar-act-parametri:hover { background: #FEE2E2; border-color: #FECACA; }
.mar-act-altro { color: #6B7280; } .mar-act-altro:hover { background: #F3F4F6; border-color: #D1D5DB; }

.mar-cell-result { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 2px; position: relative; }
.mar-res-icon { font-size: 26px !important; }
.mar-res-info { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.mar-res-time { font-size: 11px; font-weight: 700; color: #16A34A; }
.mar-res-op { font-size: 9px; color: #64748B; font-weight: 600; }
.mar-res-motivo { font-size: 9px; color: #94A3B8; font-weight: 600; max-width: 100px; text-align: center; line-height: 1.2; }
.mar-res-note { font-size: 12px; cursor: help; }
.mar-undo-btn { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: none; background: rgba(0,0,0,.06); color: #94A3B8; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: all .15s; padding: 0; }
.mar-undo-btn .material-symbols-rounded { font-size: 12px; }
.mar-cell-result:hover .mar-undo-btn { opacity: 1; }
.mar-undo-btn:hover { background: #FEE2E2; color: #DC2626; }

.mar-td-note { padding: 10px; font-size: 11px; color: #64748B; text-align: left; vertical-align: middle; border-left: 1px solid #F1F5F9; background: #FAFAFE; }
.mar-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 14px 18px; margin-top: 14px; background: linear-gradient(135deg, #F8FAFC, #F1F5F9); border-radius: 10px; border: 1px solid #E2E8F0; }
.mar-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #475569; font-weight: 500; }
.mar-orari-preset { display: inline-block; padding: 4px 12px; background: linear-gradient(135deg, #EDE9FE, #DDD6FE); color: #6D28D9; border: 1px solid #C4B5FD; border-radius: 6px; font-size: 11px; font-weight: 700; cursor: pointer; transition: all .15s; }
.mar-orari-preset:hover { background: linear-gradient(135deg, #DDD6FE, #C4B5FD); transform: translateY(-1px); }
.mar-motivo-overlay { position: absolute; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 100; border-radius: 14px; backdrop-filter: blur(4px); }
.mar-motivo-panel { background: #fff; border-radius: 14px; padding: 24px; max-width: 440px; width: 92%; box-shadow: 0 24px 48px rgba(0,0,0,.18); }
.mar-motivo-header { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; color: #1E1B4B; margin-bottom: 16px; }
.mar-motivo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mar-motivo-btn { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 10px; cursor: pointer; font-size: 12px; font-weight: 500; color: #334155; text-align: left; transition: all .15s; }
.mar-motivo-btn:hover { background: #F1F5F9; border-color: #CBD5E1; transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
@media (max-width: 768px) {
    .mar-header { flex-direction: column; gap: 10px; text-align: center; }
    .mar-th-farmaco { min-width: 160px; }
    .mar-th-ora { min-width: 100px; }
    .mar-motivo-grid { grid-template-columns: 1fr; }
    .mar-legend { gap: 8px; }
    .mar-legend-item { font-size: 10px; }
    .mar-btn-somm-label { display: none; }
    .mar-actions-row { max-width: 100px; }
    .mar-act-btn { width: 22px; height: 22px; }
}

.detail-tab-stats {
    color: #2563EB !important;
}

.ts-container {
    padding: 0;
}
.ts-loading, .ts-error {
    text-align: center;
    padding: 40px 20px;
    color: #64748B;
}
.ts-error {
    color: #DC2626;
}
.ts-header {
    margin-bottom: 20px;
}
.ts-title {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ts-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.ts-kpi {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.ts-kpi::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}
.ts-kpi-wait::before { background: #F59E0B; }
.ts-kpi-visit::before { background: #2563EB; }
.ts-kpi-diag::before { background: #8B5CF6; }
.ts-kpi-total::before { background: #10B981; }
.ts-kpi-icon {
    margin-bottom: 8px;
}
.ts-kpi-wait .ts-kpi-icon { color: #F59E0B; }
.ts-kpi-visit .ts-kpi-icon { color: #2563EB; }
.ts-kpi-diag .ts-kpi-icon { color: #8B5CF6; }
.ts-kpi-total .ts-kpi-icon { color: #10B981; }
.ts-kpi-icon .material-symbols-rounded {
    font-size: 28px;
}
.ts-kpi-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.ts-kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ts-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.ts-chart-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}
.ts-chart-full {
    margin-bottom: 16px;
}
.ts-chart-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ts-chart-title .material-symbols-rounded {
    font-size: 20px;
    color: #2563EB;
}
.ts-chart-wrap {
    position: relative;
    height: 250px;
}
.ts-comparison {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}
.ts-comp-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ts-comp-title .material-symbols-rounded {
    color: #2563EB;
}
.ts-comp-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ts-comp-item {
    display: grid;
    grid-template-columns: 140px 1fr 100px;
    align-items: center;
    gap: 12px;
}
.ts-comp-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.ts-comp-bar {
    background: var(--bg-tertiary);
    border-radius: 20px;
    height: 24px;
    overflow: hidden;
}
.ts-comp-fill {
    height: 100%;
    border-radius: 20px;
    transition: width 0.8s ease;
    min-width: 4px;
}
.ts-comp-patient {
    background: linear-gradient(90deg, #F59E0B, #F97316);
}
.ts-comp-avg {
    background: linear-gradient(90deg, #94A3B8, #64748B);
}
.ts-comp-val {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: right;
}

@media (max-width: 768px) {
    .ts-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .ts-charts-grid { grid-template-columns: 1fr; }
    .ts-kpi-value { font-size: 18px; }
    .ts-comp-item { grid-template-columns: 100px 1fr 80px; }
}

.archivio-search-bar {
    padding: 0 0 16px 0;
}
.archivio-search-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.archivio-search-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.archivio-search-icon {
    font-size: 20px;
    color: var(--text-muted);
    margin-right: 8px;
    flex-shrink: 0;
}
.archivio-search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    padding: 10px 0;
    color: var(--text-primary);
    font-family: inherit;
}
.archivio-search-input::placeholder {
    color: var(--text-muted);
}
.archivio-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.archivio-search-clear:hover {
    background: var(--danger);
    color: #fff;
}
.archivio-search-clear .material-symbols-rounded {
    font-size: 16px;
}

.lang-section {
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: 8px;
    padding-top: 8px;
}
.lang-flags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px 4px;
}
.lang-flag-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    background: rgba(255,255,255,0.06);
    padding: 2px;
    transition: all 0.2s;
    position: relative;
}
.lang-flag-btn img {
    width: 100%;
    height: 100%;
    border-radius: 2px;
    object-fit: cover;
}
.lang-flag-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: scale(1.12);
    border-color: rgba(255,255,255,0.3);
}
.lang-flag-btn.active {
    border-color: var(--primary);
    background: rgba(59,130,246,0.2);
    box-shadow: 0 0 8px rgba(59,130,246,0.3);
}

.login-card .lang-flags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 12px 16px 8px;
}
.login-card .lang-flag-btn {
    width: 40px;
    height: 28px;
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 5px;
    cursor: pointer;
    background: rgba(255,255,255,0.1);
    padding: 3px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.login-card .lang-flag-btn img {
    width: 100%;
    height: 100%;
    border-radius: 3px;
    object-fit: cover;
    display: block;
}
.login-card .lang-flag-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.15);
    border-color: rgba(255,255,255,0.5);
}
.login-card .lang-flag-btn.active {
    border-color: #3B82F6;
    background: rgba(59,130,246,0.3);
    box-shadow: 0 0 10px rgba(59,130,246,0.4);
}

.symptom-flag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 2px 6px;
    background: rgba(59,130,246,0.08);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    border: 1px solid rgba(59,130,246,0.15);
    cursor: default;
    vertical-align: middle;
}
.symptom-flag-img {
    width: 16px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}
.symptom-flag-text {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.all-flags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.all-flags-row .symptom-flag {
    margin-left: 0;
}
.mini-flag .symptom-flag-text {
    max-width: 120px;
    font-size: 10px;
}
.symptom-item-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 3px;
}
.symptom-item-flags .symptom-flag {
    margin-left: 0;
    font-size: 10px;
    padding: 1px 4px;
}
.symptom-item-flags .symptom-flag-img {
    width: 14px;
    height: 10px;
}
.symptom-item-flags .symptom-flag-text {
    max-width: 140px;
    font-size: 10px;
}

.symptom-flag-clickable {
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.symptom-flag-clickable:hover {
    background: rgba(59,130,246,0.18);
    transform: scale(1.05);
    box-shadow: 0 1px 4px rgba(59,130,246,0.2);
}
.symptom-flag-clickable:active {
    transform: scale(0.97);
}

.flag-translation-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}
.flag-translation-modal.active {
    display: flex;
}
.flag-translation-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
.flag-translation-content {
    position: relative;
    background: #fff;
    border-radius: 20px;
    padding: 40px 50px 50px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
    animation: flagModalIn 0.25s ease-out;
}
@keyframes flagModalIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.flag-translation-close {
    position: absolute;
    top: 12px;
    right: 18px;
    background: none;
    border: none;
    font-size: 32px;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}
.flag-translation-close:hover {
    background: #f0f0f0;
    color: #333;
}
.flag-translation-flag-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 24px;
}
.flag-translation-flag-img {
    width: 56px;
    height: 40px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    object-fit: cover;
}
.flag-translation-lang-name {
    font-size: 20px;
    font-weight: 600;
    color: #555;
    letter-spacing: 0.3px;
}
.flag-translation-text {
    font-size: 36px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.3;
    word-break: break-word;
    padding: 20px 10px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    border: 2px solid rgba(59,130,246,0.15);
}

.dark .flag-translation-content {
    background: #1e1e2e;
}
.dark .flag-translation-close {
    color: #aaa;
}
.dark .flag-translation-close:hover {
    background: #2a2a3e;
    color: #eee;
}
.dark .flag-translation-lang-name {
    color: #bbb;
}
.dark .flag-translation-text {
    color: #f0f0f0;
    background: linear-gradient(135deg, #1a1a3e 0%, #222244 100%);
    border-color: rgba(100,140,255,0.2);
}

@media (max-width: 600px) {
    .flag-translation-content {
        padding: 30px 20px 35px;
        border-radius: 14px;
    }
    .flag-translation-text {
        font-size: 28px;
        padding: 16px 8px;
    }
    .flag-translation-flag-img {
        width: 44px;
        height: 32px;
    }
    .flag-translation-lang-name {
        font-size: 17px;
    }
}

/* ═══════════════════════════════════════════════════
   AI SUPPORT PANEL — OSS Shift Coverage
   ═══════════════════════════════════════════════════ */
#aiSupportContainer { margin-top: 18px; }

.aisp {
    background: #fff;
    border: 1.5px solid #E2E8F0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

/* — header — */
.aisp-hdr {
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
    padding: 14px 20px 12px;
    border-bottom: 2px solid rgba(255,255,255,0.08);
}
.aisp-ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #38BDF8;
    background: rgba(56,189,248,0.12);
    border: 1px solid rgba(56,189,248,0.3);
    border-radius: 6px;
    padding: 3px 10px;
    margin-bottom: 8px;
}
.aisp-ai-badge .material-symbols-rounded { font-size: 13px; }
.aisp-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.aisp-title-icon { font-size: 20px; color: #38BDF8; }
.aisp-title {
    font-size: 15px;
    font-weight: 700;
    color: #F8FAFC;
    flex: 1;
    min-width: 0;
}
.aisp-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.aisp-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.aisp-stat .material-symbols-rounded { font-size: 14px; }
.aisp-stat-ok   { background: rgba(34,197,94,0.15);  color: #4ADE80; border: 1px solid rgba(74,222,128,0.3); }
.aisp-stat-warn { background: rgba(239,68,68,0.15);  color: #F87171; border: 1px solid rgba(248,113,113,0.3); }
.aisp-stat-info { background: rgba(148,163,184,0.15);color: #94A3B8; border: 1px solid rgba(148,163,184,0.3); }

/* — coverage grid — */
.aisp-scroll {
    overflow-x: auto;
    padding: 0;
    -webkit-overflow-scrolling: touch;
}
.aisp-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: max-content;
}
.aisp-lth {
    width: 52px;
    min-width: 52px;
    background: #F8FAFC;
    border-right: 2px solid #E2E8F0;
    border-bottom: 1px solid #E2E8F0;
    text-align: center;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748B;
    padding: 6px 4px;
}
.aisp-dth {
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    text-align: center;
    padding: 4px 2px;
    background: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    border-right: 1px solid #F1F5F9;
}
.aisp-dth.aisp-we { background: #FFF5F5; }
.aisp-dth.aisp-dth-err { background: #FFF1F2; border-bottom: 2px solid #FCA5A5; }
.aisp-dn { font-size: 9px; color: #94A3B8; font-weight: 600; line-height: 1.2; }
.aisp-dm { font-size: 13px; font-weight: 800; color: #1E293B; line-height: 1.2; }
.aisp-dth.aisp-we .aisp-dm { color: #DC2626; }

.aisp-ltd {
    background: #F8FAFC;
    border-right: 2px solid #E2E8F0;
    text-align: center;
    padding: 5px 4px;
    border-bottom: 1px solid #F1F5F9;
}
.aisp-sbadge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 32px;
    height: 22px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 800;
    color: #fff;
}

.aisp-ctd {
    text-align: center;
    vertical-align: middle;
    padding: 4px 2px;
    border-right: 1px solid rgba(0,0,0,0.04);
    border-bottom: 1px solid rgba(0,0,0,0.04);
    height: 34px;
}
.aisp-ctd.aisp-ok   { background: #F0FDF4; color: #16A34A; }
.aisp-ctd.aisp-one  { background: #FFFBEB; color: #D97706; }
.aisp-ctd.aisp-zero { background: #FFF1F2; color: #DC2626; }
.aisp-ck  { font-size: 16px; display: block; }
.aisp-cnt { font-size: 13px; font-weight: 800; display: block; line-height: 1; }
.aisp-wk  { font-size: 12px; display: block; line-height: 1; }

/* — alert cards section — */
.aisp-alerts {
    border-top: 1.5px solid #FEE2E2;
    background: #FFFBFB;
    padding: 16px 20px;
}
.aisp-alerts-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #991B1B;
    margin-bottom: 14px;
}
.aisp-alerts-title .material-symbols-rounded { font-size: 18px; }

.aisp-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}
.aisp-card {
    background: #fff;
    border: 1.5px solid #FEE2E2;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(239,68,68,0.06);
}
.aisp-card-hdr {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: #FFF5F5;
    border-bottom: 1px solid #FEE2E2;
}
.aisp-card-date {
    font-size: 13px;
    font-weight: 700;
    color: #1E293B;
    line-height: 1.3;
}
.aisp-card-shift {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 3px;
    flex-wrap: wrap;
}
.aisp-spill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
}
.aisp-gap {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #64748B;
}

/* candidates list */
.aisp-cands {
    padding: 10px 14px 12px;
}
.aisp-cands-lbl {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748B;
    margin-bottom: 8px;
}
.aisp-cands-lbl .material-symbols-rounded { font-size: 14px; color: #16A34A; }
.aisp-cand-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid #F1F5F9;
}
.aisp-cand-row:last-child { border-bottom: none; }
.aisp-cand-av {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}
.aisp-cand-name {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: #1E293B;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aisp-cand-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.aisp-tag-riposo { background: #F0FDF4; color: #16A34A; border: 1px solid #BBF7D0; }
.aisp-tag-free   { background: #F8FAFC; color: #64748B; border: 1px solid #E2E8F0; }

.aisp-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #25D366;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 8px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}
.aisp-wa-btn:hover { background: #128C7E; transform: scale(1.04); }

.aisp-no-cands {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: 11px;
    color: #DC2626;
    font-weight: 500;
}
.aisp-no-cands .material-symbols-rounded { font-size: 16px; }

@media (max-width: 700px) {
    .aisp-stats { gap: 5px; }
    .aisp-stat  { font-size: 10px; padding: 3px 7px; }
    .aisp-title { font-size: 13px; }
    .aisp-cards { grid-template-columns: 1fr; }
    .aisp-alerts { padding: 12px; }
}

/* ====================================================
   FERIE ESTIVE TAB — Prospetto Rotazione
   ==================================================== */

/* Tab bar */
.ferie-tab-bar {
    display: flex;
    gap: 4px;
    margin: 14px 0 0 0;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}
.ferie-tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: color .15s, border-color .15s, background .15s;
}
.ferie-tab-btn:hover { color: var(--primary); background: var(--primary-50); }
.ferie-tab-btn.active { color: #10B981; border-bottom-color: #10B981; background: #F0FDF4; }
.ferie-tab-btn .material-symbols-rounded { font-size: 18px; }

/* Ferie toolbar */
.ferie-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px 16px;
    margin: 14px 0;
}
.ferie-toolbar-left { display: flex; align-items: center; gap: 6px; }
.ferie-toolbar-center { display: flex; align-items: center; }
.ferie-toolbar-right { display: flex; align-items: center; gap: 8px; }
.ferie-year-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    min-width: 60px;
    text-align: center;
}

/* Estate header */
.ferie-estate-header {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
    border: 1px solid #6EE7B7;
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 18px;
}
.ferie-estate-title {
    font-size: 18px;
    font-weight: 700;
    color: #065F46;
}
.ferie-estate-sub {
    font-size: 13px;
    color: #047857;
    margin-top: 2px;
}

/* Griglia 3 periodi */
.ferie-periodi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 18px;
}
.ferie-periodo-card {
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    transition: box-shadow .2s, border-color .2s;
}
.ferie-periodo-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); border-color: #6EE7B7; }
.ferie-periodo-header {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
}
.ferie-periodo-header .material-symbols-rounded { font-size: 20px; }
.ferie-periodo-c1 .ferie-periodo-header { background: linear-gradient(135deg,#059669,#10B981); }
.ferie-periodo-c2 .ferie-periodo-header { background: linear-gradient(135deg,#0369A1,#0EA5E9); }
.ferie-periodo-c3 .ferie-periodo-header { background: linear-gradient(135deg,#7C3AED,#A78BFA); }
.ferie-periodo-c4 .ferie-periodo-header { background: linear-gradient(135deg,#B45309,#F59E0B); }
.ferie-periodo-c5 .ferie-periodo-header { background: linear-gradient(135deg,#0F766E,#14B8A6); }
.ferie-periodo-c6 .ferie-periodo-header { background: linear-gradient(135deg,#9D174D,#EC4899); }
/* Colore border per ogni card */
.ferie-periodo-c1 { border-color: #6EE7B7; }
.ferie-periodo-c2 { border-color: #7DD3FC; }
.ferie-periodo-c3 { border-color: #C4B5FD; }
.ferie-periodo-c4 { border-color: #FCD34D; }
.ferie-periodo-c5 { border-color: #5EEAD4; }
.ferie-periodo-c6 { border-color: #F9A8D4; }
.ferie-periodo-dates {
    font-size: 12.5px;
    font-weight: 600;
    opacity: .92;
    margin-top: 2px;
}
.ferie-periodo-body { padding: 16px; }
.ferie-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.ferie-slot:last-child { margin-bottom: 0; }
.ferie-slot-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    color: #fff;
}
.ferie-slot-1 .ferie-slot-label { background: #10B981; }
.ferie-slot-2 .ferie-slot-label { background: #0EA5E9; }
.ferie-slot select {
    flex: 1;
    padding: 7px 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-light);
    background: var(--bg);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s, color .15s;
    appearance: auto;
}
.ferie-slot select.has-value {
    border-color: #10B981;
    background: #F0FDF4;
    color: #065F46;
    font-weight: 600;
}
.ferie-slot-2 select.has-value {
    border-color: #0EA5E9;
    background: #F0F9FF;
    color: #0C4A6E;
}
.ferie-slot select:focus { outline: none; border-color: #10B981; box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.ferie-slot-2 select:focus { border-color: #0EA5E9; box-shadow: 0 0 0 3px rgba(14,165,233,.15); }
.ferie-slot select:disabled { opacity: .5; cursor: not-allowed; }

/* Badge persona assegnata */
.ferie-persona-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #F0FDF4;
    border: 1px solid #A7F3D0;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: #065F46;
    flex: 1;
}
.ferie-persona-badge.slot-vuoto {
    background: var(--bg);
    border-color: var(--border-color);
    color: var(--text-light);
    font-weight: 400;
    font-style: italic;
}
.ferie-persona-badge .material-symbols-rounded { font-size: 16px; }

/* Rotazione badge nell'header */
.ferie-rot-badge {
    font-size: 10.5px;
    background: rgba(255,255,255,.25);
    border-radius: 10px;
    padding: 1px 8px;
    margin-left: auto;
}

/* Storico table */
.ferie-storico-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.ferie-storico-table th {
    background: var(--primary-50);
    color: var(--primary-dark);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}
.ferie-storico-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.ferie-storico-table tr:last-child td { border-bottom: none; }
.ferie-storico-table tr:hover td { background: var(--bg); }
.ferie-storico-table tr.anno-corrente td { background: #F0FDF4; font-weight: 600; }
.ferie-storico-table tr.anno-corrente .anno-label {
    color: #065F46;
    background: #D1FAE5;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    vertical-align: middle;
    margin-left: 4px;
}

.ferie-periodo-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11.5px;
    font-weight: 600;
}
.ferie-periodo-tag-1 { background: #D1FAE5; color: #065F46; }
.ferie-periodo-tag-2 { background: #DBEAFE; color: #1E40AF; }
.ferie-periodo-tag-3 { background: #EDE9FE; color: #5B21B6; }
.ferie-periodo-tag-4 { background: #FEF3C7; color: #92400E; }
.ferie-periodo-tag-5 { background: #CCFBF1; color: #134E4A; }
.ferie-periodo-tag-6 { background: #FCE7F3; color: #831843; }

/* Save status */
.ferie-save-btn {
    padding: 5px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    background: #10B981;
    color: #fff;
}
.ferie-save-btn:hover { background: #059669; }
.ferie-save-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Category buttons for ferie (uses same turni-cat-btn class, add data-ruolo-ferie variants) */
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="medico"] { border-color: #90CAF9; color: #1565C0; background: #E3F2FD; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="medico"].active { background: #1565C0; color: #fff; border-color: #1565C0; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="medico"]:hover:not(.active) { background: #BBDEFB; color: #0D47A1; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="infermiere"] { border-color: #A5D6A7; color: #2E7D32; background: #E8F5E9; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="infermiere"].active { background: #2E7D32; color: #fff; border-color: #2E7D32; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="infermiere"]:hover:not(.active) { background: #C8E6C9; color: #1B5E20; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="oss"] { border-color: #FFCC80; color: #E65100; background: #FFF3E0; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="oss"].active { background: #E65100; color: #fff; border-color: #E65100; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="oss"]:hover:not(.active) { background: #FFE0B2; color: #BF360C; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="ausiliare"] { border-color: #CE93D8; color: #7B1FA2; background: #F3E5F5; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="ausiliare"].active { background: #7B1FA2; color: #fff; border-color: #7B1FA2; }
.ferie-toolbar .turni-cat-btn[data-ruolo-ferie="ausiliare"]:hover:not(.active) { background: #E1BEE7; color: #6A1B9A; }

@media (max-width: 900px) {
    .ferie-periodi-grid { grid-template-columns: 1fr; }
    .ferie-toolbar { flex-direction: column; align-items: flex-start; }
}

.ac-wrapper { position: relative; }
.ac-dropdown {
    display: none;
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    z-index: 1050;
    background: #fff;
    border: 1px solid #CBD5E1;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 220px;
    overflow-y: auto;
    margin-top: 2px;
}
.ac-dropdown.ac-open { display: block; }
.ac-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #334155;
    border-bottom: 1px solid #F1F5F9;
    transition: background 0.12s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.ac-active {
    background: #EFF6FF;
    color: #1E40AF;
}
.ac-item.ac-active { font-weight: 500; }
