:root {
    color-scheme: light;
    --bg: #f2f3f5;
    --paper: #fff;
    --ink: #17191c;
    --muted: #585e66;
    --line: #dfe2e6;
    --button: #16181c;
    --button-ink: #fff;
    --soft: #f0f1f3;
    --focus: #4774c6;
    --danger: #9c2626;
    --danger-bg: #fff1f1;
    --success: #285d40;
    --success-bg: #edf7ef;
    --radius: 16px;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #101114;
    --paper: #191b20;
    --ink: #f3f4f6;
    --muted: #b7bcc5;
    --line: #363940;
    --button: #eceef1;
    --button-ink: #16181c;
    --soft: #23262d;
    --focus: #a4bbef;
    --danger: #ffc0bf;
    --danger-bg: #41282a;
    --success: #a9dfba;
    --success-bg: #233e31;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: inherit; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
button, .button {
    min-height: 44px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    cursor: pointer;
    padding: 8px 15px;
    border: 1px solid transparent;
    text-decoration: none;
    font-weight: 650;
    line-height: 1.25;
    text-align: center;
}
button:disabled { cursor: wait; opacity: .65; }
.primary { background: var(--button); color: var(--button-ink); }
.primary:hover { filter: brightness(.86); }
.secondary { color: var(--ink); background: var(--soft); border-color: var(--line); }
.secondary:hover, .quiet:hover { filter: brightness(.90); }
.quiet { color: var(--muted); background: none; }
.danger { color: var(--danger); background: var(--danger-bg); }
.brand { display: flex; align-items: center; gap: 13px; font-size: 15px; font-weight: 750; letter-spacing: .09em; text-decoration: none; }
.brand small { display: block; font-size: 10px; letter-spacing: .27em; opacity: .8; }
.logo { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #646a75; color: #fff; background: #20232a; border-radius: 12px; font-size: 24px; letter-spacing: 0; }
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #131519; color: #f2f4f6; padding: 28px 18px 18px; display: flex; flex-direction: column; gap: 34px; }
.sidebar .brand { margin-inline: 10px; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { display: flex; gap: 11px; align-items: center; min-height: 46px; border: 1px solid transparent; border-radius: 10px; padding: 9px 12px; text-decoration: none; color: #cbd0d8; font-size: 14px; }
.sidebar nav [aria-current], .sidebar nav a:hover { background: #292d34; color: white; border-color: #393e48; }
.sidebar nav a span { color: #bac2cf; font-size: 20px; line-height: 1; width: 22px; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 13px 8px 0; border-top: 1px solid #313641; display: grid; gap: 5px; overflow-wrap: anywhere; }
.sidebar-footer small { display: block; color: #c3c9d1; }
.sidebar-footer .quiet { padding-inline: 0; color: #d1d6de; }
.topbar { min-height: 66px; padding: 5px clamp(16px, 4vw, 48px); display: flex; align-items: center; gap: 12px; justify-content: space-between; border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar-label { font-size: .89rem; color: var(--muted); }
.menu-toggle { display: none; }
.stage main { max-width: 1260px; margin-inline: auto; padding: clamp(20px, 4vw, 52px) clamp(16px, 4vw, 48px) 60px; }
.section-title { margin: 0 0 24px; }
h1, h2, p { margin: 0; overflow-wrap: anywhere; }
h1 { line-height: 1.16; font-size: clamp(1.75rem, 3.8vw, 2.75rem); letter-spacing: -.048em; }
h2 { font-size: 1.14rem; letter-spacing: -.02em; }
.section-title p { color: var(--muted); margin-top: 9px; }
.hero { min-height: 148px; padding: 24px clamp(20px, 3vw, 37px); margin-bottom: 20px; border-radius: var(--radius); background: #202329; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hero .primary { background: #f1f3f6; color: #17191c; }
.hero .section-title { margin: 0; }
.hero .section-title p { color: #d0d6df; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.metric { display: grid; gap: 5px; text-decoration: none; }
.metric span, .empty, .muted { color: var(--muted); }
.metric strong { font-size: 2.1rem; line-height: 1.2; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: clamp(16px, 3vw, 26px); margin: 0 0 18px; }
.panel h2 + p { margin-top: 8px; }
.panel p + button { margin-top: 12px; }
.panel-heading, .actions, .search-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading { margin-bottom: 15px; }
.panel-heading .section-title { margin: 0; }
.actions, .search-row { justify-content: flex-start; }
.actions form { margin: 0; }
.search-row input:not([type=hidden]) { flex: 1 1 220px; }
.record-list { padding: 0; margin: 0; list-style: none; }
.record-list li { display: flex; min-width: 0; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.record-list small { display: block; color: var(--muted); }
.search-row + .record-list { margin-top: 12px; }
.empty { padding: 12px 0; }
.entry-shell { display: grid; justify-items: center; align-items: center; min-height: 100vh; padding: 24px 16px; }
.entry { width: min(100%, 570px); }
.entry .brand { margin-bottom: 24px; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; min-width: 0; font-size: .88rem; font-weight: 620; }
.field.wide { grid-column: 1 / -1; }
.field b { color: var(--muted); }
input:not([type=checkbox]), select, textarea {
    min-width: 0; min-height: 46px; width: 100%; color: var(--ink); background: var(--paper);
    border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; font-size: 16px;
}
input[type=file] { max-width: min(100%, 430px); }
textarea { resize: vertical; }
.stack { display: grid; gap: 15px; }
.stack > .panel { margin: 0; }
.stack .panel > h2, .panel form + h2 { margin-bottom: 14px; }
.scenario-button { margin: 12px 0 16px; }
.pick-row { margin-bottom: 16px; align-items: end; }
.pick-row .field { flex: 0 1 370px; }
.notice { border-radius: 9px; margin-bottom: 15px; padding: 12px 15px; color: var(--danger); background: var(--danger-bg); overflow-wrap: anywhere; }
.notice.success { color: var(--success); background: var(--success-bg); }
.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 18px; margin: 0; }
.summary dt { color: var(--muted); font-size: .87rem; }
.summary dd { margin-inline-start: 0; overflow-wrap: anywhere; }
.pdf-preview { border: 1px solid var(--line); width: 100%; height: min(76vh, 780px); min-height: 350px; border-radius: 8px; background: #f4f4f4; }
.checks { display: flex; gap: 7px; align-items: flex-start; }
.checks input { flex: none; height: 18px; width: 18px; margin: 3px; }
.photos { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.photo { width: 160px; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; border-radius: 8px; }
@media (max-width: 780px) {
    .app-shell { display: block; }
    .sidebar { display: none; padding: 18px 16px; gap: 17px; }
    .sidebar.open { display: flex; }
    .menu-toggle { display: inline-flex; }
    .topbar { min-height: 58px; }
}
@media (max-width: 500px) {
    .fields, .summary { grid-template-columns: minmax(0, 1fr); }
    .hero { flex-direction: column; align-items: flex-start; }
    .metrics { gap: 6px; }
    .metric { padding: 9px; font-size: .75rem; }
    .metric strong { font-size: 1.45rem; }
    .record-list li { flex-wrap: wrap; }
    .panel-heading > .button { width: 100%; }
    .pick-row .field { flex-basis: 100%; }
}

.ocr-panel {
    margin: 0 0 18px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
}
.ocr-panel > summary { cursor: pointer; font-weight: 650; }
.ocr-note { margin: 6px 0 11px; color: var(--muted); font-size: .9rem; }
.ocr-start { align-self: end; }
.ocr-status:not(:empty) { margin-top: 8px; }
.ocr-results:not(:empty) { margin-top: 10px; }
.ocr-raw { grid-column: 1 / -1; }
.ocr-raw pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.ocr-check select { border-color: #a66b28; }
.ocr-filled input { border-color: #58846c; }

.policy-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.account-check { display: flex; align-items: flex-start; gap: .6rem; }
.account-check input { flex: 0 0 auto; width: 1.1rem; height: 1.1rem; margin: .15rem 0; }
.account-card { border-top: 1px solid var(--line, #7775); padding: .8rem 0; }
.account-card summary { cursor: pointer; overflow-wrap: anywhere; }
.account-card summary span { display: block; margin: .3rem 0 0 1rem; }
.account-card > form, .account-delete, .panel > summary + form { margin-top: 1rem; }
.account-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: .6rem; }
.account-details dt { font-size: .85rem; }
.account-details dd { margin: .2rem 0 0; overflow-wrap: anywhere; }
.account-search .actions { align-self: end; }
