/* The site scans page. The ERP's own look (Filament: Inter, zinc greys, its amber accent, 12 px panels, 8 px controls)
   so the framed page reads as part of the ERP. One accent, used once a screen: the point cloud's download. Status
   colours mean status only. Inside the ERP the page follows its theme (app.js sets data-theme on <html>). */

:root {
  color-scheme: light;
  --canvas: #fafafa;
  --surface: #ffffff;
  --well: #f4f4f5;
  --hover: #f4f4f5;
  --selected: #ececee;
  --line: rgba(9, 9, 11, 0.07);
  --line-strong: rgba(9, 9, 11, 0.12);
  --ink-strong: #09090b;
  --ink: #3f3f46;
  --ink-faint: #71717a;
  --icon: #a1a1aa;
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-ink: #ffffff;
  --success: #15803d;
  --info: #2563eb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-ink: #991b1b;
  --caution-soft: #fffbeb;
  --caution-ink: #92400e;
  --caution-icon: #d97706;
  --pending: #71717a;
  --shadow: 0 1px 2px rgba(9, 9, 11, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] { color-scheme: dark; }
/* the dark palette: when the ERP says dark, and outside the ERP when the system is dark */
:root[data-theme="dark"] {
  --canvas: #09090b; --surface: #18181b; --well: #27272a; --hover: #222226; --selected: #2a2a2e;
  --line: rgba(255, 255, 255, 0.08); --line-strong: rgba(255, 255, 255, 0.14);
  --ink-strong: #fafafa; --ink: #d4d4d8; --ink-faint: #a1a1aa; --icon: #71717a;
  --accent: #f59e0b; --accent-hover: #fbbf24; --accent-ink: #18181b;
  --success: #4ade80; --info: #60a5fa; --danger: #f87171; --danger-soft: rgba(248, 113, 113, 0.1); --danger-ink: #fca5a5;
  --caution-soft: rgba(245, 158, 11, 0.1); --caution-ink: #fcd34d; --caution-icon: #f59e0b; --pending: #a1a1aa;
  --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #09090b; --surface: #18181b; --well: #27272a; --hover: #222226; --selected: #2a2a2e;
    --line: rgba(255, 255, 255, 0.08); --line-strong: rgba(255, 255, 255, 0.14);
    --ink-strong: #fafafa; --ink: #d4d4d8; --ink-faint: #a1a1aa; --icon: #71717a;
    --accent: #f59e0b; --accent-hover: #fbbf24; --accent-ink: #18181b;
    --success: #4ade80; --info: #60a5fa; --danger: #f87171; --danger-soft: rgba(248, 113, 113, 0.1); --danger-ink: #fca5a5;
    --caution-soft: rgba(245, 158, 11, 0.1); --caution-ink: #fcd34d; --caution-icon: #f59e0b; --pending: #a1a1aa;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
p { margin: 0; }

.ic { display: inline-flex; flex: none; width: 16px; height: 16px; color: var(--icon); }
.ic svg { width: 16px; height: 16px; }

.masthead { padding: 20px 24px 0; font-size: 16px; font-weight: 600; color: var(--ink-strong); }

/* ── layout ─────────────────────────────────────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100%; min-height: 0; padding: 1px; }
body:has(.masthead:not([hidden])) .app { height: calc(100% - 44px); padding: 16px 24px 24px; }
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); gap: 24px; }
.list { overflow-y: auto; min-height: 0; margin: 0 -8px; padding: 0 8px 8px; }
.detail {
  overflow-y: auto; min-height: 0; container-type: inline-size;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow), 0 0 0 1px var(--line);
  padding: 20px 24px 24px;
}

/* ── toolbar ────────────────────────────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; flex-wrap: wrap; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--well); border-radius: 10px; }
.seg-item {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 0; border-radius: 7px; background: transparent; color: var(--ink-faint); cursor: pointer; font-weight: 500; font-size: 13px;
}
.seg-item:hover { color: var(--ink-strong); }
.seg-item[aria-selected="true"] { background: var(--surface); color: var(--ink-strong); box-shadow: 0 1px 2px rgba(9, 9, 11, 0.08), 0 0 0 1px var(--line); }
.seg-count { font-variant-numeric: tabular-nums; color: var(--ink-faint); font-weight: 400; }
.search {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; margin-left: auto; width: 240px;
  background: var(--surface); border-radius: var(--radius-sm); box-shadow: 0 0 0 1px var(--line-strong);
}
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 13px; }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); }

/* ── list ───────────────────────────────────────────────────────────────────────────────────── */
.row {
  display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 12px;
  width: 100%; padding: 8px; border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer;
}
.row + .row { margin-top: 2px; }
.row:hover { background: var(--hover); }
.row[aria-current="true"] { background: var(--selected); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row-thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--well); display: block; }
.thumb-empty { display: grid; place-items: center; }
.row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
.row-title { color: var(--ink-strong); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-when { flex: none; color: var(--ink-faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.row-sub { color: var(--ink-faint); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.row-line .status { flex: none; font-size: 12px; }
.list-note { color: var(--ink-faint); padding: 12px 8px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-faint); white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pending); flex: none; }
.status-done { color: var(--success); }
.status-done .dot { background: var(--success); }
.status-processing { color: var(--info); }
.status-processing .dot { background: var(--info); animation: pulse 1.6s ease-in-out infinite; }
.status-failed { color: var(--danger); }
.status-failed .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .status-processing .dot { animation: none; } }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 48px 16px; color: var(--ink-faint); }
.empty-ic, .empty-ic svg { width: 24px; height: 24px; }
.empty-title { color: var(--ink-strong); font-weight: 500; margin-top: 6px; }

/* ── one scan ───────────────────────────────────────────────────────────────────────────────── */
.back { display: none; }
.detail-side > .group:first-child { margin-top: 0; }
@container (min-width: 720px) {
  .detail-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 300px); gap: 32px; align-items: start; }
  .detail-side { position: sticky; top: 0; }
}
@container (max-width: 719px) {
  .detail-side > .group:first-child { margin-top: 24px; }
}
.hero { border-radius: 10px; overflow: hidden; background: var(--well); aspect-ratio: 16 / 10; max-height: 360px; width: 100%; }
.hero img { width: 100%; height: 100%; object-fit: contain; display: block; }
.hero-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--ink-faint); font-size: 13px; aspect-ratio: 16 / 5; }
.hero-ic, .hero-ic svg { width: 20px; height: 20px; }
.hero-failed .hero-ic { color: var(--danger); }

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-top: 16px; }
.head-text { min-width: 0; }
.title { color: var(--ink-strong); font-size: 16px; font-weight: 600; line-height: 1.35; }
.sub { color: var(--ink-faint); font-size: 13px; margin-top: 4px; }
.head .status { margin-top: 2px; }

.facts { display: flex; align-items: flex-end; gap: 8px 24px; margin-top: 20px; flex-wrap: wrap; }
.fact-main { display: flex; flex-direction: column; gap: 2px; }
.fact-label { color: var(--ink-faint); font-size: 13px; }
.fact-value { color: var(--ink-strong); font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.fact-lines { display: flex; gap: 8px 16px; flex-wrap: wrap; padding-bottom: 3px; color: var(--ink); }
.faint { color: var(--ink-faint); }

.callout { display: flex; gap: 10px; margin-top: 20px; padding: 12px 14px; border-radius: 10px; background: var(--caution-soft); color: var(--caution-ink); font-size: 13px; }
.callout .ic { color: var(--caution-icon); margin-top: 1px; }
.callout p + p { margin-top: 4px; }
.callout-title { font-weight: 600; margin-bottom: 2px; }
.callout-danger { background: var(--danger-soft); color: var(--danger-ink); }
.callout-danger .ic { color: var(--danger); }

.group { margin-top: 24px; }
.group-title { color: var(--ink-faint); font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.file { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.file + .file { box-shadow: 0 -1px 0 var(--line); }
.file-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-title { color: var(--ink-strong); font-weight: 500; }
.ext { color: var(--ink-faint); font-weight: 400; margin-left: 6px; font-size: 13px; }
.file-sub { color: var(--ink-faint); font-size: 13px; }
.hint { color: var(--ink-faint); font-size: 13px; margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; flex: none;
  border: 0; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-strong); font-size: 13px; font-weight: 500; cursor: pointer;
  box-shadow: 0 1px 2px rgba(9, 9, 11, 0.05), 0 0 0 1px var(--line-strong);
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn .ic { color: var(--ink-faint); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(9, 9, 11, 0.1); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary .ic { color: currentColor; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.meta { margin-top: 24px; padding-top: 16px; box-shadow: 0 -1px 0 var(--line); display: grid; gap: 6px; font-size: 13px; }
.meta-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; }
.meta-k { color: var(--ink-faint); }
.meta-v { color: var(--ink); display: inline-flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.link { color: var(--accent); text-decoration: none; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.link:hover { text-decoration: underline; }
.ic-inline, .ic-inline svg { width: 14px; height: 14px; color: currentColor; }

.error { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger-ink); font-size: 13px; }
.error .ic { color: var(--danger); }
.error .btn { margin-left: auto; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 10px 14px; border-radius: 10px; background: var(--ink-strong); color: var(--canvas); font-size: 13px;
}

.signin { display: grid; gap: 12px; max-width: 320px; margin: 48px auto; padding: 24px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.signin-title { color: var(--ink-strong); font-weight: 600; }
.signin label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-faint); }
.signin input { height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: var(--surface); box-shadow: 0 0 0 1px var(--line-strong); color: var(--ink-strong); }
.signin .btn { justify-content: center; }
.signin-note { color: var(--ink-faint); font-size: 13px; }

/* ── phone and narrow frames: the list, then one scan with a way back ────────────────────────── */
@media (max-width: 760px) {
  .split { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .app[data-view="list"] .detail { display: none; }
  .app[data-view="detail"] .list, .app[data-view="detail"] .toolbar { display: none; }
  .detail { padding: 16px; }
  .back { display: inline-flex; align-items: center; gap: 4px; margin: -4px 0 12px -6px; padding: 4px 6px; border: 0; border-radius: 6px; background: transparent; color: var(--accent); font-weight: 500; cursor: pointer; }
  .back .ic { color: currentColor; }
  .search { width: 100%; margin-left: 0; }
  .seg { max-width: 100%; overflow-x: auto; }
  .meta-row { grid-template-columns: 96px minmax(0, 1fr); }
  body:has(.masthead:not([hidden])) .app { padding: 12px 16px 16px; }
}
