/* ECI platform — design system. One accent, neutral surfaces, status colours only for state. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --line: #e4e7ec; --line-strong: #d0d5dd;
  --ink: #101828; --ink-2: #475467; --ink-3: #98a2b3;
  --accent: #1d4ed8; --accent-strong: #1e40af; --accent-soft: #eef3ff;
  --ok: #067647; --ok-soft: #ecfdf3; --warn: #b54708; --warn-soft: #fffaeb; --bad: #b42318; --bad-soft: #fef3f2;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .05); --side: 248px; --top: 56px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* shell */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { height: var(--top); display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.brand img { height: 36px; max-width: 100%; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.nav h2 { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 14px 10px 4px; line-height: 1.35; }
.nav a { display: block; padding: 5px 10px; border-radius: 7px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.side-foot { border-top: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; }
.side-foot img { height: 18px; width: auto; opacity: .85; }
.main { display: flex; flex-direction: column; min-width: 0; }
.top { height: var(--top); background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.top h1 { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .actions { display: flex; align-items: center; gap: 8px; }
.progressbar { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 100; overflow: hidden; }
.progressbar::after { content: ""; position: absolute; inset: 0; width: 35%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.page { padding: 20px 24px 40px; max-width: 1500px; width: 100%; }
.btn.menu-btn { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 1100; width: var(--side); transform: translateX(-100%); transition: transform .18s; }
  .side.open { transform: none; box-shadow: 0 10px 40px rgba(16, 24, 40, .2); }
  .btn.menu-btn { display: inline-flex; }
  .top, .page { padding-left: 14px; padding-right: 14px; }
}

/* layout */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row.center { align-items: center; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack.tight { gap: 10px; }
.region { min-width: 0; }
.grid { display: grid; gap: 16px; align-items: start; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.split { grid-template-columns: 340px minmax(0, 1fr); }
@media (max-width: 1100px) { .cols-2, .split { grid-template-columns: minmax(0, 1fr); } }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 48px; flex-wrap: wrap; }
.card > header h2 { font-size: 13px; font-weight: 600; }
.card > header select, .card > header input { width: auto; height: 30px; font-size: 13px; }
.card > header input[type=search] { width: 220px; }
.card > .body { padding: 16px; }
.card > .body.flush { padding: 0; }
.card > .body.flush .skeletons, .card > .body.flush .region > .error { margin: 14px; }
.stat { padding: 14px 16px; }
.stat .label { color: var(--ink-2); font-size: 12px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* controls */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.field > span { font-size: 12px; font-weight: 500; color: var(--ink-2); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=url], input[type=search], select, textarea { height: 36px; padding: 0 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid var(--accent-soft); }
.check { display: inline-flex; align-items: center; gap: 6px; height: 36px; color: var(--ink-2); font-weight: 500; cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 36px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn.danger { color: var(--bad); }
.btn.small { height: 28px; padding: 0 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.busy::before { content: ""; width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 6px; cursor: pointer; font-weight: 550; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* photo and file input */
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg); min-height: 260px; padding: 16px; cursor: pointer; text-align: center; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.compact { min-height: 120px; }
.drop img, .drop video { max-width: 100%; max-height: 300px; border-radius: 8px; display: block; }
.drop .hint { color: var(--ink-2); font-weight: 600; }
.drop .formats { color: var(--ink-3); font-size: 12px; }
.drop input[type=file] { display: none; }

/* state */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #abefc6; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #fedf89; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: #fecdca; }
.badge.info { background: var(--accent-soft); color: var(--accent-strong); border-color: #c7d7fe; }
.verdict { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.verdict strong { font-size: 18px; }
.verdict.ok { background: var(--ok-soft); border-color: #abefc6; color: var(--ok); }
.verdict.warn { background: var(--warn-soft); border-color: #fedf89; color: var(--warn); }
.verdict.bad { background: var(--bad-soft); border-color: #fecdca; color: var(--bad); }
.skeleton { border-radius: 6px; background: linear-gradient(90deg, #eef0f3 25%, #f8f9fb 50%, #eef0f3 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; height: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeletons { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.waiting { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 32px 16px; color: var(--ink-2); font-weight: 550; }
.waiting::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: spin .7s linear infinite; }
.waiting time { font-variant-numeric: tabular-nums; color: var(--ink-3); }
.empty { padding: 32px 16px; text-align: center; color: var(--ink-3); font-weight: 500; }
.error { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); border: 1px solid #fecdca; font-weight: 500; overflow-wrap: anywhere; }
.stale { opacity: .45; pointer-events: none; transition: opacity .15s; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1300; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; font-weight: 500; max-width: 360px; box-shadow: 0 8px 24px rgba(16, 24, 40, .2); }
.toast.bad { background: var(--bad); }

/* data */
.table-wrap { overflow: auto; max-height: 62vh; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { position: sticky; top: 0; background: #fbfcfd; font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
td.num, th.num { text-align: right; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--ink-2); }
.kv { display: grid; grid-template-columns: minmax(110px, 40%) minmax(0, 1fr); }
.kv > dt, .kv > dd { padding: 7px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.kv > dt { color: var(--ink-2); padding-right: 12px; }
.kv > dd { font-weight: 550; }
.kv > dt:last-of-type, .kv > dd:last-of-type { border-bottom: 0; }
.list { display: flex; flex-direction: column; }
.list > button, .list > .item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; }
.list > :last-child { border-bottom: 0; }
.list > button { cursor: pointer; }
.list > button:hover { background: var(--bg); }
.list > button[aria-pressed="true"] { background: var(--accent-soft); }
.list.scroll { max-height: 62vh; overflow-y: auto; }
.faces { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.face { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.face .pic { aspect-ratio: 4 / 5; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.face .pic img { width: 100%; height: 100%; object-fit: cover; }
.face .meta { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.face .meta .score { font-weight: 650; font-variant-numeric: tabular-nums; }
.face .meta .id { color: var(--ink-3); font-size: 11px; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare { max-width: 520px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.snippet { color: var(--ink-2); overflow-wrap: anywhere; }
.snippet em { background: #fef0c7; color: var(--ink); font-style: normal; font-weight: 600; }
pre.text { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, "Noto Sans Mono", monospace; max-height: 420px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.page-img { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.canvas { height: 62vh; min-height: 360px; width: 100%; }
.chart { height: 320px; width: 100%; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(16, 24, 40, .35); z-index: 1200; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(660px, 100%); background: var(--surface); z-index: 1201; display: flex; flex-direction: column; box-shadow: -12px 0 32px rgba(16, 24, 40, .15); }
.drawer > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer > header h2 { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer > .body { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }

/* sign-in */
.login { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 1250; padding: 16px; }
.login form { width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 30px rgba(16, 24, 40, .08); }
.login img { height: 54px; align-self: center; }
.login h1 { font-size: 15px; text-align: center; }
.login .btn { width: 100%; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0s !important; transition: none !important; } }
