:root {
  --blue: #0984E3; --blue-d: #0a6cb8; --bg: #eef2f7; --surface: #ffffff;
  --line: #e6ebf2; --text: #2f3542; --muted: #7a8595;
  --good: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 4px 16px rgba(20,30,50,.07);
  --shadow-hover: 0 10px 28px rgba(20,30,50,.12);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
input, select, button, textarea { font: inherit; }
input, select, textarea { padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; width: 100%; transition: border-color .15s ease, box-shadow .15s ease; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(9,132,227,.15); }

.btn { padding: .58rem .95rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--text); cursor: pointer; transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease; }
.btn:hover { border-color: var(--blue); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); box-shadow: 0 2px 8px rgba(9,132,227,.25); }
.btn-primary:hover { background: var(--blue-d); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(9,132,227,.3); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--blue); box-shadow: none; }
.btn-ghost:hover { background: rgba(9,132,227,.08); }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--surface); padding: 2rem; border-radius: var(--radius); box-shadow: var(--shadow); display: grid; gap: 1rem; width: 340px; }
.login-card h1 { font-size: 1.2rem; color: var(--blue); margin: 0 0 .25rem; }
.login-card label { display: grid; gap: .35rem; font-size: .85rem; color: var(--muted); }
.error { color: var(--bad); font-size: .85rem; }

/* App shell */
#app { min-height: 100vh; display: flex; flex-direction: column; }
.appbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; }
.appbar .brand { font-weight: 800; color: var(--blue); letter-spacing: .2px; }
.appbar .brand sup { color: var(--muted); font-weight: 600; }
.appbar .crumb { color: var(--muted); font-size: .9rem; }
.appbar .spacer { flex: 1; }
.appbar .who { font-size: .9rem; color: var(--text); }
.pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; padding: .2rem .55rem; border-radius: 999px; background: #eaf7ee; color: var(--good); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }

#body { flex: 1; display: grid; grid-template-columns: 232px 1fr; }
#sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: .75rem; }
#sidebar a { display: block; padding: .55rem .7rem; border-radius: 8px; color: var(--text); text-decoration: none; cursor: pointer; font-size: .92rem; }
#sidebar a:hover { background: #f2f6fb; }
#sidebar a.active { background: var(--blue); color: #fff; }
#sidebar a.disabled { opacity: .4; pointer-events: none; }
#sidebar hr { border: none; border-top: 1px solid var(--line); margin: .5rem .2rem; }
#view { padding: 1.75rem 2.25rem; }
h1 { font-size: 1.35rem; letter-spacing: -.01em; margin: 0 0 1.25rem; }
h3 { font-size: 1rem; letter-spacing: -.005em; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.15rem 1.35rem; transition: box-shadow .18s ease, transform .18s ease; }
.cards { display: flex; gap: 1rem; flex-wrap: wrap; }
.cards .card { min-width: 150px; }
.cards .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.cards .n { font-size: 1.9rem; font-weight: 800; color: var(--blue); }
.badge { display: inline-block; font-size: .74rem; padding: .12rem .5rem; border-radius: 6px; background: #eef2f7; color: var(--muted); }
.flag { display: inline-block; background: #fff1e6; color: #b45309; padding: .1rem .45rem; border-radius: 6px; font-size: .72rem; margin-right: .25rem; }

table { border-collapse: collapse; width: 100%; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { border-bottom: 1px solid var(--line); padding: .6rem .7rem; text-align: left; font-size: .86rem; }
th { background: #f7f9fc; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; transition: background .12s ease; }
tr.clickable:hover td { background: #f2f8ff; }

/* Verifier split-pane */
.verifier { display: grid; grid-template-columns: 1fr 380px; gap: 1rem; align-items: start; }
.verifier .head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.verifier .head h1 { margin: 0; }
.scanpanel { background: #333a45; border-radius: var(--radius); overflow: hidden; }
.scanpanel .toolbar { display: flex; align-items: center; gap: .4rem; padding: .5rem .6rem; color: #dfe6ef; font-size: .82rem; }
.scanpanel .toolbar .btn { padding: .3rem .6rem; font-size: .82rem; }
.scanpanel .stage { height: auto; min-height: 520px; overflow: auto; display: grid; place-items: start center; background: #2a2f38; cursor: grab; }
.scanpanel .stage.grabbing { cursor: grabbing; }
.scanpanel .stage img { transition: transform .12s ease; transform-origin: center center; user-select: none; -webkit-user-drag: none; }
.scanpanel .empty { color: #aab3c0; padding: 2rem; text-align: center; }
.form .score { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.form .score.good { background: #eaf7ee; color: var(--good); }
.form .score.warn { background: #fdf3e6; color: var(--warn); }
.form .score.bad { background: #fdeaea; color: var(--bad); }
.form .field { margin-bottom: .9rem; }
.form .field label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }
.hint { font-size: .76rem; color: var(--warn); margin-top: .25rem; }
.hint.bad { color: var(--bad); }
.actions { display: flex; gap: .6rem; margin-top: 1rem; }

/* Claim result */
.claim .card { margin-bottom: 1rem; }
.status-chip { display: inline-flex; align-items: center; line-height: 1; padding: .45rem .85rem; border-radius: 999px; font-weight: 700; font-size: .85rem; margin: 0; }
.status-chip.s-auto_approved { background: #eaf7ee; color: var(--good); }
.status-chip.s-additional_verification { background: #fdf3e6; color: var(--warn); }
.status-chip.s-incomplete { background: #fdeaea; color: var(--bad); }
.status-chip.s-needs_review { background: #eef2f7; color: var(--muted); }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1.5rem; }
.info-grid .k { display: block; font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.info-grid .v { font-size: .9rem; }
.warnbox { background: #fff8ec; border-color: #f3e2c0; }
.completeness { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; font-size: .88rem; }
.ref { background: #eef2f7; color: var(--muted); border-radius: 5px; padding: 0 .35rem; font-size: .72rem; }
/* Single aligned coverage table */
.coverage td.num, .coverage th.num { text-align: right; white-space: nowrap; }
.coverage .los-head td { background: #eef3fa; font-weight: 700; font-size: .9rem; color: var(--text); border-top: 2px solid #dfe7f1; }
.coverage .los-sub td { font-weight: 700; background: #fafbfd; border-bottom: 2px solid #dfe7f1; }
.coverage .los-sub td:first-child { color: var(--muted); }
tr.v-covered td:first-child { color: var(--good); }
tr.v-not td:first-child { color: var(--bad); }
tr.v-review td:first-child { color: var(--warn); }
.totals { display: flex; gap: 1.5rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.totals div { display: grid; }
.totals span { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.totals strong { font-size: 1.15rem; }
.totals .ok strong { color: var(--good); }
.totals .bad strong { color: var(--bad); }
.totals .rev strong { color: var(--warn); }
.actions-list ul { padding-left: 1.1rem; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,30,50,.45); display: grid; place-items: center; z-index: 50; animation: fade .15s ease; }
.modal { background: #fff; border-radius: var(--radius); width: min(760px, 92vw); max-height: 88vh; overflow: auto; box-shadow: 0 24px 64px rgba(20,30,50,.28); animation: pop .18s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* Spinner / loading */
.spinner { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
.spinner.lg { width: 42px; height: 42px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; flex-direction: column; align-items: center; gap: .85rem; padding: 2rem; color: var(--muted); font-size: .9rem; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.modal-body { padding: 1.25rem; }
.modal-body label { display: block; font-size: .78rem; color: var(--muted); margin: .6rem 0 .25rem; }

/* Sidebar toggle + full-page scan + claim form */
#body.collapsed { grid-template-columns: 1fr; }
#body.collapsed #sidebar { display: none; }
.appbar .navtoggle { font-size: 1.1rem; line-height: 1; padding: .35rem .55rem; }
/* Full column width; the stage (height:auto) grows to the page so there's no
   internal scrollbar — the page scrolls instead. */
.scanpanel .stage img { max-width: 100%; height: auto; }
.status-row { display: flex; align-items: center; gap: .6rem; margin: 1rem 0; }
.read-chip { display: inline-flex; align-items: center; line-height: 1; padding: .45rem .85rem; border-radius: 999px; font-size: .8rem; font-weight: 600; margin: 0; }
.read-good { background: #eaf7ee; color: var(--good); }
.read-warn { background: #fdf3e6; color: var(--warn); }
.read-bad { background: #fdeaea; color: var(--bad); }
.card-foot { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.claim-form label { display: block; font-size: .78rem; color: var(--muted); margin: .7rem 0 .25rem; }
.claim-form input, .claim-form textarea { width: 100%; }
.claim-form textarea { resize: vertical; line-height: 1.35; }

/* Info note banner */
.note { background: #eef5fe; border: 1px solid #d3e6fb; color: #1c4e80; padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .88rem; margin-bottom: 1.25rem; }
.fld-label { display: block; font-size: .74rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: .4rem; }

/* Drag-and-drop upload zone */
.dropzone { border: 2px dashed #cdd7e5; border-radius: var(--radius); padding: 2.4rem 1rem; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: rgba(9,132,227,.05); }
.dropzone .dz-icon { font-size: 1.9rem; line-height: 1; margin-bottom: .5rem; }
.dropzone .dz-main { color: var(--blue); font-weight: 700; }
.dropzone .dz-sub { font-size: .8rem; margin-top: .25rem; }
.dropzone .dz-file { margin-top: .6rem; color: var(--blue); font-weight: 600; font-size: .88rem; }

.btn-block { width: 100%; display: block; }

/* T&C viewer (modal) */
.tnc-view { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; line-height: 1.55; margin: 0; color: var(--text); }

/* Reviewer decision: Confirm / Hold / Escalate */
.decision-bar { flex-wrap: wrap; }
.btn-confirm { background: var(--good); color: #fff; border-color: var(--good); }
.btn-confirm:hover { background: #12833c; border-color: #12833c; }
.btn-hold { background: var(--warn); color: #fff; border-color: var(--warn); }
.btn-hold:hover { background: #b9660a; border-color: #b9660a; }
.btn-escalate { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-escalate:hover { background: #b91c1c; border-color: #b91c1c; }
.decision-chip { display: inline-flex; align-items: center; line-height: 1; padding: .45rem .85rem; border-radius: 999px; font-weight: 700; font-size: .85rem; }
.d-confirmed { background: #eaf7ee; color: var(--good); }
.d-on_hold { background: #fdf3e6; color: var(--warn); }
.d-escalated { background: #fdeaea; color: var(--bad); }
.decide-table input { padding: .35rem .5rem; text-align: right; }
.decide-table tfoot .num { font-size: .95rem; }
.modal.modal-wide { width: min(960px, 96vw); }
.decide-items th, .decide-items td { font-size: .82rem; padding: .5rem .55rem; }
.decide-items input { width: 120px; padding: .35rem .5rem; text-align: right; }
.decide-items .stat-cell { text-align: center; }
.decide-items tfoot .num { font-size: .92rem; }

/* On/off toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider { position: absolute; inset: 0; cursor: pointer; background: #c7cfda; border-radius: 999px; transition: background .15s ease; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s ease; }
.switch input:checked + .slider { background: var(--good); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* Status badges on the claims dashboard */
.st-confirmed { background: #eaf7ee; color: var(--good); }
.st-on_hold { background: #fdf3e6; color: var(--warn); }
.st-escalated { background: #fdeaea; color: var(--bad); }
.st-auto_approved { background: #eaf7ee; color: var(--good); }
.st-additional_verification { background: #fdf3e6; color: var(--warn); }
.st-incomplete { background: #fdeaea; color: var(--bad); }
