/* Forensic Economics Damages Calculator — Styles */
:root {
    --primary: #1a365d;
    --primary-dark: #0f2440;
    --primary-light: #2c5282;
    --accent: #2b6cb0;
    --accent-light: #4299e1;
    --success: #38a169;
    --success-light: #c6f6d5;
    --warning: #d69e2e;
    --warning-light: #fefcbf;
    --danger: #e53e3e;
    --danger-light: #fed7d7;
    --white: #ffffff;
    --light-bg: #f7fafc;
    --gray-50: #f9fafb;
    --gray-100: #edf2f7;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e0;
    --gray-400: #a0aec0;
    --gray-500: #718096;
    --gray-600: #4a5568;
    --gray-700: #2d3748;
    --gray-800: #1a202c;
    --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', 'Consolas', monospace;
    --sidebar-width: 240px;
    --topbar-height: 42px;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
    --shadow: 0 2px 8px rgba(0,0,0,.08);
    --shadow-md: 0 4px 14px rgba(0,0,0,.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
    --transition: .2s ease;
    --transition-slow: .35s ease;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: var(--font-sans); color: var(--gray-700); background: var(--light-bg); line-height: 1.55; min-height: 100vh; }
body.auth-locked { overflow: hidden; }
body.auth-locked .app-wrapper {
    filter: blur(2px);
    pointer-events: none;
    user-select: none;
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-light); }
h1,h2,h3,h4 { color: var(--primary); font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.5rem; margin-bottom: .5rem; letter-spacing: -.02em; }
h2 { font-size: 1.25rem; margin-bottom: .5rem; }
h3 { font-size: 1.1rem; margin-bottom: .4rem; }

/* ── Auth Gate ───────────────────────────────────────────── */
.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 2400;
    background: rgba(15, 23, 42, .66);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.auth-card {
    width: min(460px, 92vw);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.1rem;
}
.auth-tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: .8rem;
}
.auth-form {
    margin-top: .3rem;
}
.inline-checkbox {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-size: .86rem;
    color: var(--gray-600);
}

/* ── Profile Bar ─────────────────────────────────────────── */
.profile-bar {
    position: fixed; top: 0; left: var(--sidebar-width); right: 0;
    height: var(--topbar-height); background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem; z-index: 900; box-shadow: var(--shadow-sm);
    transition: left var(--transition-slow);
}
.profile-bar .profile-actions { display: flex; align-items: center; gap: .35rem; }
.context-actions {
    margin-left: auto;
    margin-right: .5rem;
}
.context-actions:empty {
    display: none;
}
.context-actions .ctx-label {
    font-size: .7rem;
    color: var(--gray-400);
    margin-right: .25rem;
    font-weight: 500;
}
.profile-bar .form-select { height: 28px; padding: .15rem .5rem; font-size: .75rem; }
.profile-bar .btn-sm { padding: .2rem .55rem; font-size: .7rem; }
.profile-bar .profile-actions { min-width: 0; }
#active-case-label {
    max-width: 360px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}
.header-nav {
    gap: .4rem;
}
.header-nav-btn {
    min-width: 84px;
}
.header-nav-btn.active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}
.header-nav-btn.active:hover {
    background: #3182ce;
    border-color: #3182ce;
}

/* Autosave dot indicator */
.autosave-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--gray-300);
    display: inline-block; transition: background var(--transition);
    cursor: help;
}
.autosave-dot.saved { background: var(--success); }

/* ── Layout ──────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    display: flex; flex-direction: column; z-index: 1000; overflow-y: auto;
    transition: transform var(--transition-slow);
}
.sidebar-header { padding: 1rem 1.1rem .8rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-header .logo-text { font-size: 1rem; font-weight: 700; color: var(--white); letter-spacing: -.01em; }
.sidebar-header .logo-sub { font-size: .62rem; color: rgba(255,255,255,.5); margin-top: 2px; text-transform: uppercase; letter-spacing: .8px; }
.sidebar-nav { flex: 1; padding: .35rem 0; list-style: none; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem 1rem; color: rgba(255,255,255,.65);
    font-size: .8rem; font-weight: 500; border-left: 3px solid transparent;
    cursor: pointer; transition: all var(--transition);
    user-select: none; position: relative;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: var(--white); }
.sidebar-nav .nav-link.active {
    background: rgba(255,255,255,.12); color: var(--white);
    border-left-color: var(--accent-light); font-weight: 600;
}
.sidebar-nav .nav-link .nav-icon {
    flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
    font-size: .7rem; font-weight: 700; background: rgba(255,255,255,.1);
    border-radius: 4px; color: rgba(255,255,255,.7); transition: all var(--transition);
}
.sidebar-nav .nav-link.active .nav-icon {
    background: var(--accent-light); color: var(--white);
}
.sidebar-nav .nav-link .nav-completion {
    margin-left: auto; width: 7px; height: 7px; border-radius: 50%;
    background: rgba(255,255,255,.15); flex-shrink: 0; transition: background var(--transition);
}
.sidebar-nav .nav-link .nav-completion.complete {
    background: var(--success); box-shadow: 0 0 6px rgba(56,161,105,.4);
}
.sidebar-nav .nav-link .nav-completion.partial {
    background: var(--warning);
}
.sidebar-nav .nav-divider { height: 1px; background: rgba(255,255,255,.08); margin: .35rem 1rem; }
.sidebar-nav .nav-section-label { padding: .6rem 1rem .2rem; font-size: .6rem; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,.35); font-weight: 700; }
.sidebar-footer { padding: .6rem 1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .65rem; color: rgba(255,255,255,.35); }

/* Mobile hamburger */
.hamburger-btn {
    display: none; position: fixed; top: 8px; left: 8px; z-index: 1100;
    background: var(--primary); color: var(--white); border: none; border-radius: var(--radius);
    width: 34px; height: 34px; cursor: pointer; font-size: 1.1rem;
    display: none; align-items: center; justify-content: center;
    box-shadow: var(--shadow);
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
    z-index: 999; opacity: 0; transition: opacity var(--transition-slow);
}
.sidebar-overlay.visible { display: block; opacity: 1; }

/* ── Main Content ────────────────────────────────────────── */
.main-content {
    flex: 1; margin-left: var(--sidebar-width); margin-top: var(--topbar-height);
    padding: 1.25rem 2rem 4.5rem; min-height: calc(100vh - var(--topbar-height));
    transition: margin-left var(--transition-slow);
    overflow-x: hidden; /* tables scroll inside .table-wrapper, not here */
    max-width: calc(100vw - var(--sidebar-width));
}

/* Screen transitions */
.screen { display: none; animation: fadeSlideIn .25s ease; }
.screen.active { display: block; }
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Screen header — no breadcrumb */
.screen-header { margin-bottom: 1rem; }
.screen-header h1 { margin-bottom: 0; }

/* Content sections — tighter */
.content-section {
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg); padding: 1.15rem 1.5rem;
    margin-bottom: 1rem; box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.content-section:hover { box-shadow: var(--shadow); }
.section-title {
    font-size: 1rem; color: var(--primary); margin-bottom: .85rem;
    padding-bottom: .45rem; border-bottom: 2px solid var(--gray-100);
    display: flex; align-items: center; gap: .5rem;
}
.section-title .section-icon {
    width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent); color: var(--white); border-radius: 4px; font-size: .65rem; font-weight: 700;
    flex-shrink: 0;
}
.section-subtitle {
    font-size: .9rem;
    color: var(--primary);
    margin-bottom: .5rem;
}

/* ── Forms — tighter ─────────────────────────────────────── */
.form-group { margin-bottom: .75rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 170px; }
.form-row-tight { display: flex; gap: .75rem; flex-wrap: wrap; }
.form-row-tight .form-group { flex: 1; min-width: 150px; }
/* ── Earnings Sub-Tabs ──────────────────────────────────── */
.earnings-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--gray-200);
    background: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 0 .5rem;
}
.earnings-tab {
    padding: .6rem 1.2rem;
    font-size: .85rem;
    font-weight: 500;
    color: var(--gray-500);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
    white-space: nowrap;
}
.earnings-tab:hover {
    color: var(--primary);
    background: var(--gray-50);
}
.earnings-tab.active {
    color: var(--primary);
    border-bottom-color: var(--accent);
    font-weight: 600;
}
.earnings-tab-panel {
    display: none;
}
.earnings-tab-panel.active {
    display: block;
}

.fringe-module {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
    padding: .85rem;
    margin-bottom: .85rem;
}
.fringe-benefit-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: .3rem .65rem;
    max-height: 180px;
    overflow-y: auto;
    padding: .25rem .15rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
}
.fringe-actions {
    display: flex;
    gap: .45rem;
    flex-wrap: wrap;
}
.form-label {
    display: block; font-size: .75rem; font-weight: 600; color: var(--gray-600);
    margin-bottom: .3rem; text-transform: uppercase; letter-spacing: .3px;
}
.form-label .required { color: var(--danger); font-weight: 700; }
.form-control, .form-select {
    width: 100%; padding: .45rem .65rem; font-size: .86rem;
    font-family: var(--font-sans); color: var(--gray-700);
    background: var(--white); border: 1.5px solid var(--gray-300);
    border-radius: var(--radius); transition: all var(--transition);
}
.form-control:hover, .form-select:hover {
    border-color: var(--gray-400);
}
.form-control:focus, .form-select:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(43,108,176,.12);
}
.form-control:disabled, .form-select:disabled {
    background: var(--gray-50); color: var(--gray-500); border-color: var(--gray-200);
    cursor: not-allowed;
}
.form-control.is-valid { border-color: var(--success); }
.form-control.is-invalid { border-color: var(--danger); }
.form-select {
    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 fill='%23718096' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .6rem center; padding-right: 1.8rem;
}
.form-text { font-size: .72rem; color: var(--gray-500); margin-top: .2rem; line-height: 1.35; }
.form-check { display: flex; align-items: center; gap: .4rem; margin-bottom: .3rem; }
.form-check input[type="checkbox"], .form-check input[type="radio"] {
    accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer;
}
.form-check-label { font-size: .83rem; color: var(--gray-600); cursor: pointer; }
.input-group { display: flex; align-items: stretch; }
.input-group .input-prefix, .input-group .input-suffix {
    display: flex; align-items: center; padding: 0 .55rem; font-size: .78rem;
    font-weight: 600; color: var(--gray-500); background: var(--gray-50);
    border: 1.5px solid var(--gray-300); white-space: nowrap;
}
.input-group .input-prefix { border-right: none; border-radius: var(--radius) 0 0 var(--radius); }
.input-group .input-suffix { border-left: none; border-radius: 0 var(--radius) var(--radius) 0; }
.input-group .form-control { border-radius: 0; flex: 1; }
.input-group:focus-within .input-prefix,
.input-group:focus-within .input-suffix {
    border-color: var(--accent); background: rgba(43,108,176,.04);
}
.validation-msg { font-size: .72rem; margin-top: .2rem; display: none; }
.validation-msg.show { display: block; }
.validation-msg.error { color: var(--danger); }
.validation-msg.success { color: var(--success); }

/* Pediatric scenario chips */
.scenario-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .2rem;
}
.scenario-chip {
    position: relative;
    cursor: pointer;
}
.scenario-chip input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.scenario-chip span {
    display: inline-block;
    padding: .4rem .7rem;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--white);
    transition: all var(--transition);
}
.scenario-chip input[type="radio"]:checked + span {
    color: var(--white);
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.scenario-chip input[type="radio"]:focus + span {
    box-shadow: 0 0 0 3px rgba(43,108,176,.15);
}

.ref-list {
    margin: 0;
    padding-left: 1.2rem;
}
.ref-list li {
    margin-bottom: .35rem;
    color: var(--gray-600);
    font-size: .8rem;
}

/* Tooltips */
.has-tooltip { position: relative; }
.has-tooltip .tooltip-text {
    visibility: hidden; opacity: 0; position: absolute; bottom: calc(100% + 6px); left: 50%;
    transform: translateX(-50%); background: var(--gray-800); color: var(--white);
    padding: .35rem .6rem; border-radius: var(--radius); font-size: .7rem;
    white-space: nowrap; z-index: 100; pointer-events: none;
    transition: opacity .15s, visibility .15s;
}
.has-tooltip .tooltip-text::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: var(--gray-800);
}
.has-tooltip:hover .tooltip-text { visibility: visible; opacity: 1; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .45rem 1rem; font-size: .8rem; font-weight: 600;
    font-family: var(--font-sans); border: 1.5px solid transparent;
    border-radius: var(--radius); cursor: pointer;
    transition: all var(--transition); white-space: nowrap; line-height: 1.4;
}
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: #3182ce; box-shadow: var(--shadow); }
.btn-secondary { background: var(--white); color: var(--gray-600); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); box-shadow: var(--shadow-sm); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #2f855a; box-shadow: var(--shadow); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #c53030; }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent); color: var(--white); }
.btn-sm { padding: .25rem .6rem; font-size: .73rem; }
.btn-lg { padding: .6rem 1.4rem; font-size: .9rem; border-radius: 8px; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.btn .btn-spinner {
    display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3);
    border-top-color: var(--white); border-radius: 50%; animation: spin .6s linear infinite;
}

/* ── Floating Navigation Bar ─────────────────────────────── */
.floating-nav {
    position: fixed; bottom: 0; left: var(--sidebar-width); right: 0;
    height: 48px; background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem; z-index: 800;
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
    transition: left var(--transition-slow);
}
.floating-nav .btn { min-width: 90px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: scroll; margin-bottom: .75rem;
    border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
}

/* Always-visible scrollbars for horizontally-scrollable areas */
.table-wrapper,
.sensitivity-wrapper {
    scrollbar-width: auto;                       /* Firefox: normal-sized scrollbar */
    scrollbar-color: var(--gray-400) var(--gray-100);
}
.table-wrapper::-webkit-scrollbar,
.sensitivity-wrapper::-webkit-scrollbar {
    height: 12px;                                /* horizontal scrollbar height */
    width: 12px;                                 /* vertical scrollbar width */
    background: var(--gray-100);
    border-radius: 6px;
}
.table-wrapper::-webkit-scrollbar-thumb,
.sensitivity-wrapper::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 6px;
    border: 2px solid var(--gray-100);
    min-height: 30px;
}
.table-wrapper::-webkit-scrollbar-thumb:hover,
.sensitivity-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}
.table-wrapper::-webkit-scrollbar-corner,
.sensitivity-wrapper::-webkit-scrollbar-corner {
    background: var(--gray-100);
}
table.data-table { min-width: 100%; width: max-content; border-collapse: collapse; font-size: .82rem; white-space: nowrap; }
.data-table thead { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); color: var(--white); }
.data-table thead th {
    padding: .5rem .7rem; font-weight: 600; font-size: .7rem;
    text-transform: uppercase; letter-spacing: .5px; text-align: left;
    border-bottom: 2px solid var(--primary-dark); position: sticky; top: 0; z-index: 2;
}
.data-table thead th.text-right, .data-table tbody td.text-right { text-align: right; }
.data-table thead th.text-center, .data-table tbody td.text-center { text-align: center; }
.data-table tbody td {
    padding: .4rem .7rem; border-bottom: 1px solid var(--gray-100);
    vertical-align: middle; transition: background var(--transition);
}
.data-table.table-striped tbody tr:nth-child(even) { background: var(--gray-50); }
.data-table tbody tr:hover { background: rgba(43,108,176,.04); }
.data-table td .cell-input {
    width: 100%; padding: .25rem .4rem; border: 1.5px solid transparent;
    border-radius: 4px; font-size: .8rem; font-family: var(--font-sans);
    background: transparent; text-align: inherit; transition: all var(--transition);
}
.data-table td .cell-input:hover { border-color: var(--gray-300); background: var(--white); }
.data-table td .cell-input:focus { border-color: var(--accent); background: var(--white); outline: none; box-shadow: 0 0 0 2px rgba(43,108,176,.1); }
.data-table tbody tr.row-total { background: var(--gray-100); font-weight: 700; border-top: 2px solid var(--gray-300); }
.hc-workbook-table thead {
    background: #f3f4f6;
    color: #111827;
}
.hc-workbook-table thead th {
    text-transform: none;
    letter-spacing: 0;
    font-size: .72rem;
    border-bottom: 2px solid #9ca3af;
    text-align: center;
    white-space: normal;
}
.hc-workbook-table tbody td {
    white-space: normal;
}
.hc-workbook-table tbody tr.row-total {
    background: #e5e7eb;
}
.table-actions { display: flex; justify-content: flex-start; gap: .5rem; margin-top: .4rem; }
.btn-add-row {
    font-size: .76rem; color: var(--accent); background: none;
    border: 1.5px dashed var(--accent); border-radius: var(--radius);
    padding: .3rem .7rem; cursor: pointer; transition: all var(--transition);
    font-weight: 600;
}
.btn-add-row:hover { background: rgba(43,108,176,.06); border-style: solid; }
.btn-remove-row {
    color: var(--gray-400); background: none; border: none; cursor: pointer;
    font-size: 1rem; padding: .1rem .3rem; border-radius: 4px;
    transition: all var(--transition); line-height: 1;
}
.btn-remove-row:hover { color: var(--danger); background: var(--danger-light); }

/* Empty state for tables */
.table-empty {
    padding: 1.5rem 1rem; text-align: center; color: var(--gray-400);
    font-size: .83rem; font-style: italic;
}
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--gray-500);
    background: var(--gray-50);
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius-lg);
    gap: .5rem;
}
.empty-state-icon {
    font-size: 2rem;
    opacity: .6;
    margin-bottom: .25rem;
}
.empty-state-title {
    font-size: .95rem;
    font-weight: 600;
    color: var(--gray-600);
}
.empty-state-text {
    font-size: .82rem;
    color: var(--gray-400);
    max-width: 360px;
}
.empty-state .btn {
    margin-top: .5rem;
}

/* ── Form Validation ────────────────────────────────────── */
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 2px rgba(229, 62, 62, .15);
}
.validation-msg {
    font-size: .72rem;
    color: var(--danger);
    margin-top: .2rem;
    display: none;
    align-items: center;
    gap: .25rem;
}
.validation-msg.visible {
    display: flex;
}
.validation-msg::before {
    content: '⚠';
    font-size: .7rem;
}

/* ── Sortable Table Headers ─────────────────────────────── */
.sortable-th {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background var(--transition);
}
.sortable-th:hover {
    background: rgba(0,0,0,.05);
}
.sort-arrow {
    display: inline-block;
    font-size: .65rem;
    margin-left: .25rem;
    opacity: .3;
    transition: opacity var(--transition);
}
.sort-arrow::after {
    content: '⇅';
}
.sortable-th.sort-asc .sort-arrow,
.sortable-th.sort-desc .sort-arrow {
    opacity: 1;
}
.sortable-th.sort-asc .sort-arrow::after {
    content: '↑';
}
.sortable-th.sort-desc .sort-arrow::after {
    content: '↓';
}

/* ── Sensitivity Matrix ──────────────────────────────────── */
.sensitivity-wrapper { overflow-x: auto; margin: .75rem 0; }
table.sensitivity-matrix {
    border-collapse: collapse; font-size: .76rem; font-family: var(--font-mono);
    width: auto; margin: 0 auto; border-radius: var(--radius-lg); overflow: hidden;
}
.sensitivity-matrix th, .sensitivity-matrix td {
    padding: .4rem .55rem; text-align: center; border: 1px solid var(--gray-200);
    min-width: 82px; white-space: nowrap; transition: all .15s;
}
.sensitivity-matrix thead th {
    background: var(--primary); color: var(--white); font-weight: 600;
    font-size: .68rem; text-transform: uppercase; letter-spacing: .3px;
}
.sensitivity-matrix tbody th {
    background: var(--primary-light); color: var(--white);
    font-weight: 600; text-align: right; padding-right: .6rem;
}
.sensitivity-matrix .corner-label { background: var(--primary-dark); color: rgba(255,255,255,.6); font-size: .64rem; }
.sensitivity-matrix td.base-case {
    background: var(--accent); color: var(--white); font-weight: 700;
    box-shadow: inset 0 0 0 2px var(--primary);
}
.sensitivity-matrix td.heat-high   { background: #c6f6d5; color: #22543d; }
.sensitivity-matrix td.heat-mid    { background: #fefcbf; color: #744210; }
.sensitivity-matrix td.heat-low    { background: #fed7d7; color: #9b2c2c; }
.sensitivity-matrix td:hover { outline: 2px solid var(--accent-light); outline-offset: -2px; z-index: 1; position: relative; }

/* ── Dashboard Cards ─────────────────────────────────────── */
.dashboard-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .85rem; margin-bottom: 1.25rem;
}
.db-case-row-active {
    background: rgba(43,108,176,.09) !important;
}
.ped-education-row-active {
    background: rgba(43,108,176,.09) !important;
}
.db-case-actions {
    display: inline-flex;
    gap: .35rem;
    align-items: center;
    justify-content: center;
}
.dash-card {
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg); padding: 1rem 1.15rem;
    box-shadow: var(--shadow-sm); transition: all var(--transition);
    position: relative; overflow: hidden;
}
.dash-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--gray-200); transition: background var(--transition);
}
.dash-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.dash-card .card-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .5px;
    color: var(--gray-500); margin-bottom: .3rem; font-weight: 700;
}
.dash-card .card-value {
    font-size: 1.45rem; font-weight: 700; color: var(--primary);
    line-height: 1.2; letter-spacing: -.02em;
}
.dash-card .card-sub { font-size: .72rem; color: var(--gray-400); margin-top: .25rem; }
.dash-card.card-blue::before { background: var(--accent); }
.dash-card.card-green::before { background: var(--success); }
.dash-card.card-yellow::before { background: var(--warning); }
.dash-card.card-red::before { background: var(--danger); }

.dash-workflow-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    max-width: 360px;
}

.workflow-chip {
    display: inline-flex;
    align-items: center;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .3px;
    padding: .14rem .42rem;
    border-radius: 999px;
    border: 1px solid transparent;
    text-transform: uppercase;
    white-space: nowrap;
}

.workflow-chip.done {
    background: var(--success-light);
    border-color: #9ae6b4;
    color: #22543d;
}

.workflow-chip.open {
    background: var(--warning-light);
    border-color: #f6e05e;
    color: #744210;
}

.dash-progress-track {
    width: 140px;
    height: 8px;
    border-radius: 999px;
    background: var(--gray-100);
    overflow: hidden;
    margin-left: auto;
}

.dash-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #10b981);
}

.dash-next-step {
    font-size: .74rem;
    color: var(--gray-600);
    line-height: 1.35;
}

/* ── QC Badges ───────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: .2rem;
    padding: .15rem .5rem; font-size: .66rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
    border-radius: 999px; white-space: nowrap;
}
.badge-ok { background: var(--success-light); color: #22543d; }
.badge-flag { background: var(--danger-light); color: #9b2c2c; }
.badge-warn { background: var(--warning-light); color: #744210; }
.badge-info { background: #bee3f8; color: #2a4365; }

/* QC items */
.qc-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .35rem .5rem; margin-bottom: .2rem;
    border-radius: var(--radius); transition: background var(--transition);
}
.qc-item:hover { background: var(--gray-50); }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    padding: .6rem 1rem; border-radius: var(--radius-lg); font-size: .82rem;
    margin-bottom: .75rem; border: 1px solid transparent; line-height: 1.45;
}
.alert-info { background: #ebf8ff; border-color: #90cdf4; color: #2a4365; }
.alert-success { background: var(--success-light); border-color: #9ae6b4; color: #22543d; }
.alert-warning { background: var(--warning-light); border-color: #f6e05e; color: #744210; }
.alert-danger { background: var(--danger-light); border-color: #feb2b2; color: #9b2c2c; }

/* ── Toast Notifications ─────────────────────────────────── */
.toast-container {
    position: fixed; bottom: 4rem; right: 1.5rem; z-index: 9999;
    display: flex; flex-direction: column-reverse; gap: .4rem;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex; align-items: center; gap: .55rem;
    padding: .55rem 1rem; border-radius: var(--radius-lg);
    background: var(--white); box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--accent); font-size: .82rem;
    max-width: 360px; min-width: 260px;
    animation: toastIn .3s ease;
}
.toast.toast-exit { animation: toastOut .2s ease forwards; }
.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-message { flex: 1; color: var(--gray-700); line-height: 1.3; }
.toast-close { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: .85rem; padding: .15rem; }
.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(30px); }
}

/* ── Audit Popup ─────────────────────────────────────────── */
.audit-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 1rem;
}
.audit-popup {
    width: min(980px, 100%);
    max-height: 90vh;
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}
.audit-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}
.audit-popup-header h3 {
    margin: 0;
    font-size: 0.98rem;
}
.audit-popup-body {
    padding: 0.85rem 1rem;
    overflow-y: auto;
}
.audit-popup-footer {
    border-top: 1px solid var(--gray-200);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: flex-end;
}
.audit-popup-close {
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-600);
    border-radius: var(--radius);
    width: 28px;
    height: 28px;
    cursor: pointer;
    line-height: 1;
    font-size: 1rem;
}
.audit-popup-close:hover {
    background: var(--gray-50);
}

/* ── Progress Indicator ──────────────────────────────────── */
.progress-bar-container {
    position: fixed; top: var(--topbar-height); left: var(--sidebar-width); right: 0;
    height: 3px; background: var(--gray-100); z-index: 899;
    transition: left var(--transition-slow);
}
.progress-bar-fill {
    height: 100%; background: linear-gradient(90deg, var(--accent) 0%, var(--success) 100%);
    transition: width .5s ease; width: 0%;
    border-radius: 0 2px 2px 0;
}

/* ── Slide-Out Panel (State Profile) ─────────────────────── */
.slideout-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 1100;
    opacity: 0; visibility: hidden; transition: all var(--transition-slow);
}
.slideout-overlay.visible { opacity: 1; visibility: visible; }
.slideout-panel {
    position: fixed; top: 0; right: -480px; bottom: 0; width: 460px;
    background: var(--white); z-index: 1101; overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0,0,0,.12);
    transition: right var(--transition-slow);
    padding: 1.5rem;
}
.slideout-panel.open { right: 0; }
.slideout-panel .slideout-close {
    position: absolute; top: .75rem; right: .75rem;
    background: none; border: 1px solid var(--gray-200); border-radius: var(--radius);
    width: 28px; height: 28px; cursor: pointer; font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    color: var(--gray-500); transition: all var(--transition);
}
.slideout-panel .slideout-close:hover { background: var(--gray-50); color: var(--gray-700); }
.slideout-panel h2 { font-size: 1.15rem; margin-bottom: .75rem; padding-right: 2rem; }

/* State profile summary bar (compact inline) */
.sp-summary-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
    padding: .5rem .75rem; background: var(--gray-50);
    border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
    font-size: .78rem; color: var(--gray-600);
}
.sp-summary-bar .sp-tag {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .15rem .45rem; background: var(--white);
    border: 1px solid var(--gray-200); border-radius: 4px;
    font-size: .72rem; font-weight: 600; color: var(--gray-700);
    white-space: nowrap;
}
.sp-summary-bar .sp-tag-label { color: var(--gray-400); font-weight: 500; }
.sp-summary-bar .btn-sm { margin-left: auto; }

/* ── Adjustments Toggle (inline within card) ─────────────── */
.adjustment-toggle {
    padding: .6rem 0; border-top: 1px solid var(--gray-100);
    margin-top: .5rem;
}
.adjustment-toggle .adjustment-fields {
    padding-left: .75rem; margin-top: .5rem;
    border-left: 2px solid var(--gray-200);
}
.adjustment-summary {
    font-size: .75rem;
    color: var(--gray-500);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .3rem .6rem;
    margin-top: .35rem;
    display: none;
    line-height: 1.4;
}
.adjustment-summary.visible {
    display: block;
}
.adjustment-summary strong {
    color: var(--gray-700);
    font-weight: 600;
}

/* ── Utility ─────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: .78rem; }
.text-xs { font-size: .7rem; }
.text-muted { color: var(--gray-500); }
.text-mono { font-family: var(--font-mono); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.d-none { display: none !important; }
.d-flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.max-w-sm { max-width: 350px; }
.max-w-xs { max-width: 300px; }
.max-w-xxs { max-width: 200px; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 1rem 0; }
.computed-value { font-weight: 700; color: var(--accent); font-size: .9rem; }

/* Fade in utility */
.fade-in { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Placeholder editor ──────────────────────────────────── */
.placeholder-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.placeholder-item {
    display: flex; flex-direction: column; gap: .15rem;
    padding: .4rem .6rem; background: var(--gray-50);
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    transition: border-color var(--transition);
}
.placeholder-item:hover { border-color: var(--gray-300); }
.placeholder-tag { font-size: .66rem; font-weight: 700; color: var(--gray-400); font-family: var(--font-mono); }
.placeholder-value { font-size: .8rem; color: var(--gray-700); }
.placeholder-input {
    width: 100%; padding: .3rem .5rem; font-size: .8rem;
    border: 1.5px solid var(--gray-300); border-radius: 4px;
    font-family: var(--font-sans); transition: border-color var(--transition);
}
.placeholder-input:focus { outline: none; border-color: var(--accent); }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid var(--gray-200); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Loading shimmer */
.shimmer { background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%); background-size: 200% 100%; animation: shimmer 1.5s ease infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Keyboard shortcut hints ─────────────────────────────── */
.kbd {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .08rem .35rem; font-size: .62rem; font-family: var(--font-mono);
    background: var(--gray-100); border: 1px solid var(--gray-300);
    border-radius: 3px; color: var(--gray-500); min-width: 18px;
    box-shadow: 0 1px 0 var(--gray-300);
}

/* ── Collapsible sections ────────────────────────────────── */
.collapsible-header {
    cursor: pointer; display: flex; align-items: center; justify-content: space-between;
    user-select: none;
}
.collapsible-header .collapse-icon {
    transition: transform var(--transition); font-size: .8rem; color: var(--gray-400);
}
.collapsible-header.collapsed .collapse-icon { transform: rotate(-90deg); }
.collapsible-body { overflow: hidden; transition: max-height var(--transition-slow); }
.collapsible-body.collapsed { max-height: 0 !important; }

/* ── State Rules Panels (in slideout) ─────────────────────  */
.sp-rule-panel {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 0.4rem;
    overflow: hidden;
    background: var(--white);
}
.sp-rule-panel .collapsible-header {
    padding: 0.55rem 0.85rem;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-50);
    border-bottom: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}
.sp-rule-panel .collapsible-header:hover {
    background: var(--gray-100);
}
.sp-rule-panel .collapsible-header.open {
    border-bottom-color: var(--gray-200);
    color: var(--primary);
}
.sp-rule-panel .collapsible-header.open .collapse-icon {
    transform: rotate(90deg);
    color: var(--accent);
}
.sp-rule-panel .collapsible-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}
.sp-rule-panel .collapsible-body.open {
    max-height: 600px;
    overflow-y: auto;
}
.sp-notes-text {
    padding: 0.6rem 0.85rem;
    font-size: 0.8rem;
    line-height: 1.55;
    color: var(--gray-600);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
}
.sp-notes-text::-webkit-scrollbar { width: 5px; }
.sp-notes-text::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }


/* ── Auto-Computed Indicators ────────────────────────────── */
.computed-auto-badge {
    display: inline-flex;
    align-items: center;
    padding: .1rem .4rem;
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: #ebf8ff;
    color: #2b6cb0;
    border-radius: 3px;
    margin-left: .35rem;
    vertical-align: middle;
    line-height: 1;
}
.computed-auto-badge.overridden {
    background: #fefcbf;
    color: #744210;
}
.input-with-reset {
    display: flex;
    gap: 0;
    align-items: stretch;
}
.input-with-reset .form-control {
    flex: 1;
}
.input-with-reset .input-reset-btn {
    border-radius: 0 var(--radius) var(--radius) 0;
    border-left: none;
    padding: .3rem .5rem;
    font-size: .85rem;
    line-height: 1;
    white-space: nowrap;
}
.input-with-reset .input-reset-btn:not(.d-none) ~ .form-control,
.input-with-reset:has(.input-reset-btn:not(.d-none)) .form-control {
    border-radius: var(--radius) 0 0 var(--radius);
}

/* ── Print ───────────────────────────────────────────────── */
@media print {
    .sidebar, .profile-bar, .btn, .btn-group, .table-actions, .btn-add-row,
    .btn-remove-row, .toast-container, .hamburger-btn, .progress-bar-container,
    .sidebar-overlay, .floating-nav, .slideout-overlay, .slideout-panel { display: none !important; }
    .main-content { margin: 0; padding: .5rem; }
    .screen { display: block !important; page-break-before: always; }
    .screen:first-child { page-break-before: auto; }
    .content-section { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
    .earnings-tabs { display: none !important; }
    .earnings-tab-panel { display: block !important; }
    .data-table thead { background: #1a365d !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .dash-card { break-inside: avoid; }
    body { font-size: 12px; }
}

/* ── Responsive ──────────────────────────────────────────── */
/* Medium screens — side-by-side windows, tablets landscape */
@media (max-width: 1100px) {
    .profile-bar { padding: 0 .5rem; gap: .25rem; flex-wrap: nowrap; overflow: hidden; }
    .profile-bar .header-nav { gap: .2rem; flex-shrink: 0; }
    .header-nav-btn { min-width: auto; padding: .2rem .4rem; font-size: .65rem; }
    #active-case-label { max-width: 140px; font-size: .65rem; }
    .profile-bar .profile-actions { gap: .2rem; }
    .profile-bar .btn-sm { padding: .15rem .4rem; font-size: .65rem; white-space: nowrap; }
    .profile-bar .text-xs { font-size: .6rem; }
    /* Hide lower-priority auth buttons */
    #btn-auth-manage-users, #btn-auth-create-user { display: none !important; }
}
@media (max-width: 900px) {
    .header-nav-btn { min-width: auto; padding: .2rem .35rem; font-size: .6rem; }
    .allinone-toggle { display: none !important; }
    #active-case-label { max-width: 100px; }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 260px; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .hamburger-btn { display: flex; }
    .profile-bar { left: 0; padding: 0 .5rem; }
    .header-nav { display: none !important; }
    #active-case-label { max-width: 200px; font-size: .7rem; }
    .main-content { margin-left: 0; padding: 1rem 1rem 4.5rem; }
    .progress-bar-container { left: 0; }
    .floating-nav { left: 0; padding: 0 1rem; }
    .form-row, .form-row-tight { flex-direction: column; gap: .5rem; }
    .form-row .form-group, .form-row-tight .form-group { min-width: 100%; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .placeholder-grid { grid-template-columns: 1fr; }
    .toast-container { left: 1rem; right: 1rem; bottom: 4rem; }
    .toast { max-width: 100%; min-width: auto; }
    h1 { font-size: 1.25rem; }
    .slideout-panel { width: 100%; right: -100%; }
    .max-w-sm, .max-w-xs, .max-w-xxs { max-width: 100%; }
}

@media (min-width: 1400px) {
    .dashboard-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ═══════════════════════════════════════════════════════════
   Evaluee Directory & Case Management System
   ═══════════════════════════════════════════════════════════ */

/* Directory top bar */
.directory-toolbar {
    display: flex; gap: .75rem; align-items: center;
    flex-wrap: wrap; margin-bottom: 1rem;
}
.directory-toolbar .form-control {
    flex: 1; min-width: 200px; max-width: 400px;
}
.directory-stats {
    font-size: .78rem; color: var(--gray-500); margin-left: auto;
}

/* Evaluee cards */
.evaluee-list {
    display: flex; flex-direction: column; gap: .75rem;
}
.evaluee-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    overflow: hidden;
}
.evaluee-card:hover {
    box-shadow: var(--shadow);
}
.evaluee-card.is-active {
    border-left-color: var(--success);
    background: #f0fdf4;
}
.evaluee-card-header {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1rem;
    cursor: pointer;
    user-select: none;
}
.evaluee-card-header:hover {
    background: var(--gray-50);
}
.evaluee-expand-icon {
    font-size: .7rem; color: var(--gray-400);
    transition: transform var(--transition);
    flex-shrink: 0; width: 16px; text-align: center;
}
.evaluee-card.is-expanded .evaluee-expand-icon {
    transform: rotate(90deg);
}
.evaluee-name {
    font-size: 1rem; font-weight: 600; color: var(--primary);
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.evaluee-meta {
    display: flex; gap: .75rem; align-items: center; flex-shrink: 0;
}
.evaluee-case-count {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent); color: var(--white);
    font-size: .65rem; font-weight: 700;
    padding: .15rem .5rem; border-radius: 10px;
    min-width: 22px;
}
.evaluee-date {
    font-size: .72rem; color: var(--gray-400);
}
.evaluee-actions {
    display: flex; gap: .35rem; flex-shrink: 0;
}

/* Evaluee body (cases) */
.evaluee-card-body {
    display: none;
    border-top: 1px solid var(--gray-100);
    padding: .65rem .85rem .85rem;
    background: var(--gray-50);
}
.evaluee-card.is-expanded .evaluee-card-body {
    display: block;
}

/* Case sub-cards */
.case-card-list {
    display: flex; flex-direction: column; gap: .5rem;
}
.case-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .5rem;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .65rem .85rem;
    transition: all var(--transition);
    cursor: pointer;
}
.case-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--accent-light);
}
.case-card.is-active-case {
    border-color: var(--success);
    background: #f0fdf4;
}
.case-card-info {
    display: flex; flex-wrap: wrap; gap: .35rem .85rem;
    align-items: center; min-width: 0;
}
.case-card-name {
    font-weight: 600; font-size: .88rem; color: var(--gray-700);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 240px;
}
.case-card-details {
    display: flex; flex-wrap: wrap; gap: .25rem .65rem;
    font-size: .72rem; color: var(--gray-500);
}
.case-card-details span {
    white-space: nowrap;
}
.case-card-damages {
    font-size: .82rem; font-weight: 700; color: var(--primary);
    white-space: nowrap;
}
.case-card-actions {
    display: flex; gap: .35rem; align-items: center; flex-shrink: 0;
}
.btn-duplicate-case {
    color: var(--gray-600); border-color: var(--gray-300); font-size: .72rem;
}
.btn-duplicate-case:hover {
    background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-400);
}

/* Case type badges */
.badge {
    display: inline-block;
    font-size: .6rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .4px;
    padding: .12rem .45rem;
    border-radius: 3px;
    white-space: nowrap;
}
.badge-pi { background: #dbeafe; color: #1e40af; }
.badge-lcp { background: #fef3c7; color: #92400e; }
.badge-wd { background: #fce7f3; color: #9d174d; }
.badge-employment { background: #d1fae5; color: #065f46; }
.badge-pediatric { background: #ede9fe; color: #5b21b6; }

/* New case form within evaluee card */
.evaluee-new-case-bar {
    display: flex; gap: .5rem; align-items: center;
    margin-top: .65rem; padding-top: .65rem;
    border-top: 1px dashed var(--gray-200);
    flex-wrap: wrap;
}
.evaluee-new-case-bar .form-select,
.evaluee-new-case-bar .form-control {
    font-size: .78rem; padding: .3rem .5rem;
    max-width: 180px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--gray-400);
}
.empty-state-icon {
    font-size: 3rem; margin-bottom: .75rem;
    opacity: .5;
}
.empty-state-title {
    font-size: 1.1rem; font-weight: 600;
    color: var(--gray-600); margin-bottom: .35rem;
}
.empty-state-text {
    font-size: .82rem; margin-bottom: 1rem;
    max-width: 360px; margin-left: auto; margin-right: auto;
}

/* Active case context in sidebar */
.sidebar-case-context {
    padding: .5rem .85rem;
    background: rgba(43,108,176,.08);
    border-radius: var(--radius);
    margin: 0 .65rem .5rem;
    font-size: .72rem;
    line-height: 1.4;
    display: none;
}
.sidebar-case-context.has-case {
    display: block;
}
.sidebar-case-context .ctx-evaluee {
    color: var(--gray-500);
    font-weight: 500;
}
.sidebar-case-context .ctx-case {
    color: var(--primary);
    font-weight: 600;
    display: block;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Dashboard action bar */
.dash-action-bar {
    display: flex; gap: .5rem; flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Dashboard case header */
.dash-case-header {
    display: flex; align-items: center; gap: .75rem;
    margin-bottom: .25rem; flex-wrap: wrap;
}
.dash-case-header .breadcrumb {
    display: flex; align-items: center; gap: .35rem;
    font-size: .78rem; color: var(--gray-500);
}
.dash-case-header .breadcrumb .sep {
    color: var(--gray-300);
}
.dash-case-header .breadcrumb .evaluee-link {
    cursor: pointer; color: var(--accent);
}
.dash-case-header .breadcrumb .evaluee-link:hover {
    text-decoration: underline;
}
.dash-case-header .case-title {
    font-size: 1.25rem; font-weight: 700; color: var(--primary);
}

/* Sidebar section grayed out when no case loaded */
.sidebar-nav .nav-group-locked .nav-link {
    opacity: .4; pointer-events: none;
}
.sidebar-nav .nav-group-locked.nav-group-unlocked .nav-link {
    opacity: 1; pointer-events: auto;
}

/* Quick-start card */
.quick-start-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}
.quick-start-card h3 {
    font-size: .88rem; margin-bottom: .65rem;
}
.quick-start-form {
    display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap;
}
.quick-start-form .form-group {
    min-width: 0;
}
.quick-start-form .form-group label {
    font-size: .7rem;
}

@media (max-width: 768px) {
    .evaluee-card-header { flex-wrap: wrap; }
    .evaluee-meta { width: 100%; justify-content: flex-start; margin-top: .35rem; }
    .case-card { grid-template-columns: 1fr; }
    .case-card-actions { justify-content: flex-end; }
    .directory-toolbar { flex-direction: column; }
    .directory-toolbar .form-control { max-width: 100%; }
    .directory-stats { margin-left: 0; }
    .dash-case-header { flex-direction: column; align-items: flex-start; }
    .quick-start-form { flex-direction: column; }
}

/* ── QC Badge Styles ────────────────────────────── */
.qc-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; }
.qc-badge-pass { background: var(--success-bg, #dcfce7); color: var(--success-text, #166534); }
.qc-badge-fail { background: var(--error-bg, #fee2e2); color: var(--error-text, #991b1b); }
.qc-badge-warn { background: var(--warning-bg, #fef9c3); color: var(--warning-text, #854d0e); }

/* ── Tooltip Styles ─────────────────────────────── */
.help-tip { position: relative; display: inline-block; width: 16px; height: 16px; border-radius: 50%; background: var(--accent, #3b82f6); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 16px; cursor: help; margin-left: 4px; vertical-align: middle; }
.help-tip::after { content: attr(data-tip); position: absolute; left: 50%; bottom: 125%; transform: translateX(-50%); background: #1e293b; color: #f8fafc; padding: 6px 10px; border-radius: 6px; font-size: 0.72rem; font-weight: 400; white-space: normal; width: max-content; max-width: 280px; opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 100; line-height: 1.4; }
.help-tip:hover::after, .help-tip:focus::after { opacity: 1; }

/* ── Sidebar Completion Indicators ──────────────── */
.nav-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--border, #d1d5db); margin-right: 6px; vertical-align: middle; }
.nav-status-partial { background: var(--warning-text, #f59e0b); border-color: var(--warning-text, #f59e0b); }
.nav-status-complete { background: var(--success-text, #22c55e); border-color: var(--success-text, #22c55e); }

/* ── Field Validation ───────────────────────────── */
.field-error { border-color: #ef4444 !important; }
.field-error-msg { color: #ef4444; font-size: 0.72rem; margin-top: 2px; }
.field-warning { border-color: #f59e0b !important; }
.field-warning-msg { color: #92400e; font-size: 0.72rem; margin-top: 2px; }

/* ── Dashboard Assumptions Panel ────────────────── */
.dash-assumptions { background: var(--bg-card, #fff); border: 1px solid var(--border, #e2e8f0); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.dash-assumptions-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.dash-assumptions-header h4 { margin: 0; font-size: 0.9rem; }
.dash-assumptions-toggle { background: none; border: none; font-size: 1rem; cursor: pointer; color: var(--text-secondary, #64748b); }
.dash-assumptions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 16px; margin-top: 12px; }
.dash-assumptions-grid.collapsed { display: none; }
.dash-assumption-item { display: flex; flex-direction: column; }
.dash-assumption-label { font-size: 0.7rem; color: var(--text-secondary, #64748b); text-transform: uppercase; letter-spacing: 0.5px; }
.dash-assumption-value { font-size: 0.85rem; font-weight: 600; }

/* ── Glossary ───────────────────────────────────── */
.glossary-section { background: var(--bg-card, #fff); border: 1px solid var(--border, #e2e8f0); border-radius: 8px; padding: 16px; margin-top: 16px; }
.glossary-section h4 { margin-top: 0; }
.glossary-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.glossary-item dt { font-weight: 600; font-size: 0.85rem; margin-bottom: 2px; }
.glossary-item dd { margin: 0 0 8px 0; font-size: 0.8rem; color: var(--text-secondary, #64748b); line-height: 1.4; }

/* ── Export Progress Overlay ─────────────────────── */
.export-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.2s ease;
}
.export-overlay.d-none { display: none !important; }
.export-overlay-content {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem 3rem;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    min-width: 320px;
    max-width: 420px;
}
.export-overlay-content h3 {
    margin: 1rem 0 0.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}
.export-overlay-content p {
    font-size: 0.85rem;
    margin: 0 0 1rem;
    line-height: 1.5;
}
.export-spinner {
    width: 48px; height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--primary, #2563eb);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
.export-timer {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    font-variant-numeric: tabular-nums;
}

/* ── Import Case Info Section ────────────────────────────── */
.import-case-info-section {
    border-left: 4px solid var(--accent);
}
.import-case-info-section textarea {
    font-family: var(--font-sans);
    resize: vertical;
    min-height: 120px;
}
.import-case-info-section .collapsible-header {
    padding: 0;
}
.import-case-info-section .collapsible-body {
    transition: max-height var(--transition-slow);
}
.import-case-info-section .collapsible-body.collapsed {
    max-height: 0 !important;
    overflow: hidden;
}

/* ── PC/PM Analysis Screen ──────────────────────────────── */

/* Stepper progress bar */
.pcpm-stepper {
    padding: 1rem 0;
}
.pcpm-stepper-track {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}
.pcpm-step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    cursor: pointer;
    opacity: .5;
    transition: opacity var(--transition);
}
.pcpm-step-indicator.active,
.pcpm-step-indicator.completed {
    opacity: 1;
}
.pcpm-step-indicator .step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-600);
    font-weight: 600;
    font-size: .9rem;
    transition: background var(--transition), color var(--transition);
}
.pcpm-step-indicator.active .step-num {
    background: var(--accent);
    color: #fff;
}
.pcpm-step-indicator.completed .step-num {
    background: var(--success, #22c55e);
    color: #fff;
}
.pcpm-step-indicator .step-label {
    font-size: .72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.pcpm-step-indicator.active .step-label {
    color: var(--accent);
    font-weight: 600;
}
.pcpm-step-connector {
    flex: 1;
    height: 2px;
    background: var(--gray-200);
    min-width: 2rem;
    max-width: 6rem;
    margin: 0 .25rem;
    margin-bottom: 1.1rem;
}

/* Step content panels */
.pcpm-step-content {
    display: none;
}
.pcpm-step-content.active {
    display: block;
    animation: fadeInUp .25s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Auto-filled badge */
.auto-filled-badge {
    display: inline-block;
    background: var(--green-50, #f0fdf4);
    color: var(--success, #22c55e);
    border: 1px solid var(--green-200, #bbf7d0);
    border-radius: 1rem;
    padding: .1rem .55rem;
    font-size: .68rem;
    font-weight: 600;
    vertical-align: middle;
    margin-left: .35rem;
}

/* Education scenario chips (selectable) */
.edu-chip {
    display: inline-block;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .5rem .85rem;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    text-align: center;
    min-width: 120px;
}
.edu-chip:hover {
    border-color: var(--accent-light);
    box-shadow: var(--shadow-sm);
}
.edu-chip.selected {
    border-color: var(--accent);
    background: var(--blue-50, #eff6ff);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .15);
}
.edu-chip .chip-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-primary);
}
.edu-chip .chip-value {
    font-size: .9rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: .15rem;
}

/* Results grid */
.pcpm-results-grid .dash-card {
    text-align: center;
}
.pcpm-results-grid .dash-card .card-value {
    font-size: 1.35rem;
}
.pcpm-results-grid .dash-card .card-sub {
    font-size: .68rem;
    line-height: 1.3;
}

/* ═══════════════════════════════════════════════════════════
   Mobile-Responsive Enhancements
   ═══════════════════════════════════════════════════════════ */

/* ── Tablet: screens below 768px ────────────────────────── */
@media (max-width: 768px) {
    /* Earnings sub-tabs responsive */
    .earnings-tabs {
        padding: 0 .25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .earnings-tab {
        padding: .5rem .8rem;
        font-size: .78rem;
        min-height: 44px;
    }

    /* Touch-friendly form controls */
    .form-control, .form-select {
        min-height: 44px;
        font-size: .92rem;
        padding: .55rem .75rem;
    }
    .btn {
        min-height: 44px;
        padding: .55rem 1rem;
        font-size: .85rem;
    }
    .btn-sm {
        min-height: 38px;
        padding: .4rem .7rem;
        font-size: .78rem;
    }
    .form-check input[type="checkbox"],
    .form-check input[type="radio"] {
        width: 20px;
        height: 20px;
    }
    .form-check-label {
        font-size: .88rem;
    }

    /* Sidebar hamburger toggle */
    .hamburger-btn {
        display: flex;
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
        top: 4px;
        left: 4px;
    }

    /* Profile bar adjustments */
    .profile-bar {
        height: auto;
        min-height: var(--topbar-height);
        flex-wrap: wrap;
        gap: .35rem;
        padding: .35rem .5rem;
    }
    .profile-bar .profile-actions {
        flex-wrap: wrap;
        gap: .3rem;
    }
    #active-case-label {
        max-width: 140px;
        font-size: .65rem;
    }

    /* Main content padding */
    .main-content {
        padding: .75rem .65rem 5rem;
    }

    /* Content sections tighter on tablet */
    .content-section {
        padding: .85rem 1rem;
        margin-bottom: .75rem;
        border-radius: var(--radius);
    }

    /* Tables horizontal scroll */
    .table-wrapper {
        -webkit-overflow-scrolling: touch;
        margin-left: -.5rem;
        margin-right: -.5rem;
        padding: 0 .5rem;
        border: none;
        border-radius: 0;
    }
    table.data-table {
        font-size: .76rem;
    }
    .data-table thead th {
        padding: .4rem .5rem;
        font-size: .65rem;
    }
    .data-table tbody td {
        padding: .35rem .5rem;
    }
    .data-table td .cell-input {
        font-size: .76rem;
        padding: .2rem .3rem;
    }

    /* Sensitivity matrix scroll */
    .sensitivity-wrapper {
        -webkit-overflow-scrolling: touch;
    }
    table.sensitivity-matrix {
        font-size: .68rem;
    }

    /* Dashboard grid single column */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: .65rem;
    }
    .dash-card .card-value {
        font-size: 1.2rem;
    }

    /* Floating nav adjustments */
    .floating-nav {
        height: 56px;
        padding: 0 .75rem;
    }
    .floating-nav .btn {
        min-width: 70px;
        font-size: .76rem;
    }

    /* Slideout panel full width */
    .slideout-panel {
        width: 100%;
        right: -100%;
        padding: 1rem;
    }

    /* Toast container */
    .toast-container {
        left: .75rem;
        right: .75rem;
        bottom: 4.5rem;
    }
    .toast {
        max-width: 100%;
        min-width: auto;
        font-size: .8rem;
    }

    /* Auth gate card */
    .auth-card {
        width: 100%;
        max-width: 100%;
        padding: 1rem;
    }

    /* Audit popup */
    .audit-popup {
        width: 100%;
        max-height: 85vh;
    }

    /* Fringe benefit list */
    .fringe-benefit-list {
        grid-template-columns: 1fr;
    }

    /* Placeholder grid */
    .placeholder-grid {
        grid-template-columns: 1fr;
    }

    /* Form row adjustments */
    .form-row, .form-row-tight {
        flex-direction: column;
        gap: .5rem;
    }
    .form-row .form-group,
    .form-row-tight .form-group {
        min-width: 100%;
    }

    /* Max-width overrides */
    .max-w-sm, .max-w-xs, .max-w-xxs {
        max-width: 100%;
    }

    /* Section titles */
    .section-title {
        font-size: .92rem;
    }
    h1 {
        font-size: 1.2rem;
    }
    h2 {
        font-size: 1.1rem;
    }
    h3 {
        font-size: 1rem;
    }

    /* Scenario chips wrap */
    .scenario-chip-row {
        gap: .35rem;
    }
    .scenario-chip span {
        padding: .45rem .65rem;
        font-size: .76rem;
    }

    /* QC items */
    .qc-item {
        flex-wrap: wrap;
    }

    /* Workflow chips */
    .dash-workflow-chips {
        max-width: 100%;
    }

    /* Evaluee card adjustments */
    .evaluee-card-header {
        flex-wrap: wrap;
        padding: .75rem .85rem;
    }
    .evaluee-meta {
        width: 100%;
        justify-content: flex-start;
        margin-top: .35rem;
    }
    .evaluee-name {
        font-size: .92rem;
    }
    .case-card {
        grid-template-columns: 1fr;
    }
    .case-card-actions {
        justify-content: flex-end;
    }
    .case-card-name {
        max-width: 100%;
    }

    /* Directory toolbar */
    .directory-toolbar {
        flex-direction: column;
    }
    .directory-toolbar .form-control {
        max-width: 100%;
    }
    .directory-stats {
        margin-left: 0;
    }

    /* Quick start form */
    .quick-start-form {
        flex-direction: column;
    }
    .quick-start-form .form-group {
        min-width: 100% !important;
    }

    /* Dashboard case header */
    .dash-case-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* New case bar */
    .evaluee-new-case-bar {
        flex-direction: column;
    }
    .evaluee-new-case-bar .form-select,
    .evaluee-new-case-bar .form-control {
        max-width: 100%;
    }

    /* Assumptions grid */
    .dash-assumptions-grid {
        grid-template-columns: 1fr;
    }

    /* Glossary */
    .glossary-list {
        grid-template-columns: 1fr;
    }

    /* Export overlay */
    .export-overlay-content {
        min-width: auto;
        max-width: 90vw;
        padding: 1.5rem;
    }

    /* SP summary bar */
    .sp-summary-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Input group touch targets */
    .input-group .input-prefix,
    .input-group .input-suffix {
        padding: 0 .65rem;
        font-size: .82rem;
    }

    /* Button groups wrap */
    .btn-group {
        flex-wrap: wrap;
        gap: .4rem;
    }

    /* Fringe actions */
    .fringe-actions {
        flex-direction: column;
    }

    /* Progress bar */
    .dash-progress-track {
        width: 100px;
    }

    /* PC/PM Stepper & Results */
    .pcpm-stepper-track {
        gap: 0;
    }
    .pcpm-step-connector {
        min-width: 1rem;
        max-width: 3rem;
    }
    .pcpm-step-indicator .step-label {
        font-size: .62rem;
    }
    .pcpm-results-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    .edu-chip {
        min-width: 100px;
        padding: .4rem .6rem;
    }
}

/* ── Phone: screens below 480px ─────────────────────────── */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    /* Even more compact content */
    .main-content {
        padding: .5rem .45rem 5rem;
    }
    .content-section {
        padding: .65rem .75rem;
        margin-bottom: .6rem;
    }

    /* Headers */
    h1 {
        font-size: 1.1rem;
    }
    h2 {
        font-size: 1rem;
    }
    h3 {
        font-size: .92rem;
    }
    .section-title {
        font-size: .86rem;
        flex-wrap: wrap;
    }
    .section-title .section-icon {
        width: 18px;
        height: 18px;
        font-size: .58rem;
    }

    /* Sidebar full width */
    :root {
        --sidebar-width: 100vw;
    }
    .sidebar {
        width: 100vw;
    }

    /* Profile bar compact — single row on phone */
    .profile-bar {
        padding: .25rem .4rem;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: .25rem;
    }
    .profile-bar .profile-actions {
        flex-wrap: nowrap;
        flex-shrink: 0;
        gap: .2rem;
    }
    .profile-bar .btn-sm {
        padding: .25rem .35rem;
        font-size: .62rem;
        min-height: 32px;
        white-space: nowrap;
    }
    #active-case-label {
        max-width: 80px;
        font-size: .56rem;
    }
    /* Hide admin-only buttons on small phones to save space */
    #btn-auth-manage-users,
    #btn-auth-create-user {
        display: none !important;
    }

    /* Autosave dot */
    .autosave-dot {
        width: 6px;
        height: 6px;
    }

    /* Touch targets minimum 44px */
    .form-control, .form-select {
        min-height: 44px;
        font-size: .9rem;
    }
    .btn {
        min-height: 44px;
        font-size: .82rem;
    }
    .btn-sm {
        min-height: 40px;
    }

    /* Tables */
    .data-table thead th {
        font-size: .6rem;
        padding: .3rem .4rem;
        letter-spacing: .3px;
    }
    .data-table tbody td {
        padding: .3rem .4rem;
        font-size: .74rem;
    }
    table.data-table {
        font-size: .72rem;
    }

    /* Cards */
    .dash-card {
        padding: .75rem .85rem;
    }
    .dash-card .card-value {
        font-size: 1.1rem;
    }
    .dash-card .card-label {
        font-size: .62rem;
    }
    .dash-card .card-sub {
        font-size: .68rem;
    }

    /* Floating nav */
    .floating-nav {
        height: 52px;
        padding: 0 .5rem;
    }
    .floating-nav .btn {
        min-width: 60px;
        font-size: .72rem;
        padding: .4rem .6rem;
    }

    /* Toast */
    .toast-container {
        left: .5rem;
        right: .5rem;
    }
    .toast {
        padding: .45rem .75rem;
        font-size: .78rem;
    }

    /* Badges */
    .badge {
        font-size: .56rem;
        padding: .1rem .35rem;
    }

    /* Form labels */
    .form-label {
        font-size: .72rem;
    }
    .form-text {
        font-size: .68rem;
    }

    /* Input groups */
    .input-group .input-prefix,
    .input-group .input-suffix {
        padding: 0 .5rem;
        font-size: .78rem;
    }

    /* Evaluee cards */
    .evaluee-card-header {
        padding: .65rem .75rem;
    }
    .evaluee-name {
        font-size: .86rem;
    }
    .evaluee-case-count {
        font-size: .6rem;
    }
    .evaluee-date {
        font-size: .66rem;
    }

    /* Case cards */
    .case-card {
        padding: .5rem .65rem;
    }
    .case-card-name {
        font-size: .82rem;
    }
    .case-card-details {
        font-size: .66rem;
    }

    /* Alert */
    .alert {
        padding: .5rem .75rem;
        font-size: .78rem;
    }

    /* Slideout */
    .slideout-panel {
        padding: .75rem;
    }
    .slideout-panel h2 {
        font-size: 1rem;
    }

    /* Auth */
    .auth-card {
        padding: .85rem;
    }
    .auth-card h2 {
        font-size: 1.05rem;
    }

    /* Keyboard shortcut hints hidden on small screens */
    .kbd {
        display: none;
    }

    /* Sidebar footer */
    .sidebar-footer {
        font-size: .6rem;
    }

    /* Collapsible sections */
    .collapsible-header {
        padding: .5rem .65rem;
        font-size: .82rem;
    }

    /* SP rule panels */
    .sp-rule-panel .collapsible-header {
        padding: .45rem .65rem;
        font-size: .8rem;
    }
    .sp-notes-text {
        padding: .45rem .65rem;
        font-size: .76rem;
    }

    /* Prevent horizontal overflow */
    .app-wrapper {
        overflow-x: hidden;
    }
    body {
        overflow-x: hidden;
    }

    /* PC/PM Stepper on phone */
    .pcpm-stepper-track {
        flex-wrap: wrap;
        gap: .25rem;
        justify-content: center;
    }
    .pcpm-step-connector {
        display: none;
    }
    .pcpm-step-indicator {
        flex-direction: row;
        gap: .35rem;
    }
    .pcpm-step-indicator .step-num {
        width: 1.8rem;
        height: 1.8rem;
        font-size: .8rem;
    }
    .pcpm-results-grid {
        grid-template-columns: 1fr !important;
    }
    .edu-chip {
        min-width: 90px;
        font-size: .8rem;
    }

    /* Import case info section */
    .import-case-info-section textarea {
        min-height: 100px;
    }
}

/* ═══════════════════════════════════════════════════════════
   iPhone & iOS Optimizations
   Safe areas, input zoom prevention, momentum scrolling
   ═══════════════════════════════════════════════════════════ */

/* Safe area insets for notch/dynamic island/home indicator */
@supports (padding: env(safe-area-inset-top)) {
    .profile-bar {
        padding-top: max(0.35rem, env(safe-area-inset-top));
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
    }
    .sidebar {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .floating-nav {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
        height: calc(56px + env(safe-area-inset-bottom));
    }
    .main-content {
        padding-bottom: calc(5rem + env(safe-area-inset-bottom));
    }
    .toast-container {
        bottom: calc(4.5rem + env(safe-area-inset-bottom));
    }
    .hamburger-btn {
        top: max(4px, env(safe-area-inset-top));
        left: max(4px, env(safe-area-inset-left));
    }
}

/* Prevent iOS input zoom — inputs must be >= 16px */
@media (max-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="tel"],
    input[type="url"],
    select,
    textarea {
        font-size: max(16px, 1rem) !important;
    }
}

/* iPhone SE / small phone optimizations (375px and below) */
@media (max-width: 375px) {
    .main-content {
        padding: .4rem .35rem 5.5rem;
    }
    .content-section {
        padding: .55rem .6rem;
        margin-bottom: .5rem;
    }
    h1 { font-size: 1.05rem; }
    h2 { font-size: .95rem; }

    .profile-bar .btn-sm {
        padding: .25rem .35rem;
        font-size: .64rem;
        min-height: 36px;
    }
    #active-case-label {
        max-width: 80px;
        font-size: .56rem;
    }

    .form-label {
        font-size: .7rem;
    }

    .evaluee-card-header {
        padding: .55rem .65rem;
    }
    .evaluee-name {
        font-size: .82rem;
    }

    .floating-nav .btn {
        min-width: 52px;
        font-size: .68rem;
        padding: .35rem .45rem;
    }

    .dash-card .card-value {
        font-size: 1rem;
    }

    /* Stack scenario chips vertically on small phones */
    .scenario-chip-row {
        flex-direction: column;
    }
}

/* iOS momentum scrolling for all scrollable areas */
.table-wrapper,
.sensitivity-wrapper,
.evaluee-list,
.case-list-body,
#user-mgmt-table-wrap,
.slideout-panel {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Smooth scrolling within main content */
.main-content {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Better touch targets for inline action buttons */
@media (max-width: 768px) {
    .evaluee-actions .btn,
    .case-card-actions .btn {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Sidebar nav items need bigger touch targets */
    .nav-link {
        padding: .7rem 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    /* Checkbox/radio touch areas */
    .inline-checkbox,
    .form-check {
        min-height: 44px;
        display: flex;
        align-items: center;
        gap: .5rem;
    }
    .inline-checkbox input[type="checkbox"],
    .inline-checkbox input[type="radio"] {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    /* Collapsible headers bigger touch target */
    .collapsible-header {
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    /* Table action buttons in healthcare/offsets */
    .data-table .btn-sm,
    .data-table button {
        min-width: 36px;
        min-height: 36px;
        padding: .25rem .4rem;
    }

    /* Screen header with better spacing */
    .screen-header {
        padding: .5rem 0;
        margin-bottom: .5rem;
    }
}

/* Landscape mode on phones */
@media (max-height: 500px) and (max-width: 900px) {
    .floating-nav {
        height: 44px;
    }
    .main-content {
        padding-bottom: 3.5rem;
    }
    .profile-bar {
        min-height: 36px;
    }
    .profile-bar .btn-sm {
        min-height: 32px;
        font-size: .68rem;
    }
}

/* Disable hover effects on touch devices (prevents sticky hover) */
@media (hover: none) {
    .nav-link:hover {
        background: transparent;
    }
    .evaluee-card-header:hover {
        background: transparent;
    }
    .btn:hover {
        filter: none;
    }
    .nav-link.active {
        background: var(--gray-100);
    }
}

/* ── All-in-One Mode (Claude Co-work) ─────────────────── */
.allinone-toggle {
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 500;
}
.allinone-toggle.active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

body.allinone-mode .screen {
    display: block !important;
    animation: none;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 3px solid var(--gray-200);
    position: relative;
}
body.allinone-mode .screen::before {
    content: attr(data-claude-screen);
    display: block;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--gray-400);
    background: var(--gray-100);
    padding: 4px 10px;
    border-radius: var(--radius);
    margin-bottom: .75rem;
    width: fit-content;
}
body.allinone-mode #screen-case-management,
body.allinone-mode #screen-quick-estimate {
    display: none !important;
}
body.allinone-mode .floating-nav {
    display: none !important;
}
body.allinone-mode .context-actions {
    display: none !important;
}
body.allinone-mode .screen:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* ── Always-visible scrollbars (sidebar, modals, lists) ─── */
.sidebar,
.evaluee-list,
.case-list-body,
.slideout-panel,
.fringe-benefit-list,
.sp-notes-text {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.25) transparent;
}
.sidebar::-webkit-scrollbar {
    width: 8px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.25);
    border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.4);
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.evaluee-list,
.case-list-body,
.slideout-panel,
.fringe-benefit-list,
.sp-notes-text {
    scrollbar-color: var(--gray-400) transparent;
}
.evaluee-list::-webkit-scrollbar,
.case-list-body::-webkit-scrollbar,
.slideout-panel::-webkit-scrollbar,
.fringe-benefit-list::-webkit-scrollbar,
.sp-notes-text::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    background: transparent;
}
.evaluee-list::-webkit-scrollbar-thumb,
.case-list-body::-webkit-scrollbar-thumb,
.slideout-panel::-webkit-scrollbar-thumb,
.fringe-benefit-list::-webkit-scrollbar-thumb,
.sp-notes-text::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}
.evaluee-list::-webkit-scrollbar-thumb:hover,
.case-list-body::-webkit-scrollbar-thumb:hover,
.slideout-panel::-webkit-scrollbar-thumb:hover,
.fringe-benefit-list::-webkit-scrollbar-thumb:hover,
.sp-notes-text::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* ── Assistant Sidebar ────────────────────────────────────────── */
.assistant-sidebar {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 380px; max-width: 100vw;
    z-index: 10000;
    background: #fff;
    border-left: 1px solid var(--gray-200);
    box-shadow: -2px 0 20px rgba(0,0,0,0.10);
    display: flex; flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    pointer-events: none;
}
.assistant-sidebar.open {
    transform: translateX(0);
    pointer-events: auto;
}
/* FAB */
.assistant-chat-fab {
    position: fixed; bottom: 70px; right: 20px;
    z-index: 9998; width: 50px; height: 50px;
    border-radius: 50%; background: var(--primary); color: #fff;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 12px rgba(0,0,0,0.25);
    transition: transform 0.2s, background 0.2s;
}
.assistant-chat-fab:hover { background: var(--primary-dark); transform: scale(1.08); }
.assistant-chat-fab.hidden { display: none; }
/* Header */
.assistant-sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; background: var(--primary); color: #fff; flex-shrink: 0;
}
.assistant-sidebar-header-left { display: flex; align-items: center; gap: 8px; }
.assistant-sidebar-title { font-weight: 600; font-size: 14px; }
.assistant-sidebar-close {
    background: none; border: none; color: #fff; font-size: 20px;
    cursor: pointer; padding: 0 4px; opacity: 0.8;
}
.assistant-sidebar-close:hover { opacity: 1; }
/* Case context bar */
.assistant-case-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50, #f7fafc); flex-shrink: 0; min-height: 36px;
}
.assistant-case-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.assistant-case-label {
    font-size: 12px; font-weight: 600; color: var(--gray-800);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.assistant-case-type {
    font-size: 10px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px;
}
.assistant-case-progress {
    width: 60px; height: 6px; background: var(--gray-200);
    border-radius: 3px; overflow: hidden; flex-shrink: 0;
}
.assistant-progress-fill {
    height: 100%; background: var(--success, #38a169);
    border-radius: 3px; transition: width 0.3s;
    width: 0%;
}
.assistant-progress-text { font-size: 10px; color: var(--gray-500); flex-shrink: 0; }
/* Quick actions */
.assistant-quick-actions {
    display: flex; gap: 4px; padding: 6px 14px;
    border-bottom: 1px solid var(--gray-200); flex-shrink: 0;
}
.assistant-quick-btn {
    flex: 1; padding: 5px 4px; font-size: 11px; font-weight: 500;
    border: 1px solid var(--gray-300); border-radius: 6px;
    background: #fff; color: var(--primary); cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.assistant-quick-btn:hover {
    background: var(--gray-100); border-color: var(--primary-light);
}
/* Messages */
.assistant-sidebar-messages {
    flex: 1; overflow-y: auto; padding: 12px; display: flex;
    flex-direction: column; gap: 10px;
}
.assistant-sidebar-messages::-webkit-scrollbar { width: 5px; }
.assistant-sidebar-messages::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
.assistant-chat-welcome {
    text-align: center; padding: 16px 8px; color: var(--gray-700);
    font-size: 13px; line-height: 1.5;
}
.assistant-chat-welcome p { margin: 0 0 6px; }
.assistant-chat-suggestions { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.assistant-suggestion-chip {
    background: var(--gray-100, #f0f4f8); border: 1px solid var(--gray-200, #e2e8f0);
    border-radius: 8px; padding: 7px 10px; font-size: 11.5px;
    color: var(--primary); cursor: pointer; text-align: left;
    transition: background 0.15s; line-height: 1.35;
}
.assistant-suggestion-chip:hover {
    background: var(--gray-200); border-color: var(--primary-light);
}
/* Messages */
.assistant-msg {
    max-width: 90%; padding: 8px 12px; border-radius: 10px;
    font-size: 12.5px; line-height: 1.5; word-wrap: break-word;
}
.assistant-msg-user {
    align-self: flex-end; background: var(--primary); color: #fff;
    border-bottom-right-radius: 3px;
}
.assistant-msg-bot {
    align-self: flex-start; background: var(--gray-100, #f0f4f8);
    color: var(--gray-800); border-bottom-left-radius: 3px;
}
.assistant-msg-bot .assistant-actions-summary {
    margin-top: 6px; padding-top: 6px;
    border-top: 1px solid var(--gray-200); font-size: 11px;
    color: var(--gray-600);
}
.assistant-msg-bot .assistant-action-item {
    display: flex; align-items: center; gap: 5px; padding: 1px 0;
}
.assistant-msg-bot .assistant-action-check { color: var(--success, #38a169); font-weight: bold; }
.assistant-msg-bot .assistant-action-fail { color: var(--danger, #e53e3e); font-weight: bold; }
.assistant-msg-typing {
    align-self: flex-start; background: var(--gray-100); color: var(--gray-500);
    border-bottom-left-radius: 3px; font-style: italic; font-size: 12px;
}
.assistant-msg-system {
    align-self: center; background: var(--gray-100); color: var(--gray-600);
    font-size: 11px; padding: 4px 10px; border-radius: 8px; text-align: center;
}
/* Input area */
.assistant-sidebar-input-area {
    display: flex; align-items: flex-end; gap: 6px;
    padding: 10px 12px; border-top: 1px solid var(--gray-200);
    background: #fff; flex-shrink: 0;
}
.assistant-sidebar-input {
    flex: 1; resize: none;
    border: 1px solid var(--gray-300); border-radius: 10px;
    padding: 8px 12px; font-size: 12.5px; font-family: inherit;
    line-height: 1.4; max-height: 120px; outline: none;
    transition: border-color 0.15s;
}
.assistant-sidebar-input:focus { border-color: var(--primary); }
.assistant-sidebar-input.paste-mode {
    border-color: var(--warning, #dd6b20); background: #fffbf0;
}
.assistant-sidebar-send {
    background: var(--primary); color: #fff; border: none;
    border-radius: 50%; width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; transition: background 0.15s;
}
.assistant-sidebar-send:hover { background: var(--primary-dark); }
.assistant-sidebar-send:disabled { background: var(--gray-300); cursor: not-allowed; }
/* Responsive */
@media (max-width: 768px) {
    .assistant-sidebar { width: 100vw; }
    .assistant-chat-fab { bottom: 60px; right: 12px; width: 44px; height: 44px; }
}
@media (max-width: 480px) {
    .assistant-sidebar-input { font-size: 14px; }
}
