/* 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; }
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; }

/* ── 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; }
.profile-bar .form-select { height: 28px; padding: .15rem .5rem; font-size: .75rem; }
.profile-bar .btn-sm { padding: .2rem .55rem; font-size: .7rem; }

/* 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);
}

/* 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; }
.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: auto; margin-bottom: .75rem;
    border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
}
table.data-table { width: 100%; 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;
}

/* ── 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;
}
.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); }

/* ── 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); }
}

/* ── 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);
}

/* ── 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; }
    .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 ──────────────────────────────────────────── */
@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; }
    .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); }
}
