/* ===========================================================================
   Bank2Excel — design system
   "Ledger": an accountant's working desk. Ink sidebar, paper canvas with faint
   ruled lines, serif headlines, monospaced figures. Créer Société azure + gold.
   Token layers: primitives → semantic. Components reference semantic tokens only.
   =========================================================================== */

:root {
  /* Brand scale — Créer Société azure (#027FBC) */
  --blue-50:  #e8f4fa;
  --blue-100: #cfe7f4;
  --blue-200: #9fd0ea;
  --blue-300: #62b4de;
  --blue-400: #2a9ad3;
  --blue-500: #0693e3;
  --blue-600: #027fbc;   /* primary */
  --blue-700: #026a9e;
  --blue-800: #064f74;
  --blue-900: #07212d;

  /* Gold accent */
  --gold-300: #ffd977;
  --gold-400: #ffcb45;
  --gold-500: #fcb900;
  --gold-700: #ff6900;

  /* Ink (teal-tinted) */
  --ink-50:  #f5f8f9;
  --ink-100: #eaf0f3;
  --ink-200: #dbe4e9;
  --ink-300: #c2d0d8;
  --ink-400: #8ea4b1;
  --ink-500: #5f7787;
  --ink-600: #3a5d6f;
  --ink-700: #1d4254;
  --ink-800: #0e2c3a;
  --ink-900: #07212d;
  --ink-950: #041820;

  /* Status hues */
  --green-50: #e8f7ef; --green-500: #13a368; --green-700: #0b6b43;
  --red-50:   #fdeeec; --red-500:   #df4a3e; --red-700:   #a3291f;
  --amber-50: #fff4e2; --amber-500: #e3901f; --amber-700: #985404;

  /* Type */
  --font-ui: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Layout */
  --sidebar-w: 248px;

  /* ---- Semantic (light) ---- */
  --bg:          #f2f5f6;
  --rule:        rgba(7, 33, 45, .035);
  --surface:     #ffffff;
  --surface-2:   var(--ink-50);
  --surface-3:   var(--ink-100);
  --ink:         var(--ink-900);
  --ink-2:       var(--ink-600);
  --muted:       var(--ink-500);
  --line:        var(--ink-200);
  --line-strong: var(--ink-300);

  --primary:        var(--blue-600);
  --primary-hover:  var(--blue-700);
  --primary-ink:    #ffffff;
  --primary-soft:   var(--blue-50);
  --primary-soft-b: var(--blue-100);
  --on-soft:        var(--blue-700);

  --accent:      var(--gold-500);
  --accent-soft: #fff6dc;

  --ok-bg: var(--green-50); --ok-ink: var(--green-700); --ok-accent: var(--green-500);
  --err-bg: var(--red-50);  --err-ink: var(--red-700);  --err-accent: var(--red-500);
  --warn-bg: var(--amber-50); --warn-ink: var(--amber-700); --warn-accent: var(--amber-500);
  --info-bg: var(--blue-50); --info-ink: var(--blue-700);

  --focus: var(--blue-400);

  /* The sidebar is ink in both themes. */
  --side-bg:     var(--ink-900);
  --side-ink:    #d7e4ea;
  --side-muted:  #7f9aa8;
  --side-hover:  rgba(255,255,255,.06);
  --side-active: rgba(255,255,255,.10);
  --side-line:   rgba(255,255,255,.08);

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(7,33,45,.05);
  --shadow-sm: 0 1px 2px rgba(7,33,45,.04), 0 2px 6px -2px rgba(7,33,45,.06);
  --shadow-md: 0 8px 20px -8px rgba(7,33,45,.16), 0 2px 6px -3px rgba(7,33,45,.08);
  --shadow-lg: 0 24px 50px -18px rgba(7,33,45,.28), 0 8px 18px -10px rgba(7,33,45,.14);

  /* Radii */
  --r-xs: 6px; --r-sm: 8px; --r: 11px; --r-lg: 14px; --r-xl: 20px; --r-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-fast: .14s; --t: .22s;

  color-scheme: light;
}

/* ---- Semantic (dark): applied via OS preference OR explicit toggle ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:          var(--ink-950);
    --rule:        rgba(255,255,255,.022);
    --surface:     #0a2330;
    --surface-2:   #0d2a39;
    --surface-3:   #113243;
    --ink:         #e8f0f3;
    --ink-2:       #a9bfca;
    --muted:       #7e98a6;
    --line:        #19394a;
    --line-strong: #24495c;
    --primary:        var(--blue-400);
    --primary-hover:  var(--blue-300);
    --primary-ink:    #04161e;
    --primary-soft:   #0c3043;
    --primary-soft-b: #154764;
    --on-soft:        var(--blue-200);
    --accent-soft: #2b2410;
    --ok-bg: #0c2c22;  --ok-ink: #6fe0a6;  --ok-accent: var(--green-500);
    --err-bg: #2f1714; --err-ink: #ff9d92; --err-accent: var(--red-500);
    --warn-bg: #2d2210; --warn-ink: #f4be6c; --warn-accent: var(--amber-500);
    --info-bg: #0c2c3e; --info-ink: #9fd0ea;
    --side-bg:     #03121a;
    --side-line:   rgba(255,255,255,.06);
    --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.45);
    --shadow-md: 0 10px 24px -8px rgba(0,0,0,.6);
    --shadow-lg: 0 24px 50px -16px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:          var(--ink-950);
  --rule:        rgba(255,255,255,.022);
  --surface:     #0a2330;
  --surface-2:   #0d2a39;
  --surface-3:   #113243;
  --ink:         #e8f0f3;
  --ink-2:       #a9bfca;
  --muted:       #7e98a6;
  --line:        #19394a;
  --line-strong: #24495c;
  --primary:        var(--blue-400);
  --primary-hover:  var(--blue-300);
  --primary-ink:    #04161e;
  --primary-soft:   #0c3043;
  --primary-soft-b: #154764;
  --on-soft:        var(--blue-200);
  --accent-soft: #2b2410;
  --ok-bg: #0c2c22;  --ok-ink: #6fe0a6;  --ok-accent: var(--green-500);
  --err-bg: #2f1714; --err-ink: #ff9d92; --err-accent: var(--red-500);
  --warn-bg: #2d2210; --warn-ink: #f4be6c; --warn-accent: var(--amber-500);
  --info-bg: #0c2c3e; --info-ink: #9fd0ea;
  --side-bg:     #03121a;
  --side-line:   rgba(255,255,255,.06);
  --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.45);
  --shadow-md: 0 10px 24px -8px rgba(0,0,0,.6);
  --shadow-lg: 0 24px 50px -16px rgba(0,0,0,.7);
}

/* ===========================================================================
   Base
   =========================================================================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--bg);
  /* Ruled ledger paper, fading out toward the bottom. */
  background-image:
    radial-gradient(900px 420px at 85% -10%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 70%),
    repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}

a { color: var(--primary); }
::selection { background: var(--primary-soft-b); color: var(--on-soft); }

:where(a, button, input, select, textarea, .dropzone, .combo-item, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.num, td.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ===========================================================================
   App shell: ink sidebar + paper canvas
   =========================================================================== */
body.is-authed { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
body.is-guest  { display: flex; flex-direction: column; }

.sidebar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-direction: column; gap: 6px;
  height: 100dvh; padding: 22px 16px 16px;
  background:
    radial-gradient(260px 200px at 0% 0%, rgba(42,154,211,.18), transparent 70%),
    var(--side-bg);
  color: var(--side-ink);
  border-right: 1px solid var(--side-line);
}
body.is-guest .sidebar {
  position: static; height: auto; flex-direction: row; align-items: center;
  padding: 18px clamp(16px, 4vw, 32px); background: transparent; border: 0; color: var(--ink);
}

.brand {
  display: inline-flex; align-items: center; gap: 11px;
  padding: 0 6px 18px; margin-bottom: 10px;
  text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--side-line);
}
body.is-guest .brand { display: none; } /* the sign-in card carries the full logo */
.brand .brand-mark {
  flex: none; width: 38px; height: 38px; object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(2,127,188,.35));
}
.brand .wordmark { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brand .wordmark-name {
  font-family: var(--font-display); font-size: 1.42rem; line-height: 1; letter-spacing: -.005em; white-space: nowrap;
}
.brand .wordmark-name i { color: var(--accent); font-style: italic; }
.brand .wordmark-by {
  font-family: var(--font-mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--side-muted); white-space: nowrap;
}
body.is-guest .brand .wordmark-by { color: var(--muted); }
body.is-guest .brand .wordmark-name i { color: var(--primary); }

.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav-label {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--side-muted); padding: 8px 10px 6px;
}
.sidenav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--r-sm);
  font-size: .9rem; font-weight: 500; color: var(--side-ink); text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidenav a svg { width: 18px; height: 18px; flex: none; opacity: .75; }
.sidenav a em { font-style: normal; color: var(--side-muted); }
.sidenav a:hover { background: var(--side-hover); color: #fff; }
.sidenav a[aria-current="page"] { background: var(--side-active); color: #fff; }
.sidenav a[aria-current="page"] svg { opacity: 1; color: var(--gold-400); }
.sidenav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}

.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 4px;
  padding-top: 14px; border-top: 1px solid var(--side-line);
}
body.is-guest .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
.sidebar-foot .spacer { flex: 1; }

.userchip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: var(--r-pill);
  background: rgba(255,255,255,.06); border: 1px solid var(--side-line);
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--side-ink);
}
.userchip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok-accent); box-shadow: 0 0 0 3px rgba(19,163,104,.2); }

.iconbtn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent;
  color: var(--side-muted); cursor: pointer; text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.iconbtn:hover { background: var(--side-hover); color: #fff; }
body.is-guest .iconbtn { color: var(--ink-2); }
body.is-guest .iconbtn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.iconbtn svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
body.is-guest .main { flex: 1; min-height: 0; }

/* ===========================================================================
   Layout
   =========================================================================== */
.container {
  width: 100%; max-width: 1180px; flex: 1;
  margin: 0 auto; padding: clamp(24px, 4vw, 48px) clamp(16px, 4vw, 44px) 24px;
}
.container.tight { max-width: 560px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.split > aside { display: grid; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(20px, 3vw, 28px);
  box-shadow: var(--shadow-sm);
}
.card.narrow { max-width: 520px; margin: 0 auto; }
.card + .card { margin-top: 20px; }
.split + .card, .page-head + .card { margin-top: 0; }

/* Quiet side panel. */
.panel {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  padding: 18px 18px 16px;
}
.panel .panel-title {
  margin: 0 0 14px; font-family: var(--font-mono); font-size: .68rem; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.panel p { margin: 0; font-size: .86rem; color: var(--ink-2); }
.panel p + p { margin-top: 8px; }

/* Numbered steps (side panels). */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 12px; }
.steps li {
  counter-increment: step; position: relative; padding-left: 36px;
  font-size: .86rem; color: var(--ink-2); line-height: 1.5;
}
.steps li strong { color: var(--ink); font-weight: 600; }
.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: -1px;
  font-family: var(--font-mono); font-size: .72rem; font-weight: 500;
  color: var(--primary); background: var(--primary-soft); border: 1px solid var(--primary-soft-b);
  border-radius: 6px; padding: 1px 5px;
}

/* Engine / reader status list. */
.statuslist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.statuslist li { display: flex; gap: 10px; align-items: flex-start; font-size: .85rem; color: var(--ink-2); line-height: 1.45; }
.statuslist li strong { display: block; color: var(--ink); font-weight: 600; }
.statuslist .led {
  flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%;
  background: var(--line-strong);
}
.statuslist .led.on   { background: var(--ok-accent);   box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok-accent) 22%, transparent); }
.statuslist .led.warn { background: var(--warn-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn-accent) 22%, transparent); }

/* ===========================================================================
   Typography & page header
   =========================================================================== */
.page-head { margin: 4px 0 26px; max-width: 760px; }
.page-head h1 { margin-bottom: 10px; }

h1 {
  margin: 0 0 6px;
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(2rem, 4.2vw, 2.85rem); line-height: 1.04; letter-spacing: -.012em;
  color: var(--ink);
}
h1 em { font-style: italic; color: var(--primary); }
h2, h3 { font-family: var(--font-ui); }
h3 { margin: 28px 0 8px; font-size: 1rem; font-weight: 600; letter-spacing: -.01em; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 4px; font-size: 1.05rem; font-weight: 600; }

.lead { color: var(--ink-2); font-size: 1rem; margin: 0; max-width: 64ch; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.link { color: var(--primary); text-decoration: none; font-weight: 600; cursor: pointer; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
  font-family: var(--font-mono); font-size: .7rem; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--accent); }
.eyebrow svg { width: 14px; height: 14px; color: var(--primary); }

/* ===========================================================================
   Forms
   =========================================================================== */
label { display: block; margin: 16px 0 0; font-weight: 500; font-size: .86rem; color: var(--ink); }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=month], select, textarea {
  width: 100%; padding: 10px 12px; margin-top: 6px;
  font: inherit; font-size: .94rem; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  box-shadow: inset 0 1px 1px rgba(7,33,45,.03);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--ink-400); }
input:hover, select:hover, textarea:hover { border-color: var(--ink-400); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 24%, transparent);
}
textarea { resize: vertical; min-height: 76px; font-family: var(--font-mono); font-size: .84rem; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235f7787' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 36px;
}

input[type=file] { font: inherit; font-size: .86rem; color: var(--ink-2); max-width: 100%; }
input[type=file]::file-selector-button {
  margin-right: 12px; padding: 8px 14px;
  font: inherit; font-weight: 600; font-size: .84rem; color: var(--ink);
  background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
  cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast);
}
input[type=file]::file-selector-button:hover { border-color: var(--primary); background: var(--primary-soft); }

label.checkbox {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px; padding: 11px 14px;
  font-weight: 500; font-size: .9rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast);
}
label.checkbox:hover { border-color: var(--line-strong); }
label.checkbox:has(input:checked) { border-color: var(--primary-soft-b); background: var(--primary-soft); }
label.checkbox input { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); cursor: pointer; }
label.checkbox.inline { display: inline-flex; margin: 0; padding: 7px 12px; font-size: .84rem; }

/* ===========================================================================
   Buttons
   =========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; min-height: 42px;
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1;
  border: 1px solid transparent; border-radius: var(--r-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast),
              transform var(--t-fast), box-shadow var(--t-fast);
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 88%, #fff), var(--primary));
  color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary) 80%, #000);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 1px 2px rgba(2,63,94,.25);
}
.btn.primary:hover { background: var(--primary-hover); box-shadow: inset 0 1px 0 rgba(255,255,255,.18), var(--shadow-md); }
.btn.primary svg { transition: transform var(--t) var(--ease-out); }
.btn.primary:hover svg { transform: translateX(2px); }

.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--ink-400); }

.btn.block { width: 100%; }
.btn.lg { padding: 13px 22px; min-height: 50px; font-size: .98rem; border-radius: var(--r); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.sm { padding: 5px 10px; min-height: 0; font-size: .78rem; border-radius: var(--r-xs); box-shadow: none; }

/* ===========================================================================
   Dropzone
   =========================================================================== */
.dropzone {
  position: relative; z-index: 0; margin-top: 22px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r);
  padding: clamp(30px, 5vw, 46px) 24px; text-align: center;
  cursor: pointer;
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box;
  transition: border-color var(--t), background var(--t), transform var(--t-fast), box-shadow var(--t);
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.drag {
  border-color: var(--primary); border-style: solid; background: var(--primary-soft);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--focus) 18%, transparent); transform: scale(1.004);
}
.dropzone .dz-icon {
  position: relative;
  display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 16px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  color: var(--primary); box-shadow: var(--shadow-sm);
  transition: transform var(--t) var(--ease-out), color var(--t-fast);
}
/* A second "sheet" behind the icon tile, like a stack of documents. */
.dropzone .dz-icon::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; background: var(--surface); border: 1px solid var(--line);
  transform: rotate(-8deg) translate(-5px, 2px); transition: transform var(--t) var(--ease-out);
}
.dropzone:hover .dz-icon, .dropzone.drag .dz-icon { transform: translateY(-3px); }
.dropzone:hover .dz-icon::before, .dropzone.drag .dz-icon::before { transform: rotate(-14deg) translate(-9px, 3px); }
.dropzone .dz-icon svg { width: 25px; height: 25px; }
.dropzone.has-file { border-style: solid; border-color: color-mix(in srgb, var(--ok-accent) 55%, transparent); background: var(--ok-bg); }
.dropzone.has-file .dz-icon { color: var(--ok-accent); }
#dropLabel { margin: 0 0 4px; font-weight: 600; font-size: 1rem; color: var(--ink); }
#dropLabel.is-file, .has-file #dropLabel { color: var(--ok-ink); }
.dropzone .muted { margin: 6px auto 0; max-width: 52ch; line-height: 1.5; }

/* ===========================================================================
   Searchable combobox
   =========================================================================== */
.combo { position: relative; margin-top: 6px; }
.combo-input { margin-top: 0 !important; }
.combo-input.invalid {
  border-color: var(--err-accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--err-accent) 24%, transparent);
  animation: shake .3s var(--ease);
}
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.combo-list {
  list-style: none; margin: 6px 0 0; padding: 6px; position: absolute; z-index: 25;
  left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  max-height: 280px; overflow-y: auto;
  animation: pop .14s var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.combo-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-xs); cursor: pointer; font-size: .92rem; font-weight: 500;
}
.combo-item:hover, .combo-item.active { background: var(--primary-soft); color: var(--on-soft); }
.combo-item .muted { font-family: var(--font-mono); font-size: .74rem; font-weight: 400; }
.combo-item.active .muted, .combo-item:hover .muted { color: color-mix(in srgb, var(--on-soft) 70%, transparent); }
.combo-new { border-top: 1px solid var(--line); color: var(--primary); font-weight: 600; margin-top: 4px; }

/* ===========================================================================
   Document-type radio cards
   =========================================================================== */
.doctype { display: flex; gap: 10px; margin: 16px 0; }
.doctype .radio {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 0; padding: 13px; font-weight: 600; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.doctype .radio:hover { border-color: var(--line-strong); }
.doctype .radio:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--on-soft); }

/* ===========================================================================
   Flash / alerts
   =========================================================================== */
.flash {
  position: relative;
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 14px 12px 16px; border-radius: var(--r-sm); margin: 14px 0; font-size: .9rem;
  border: 1px solid transparent; line-height: 1.5; overflow: hidden;
}
.flash::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: currentColor; opacity: .55; }
.flash .flash-ico { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.flash.error   { background: var(--err-bg);  color: var(--err-ink);  border-color: color-mix(in srgb, var(--err-accent) 26%, transparent); }
.flash.ok, .flash.success { background: var(--ok-bg); color: var(--ok-ink); border-color: color-mix(in srgb, var(--ok-accent) 24%, transparent); }
.flash.info    { background: var(--info-bg); color: var(--info-ink); border-color: color-mix(in srgb, var(--primary) 18%, transparent); }
.flash.warn    { background: var(--warn-bg); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn-accent) 26%, transparent); }
.flash strong { font-weight: 650; }
.flash .link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ===========================================================================
   Result / status header
   =========================================================================== */
.status-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.status-badge {
  display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 50%;
}
.status-badge svg { width: 26px; height: 26px; }
.status-badge.ok   { background: var(--ok-bg);   color: var(--ok-accent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok-accent) 10%, transparent); }
.status-badge.warn { background: var(--warn-bg); color: var(--warn-accent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--warn-accent) 10%, transparent); }
.status-hero h1 { margin: 0; }

/* Large figure on the result page. */
.figure { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 6px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.figure b { font-family: var(--font-display); font-weight: 400; font-size: 3rem; line-height: 1; color: var(--ink); }
.figure span { color: var(--ink-2); }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.downloads .btn { margin: 0; }

/* ===========================================================================
   Column-mapping cards (preview)
   =========================================================================== */
.colmap {
  display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 14px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.colmap::-webkit-scrollbar { height: 8px; }
.colmap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
.colcard {
  scroll-snap-align: start; flex: none;
  min-width: 160px; border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px; background: var(--surface-2);
  transition: border-color var(--t-fast);
}
.colcard:hover { border-color: var(--line-strong); }
.colcard:has(option[value="ignore"]:checked) { opacity: .7; }
.colhead { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font-family: var(--font-mono); font-weight: 500; font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 8px; color: var(--ink-2); }
.colcard select { margin-top: 0; padding: 7px 30px 7px 10px; font-size: .84rem; }
.samples { margin-top: 10px; }
.scell {
  font-family: var(--font-mono); font-size: .72rem; color: var(--muted); padding: 4px 0; border-top: 1px dashed var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 136px;
}

/* ===========================================================================
   Data table
   =========================================================================== */
.tablewrap {
  overflow: auto; max-height: 72vh;
  border: 1px solid var(--line); border-radius: var(--r); margin-top: 10px;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .85rem; }
th, td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th {
  background: var(--surface-2); position: sticky; top: 0; z-index: 2;
  font-family: var(--font-mono); font-size: .66rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  border-bottom-color: var(--line-strong);
}
th.num { text-align: right; }
tbody tr { transition: background var(--t-fast); }
tbody tr:nth-child(even of :not(.answer-row)) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
tbody tr:hover td { background: var(--primary-soft); }
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-size: .82rem; }
td.muted.small { font-size: .8rem; }
td.muted.small:last-child { font-family: var(--font-mono); font-size: .72rem; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; align-items: center; margin: 8px 0; }
.kv label { margin: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 24px; }
.actions .btn { margin: 0; }

/* ===========================================================================
   Processing overlay
   =========================================================================== */
.proc-overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: color-mix(in srgb, var(--ink-950) 55%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade .2s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.proc-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 32px 34px; text-align: center; box-shadow: var(--shadow-lg); max-width: 380px; width: 100%;
  animation: pop .26s var(--ease-out);
}
.proc-box .spinner {
  width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--primary); border-right-color: var(--accent);
  animation: spin .9s linear infinite;
}
.proc-box .proc-title { font-family: var(--font-display); font-size: 1.6rem; line-height: 1.1; margin-bottom: 8px; }
.proc-box .proc-sub { color: var(--muted); font-size: .88rem; line-height: 1.5; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================================================
   Footer
   =========================================================================== */
.foot {
  display: flex; align-items: flex-start; justify-content: center; gap: 8px;
  max-width: 1180px; width: 100%; margin: 0 auto;
  padding: 18px clamp(16px, 4vw, 44px) 26px; font-size: .78rem; color: var(--muted); line-height: 1.5;
}
.foot svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--ok-accent); }

.hidden { display: none !important; }

/* ===========================================================================
   Page-load reveal
   =========================================================================== */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.container > * { animation: rise .5s var(--ease-out) both; }
.container > *:nth-child(2) { animation-delay: .06s; }
.container > *:nth-child(3) { animation-delay: .12s; }
.container > *:nth-child(4) { animation-delay: .18s; }
.split > * { animation: rise .5s var(--ease-out) both; }
.split > aside { animation-delay: .1s; }

/* ===========================================================================
   Bills page
   =========================================================================== */
.client-pick { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 18px; }
.client-pick > label { margin-top: 0; }
.client-pick .span { grid-column: 1 / -1; }
.client-pick input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.vat-choice { border: 0; margin: 0; padding: 0; min-width: 0; }
.vat-choice legend { padding: 0; font-weight: 500; font-size: .86rem; color: var(--ink); }
.vat-choice .checkbox.inline { margin: 8px 8px 0 0; }
@media (max-width: 640px) { .client-pick { grid-template-columns: 1fr; } }
.bill-summary { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.bill-summary .section-title { margin: 0; }
#counts { font-family: var(--font-mono); font-size: .76rem; font-weight: 400; color: var(--muted); }
.table-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.table-tools p { margin: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 8px; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok   { background: var(--ok-bg);   color: var(--ok-ink);   border-color: color-mix(in srgb, var(--ok-accent) 22%, transparent); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn-accent) 30%, transparent); }
.pill.muted { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
td.vendor { white-space: normal; min-width: 200px; max-width: 320px; }
.tag-new { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: var(--r-pill);
  font-size: .68rem; font-weight: 600; vertical-align: 1px; color: var(--on-soft); background: var(--primary-soft); }
.reasons { margin: 5px 0 0; padding: 0; list-style: none; display: grid; gap: 2px;
  font-size: .78rem; line-height: 1.4; color: var(--warn-ink); }
.reasons li { position: relative; padding-left: 12px; }
.reasons li::before { content: ""; position: absolute; left: 2px; top: .55em; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.reasons li.more { color: var(--muted); }
.reasons li.more::before { display: none; }
.reasons.in-panel { margin: -4px 0 14px; gap: 4px; font-size: .86rem; columns: 2; display: block; }
.reasons.in-panel li { break-inside: avoid; margin-bottom: 4px; }

td .btn.sm { margin-left: 8px; }
.answered { margin-top: 4px; color: var(--ok-ink); font-size: .78rem; line-height: 1.4; }
tr.answer-row > td, tr.answer-row:hover > td { background: var(--surface-2); white-space: normal; border-left: 3px solid var(--warn-accent); padding: 18px 22px 20px; }
/* Kept in view while the wide table scrolls sideways. */
.answer-box { display: grid; gap: 18px; position: sticky; left: 22px;
  width: min(640px, calc(100vw - var(--sidebar-w) - 160px)); }
.question-text { margin: 0 0 12px; font-size: .92rem; font-weight: 600; line-height: 1.45; color: var(--ink); }
.opts { display: grid; gap: 8px; }
/* One answer per line: a bold action, its effect underneath. */
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  padding: 11px 16px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  transition: border-color var(--t-fast), background var(--t-fast);
}
button.choice:hover, .choice.active { border-color: var(--primary); background: var(--primary-soft); }
.choice-title { font-size: .88rem; font-weight: 600; line-height: 1.35; }
.choice-hint { font-size: .8rem; color: var(--muted); line-height: 1.4; }
.choice.quiet { background: transparent; border-style: dashed; }
.choice.quiet .choice-title { font-weight: 500; color: var(--ink-2); }
.choice.has-input { cursor: default; }
.choice-field { display: flex; gap: 8px; margin-top: 8px; width: 100%; }
.choice-field input { margin: 0; flex: 0 1 240px; min-width: 0; padding: 7px 10px; font-size: .86rem; }
.choice-field .btn { margin: 0; }
.bill-edit {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 14px; align-items: end;
  padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.bill-edit label { margin: 6px 0 0; font-size: .78rem; display: flex; flex-direction: column; color: var(--ink-2); }
.bill-edit input, .bill-edit select { margin-top: 4px; padding: 7px 10px; font-size: .86rem; }
.bill-edit .btn { margin-top: 10px; justify-self: start; }
.answer-error { margin: 0; color: var(--err-ink); font-weight: 600; }
.bill-edit label.flagged { color: var(--warn-ink); font-weight: 600; }
.bill-edit label.flagged input, .bill-edit label.flagged select { border-color: var(--warn-accent); background: var(--warn-bg); }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; justify-self: start; font-size: .84rem; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.bill-text { margin: 0; max-height: 280px; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font-family: var(--font-mono); font-size: .74rem; line-height: 1.5; white-space: pre-wrap; }

.subsection { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.subsection h3 { margin-top: 0; }

#progress:not(:empty) {
  display: flex; align-items: center; gap: 8px; margin-top: 14px !important;
  font-family: var(--font-mono); font-size: .76rem; color: var(--ink-2);
}
#progress:not(:empty)::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ===========================================================================
   Sign-in
   =========================================================================== */
.signin { margin-top: clamp(10px, 6vh, 70px); }
.signin .card { padding: clamp(26px, 5vw, 40px); box-shadow: var(--shadow-lg); }
.signin h1 { font-size: clamp(2.4rem, 6vw, 3.2rem); }
.signin-logo { margin: 0 0 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.signin-logo img { display: block; width: 168px; height: auto; }
.signin-logo .logo-dark { display: none; }
:root[data-theme="dark"] .signin-logo .logo-light { display: none; }
:root[data-theme="dark"] .signin-logo .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .signin-logo .logo-light { display: none; }
  :root:not([data-theme="light"]) .signin-logo .logo-dark { display: block; }
}

/* ===========================================================================
   Responsive
   =========================================================================== */
@media (max-width: 1040px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  body.is-authed { display: flex; flex-direction: column; }
  .sidebar {
    height: auto; flex-direction: row; align-items: center; gap: 4px;
    padding: 10px clamp(12px, 3vw, 20px);
  }
  .brand { padding: 0 6px 0 0; margin: 0; border: 0; }
  .brand .wordmark-name { font-size: 1.2rem; }
  .brand .wordmark-by { display: none; }
  .brand .brand-mark { width: 32px; height: 32px; }
  .sidenav { flex-direction: row; overflow-x: auto; margin-left: 8px; scrollbar-width: none; }
  .sidenav-label, .userchip { display: none; }
  .sidenav a { padding: 7px 10px; font-size: .84rem; }
  .sidenav a[aria-current="page"]::before { left: 10px; right: 10px; top: auto; bottom: -10px; width: auto; height: 2px; border-radius: 2px; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .sidebar-foot .spacer { display: none; }
}
@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 4px; }
  .doctype { flex-direction: column; }
  .downloads .btn, .actions .btn { flex: 1; }
  .sidenav a em, .brand .wordmark { display: none; }
  .sidenav a svg { display: none; }
}

/* ===========================================================================
   Reduced motion
   =========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
