/* ==========================================================================
   Customs Extractor

   Palette is deliberately monochrome-warm with a single amber accent. The
   default indigo-on-grey of most admin templates is the thing that makes a
   tool look generated rather than designed, so it is not used anywhere.
   Type is self-hosted Geist (no CDN, works offline on the VM).
   Motion runs on one easing curve and one duration scale.
   ========================================================================== */

@font-face {
  font-family: "Geist";
  src: url("fonts/geist.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
  font-style: normal;
}

/* --- Tokens --------------------------------------------------------------- */
:root {
  /* Warm ivory paper, not blue-grey. */
  --bg:          #f6f4f0;
  --surface:     #ffffff;
  --surface-2:   #faf9f6;
  --surface-3:   #f0ede7;
  --hair:        rgba(38, 32, 24, .09);
  --hair-2:      rgba(38, 32, 24, .16);
  --inner-hi:    rgba(255, 255, 255, 0);

  --text:        #17150f;
  --text-2:      #524d44;
  --muted:       #8a8478;
  --faint:       #b0a99c;

  --accent:      #a86a08;          /* legible amber for text/icons on light */
  --accent-solid:#c88318;          /* fills */
  --accent-hov:  #b57414;
  --accent-fg:   #ffffff;
  --accent-soft: #fbf1dd;
  --accent-line: #ecd6a8;
  --accent-glow: rgba(200, 131, 24, .20);

  --ok:          #2f7d4f;
  --ok-soft:     #e6f2ea;
  --danger:      #b8402f;
  --danger-soft: #fbeae7;

  /* Dropzone backdrop: the artwork is dark navy, so on the ivory theme it is
     held well back and washed out; the scrim fades it into the page edges. */
  --bg-art-opacity: .22;
  --scrim-in:  rgba(246, 244, 240, .80);
  --scrim-out: rgba(246, 244, 240, 1);
  --glass:      rgba(255, 255, 255, .74);
  --glass-line: rgba(38, 32, 24, .10);

  --r-xl: 18px;
  --r-lg: 13px;
  --r-md: 9px;
  --r-sm: 7px;

  --sh-sm: 0 1px 2px rgba(28, 22, 14, .06);
  --sh-md: 0 8px 24px -8px rgba(28, 22, 14, .16), 0 2px 6px -2px rgba(28, 22, 14, .07);
  --sh-lg: 0 32px 72px -20px rgba(28, 22, 14, .30), 0 8px 20px -8px rgba(28, 22, 14, .13);

  --topbar-h: 54px;
  --rail-w:   284px;

  /* One easing curve, one duration scale — this is what "smooth" is made of. */
  --ease:   cubic-bezier(.22, .68, .36, 1);
  --spring: cubic-bezier(.34, 1.32, .5, 1);
  --t-fast: .13s;
  --t-mid:  .24s;
  --t-slow: .42s;

  --sans: "Geist", ui-sans-serif, "Segoe UI Variable Display", "Segoe UI",
          -apple-system, Roboto, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

[data-theme="dark"] {
  --bg:          #0a0a0b;
  --surface:     #131315;
  --surface-2:   #18181b;
  --surface-3:   #222226;
  --hair:        rgba(255, 250, 240, .075);
  --hair-2:      rgba(255, 250, 240, .15);
  --inner-hi:    rgba(255, 255, 255, .045);

  --text:        #f4f2ee;
  --text-2:      #a8a49c;
  --muted:       #78736a;
  --faint:       #55514a;

  --accent:      #e5a63c;
  --accent-solid:#e5a63c;
  --accent-hov:  #f2b855;
  --accent-fg:   #18140c;
  --accent-soft: #241c0c;
  --accent-line: #47370f;
  --accent-glow: rgba(229, 166, 60, .22);

  --ok:          #4cc189;
  --ok-soft:     #10231a;
  --danger:      #ef7a68;
  --danger-soft: #2a1512;

  --bg-art-opacity: .62;
  --scrim-in:  rgba(10, 10, 11, .52);
  --scrim-out: rgba(10, 10, 11, .97);
  --glass:      rgba(19, 19, 21, .60);
  --glass-line: rgba(255, 250, 240, .10);

  --sh-sm: 0 1px 2px rgba(0,0,0,.55);
  --sh-md: 0 10px 28px -10px rgba(0,0,0,.8), 0 2px 8px -2px rgba(0,0,0,.6);
  --sh-lg: 0 40px 90px -24px rgba(0,0,0,.9), 0 10px 24px -10px rgba(0,0,0,.7);
}

/* --- Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.02em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sm { font-size: 12px; }

::selection { background: var(--accent-glow); color: var(--text); }
:focus-visible {
  outline: 2px solid var(--accent-solid);
  outline-offset: 2px; border-radius: 6px;
}

.eyebrow {
  font-size: 10px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--faint);
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent;
  font-size: 13.5px; font-weight: 500; letter-spacing: -.005em;
  white-space: nowrap; cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.975); }
.btn svg { flex: none; }

.btn-primary {
  background: var(--accent-solid); color: var(--accent-fg);
  box-shadow: 0 1px 2px rgba(28,22,14,.2), inset 0 1px 0 rgba(255,255,255,.16);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hov);
  box-shadow: 0 4px 14px -4px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.2);
}
.btn-subtle {
  background: var(--surface); color: var(--text-2);
  border-color: var(--hair-2);
  box-shadow: var(--sh-sm), inset 0 1px 0 var(--inner-hi);
}
.btn-subtle:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-only { padding: 0; width: 30px; }
.btn-subtle.is-on {
  background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent-line);
}

/* --- Inputs --------------------------------------------------------------- */
.field-label {
  display: block; margin-bottom: 7px;
  font-size: 12.5px; font-weight: 550; color: var(--text-2);
}
.field-label.spaced { margin-top: 15px; }
input[type="password"], input[type="text"], input[type="search"] {
  width: 100%; height: 40px; padding: 0 13px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--hair-2); border-radius: var(--r-md);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
input:focus {
  outline: none; border-color: var(--accent-solid);
  box-shadow: 0 0 0 3.5px var(--accent-glow);
}
input::placeholder { color: var(--faint); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.checkline {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none;
}
.checkline.sm { font-size: 12.5px; }
.checkline input { accent-color: var(--accent-solid); width: 14px; height: 14px; margin: 0; }

/* --- Spinner -------------------------------------------------------------- */
.spinner {
  width: 14px; height: 14px; flex: none;
  border: 2px solid var(--hair-2); border-top-color: var(--accent-solid);
  border-radius: 50%; animation: spin .6s linear infinite;
}
.spinner.lg { width: 28px; height: 28px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Indeterminate top bar while anything is extracting. */
.topline {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 100;
  overflow: hidden; pointer-events: none;
}
.topline::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent-solid), transparent);
  animation: sweep 1.25s var(--ease) infinite;
}
@keyframes sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ==========================================================================
   Sign-in
   ========================================================================== */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(820px 460px at 50% -8%, var(--accent-glow), transparent 68%),
    var(--bg);
}
.gate-card {
  width: 100%; max-width: 390px; padding: 34px 34px 26px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg), inset 0 1px 0 var(--inner-hi);
  animation: rise var(--t-slow) var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.gate-mark {
  display: grid; place-items: center;
  width: 44px; height: 44px; margin-bottom: 20px;
  border-radius: 13px; color: var(--accent-fg);
  background: linear-gradient(155deg, var(--accent-solid), var(--accent-hov));
  box-shadow: 0 8px 20px -6px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.25);
}
.gate-card h1 { font-size: 22px; letter-spacing: -.035em; }
.gate-sub { margin: 5px 0 26px; color: var(--muted); font-size: 13.5px; }
.gate-input-wrap { position: relative; }
.gate-input-wrap input { padding-right: 42px; }
#gate-token { font-family: var(--mono); font-size: 13px; }
.reveal {
  position: absolute; right: 5px; top: 5px;
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--faint); cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.reveal:hover { background: var(--surface-3); color: var(--text); }
.gate-card .checkline { margin-top: 16px; }
.gate-error {
  display: flex; gap: 8px; margin-top: 16px; padding: 10px 12px;
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--r-md); font-size: 13px;
  animation: shake .34s var(--ease) both;
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  30%, 70% { transform: translateX(2px); }
  50%      { transform: translateX(-3px); }
}
.gate-card .btn-primary { margin-top: 22px; height: 40px; width: 100%; }
.gate-alt { margin-top: 18px; text-align: center; }
.linkish {
  border: 0; background: none; padding: 0;
  color: var(--accent); font-size: 12.5px; cursor: pointer;
}
.linkish:hover { text-decoration: underline; }
.gate-foot {
  margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--hair);
  text-align: center; font-size: 12.5px; color: var(--muted);
}

/* ==========================================================================
   Shell
   ========================================================================== */
.app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar-h); flex: none; padding: 0 12px 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--hair);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: 8px; color: var(--accent-fg);
  background: linear-gradient(155deg, var(--accent-solid), var(--accent-hov));
  box-shadow: 0 2px 8px -2px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: -.025em; }

.topbar-status {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 10px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-line); border-radius: 100px;
  font-size: 12.5px; font-weight: 500;
  animation: popIn var(--t-mid) var(--spring) both;
}
@keyframes popIn { from { opacity: 0; transform: scale(.9); } }
.topbar-actions { display: flex; align-items: center; gap: 3px; margin-left: auto; }
.whoami {
  display: inline-flex; align-items: center; height: 25px;
  padding: 0 10px; margin-right: 5px;
  background: var(--surface-3); color: var(--text-2);
  border-radius: 100px; font-size: 12px; font-weight: 500;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.workspace { flex: 1; display: flex; min-height: 0; }

/* --- Rail ----------------------------------------------------------------- */
.rail {
  width: var(--rail-w); flex: none; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--hair);
}
.rail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 10px 11px 17px;
}
.rail-head h2 { display: flex; align-items: center; gap: 8px; }
.count {
  min-width: 18px; padding: 1.5px 6px;
  background: var(--surface-3); color: var(--text-2);
  border-radius: 100px; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0; text-align: center;
}
.doc-list { flex: 1; overflow-y: auto; padding: 0 9px 10px; }
.doc-list:empty::after {
  content: "No documents yet";
  display: block; padding: 24px 8px; text-align: center;
  color: var(--faint); font-size: 12.5px;
}

.doc {
  position: relative; display: flex; align-items: flex-start; gap: 10px;
  width: 100%; padding: 10px 10px 10px 12px; margin-bottom: 2px;
  border: 1px solid transparent; border-radius: var(--r-lg);
  background: transparent; text-align: left; cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  animation: docIn var(--t-mid) var(--ease) both;
}
@keyframes docIn { from { opacity: 0; transform: translateX(-6px); } }
.doc:hover { background: var(--surface-2); }
.doc.is-active {
  background: var(--accent-soft); border-color: var(--accent-line);
}
.doc.is-active::before {
  content: ""; position: absolute; left: -1px; top: 9px; bottom: 9px;
  width: 2.5px; border-radius: 3px; background: var(--accent-solid);
}
.doc-status { flex: none; margin-top: 3px; }
.dot { display: block; width: 7px; height: 7px; border-radius: 50%; }
.dot.queued { background: var(--faint); }
.dot.done   { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.failed { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.doc-body { min-width: 0; flex: 1; }
.doc-name {
  display: block; font-size: 13px; font-weight: 500; line-height: 1.35;
  letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-meta {
  display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-meta.failed { color: var(--danger); }
.doc-remove {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--faint); cursor: pointer; opacity: 0;
  transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}
.doc:hover .doc-remove, .doc-remove:focus-visible { opacity: 1; }
.doc-remove:hover { background: var(--danger-soft); color: var(--danger); }

.rail-foot {
  flex: none; display: grid; gap: 6px;
  padding: 11px 12px 13px; border-top: 1px solid var(--hair);
}

/* --- Detail --------------------------------------------------------------- */
.detail { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

/* Dropzone ---------------------------------------------------------------- */
.dropzone {
  position: relative; overflow: hidden;
  flex: 1; display: grid; place-items: center; padding: 32px;
}
/* Blurred artwork. Inset negative + scale so the blur has no soft edges. */
.dropzone::before {
  content: ""; position: absolute; inset: -12%; z-index: 0;
  background-image: url("bg-documents.jpg");
  background-image: image-set(url("bg-documents.webp") type("image/webp"),
                              url("bg-documents.jpg")  type("image/jpeg"));
  background-size: cover; background-position: center;
  filter: blur(42px) saturate(1.25);
  transform: scale(1.06);
  opacity: var(--bg-art-opacity);
  /* No entrance animation here on purpose: the dropzone's ancestor starts
     display:none, which left this pseudo-element's animation parked on its
     0% keyframe (opacity 0) and the artwork never appeared. */
}
/* Scrim: keeps the card legible and fades the art into the page edges. */
.dropzone::after {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(760px 460px at 50% 46%,
              var(--scrim-in), var(--scrim-out) 76%);
}
.dz-inner {
  position: relative; z-index: 1;
  width: 100%; max-width: 480px; padding: 48px 40px 40px; text-align: center;
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid var(--glass-line); border-radius: 22px;
  box-shadow: var(--sh-lg), inset 0 1px 0 var(--inner-hi);
  transition: border-color var(--t-mid) var(--ease),
              box-shadow var(--t-mid) var(--ease),
              transform var(--t-mid) var(--ease);
  animation: rise var(--t-slow) var(--ease) both;
}
.dropzone.is-over .dz-inner {
  border-color: var(--accent-solid);
  box-shadow: var(--sh-lg), 0 0 0 4px var(--accent-glow);
  transform: translateY(-3px) scale(1.006);
}
.dz-icon {
  display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 22px;
  border-radius: 18px; color: var(--accent-fg);
  background: linear-gradient(155deg, var(--accent-solid), var(--accent-hov));
  box-shadow: 0 14px 30px -10px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.28);
}
.dz-inner h3 { font-size: 20px; letter-spacing: -.032em; }
.dz-inner > p { margin: 10px auto 24px; max-width: 340px; color: var(--muted); font-size: 13.5px; }
.dz-hint { margin-top: 16px; font-size: 12px; color: var(--faint); }
.dz-points {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  width: fit-content; margin: 28px auto 0;
  padding-top: 24px; border-top: 1px solid var(--hair);
}
.dz-point { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.dz-point svg { color: var(--accent); flex: none; }

/* States ------------------------------------------------------------------- */
.state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  padding: 32px; text-align: center;
}
.state h3 { margin-top: 18px; font-size: 17px; }
.state p { color: var(--muted); font-size: 13.5px; max-width: 380px; }
.state .btn { margin-top: 20px; }
.state-icon { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 16px; }
.state-icon.danger { background: var(--danger-soft); color: var(--danger); }

/* Skeleton while extracting — reads as the result arriving, not as a stall. */
.skeleton { flex: 1; overflow: hidden; padding: 22px 24px; animation: fadeIn var(--t-mid) var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; } }
.sk-line, .sk-block {
  background: var(--surface-3); border-radius: 6px; position: relative; overflow: hidden;
}
.sk-line::after, .sk-block::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--hair), transparent);
  animation: shimmer 1.4s var(--ease) infinite;
}
@keyframes shimmer { 100% { transform: translateX(200%); } }
.sk-line::after, .sk-block::after { transform: translateX(-100%); }
.sk-title { height: 26px; width: 320px; max-width: 70%; margin-bottom: 10px; }
.sk-sub   { height: 13px; width: 220px; max-width: 50%; margin-bottom: 26px; }
.sk-facts { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 22px; margin-bottom: 28px; }
.sk-fact  { height: 44px; }
.sk-card  { height: 132px; border-radius: var(--r-lg); margin-bottom: 16px; }
.sk-card:nth-child(odd) { height: 160px; }

/* --- Result --------------------------------------------------------------- */
.result { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.result-head {
  display: flex; align-items: flex-start; gap: 22px; flex: none;
  padding: 22px 24px 0;
  background: var(--surface); border-bottom: 1px solid var(--hair);
  animation: headIn var(--t-slow) var(--ease) both;
}
@keyframes headIn { from { opacity: 0; transform: translateY(-6px); } }
.rh-main { min-width: 0; flex: 1; }
.rh-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 10px; }
.rh-main h2 {
  font-size: 25px; letter-spacing: -.04em; line-height: 1.15; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rh-file {
  margin-top: 6px; font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rh-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 100px;
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  background: var(--surface-3); color: var(--text-2); border: 1px solid transparent;
}
.badge.boe { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge.sb  { background: var(--ok-soft); color: var(--ok); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3.5px 9px; border-radius: 100px;
  background: var(--surface-3); color: var(--muted); font-size: 11.5px;
}

/* Key facts */
.facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  row-gap: 20px; margin: 22px 0 0; padding: 0 0 18px;
}
.fact { min-width: 0; padding: 2px 18px; border-left: 1px solid var(--hair); }
.fact:nth-child(3n + 1) { border-left: 0; padding-left: 0; }
@media (min-width: 1580px) {
  .facts { grid-template-columns: repeat(6, minmax(0, 1fr)); row-gap: 0; }
  .fact:nth-child(3n + 1) { border-left: 1px solid var(--hair); padding-left: 18px; }
  .fact:nth-child(6n + 1) { border-left: 0; padding-left: 0; }
}
@media (max-width: 620px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact:nth-child(3n + 1) { border-left: 1px solid var(--hair); padding-left: 18px; }
  .fact:nth-child(2n + 1) { border-left: 0; padding-left: 0; }
}
.fact .fk {
  display: block; margin-bottom: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fact .fv {
  display: block; font-size: 21px; font-weight: 550;
  letter-spacing: -.035em; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fact .fv.empty { color: var(--faint); font-weight: 400; }

/* Segmented control */
.seg { display: flex; gap: 2px; padding: 2.5px; background: var(--surface-3); border-radius: var(--r-md); }
.seg-btn {
  height: 26px; padding: 0 12px; border: 0; border-radius: 6.5px; background: transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--sh-sm), inset 0 1px 0 var(--inner-hi);
}

/* Mapping notes — neutral, so amber stays the accent and not a warning colour. */
.warnings {
  flex: none; display: flex; gap: 11px;
  margin: 16px 24px 0; padding: 12px 14px;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--hair); border-left: 2.5px solid var(--accent-solid);
  border-radius: var(--r-md);
  font-size: 12.5px; line-height: 1.6;
  animation: fadeIn var(--t-slow) var(--ease) both;
}
.warnings svg { flex: none; margin-top: 2px; color: var(--accent); }
.warnings .w-head { font-weight: 600; color: var(--text); margin-bottom: 3px; }
.warnings ul { display: grid; gap: 3px; }

/* Body split --------------------------------------------------------------- */
.result-body { flex: 1; display: flex; min-height: 0; }
.pane-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.toolbar { display: flex; align-items: center; gap: 16px; flex: none; padding: 16px 24px 13px; }
.search { position: relative; flex: 1; max-width: 300px; }
.search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none;
}
.search input { height: 34px; padding-left: 34px; font-size: 13px; }

.groups {
  flex: 1; overflow-y: auto; padding: 0 24px 32px;
  display: flex; flex-direction: column; gap: 16px;
}

/* Plain flex flow on purpose: a nested grid inside a grid item with
   overflow:hidden collapses to one row and silently clips fields. */
.group {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm), inset 0 1px 0 var(--inner-hi);
  animation: groupIn var(--t-slow) var(--ease) both;
}
@keyframes groupIn { from { opacity: 0; transform: translateY(10px); } }
.group:nth-child(1) { animation-delay: .02s; }
.group:nth-child(2) { animation-delay: .06s; }
.group:nth-child(3) { animation-delay: .10s; }
.group:nth-child(4) { animation-delay: .14s; }
.group:nth-child(5) { animation-delay: .18s; }
.group:nth-child(6) { animation-delay: .22s; }

.group-head { padding: 14px 17px 12px; }
.rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--hair); }
.row {
  display: grid; grid-template-columns: 154px minmax(0, 1fr);
  gap: 14px; align-items: baseline;
  padding: 11px 17px; min-width: 0;
  border-bottom: 1px solid var(--hair);
}
.rows > .row:nth-child(odd):not(:last-child) { border-right: 1px solid var(--hair); }
.rows > .row:last-child,
.rows > .row:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
.row.wide { grid-column: 1 / -1; border-right: 0; }

.row .k {
  font-size: 12.5px; color: var(--muted); cursor: help;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row .v {
  font-size: 13.5px; font-weight: 500; color: var(--text); letter-spacing: -.012em;
  word-break: break-word; overflow-wrap: anywhere;
  cursor: pointer; border-radius: 6px; margin: -3px -6px; padding: 3px 6px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.row .v:hover { background: var(--accent-soft); color: var(--accent); }
.row .v.is-empty { color: var(--faint); font-weight: 400; cursor: default; }
.row .v.is-empty:hover { background: transparent; color: var(--faint); }
.row .v.num, .row .v.ident {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: -.02em;
}
.row.is-hit { background: var(--accent-soft); }

.result.is-split .rows { grid-template-columns: 1fr; }
.result.is-split .rows > .row { border-right: 0 !important; }
.result.is-split .rows > .row:last-child { border-bottom: 0; }
.result.is-split .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.result.is-split .fact:nth-child(3n + 1) { border-left: 1px solid var(--hair); padding-left: 18px; }
.result.is-split .fact:nth-child(2n + 1) { border-left: 0; padding-left: 0; }

@media (max-width: 1150px) {
  .rows { grid-template-columns: 1fr; }
  .rows > .row { border-right: 0 !important; }
  .rows > .row:last-child { border-bottom: 0; }
}

.no-results { padding: 44px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* JSON pane */
.pane-json {
  flex: 1; margin: 0; overflow: auto; padding: 4px 24px 32px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.75;
  color: var(--text-2); white-space: pre; tab-size: 2;
  animation: fadeIn var(--t-mid) var(--ease) both;
}
.pane-json .jk { color: var(--accent); }
.pane-json .js { color: var(--text); }
.pane-json .jn { color: var(--ok); }
.pane-json .jz { color: var(--faint); font-style: italic; }

/* PDF pane */
.pane-pdf {
  width: 44%; min-width: 340px; flex: none;
  border-left: 1px solid var(--hair); background: var(--surface-3);
  animation: paneIn var(--t-mid) var(--ease) both;
}
@keyframes paneIn { from { opacity: 0; transform: translateX(14px); } }
.pane-pdf iframe { width: 100%; height: 100%; border: 0; display: block; }

/* --- Drag veil ------------------------------------------------------------ */
.drag-veil {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(10, 10, 11, .55); backdrop-filter: blur(4px);
  animation: fadeIn var(--t-fast) var(--ease) both;
}
.veil-card {
  display: flex; align-items: center; gap: 12px;
  padding: 24px 34px; background: var(--surface); color: var(--text);
  border: 2px dashed var(--accent-solid); border-radius: var(--r-xl);
  box-shadow: var(--sh-lg); font-size: 15px; font-weight: 550;
  animation: rise var(--t-mid) var(--spring) both;
}
.veil-card svg { color: var(--accent); }

/* --- Modal ---------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  padding: 24px; background: rgba(10, 10, 11, .6); animation: fadeIn var(--t-fast) var(--ease) both;
}
.modal-card {
  width: 100%; max-width: 680px; max-height: 84vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--r-xl); box-shadow: var(--sh-lg);
  animation: rise var(--t-mid) var(--ease) both;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 14px 17px 21px; border-bottom: 1px solid var(--hair);
}
.modal-head h3 { font-size: 15.5px; }
.modal-body { overflow-y: auto; padding: 21px; }
.modal-body > p { color: var(--text-2); font-size: 13.5px; margin-bottom: 6px; }
.modal-body h4 { margin: 26px 0 9px; }
.code {
  position: relative; padding: 15px 16px;
  background: var(--surface-2); border: 1px solid var(--hair);
  border-radius: var(--r-md);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.75;
  color: var(--text-2); white-space: pre-wrap; word-break: break-all;
}
.code .btn { position: absolute; top: 8px; right: 8px; }

/* --- Toasts --------------------------------------------------------------- */
.toasts {
  position: fixed; z-index: 90; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px; padding: 10px 18px;
  background: var(--text); color: var(--bg); border-radius: 100px;
  box-shadow: var(--sh-md); font-size: 13px; font-weight: 500;
  animation: toastIn var(--t-mid) var(--spring) both;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.out { animation: toastOut .2s var(--ease) forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px) scale(.94); } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(6px) scale(.97); } }

/* --- Scrollbars ----------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--hair-2) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb {
  background: var(--hair-2); border-radius: 100px;
  border: 3.5px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 900px) {
  :root { --rail-w: 100%; }
  .workspace { flex-direction: column; }
  .rail { border-right: 0; border-bottom: 1px solid var(--hair); max-height: 34vh; }
  .pane-pdf { display: none !important; }
  .result-head { flex-direction: column; gap: 14px; padding-bottom: 4px; }
  .rh-actions { width: 100%; flex-wrap: wrap; }
  .facts { margin-top: 4px; }
  .brand-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .spinner { animation-duration: .8s !important; }
  .topline::after, .sk-line::after, .sk-block::after { animation-duration: 1.4s !important; }
}
