:root {
  --surface-1: #fcfcfb;
  --surface-2: #f3f4f6;
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --line: #e3e3e0;
  --brand: #1f3a5f;
  /* Categorical (fixed order) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  /* Status (reserved; always paired with icon + label) */
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
}
body { background: var(--surface-2); color: var(--ink-1); font-size: .925rem; }
.skip-link { position: absolute; left: 8px; top: 8px; z-index: 2000; background: #fff; padding: 6px 10px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #e8eef6, #f6f7f9); }
.login-card { width: 100%; max-width: 400px; }
/* Sign-in screens: a sample invoice behind the card, faded to 40 % */
.login-wrap:has(#login-form) { position: relative; overflow: hidden; isolation: isolate; }
.login-wrap:has(#login-form)::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  left: 50%; top: 50%; width: min(760px, 125vw); aspect-ratio: 8 / 11;
  transform: translate(-50%, -50%) rotate(-7deg);
  background: url("../img/invoice-sample.svg") center / contain no-repeat;
  opacity: .4;
}
.login-wrap:has(#login-form) .login-card { box-shadow: 0 24px 60px -24px rgba(13, 31, 56, .45) !important; }

/* Shell */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: 0 0 232px; background: var(--brand); color: #dbe5f1; padding: 12px 8px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { font-weight: 600; font-size: 1.1rem; color: #fff; padding: 6px 10px 14px; }
.sidebar .nav-link { color: #c9d6e6; border-radius: 6px; padding: 7px 10px; display: flex; gap: 10px; align-items: center; }
.sidebar .nav-link:hover, .sidebar .nav-link:focus-visible { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 500; }
.sidebar .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #8fa6c2; padding: 14px 10px 4px; }
.sidebar .nav-link .badge { margin-left: auto; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
main { padding: 20px; flex: 1; }
main:focus { outline: none; }
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: -240px; z-index: 1050; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0,0,0,.3); }
  main { padding: 12px 16px; }
}

/* Cards / tiles */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.panel h3 { font-size: .95rem; font-weight: 600; margin-bottom: 12px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; height: 100%; }
.tile .label { color: var(--ink-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; display: flex; gap: 6px; align-items: center; }
.tile .value { font-size: 1.6rem; font-weight: 600; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--ink-2); font-size: .78rem; }
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { border-color: var(--series-1); }
.chart-box { position: relative; height: 260px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 16px; }
.filters .form-control, .filters .form-select { width: auto; min-width: 140px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { font-size: .85rem; margin: 0; }
.table thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
.table tr.selected td { background: #e8f0fb !important; }

/* Status chips: icon + label, never color alone */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 500; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.chip i { font-size: .8rem; }
.sev-Critical { background: #fbe9e9; color: #8f1f1f; border-color: #f0c4c4; }
.sev-High { background: #fdeee6; color: #8a3a17; border-color: #f6cdb9; }
.sev-Medium { background: #fff6dd; color: #6d4c00; border-color: #f5dc9a; }
.sev-Low { background: #eef3f8; color: #3b4f66; border-color: #d4dfeb; }
.sev-None, .st-ok { background: #e7f6e7; color: #0a5c0a; border-color: #bfe5bf; }
.st-neutral { background: #eef0f3; color: #3d4450; border-color: #dadde3; }
.st-info { background: #e8f0fb; color: #1c4f8f; border-color: #c6d9f3; }
.st-warn { background: #fff6dd; color: #6d4c00; border-color: #f5dc9a; }
.st-bad { background: #fbe9e9; color: #8f1f1f; border-color: #f0c4c4; }

/* Workbench: 3 panels */
.workbench { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(300px, 380px); gap: 12px; height: calc(100vh - 100px); }
.workbench > section { background: #fff; border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; min-height: 0; }
.workbench .wb-head { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.workbench .wb-body { padding: 12px; overflow-y: auto; flex: 1; }
.queue-item { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.queue-item:hover { background: var(--surface-2); }
.queue-item.active { background: #e8f0fb; box-shadow: inset 3px 0 0 var(--series-1); }
.queue-item .amt { font-variant-numeric: tabular-nums; font-weight: 500; }
@media (max-width: 1199.98px) { .workbench { grid-template-columns: 1fr; height: auto; } .workbench > section { max-height: none; } .workbench .wb-body { max-height: 70vh; } }

.check-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.check-row:last-child { border-bottom: 0; }
.check-ico { font-size: 1.1rem; line-height: 1.2; }
.check-PASS { color: var(--good); } .check-FAIL { color: var(--critical); } .check-WARN { color: #b37a00; } .check-NA { color: #8a8a85; }
.disc { border-left: 3px solid var(--line); padding: 6px 10px; margin-bottom: 8px; background: var(--surface-1); border-radius: 0 6px 6px 0; }
.disc.sev-b-Critical { border-left-color: var(--critical); } .disc.sev-b-High { border-left-color: var(--serious); } .disc.sev-b-Medium { border-left-color: var(--warning); } .disc.sev-b-Low { border-left-color: #9fb3c8; }
.risk-meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.risk-meter > div { height: 100%; border-radius: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .85rem; }
.kv dt { color: var(--ink-2); font-weight: 400; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.conf-bar { display: inline-block; width: 40px; height: 6px; background: var(--surface-2); border-radius: 3px; vertical-align: middle; margin-left: 4px; overflow: hidden; }
.conf-bar > span { display: block; height: 100%; background: var(--series-1); }
.chat { display: flex; flex-direction: column; gap: 8px; }
.chat .msg { padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; font-size: .85rem; }
.chat .msg.user { background: #e8f0fb; align-self: flex-end; max-width: 90%; }
.chat .msg.bot { background: var(--surface-2); max-width: 100%; }
.dropzone { border: 2px dashed #b8c4d3; border-radius: 10px; padding: 32px; text-align: center; background: #fafbfc; cursor: pointer; }
.dropzone.drag { border-color: var(--series-1); background: #eef4fc; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0 6px 18px; position: relative; font-size: .85rem; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--series-1); }
.level-steps { display: flex; gap: 6px; flex-wrap: wrap; }
.level-steps .step { flex: 1; min-width: 110px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: .78rem; }
.level-steps .step.APPROVED { border-color: #bfe5bf; background: #f1faf1; }
.level-steps .step.REJECTED { border-color: #f0c4c4; background: #fdf3f3; }
.level-steps .step.current { border-color: var(--series-1); box-shadow: 0 0 0 1px var(--series-1); }
.empty { color: var(--ink-2); text-align: center; padding: 32px 8px; }
pre.json { font-size: .72rem; max-height: 140px; overflow: auto; background: var(--surface-2); padding: 6px; border-radius: 4px; margin: 0; }
@media (forced-colors: active) { .chip, .tile, .panel { border: 1px solid CanvasText; } }
.ai-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.chat { max-height: 420px; overflow-y: auto; }

/* Installation wizard */
.login-card.setup-card { max-width: 720px; }
.setup-steps { list-style: none; display: flex; gap: 4px; padding: 0; margin: 12px 0 20px; counter-reset: s; }
.setup-steps li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .75rem; color: #6b7280; text-align: center; position: relative; }
.setup-steps li:not(:last-child)::after { content: ''; position: absolute; top: 13px; left: calc(50% + 16px); right: calc(-50% + 16px); height: 2px; background: #dadde3; }
.setup-steps li.done:not(:last-child)::after { background: #1baf7a; }
.setup-steps .num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #eef0f3; color: #3d4450; font-weight: 600; border: 2px solid #dadde3; }
.setup-steps li.current { color: #1f2937; font-weight: 600; }
.setup-steps li.current .num { background: #2a78d6; border-color: #2a78d6; color: #fff; }
.setup-steps li.done .num { background: #1baf7a; border-color: #1baf7a; color: #fff; }
.setup-checks li:last-child { border-bottom: 0 !important; }
.setup-review dd { margin-bottom: .35rem; }
@media (max-width: 520px) { .setup-steps .lbl { display: none; } .setup-steps li.current .lbl { display: block; } }

/* Platform portal (request a workspace) */
#login-view:has(.portal) { display: block; place-items: initial; }
.portal { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.portal-points li { display: flex; gap: 10px; margin-bottom: 10px; }
.portal-points .bi { color: #2a78d6; font-size: 1.1rem; }
.portal-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
