/* ============================================================
   PROJECT PRISM — Design System
   Humanist, modern, enterprise tax. Indigo "Prism" accent.
   Red/green reserved ONLY for VAT data semantics.
   ============================================================ */

:root {
  /* Type */
  --font-sans: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  /* Neutral surfaces — warm, low chroma */
  --bg:        oklch(0.985 0.003 95);
  --surface:   oklch(1 0 0);
  --surface-2: oklch(0.975 0.004 95);
  --surface-3: oklch(0.955 0.005 95);
  --border:    oklch(0.915 0.004 95);
  --border-2:  oklch(0.86 0.005 95);

  /* Text */
  --text:      oklch(0.255 0.012 275);
  --text-2:    oklch(0.475 0.012 275);
  --text-3:    oklch(0.62 0.011 275);

  /* Accent — Prism indigo (overridable per theme) */
  --accent:      oklch(0.55 0.19 285);
  --accent-2:    oklch(0.48 0.2 285);
  --accent-soft: oklch(0.95 0.04 285);
  --accent-ring: oklch(0.55 0.19 285 / 0.28);
  --on-accent:   oklch(0.99 0.01 285);

  /* VAT semantics — do not theme these */
  --valid:      oklch(0.6 0.13 152);
  --valid-soft: oklch(0.95 0.05 152);
  --ignore:     oklch(0.585 0.18 25);
  --ignore-soft:oklch(0.955 0.04 30);
  /* Region preview: the field-name (header) row is purple, distinct from data (green) and
     excluded (red), and stable regardless of the themeable accent. */
  --fieldhead:     oklch(0.55 0.2 300);
  --fieldhead-soft:oklch(0.95 0.045 305);
  --warn:       oklch(0.72 0.14 72);
  --warn-soft:  oklch(0.96 0.05 80);
  --info:       oklch(0.6 0.12 245);
  --info-soft:  oklch(0.95 0.04 245);

  /* Geometry */
  --r-sm: 6px;
  --r:    9px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Spacing scale baseline (density-tweakable) */
  --density: 1;
  --row-h: 38px;

  /* Shadows — soft, modern */
  --sh-1: 0 1px 2px oklch(0.2 0.02 275 / 0.05), 0 1px 1px oklch(0.2 0.02 275 / 0.04);
  --sh-2: 0 2px 4px oklch(0.2 0.02 275 / 0.05), 0 4px 12px oklch(0.2 0.02 275 / 0.06);
  --sh-3: 0 8px 24px oklch(0.2 0.02 275 / 0.1), 0 2px 6px oklch(0.2 0.02 275 / 0.06);
  --sh-pop: 0 12px 40px oklch(0.2 0.02 275 / 0.16), 0 4px 10px oklch(0.2 0.02 275 / 0.08);
}

/* Accent themes */
[data-accent="slate"] {
  --accent: oklch(0.52 0.12 250); --accent-2: oklch(0.45 0.13 250);
  --accent-soft: oklch(0.95 0.03 250); --accent-ring: oklch(0.52 0.12 250 / 0.28);
}
[data-accent="teal"] {
  --accent: oklch(0.54 0.1 195); --accent-2: oklch(0.47 0.11 195);
  --accent-soft: oklch(0.95 0.03 195); --accent-ring: oklch(0.54 0.1 195 / 0.28);
}
[data-accent="violet"] {
  --accent: oklch(0.55 0.19 285); --accent-2: oklch(0.48 0.2 285);
  --accent-soft: oklch(0.95 0.04 285); --accent-ring: oklch(0.55 0.19 285 / 0.28);
}

[data-density="compact"] { --row-h: 32px; --density: 0.82; }
[data-density="comfy"]   { --row-h: 44px; --density: 1.15; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { height: 100%; }
::selection { background: var(--accent-soft); }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
h1,h2,h3,h4,h5 { margin: 0; font-weight: 650; letter-spacing: -0.013em; color: var(--text); }
p { margin: 0; }
a { color: inherit; }

.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-feature-settings: "ss01"; }

/* Scrollbars */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: var(--r);
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em;
  border: 1px solid transparent; background: transparent; color: var(--text);
  transition: background .14s, border-color .14s, box-shadow .14s, transform .08s, color .14s;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--sh-1); }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { background: var(--surface-3); color: var(--text-3); box-shadow: none; cursor: not-allowed; }
.btn-secondary { background: var(--surface); border-color: var(--border-2); color: var(--text); box-shadow: var(--sh-1); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn-secondary:disabled { color: var(--text-3); cursor: not-allowed; opacity: .6; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--surface); border-color: var(--border-2); color: var(--ignore); box-shadow: var(--sh-1); }
.btn-danger:hover { background: var(--ignore-soft); border-color: var(--ignore); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-icon.btn-sm { width: 30px; height: 30px; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--text-2); letter-spacing: -0.003em; }
.hint { font-size: 12px; color: var(--text-3); }
.input, .select {
  height: 40px; padding: 0 13px; border-radius: var(--r);
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  font-size: 14px; transition: border-color .14s, box-shadow .14s; width: 100%;
}
textarea.input { height: auto; padding: 10px 13px; resize: vertical; min-height: 76px; line-height: 1.5; }
.input::placeholder { color: var(--text-3); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--accent-ring); }
.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='%2375707c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px; cursor: pointer; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-pad { padding: 20px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.01em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-neutral { background: var(--surface-3); color: var(--text-2); border-color: var(--border-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent-2); }
.badge-valid { background: var(--valid-soft); color: oklch(0.45 0.13 152); }
.badge-ignore { background: var(--ignore-soft); color: oklch(0.5 0.18 25); }
.badge-warn { background: var(--warn-soft); color: oklch(0.5 0.14 60); }
.badge-info { background: var(--info-soft); color: oklch(0.47 0.12 245); }

/* ---------- Misc utility ---------- */
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }
.vdivider { width: 1px; background: var(--border); align-self: stretch; }
.muted { color: var(--text-2); }
.muted-3 { color: var(--text-3); }
.kbd { font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 5px; background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text-2); }

.fade-in { animation: fadeIn .3s cubic-bezier(.2,.8,.2,1); }
@keyframes fadeIn { from { transform: translateY(7px); } to { transform: none; } }
.pop-in { animation: popIn .18s cubic-bezier(.2,.8,.2,1); }
@keyframes popIn { from { transform: scale(.98); } to { transform: none; } }

/* scrim */
.scrim { position: fixed; inset: 0; background: oklch(0.2 0.02 275 / 0.32); backdrop-filter: blur(2px); z-index: 60; animation: fadeIn .16s ease forwards; }

/* progress bar */
.pbar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.pbar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
/* Indeterminate variant: a sliding sliver when the total is unknown (e.g. an unknown row count). */
.pbar-indeterminate { position: relative; }
.pbar-indeterminate > span { position: absolute; width: 40%; transition: none; animation: pbar-slide 1.1s ease-in-out infinite; }
@keyframes pbar-slide { 0% { left: -42%; } 100% { left: 100%; } }

/* logo marquee (auth) */
.marquee { overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.marquee-track { display: inline-flex; gap: 44px; white-space: nowrap; animation: marquee 26s linear infinite; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- Responsive layout helpers ---------- */
.row-stats { display: grid; gap: 16px; grid-template-columns: repeat(4, 1fr); }
.split-main { display: grid; gap: 20px; grid-template-columns: 1.55fr 1fr; align-items: start; }
.split-even { display: grid; gap: 22px; grid-template-columns: 1.5fr 1fr; align-items: start; }
.scroll-x { overflow-x: auto; }
@media (max-width: 1180px) {
  .row-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 980px) {
  .split-main, .split-even { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .row-stats { grid-template-columns: 1fr; }
}

.map-layout { display: grid; gap: 20px; grid-template-columns: 1fr 300px; align-items: start; }
@media (max-width: 1080px) {
  .map-layout { grid-template-columns: 1fr; }
}

/* Nav + row hover (CSS-based, avoids React imperative-style residue) */
.navitem { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r); border: none; background: transparent; color: var(--text-2); font-weight: 550; font-size: 13.5px; transition: background .12s, color .12s; width: 100%; text-align: left; cursor: pointer; }
.navitem:hover { background: var(--surface-3); }
.navitem.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 650; }
.navitem.active:hover { background: var(--accent-soft); }
.navitem-top { width: auto; }
.rowbtn { width: 100%; text-align: left; border: none; background: transparent; transition: background .12s; cursor: pointer; }
.rowbtn:hover { background: var(--surface-2); }
.st-resize::after { content: ""; position: absolute; top: 12px; bottom: 12px; right: 7px; width: 2px; border-radius: 2px; background: transparent; transition: background .12s; }
.st-resize:hover::after { background: var(--accent); }

/* ---------- Screen-size gate (phones) ----------
   Prism is built for tablet/PC. On phone-sized viewports we hide the app (#root)
   and show a polite "not available on small screens" page instead. Pure CSS so it
   works before JS loads and reacts to orientation changes. Blocked when:
     - width < 768px (portrait phones / narrow windows), OR
     - height <= 499px AND width <= 932px (a phone in landscape, but not a wide
       desktop window that merely happens to be short). */
#mobile-gate { display: none; }

@media (max-width: 767px), (max-height: 499px) and (max-width: 932px) {
  #root { display: none !important; }
  #mobile-gate {
    display: flex;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    background: linear-gradient(155deg, var(--accent-2), var(--accent));
    font-family: var(--font-sans);
    color: var(--on-accent);
    z-index: 9999;
  }
  .mobile-gate__card {
    width: 100%;
    max-width: 380px;
    margin: auto;
    text-align: center;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-3);
    padding: 34px 28px;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }
  .mobile-gate__logo {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; margin-bottom: 20px;
  }
  .mobile-gate__word { font-weight: 750; font-size: 18.5px; letter-spacing: -0.02em; color: white; }
  #mobile-gate h1 {
    font-size: 20px; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 10px; color: white;
  }
  .mobile-gate__lead {
    font-size: 14.5px; line-height: 1.55; color: white; opacity: 0.82; margin: 0;
  }
  .mobile-gate__about { margin-top: 24px; }
  .mobile-gate__tagline {
    font-size: 16px; font-weight: 700; line-height: 1.25; letter-spacing: -0.018em; color: white; margin: 0;
  }
  .mobile-gate__desc {
    font-size: 13.5px; line-height: 1.55; color: white; opacity: 0.84; margin: 10px 0 0;
  }
  .mobile-gate__desc b { opacity: 1; font-weight: 700; }
  .mobile-gate__stats {
    list-style: none; margin: 22px 0 0; padding: 0;
    display: flex; justify-content: center; gap: 18px;
  }
  .mobile-gate__stats li { display: flex; flex-direction: column; }
  .mobile-gate__stat-n { font-weight: 700; font-size: 15px; color: white; }
  .mobile-gate__stat-l { font-size: 11.5px; color: white; opacity: 0.7; line-height: 1.25; margin-top: 2px; }
  .mobile-gate__foot { margin-top: 26px; font-size: 12px; color: white; opacity: 0.6; }

  @media (max-height: 560px) {
    .mobile-gate__card { padding: 22px 24px; }
    .mobile-gate__logo { margin-bottom: 14px; }
    .mobile-gate__about { margin-top: 16px; }
    .mobile-gate__stats { margin-top: 14px; gap: 14px; }
    .mobile-gate__foot { margin-top: 16px; }
  }
}
