/* ==========================================================================
   PEVAL — Compact Enterprise Theme
   Overrides Pico CSS for a dense, professional dashboard feel.
   ========================================================================== */

/* --- Pico CSS overrides: tame the defaults --- */
:root {
    --pico-font-size: 14px;
    --pico-line-height: 1.45;
    --pico-spacing: 0.5rem;
    --pico-form-element-spacing-vertical: 0.3rem;
    --pico-form-element-spacing-horizontal: 0.5rem;
    --pico-typography-spacing-vertical: 0;

    --brand: #1e40af;
    --brand-light: #3b82f6;
    --brand-bg: #eff6ff;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --success: #16a34a;
    --warning: #ea580c;
    --danger: #dc2626;
    --info: #0284c7;
    --radius: 6px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 13.5px;
    line-height: 1.45;
    background: var(--surface-alt);
    color: var(--text);
    margin: 0;
}

/* --- Aggressive Pico resets --- */
h1, h2, h3, h4, h5, h6 { margin: 0 0 0.4rem; }
p { margin: 0 0 0.35rem; }
ul, ol { margin: 0 0 0.35rem; padding-left: 1.25rem; }
figure { margin: 0; }
form { margin: 0; }
input, select, textarea, button { margin-bottom: 0; }

/* Reset Pico article styles completely */
article {
    margin: 0 0 1rem;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
article > * { padding: 0; margin: 0; }
article > header {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
article > header h3 { margin: 0; font-size: 0.82rem; font-weight: 600; }

/* Reset Pico details styles */
details { margin-bottom: 0; }

.container { max-width: 1200px; }

/* === Top Navigation === */
.top-nav {
    background: var(--brand);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    height: 44px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    color: #fff;
}

.brand-logo { width: 24px; height: 24px; }
.brand-text { font-weight: 700; font-size: 0.9rem; letter-spacing: 0.3px; }
.brand-sub { font-size: 0.65rem; opacity: 0.6; font-weight: 400; margin-left: 0.2rem; }

.nav-links {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0;
    height: 44px;
    align-items: stretch;
}

.nav-links li { display: flex; align-items: stretch; }

.nav-links li a {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.nav-links li a:hover {
    color: rgba(255,255,255,0.95);
    background: rgba(255,255,255,0.08);
}

.nav-links li a.active {
    color: #fff;
    border-bottom-color: #fff;
    background: rgba(255,255,255,0.1);
    font-weight: 600;
}

/* === Main Content === */
.main-content {
    padding-top: 1.25rem;
    padding-bottom: 2rem;
    min-height: calc(100vh - 44px - 40px);
}

/* === Footer === */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.6rem 0;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* === Page Headers === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.page-header h1 { margin: 0; font-size: 1.25rem; font-weight: 700; }

.page-header .subtitle {
    color: var(--text-muted);
    margin: 0.15rem 0 0;
    font-size: 0.78rem;
}

.page-header a[role="button"] {
    white-space: nowrap;
    background: var(--brand);
    border-color: var(--brand);
    font-size: 0.78rem;
    padding: 0.35rem 1rem;
    border-radius: var(--radius);
    color: #fff;
    text-decoration: none;
}

/* === Panels === */
.panel {
    margin: 0 0 1rem;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.panel > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    background: transparent;
}

.panel > header h3 { margin: 0; font-size: 0.82rem; font-weight: 600; }
.panel > header .view-all { font-size: 0.72rem; color: var(--brand-light); }

.panel > figure {
    margin: 0;
    padding: 0;
    overflow-x: auto;
}

/* Padded content inside panels */
.panel-body { padding: 0.75rem 1rem; }

/* === KPI Cards === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-sm);
    margin: 0;
}

.kpi-card.kpi-approved { border-left: 3px solid var(--success); }
.kpi-card.kpi-review { border-left: 3px solid var(--warning); }

.kpi-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    white-space: nowrap;
}

.kpi-detail {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* === Section Grid === */
.section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
@media (max-width: 768px) { .section-grid { grid-template-columns: 1fr; } }

/* === Financial Grid === */
.fin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.fin-item { display: flex; flex-direction: column; }

.fin-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    margin-bottom: 0.1rem;
}

.fin-value { font-size: 0.95rem; font-weight: 600; white-space: nowrap; }
.fin-highlight { color: var(--brand); font-size: 1.05rem; }

/* === Verdict Bars === */
.verdict-bars {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.verdict-bar-row { display: flex; align-items: center; gap: 0.5rem; }

.verdict-bar-label { min-width: 85px; font-size: 0.72rem; font-weight: 500; }

.verdict-bar-track {
    flex: 1;
    height: 6px;
    background: var(--surface-alt);
    border-radius: 3px;
    overflow: hidden;
}

.verdict-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    min-width: 2px;
}

.verdict-bar-count { min-width: 24px; text-align: right; font-size: 0.78rem; font-weight: 600; }

.status-summary {
    padding: 0.5rem 1rem 0.75rem;
    border-top: 1px solid var(--border);
}

.status-summary h4 {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0;
    font-size: 0.78rem;
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 0.15em 0.5em;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-transform: capitalize;
    white-space: nowrap;
    vertical-align: middle;
}

.badge-pending    { background: #fef3c7; color: #92400e; }
.badge-incomplete { background: #f3f4f6; color: #4b5563; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-completed  { background: #dcfce7; color: #166534; }
.badge-approved   { background: #dcfce7; color: #166534; }
.badge-failed     { background: #fee2e2; color: #991b1b; }
.badge-rejected   { background: #fee2e2; color: #991b1b; }
.badge-needs_review { background: #ffedd5; color: #9a3412; }

.badge-check-pass { background: #dcfce7; color: #166534; }
.badge-check-fail { background: #fee2e2; color: #991b1b; }
.badge-check-warning { background: #fef3c7; color: #92400e; }
.badge-check-not_applicable { background: #f3f4f6; color: #4b5563; }

.badge-step-started { background: #dbeafe; color: #1e40af; }
.badge-step-completed { background: #dcfce7; color: #166534; }
.badge-step-failed { background: #fee2e2; color: #991b1b; }

.verdict-badge {
    display: inline-block;
    padding: 0.35em 1em;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    margin-bottom: 0.35rem;
}

/* === Data Tables === */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    background: var(--surface-alt);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    padding: 0.5rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:hover { background: var(--brand-bg); }

.mono { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; font-size: 0.74rem; }

/* === Buttons === */
.btn-sm {
    display: inline-block;
    padding: 0.2em 0.6em;
    background: var(--brand);
    color: #fff;
    border-radius: 3px;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    line-height: 1.5;
    vertical-align: middle;
    margin: 0;
}

.btn-sm:hover { background: var(--brand-light); color: #fff; }

.btn-secondary {
    display: inline-block;
    padding: 0.2em 0.6em;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 3px;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    vertical-align: middle;
    margin: 0;
    line-height: 1.5;
}

.btn-secondary:hover { background: var(--surface-alt); color: var(--text); }

/* Inline action groups — kills Pico form margins */
.inline-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.inline-actions form,
.inline-actions form button,
.inline-actions .badge { margin: 0; padding-top: 0; padding-bottom: 0; }
.inline-actions form button { vertical-align: middle; }

/* === Utility === */
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.dot-processing { background: var(--info); }
.dot-rejected { background: var(--danger); }

.empty-state { text-align: center; color: var(--text-muted); padding: 1.5rem; font-size: 0.82rem; }
.num { text-align: right; }
.money { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; }

/* === Drop Zone === */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    background: var(--surface);
}

.drop-zone:hover,
.drop-zone.drag-over { border-color: var(--brand-light); background: var(--brand-bg); }

.drop-zone p { margin: 0; color: var(--text-muted); font-size: 0.88rem; }
.drop-zone .drop-icon { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; color: var(--brand-light); }

.file-info {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--brand-bg);
    border-radius: var(--radius);
    font-size: 0.82rem;
}

/* === Upload page card === */
.upload-card {
    max-width: 560px;
    margin: 1.5rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.upload-card h2 { margin-top: 0; font-size: 1.15rem; }

.upload-card button[type="submit"] {
    width: 100%;
    background: var(--brand);
    border-color: var(--brand);
    font-weight: 600;
    padding: 0.6rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-top: 0.75rem;
    color: #fff;
    border: none;
    cursor: pointer;
}

.upload-card button[type="submit"]:disabled { opacity: 0.5; }

/* === Document Card === */
.document-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
}

.document-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 0.82rem;
}

.document-card p { padding: 0.4rem 1rem; font-size: 0.78rem; }

.doc-audit {
    margin: 0.5rem 1rem;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--border);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--surface-alt);
    font-size: 0.78rem;
}

.doc-audit details {
    margin-top: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.doc-audit details summary {
    padding: 0.35rem 0.6rem;
    font-size: 0.72rem;
    cursor: pointer;
    background: var(--surface-alt);
}

/* === Progress Card === */
.progress-card {
    text-align: center;
    padding: 1.25rem;
    background: var(--brand-bg);
    border-radius: var(--radius);
    border: 1px solid #bfdbfe;
    font-size: 0.82rem;
}

.progress-card progress { max-width: 350px; margin: 0.5rem auto; display: block; }

/* === Audit Summary === */
.audit-summary { padding: 0.75rem 1rem; }

.audit-summary h4 {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    margin: 0.75rem 0 0.35rem;
}

.audit-summary .fin-grid { padding: 0; }
.audit-summary figure { margin: 0; padding: 0; }

/* === Reasoning block === */
.reasoning-block {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.error-text { color: var(--danger); font-weight: 500; }

pre code {
    max-height: 250px;
    overflow-y: auto;
    display: block;
    font-size: 0.7rem;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--surface-alt);
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* === Details/Summary === */
details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

details > summary {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    background: var(--surface-alt);
    border-radius: var(--radius);
}

details[open] > summary {
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}

/* Inline details (nested, no border) */
details.inline-details {
    border: none;
    background: none;
    box-shadow: none;
    margin: 0;
}

details.inline-details > summary {
    background: none;
    padding: 0.25rem 0;
    font-size: 0.72rem;
    color: var(--brand-light);
    font-weight: 500;
}

/* === Glosa Risk Panel === */
.risk-panel { border-left: 3px solid var(--border); }
.risk-panel.risk-low { border-left-color: var(--success); }
.risk-panel.risk-medium { border-left-color: #eab308; }
.risk-panel.risk-high { border-left-color: var(--warning); }
.risk-panel.risk-critical { border-left-color: var(--danger); }

.risk-body { padding: 0.75rem 1rem; }

.badge-risk-low { background: #dcfce7; color: #166534; }
.badge-risk-medium { background: #fef3c7; color: #92400e; }
.badge-risk-high { background: #ffedd5; color: #9a3412; }
.badge-risk-critical { background: #fee2e2; color: #991b1b; }

.badge-severity-low { background: #dbeafe; color: #1e40af; }
.badge-severity-medium { background: #fef3c7; color: #92400e; }
.badge-severity-high { background: #fee2e2; color: #991b1b; }

.risk-meter { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }

.risk-meter-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--success) 0%, #eab308 40%, var(--warning) 65%, var(--danger) 100%);
    transition: width 0.8s ease;
}

/* === Financial Report — Filters === */
.filter-panel { }
.filter-panel > header { background: var(--surface-alt); }

.filter-form { padding: 0.75rem 1rem; }

.filter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
}

.filter-field { flex: 1 1 120px; max-width: 160px; }

.filter-field label {
    display: block;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.filter-field input,
.filter-field select {
    display: block;
    width: 100%;
    padding: 0.35rem 0.45rem;
    font-size: 0.78rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    line-height: 1.3;
    margin: 0;
    height: auto;
}

.filter-actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.filter-actions label { visibility: hidden; }

.filter-actions button {
    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand);
    padding: 0.35rem 0.85rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.3;
    height: auto;
    margin: 0;
}

.filter-actions button:hover { background: var(--brand-light); }

.filter-presets {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.preset-label { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); }
.filter-presets a { font-size: 0.72rem; color: var(--brand-light); text-decoration: none; }
.filter-presets a:hover { text-decoration: underline; }

/* === Monthly chart === */
.monthly-chart {
    display: flex;
    gap: 0.35rem;
    align-items: flex-end;
    padding: 1rem 1rem 0.35rem;
    overflow-x: auto;
}

.month-col { flex: 1; min-width: 48px; text-align: center; }

.month-bars {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-height: 16px;
}

.month-bar { width: 22px; border-radius: 2px 2px 0 0; min-height: 2px; }
.bar-receipt { background: var(--brand); }
.bar-copay { background: var(--warning); }

.month-label { font-size: 0.62rem; font-weight: 600; color: var(--text); margin-top: 0.25rem; }
.month-count { font-size: 0.58rem; color: var(--text-muted); }

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0.35rem 1rem 0.75rem;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    margin-right: 0.25rem;
    vertical-align: middle;
}

/* === Financial table extras === */
.financial-table .filename-cell {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.totals-row { background: var(--surface-alt); }
.risk-mini { font-size: 0.62rem; color: var(--text-muted); margin-left: 0.2rem; }
.summary-row td { padding-top: 0; border-bottom: 1px solid var(--border); }
.summary-text { font-size: 0.72rem; color: var(--text-muted); font-style: italic; }

/* === Review Queue === */
.review-card > header { flex-wrap: wrap; gap: 0.5rem; }
.review-body { padding: 0.75rem 1rem; }

.review-flags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.5rem; }

.review-flag {
    display: inline-block;
    padding: 0.15em 0.5em;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
}

.review-summary { font-size: 0.78rem; color: var(--text); margin-bottom: 0.6rem; line-height: 1.5; }

.review-details {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    padding: 0.6rem;
    background: var(--surface-alt);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.review-col-title {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.review-datum { display: flex; justify-content: space-between; font-size: 0.72rem; padding: 0.1rem 0; }

.review-check-fail {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    padding: 0.1rem 0;
}

.review-form {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}

.review-form-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.review-verdict-options { display: flex; gap: 0.3rem; flex-wrap: wrap; }

.review-option {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2em 0.5em;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.review-option:hover { background: var(--surface-alt); }
.review-option input[type="radio"] { width: 12px; height: 12px; margin: 0; }
.review-option-approved:has(input:checked) { background: #dcfce7; border-color: var(--success); }
.review-option-needs_review:has(input:checked) { background: #ffedd5; border-color: var(--warning); }
.review-option-rejected:has(input:checked) { background: #fee2e2; border-color: var(--danger); }
.review-option-incomplete:has(input:checked) { background: #f3f4f6; border-color: #6b7280; }

.review-notes {
    flex: 1;
    min-width: 120px;
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
}

.review-insurance-row {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.review-insurance-row input {
    flex: 1;
    padding: 0.25rem 0.5rem;
    font-size: 0.72rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    height: auto;
    margin: 0;
}

/* Review expandable section */
.review-expand {
    margin-top: 0.4rem;
    border: none;
    background: none;
    box-shadow: none;
}

.review-expand > summary {
    font-size: 0.72rem;
    padding: 0.3rem 0;
    background: transparent;
    color: var(--text-muted);
    border: none;
}

.review-expand[open] > summary { border: none; }

.review-expand-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.6rem 0;
}

.review-expand-body form { margin: 0; }

.review-expand-body input,
.review-expand-body select {
    display: block;
    width: 100%;
    padding: 0.25rem 0.4rem;
    font-size: 0.72rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    margin: 0 0 0.25rem;
    height: auto;
}

.review-expand-body label {
    font-size: 0.6rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.1rem;
}

.review-expand-body .btn-sm { margin-top: 0.25rem; }

/* --- Override form --- */
.override-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.override-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.override-field { position: relative; }
.override-field label {
    font-size: 0.6rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.1rem;
}
.override-field input {
    display: block;
    width: 100%;
    padding: 0.25rem 0.4rem;
    font-size: 0.72rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    margin: 0 0 0.25rem;
    height: auto;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.override-field.field-changed input {
    border-color: var(--brand-light);
    background: var(--brand-bg);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.override-field.field-changed label {
    color: var(--brand);
    font-weight: 700;
}
.override-field.field-changed::after {
    content: "edited";
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--brand);
    background: var(--brand-bg);
    padding: 0.1em 0.35em;
    border-radius: 2px;
}

.override-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    margin-top: 0.35rem;
}
.override-actions select,
.override-actions input {
    display: block;
    padding: 0.25rem 0.4rem;
    font-size: 0.72rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    margin: 0;
    height: auto;
}
.override-actions select { flex: 0 0 auto; width: auto; }
.override-actions input { flex: 1; }

/* --- Override chips (reviewed table) --- */
.override-tag {
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--warning);
    margin-left: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.override-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
}

.override-chip {
    display: inline-block;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    background: var(--brand-bg);
    color: var(--brand);
    white-space: nowrap;
}

/* --- Evidence upload drop zone --- */
.evidence-form { display: flex; flex-direction: column; }

.evidence-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--surface-alt);
}

.evidence-drop:hover,
.evidence-drop.drag-over {
    border-color: var(--info);
    background: #f0f9ff;
}

.evidence-drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.evidence-drop-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--info);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
}

.evidence-drop-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
}

.evidence-drop-hint {
    font-size: 0.62rem;
    color: var(--text-muted);
}

.evidence-file-list {
    margin-top: 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.evidence-file-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
    border-bottom: 1px solid var(--border);
}
.evidence-file-item:last-of-type { border-bottom: none; }

.evidence-file-badge {
    display: inline-block;
    padding: 0.1em 0.35em;
    border-radius: 2px;
    font-size: 0.55rem;
    font-weight: 700;
    background: #dbeafe;
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    min-width: 28px;
    text-align: center;
}

.evidence-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.evidence-file-size {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.evidence-file-total {
    padding: 0.25rem 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-alt);
    border-top: 1px solid var(--border);
}

.evidence-merge-note {
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.evidence-submit {
    background: var(--info);
    margin-top: 0.35rem;
    align-self: flex-start;
}

@media (max-width: 768px) {
    .review-details { grid-template-columns: 1fr; }
    .review-expand-body { grid-template-columns: 1fr; }
}

/* === Dashboard Charts === */

/* 3-column chart row */
.chart-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
@media (max-width: 900px) { .chart-row-3 { grid-template-columns: 1fr; } }

/* --- Activity Bar Chart --- */
.chart-activity { padding: 0.75rem 1rem 0.5rem; }

.chart-activity-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding-bottom: 0.25rem;
}

.activity-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    min-width: 0;
}

.activity-stack {
    width: 100%;
    max-width: 32px;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.4s ease;
}

.activity-seg { min-height: 1px; }
.seg-approved { background: var(--success); }
.seg-review { background: var(--warning); }
.seg-rejected { background: var(--danger); }
.seg-other { background: #cbd5e1; }

.activity-count {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
    height: 12px;
    line-height: 12px;
}

.activity-day {
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.activity-date {
    font-size: 0.55rem;
    color: var(--text-muted);
}

.chart-activity-legend {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.legend-swatch {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    margin-right: 0.2rem;
    vertical-align: middle;
}

/* --- Donut Chart --- */
.chart-donut-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

.donut-svg {
    width: 110px;
    height: 110px;
    flex-shrink: 0;
}

.donut-center-num {
    font-size: 14px;
    font-weight: 800;
    fill: var(--text);
}

.donut-center-label {
    font-size: 6px;
    font-weight: 500;
    fill: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.donut-legend { display: flex; flex-direction: column; gap: 0.35rem; }

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    color: var(--text);
}

.donut-legend-item strong {
    margin-left: auto;
    min-width: 20px;
    text-align: right;
}

/* --- Gauge Chart --- */
.chart-gauge-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem;
}

.gauge-svg {
    width: 160px;
    height: 100px;
}

.gauge-value {
    font-size: 18px;
    font-weight: 800;
    fill: var(--text);
}

.gauge-label {
    font-size: 6px;
    fill: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gauge-tick {
    font-size: 6px;
    fill: var(--text-muted);
}

.risk-dist-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    width: 100%;
    justify-content: center;
}

.risk-dist-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.risk-dist-item strong { color: var(--text); }

.risk-dist-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* --- Horizontal Bar Chart --- */
.chart-hbar-wrap {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hbar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hbar-label {
    min-width: 55px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text);
    text-align: right;
}

.hbar-track {
    flex: 1;
    height: 16px;
    background: var(--surface-alt);
    border-radius: 3px;
    overflow: hidden;
}

.hbar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    min-width: 2px;
}

.hbar-count {
    min-width: 24px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
    text-align: right;
}

/* --- Financial mini bars --- */
.fin-bars {
    padding: 0 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    border-top: 1px solid var(--border);
    margin-top: 0.25rem;
    padding-top: 0.6rem;
}

.fin-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fin-bar-label {
    min-width: 70px;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: right;
}

.fin-bar-track {
    flex: 1;
    height: 10px;
    background: var(--surface-alt);
    border-radius: 3px;
    overflow: hidden;
}

.fin-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
    min-width: 2px;
}

.fin-bar-val {
    min-width: 60px;
    font-size: 0.68rem;
    text-align: right;
    color: var(--text);
}

/* === Print === */
@media print {
    .top-nav, .site-footer, .filter-panel, .btn-secondary, .btn-sm { display: none; }
    .main-content { padding-top: 0; }
    .kpi-card { break-inside: avoid; }
    body { font-size: 11px; }
}

/* === Responsive === */
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-row-3 { grid-template-columns: 1fr; }
    .nav-inner { padding: 0 0.75rem; }
    .nav-links li a { padding: 0 0.6rem; font-size: 0.72rem; }
    .filter-field { flex-basis: 100px; }
    .chart-donut-wrap { flex-direction: column; }
}
