/* =========================================================================
   여행사 기업 분석 대시보드 — Design System v2
   에디토리얼 + 분석 도구. Light/Dark 동기.
   ========================================================================= */

/* ---------------------------------------------------------- Tokens */
:root {
  /* Color — Light (default) */
  --bg:           #f7f6f1;          /* warm ivory */
  --bg-elev:      #fdfcf8;
  --surface:      #ffffff;
  --surface-2:   #faf9f4;
  --ink:          #11161f;          /* deep blue-black */
  --ink-2:        #2b313c;
  --sub:          #5b6573;
  --mute:         #8a92a0;
  --line:         #e6e3da;
  --line-strong:  #c8c4b6;
  --hover:        rgba(17, 22, 31, .04);

  --brand:        #1f3da8;          /* deep indigo — trust */
  --brand-2:      #2c52c8;
  --brand-soft:   #e8ecfb;
  --accent:       #c9601d;          /* warm coral — travel */
  --accent-2:     #e0792f;
  --accent-soft:  #fbeada;

  --ok:           #126b46;
  --ok-soft:      #d8ecdf;
  --warn:         #a25a08;
  --warn-soft:    #fbecd3;
  --danger:       #b8331f;
  --danger-soft:  #fadcd3;
  --info:         #0e6492;
  --info-soft:    #d8ecf8;

  /* Data viz palette (categorical, color-blind safe-ish) */
  --c1: #1f3da8;
  --c2: #c9601d;
  --c3: #126b46;
  --c4: #6e3aa6;
  --c5: #b8331f;
  --c6: #0e6492;
  --c7: #8a6b13;
  --c8: #4a5160;

  /* Typography */
  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --font-serif: "Source Serif Pro", "Iowan Old Style", "Apple Garamond", Georgia, serif;

  --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-15: 15px; --fs-16: 16px;
  --fs-18: 18px; --fs-20: 20px; --fs-24: 24px; --fs-28: 28px; --fs-34: 34px; --fs-44: 44px;

  /* Shape */
  --radius-xs: 6px; --radius: 10px; --radius-lg: 14px; --radius-xl: 22px;

  /* Shadow (very subtle, layered) */
  --shadow-1: 0 1px 0 rgba(17, 22, 31, .04), 0 1px 2px rgba(17, 22, 31, .04);
  --shadow-2: 0 1px 0 rgba(17, 22, 31, .04), 0 8px 24px -12px rgba(17, 22, 31, .12);
  --shadow-hover: 0 1px 0 rgba(17, 22, 31, .04), 0 16px 40px -16px rgba(17, 22, 31, .18);
  --shadow-focus: 0 0 0 3px var(--brand-soft);

  /* Spacing rhythm (4px) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 120ms;
  --t-base: 200ms;
  --t-slow: 320ms;

  color-scheme: light;
}

/* Dark theme — same tokens, different values */
[data-theme="dark"], html[data-theme="dark"] {
  --bg:           #0c1118;
  --bg-elev:      #11171f;
  --surface:      #141a23;
  --surface-2:    #181f2a;
  --ink:          #e8eef5;
  --ink-2:        #c5cdda;
  --sub:          #8e98a8;
  --mute:         #6c7484;
  --line:         #232b38;
  --line-strong:  #364152;
  --hover:        rgba(232, 238, 245, .05);

  --brand:        #7c97ff;
  --brand-2:      #98aeff;
  --brand-soft:   rgba(124, 151, 255, .14);
  --accent:       #f0a070;
  --accent-2:     #f3b58a;
  --accent-soft:  rgba(240, 160, 112, .15);

  --ok:           #5acd95;
  --ok-soft:      rgba(90, 205, 149, .14);
  --warn:         #e6b056;
  --warn-soft:    rgba(230, 176, 86, .15);
  --danger:       #ff7d6a;
  --danger-soft:  rgba(255, 125, 106, .15);
  --info:         #74c0e8;
  --info-soft:    rgba(116, 192, 232, .15);

  --c1: #7c97ff; --c2: #f0a070; --c3: #5acd95; --c4: #b08af2;
  --c5: #ff7d6a; --c6: #74c0e8; --c7: #d8b964; --c8: #8e98a8;

  --shadow-1: 0 1px 0 rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 1px 0 rgba(0, 0, 0, .35), 0 12px 30px -12px rgba(0, 0, 0, .55);
  --shadow-hover: 0 1px 0 rgba(0, 0, 0, .4), 0 20px 48px -18px rgba(0, 0, 0, .7);
  --shadow-focus: 0 0 0 3px var(--brand-soft);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1118; --bg-elev: #11171f; --surface: #141a23; --surface-2: #181f2a;
    --ink: #e8eef5; --ink-2: #c5cdda; --sub: #8e98a8; --mute: #6c7484;
    --line: #232b38; --line-strong: #364152; --hover: rgba(232, 238, 245, .05);
    --brand: #7c97ff; --brand-2: #98aeff; --brand-soft: rgba(124, 151, 255, .14);
    --accent: #f0a070; --accent-2: #f3b58a; --accent-soft: rgba(240, 160, 112, .15);
    --ok: #5acd95; --ok-soft: rgba(90, 205, 149, .14);
    --warn: #e6b056; --warn-soft: rgba(230, 176, 86, .15);
    --danger: #ff7d6a; --danger-soft: rgba(255, 125, 106, .15);
    --info: #74c0e8; --info-soft: rgba(116, 192, 232, .15);
    --c1: #7c97ff; --c2: #f0a070; --c3: #5acd95; --c4: #b08af2;
    --c5: #ff7d6a; --c6: #74c0e8; --c7: #d8b964; --c8: #8e98a8;
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------- Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: 1.55;
  font-feature-settings: "ss01", "ss02", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}

::selection { background: var(--brand-soft); color: var(--ink); }

a {
  color: var(--brand);
  text-decoration: none;
  border-radius: 4px;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--brand-2); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: inherit;
  border-radius: var(--radius-xs);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
button:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

input, select, textarea {
  font-family: inherit;
  font-size: var(--fs-13);
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
  transition: border var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
input:hover, select:hover { border-color: var(--line-strong); }
input:focus-visible, select:focus-visible {
  border-color: var(--brand);
  box-shadow: var(--shadow-focus);
}

code, .mono { font-family: var(--font-mono); font-size: .92em; }
.serif { font-family: var(--font-serif); }
small, .small { font-size: var(--fs-12); }
.muted { color: var(--sub); }
.dim { color: var(--mute); }
.center { text-align: center; }
.hidden { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- Layout */
.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--s-6) var(--s-5) var(--s-16);
}
@media (max-width: 720px) {
  .shell { padding: var(--s-5) var(--s-4) var(--s-12); }
}

.grid { display: grid; gap: var(--s-4); }
.grid-2 { display: grid; grid-template-columns: 1.1fr 1fr; gap: var(--s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }
@media (max-width: 920px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.stack > * + * { margin-top: var(--s-3); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }

/* ---------------------------------------------------------- Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--s-3) var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
  font-size: var(--fs-14);
}
.brand-mark .dot {
  width: 10px; height: 10px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  border-radius: 3px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 30%, transparent);
}
.brand-mark .small { color: var(--sub); font-weight: 500; letter-spacing: 0; }

.topnav {
  display: flex;
  gap: var(--s-1);
  align-items: center;
  flex-wrap: wrap;
}
.topnav a {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: var(--fs-13);
  color: var(--sub);
  font-weight: 500;
}
.topnav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.topnav a.active { background: var(--brand-soft); color: var(--brand); }

.theme-toggle {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: var(--sub);
}
.theme-toggle:hover { background: var(--hover); color: var(--ink); }
.theme-toggle .icon { width: 18px; height: 18px; }
[data-theme="light"] .theme-toggle .icon-moon,
:root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: inline-block; }
[data-theme="light"] .theme-toggle .icon-sun,
:root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }

/* ---------------------------------------------------------- Hero */
.hero {
  position: relative;
  margin-top: var(--s-6);
  padding: var(--s-8) var(--s-6);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(1200px 240px at 80% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    radial-gradient(900px 280px at 0% 100%, color-mix(in srgb, var(--brand) 20%, transparent), transparent 55%),
    linear-gradient(180deg, var(--bg-elev) 0%, var(--surface) 100%);
  border: 1px solid var(--line);
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--line) 50%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line) 50%, transparent) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(700px 240px at 50% 40%, #000 30%, transparent 80%);
  pointer-events: none;
  opacity: .55;
}
.hero > * { position: relative; }
.hero h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -.02em;
  line-height: 1.08;
  font-weight: 800;
  font-family: var(--font-sans);
}
.hero .eyebrow {
  display: inline-flex;
  align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sub);
  margin-bottom: 12px;
}
.hero .eyebrow::before {
  content: "";
  width: 18px; height: 1px;
  background: var(--line-strong);
}
.hero .sub {
  margin: 10px 0 0;
  color: var(--sub);
  font-size: var(--fs-15);
  max-width: 64ch;
}
.hero-meta {
  margin-top: var(--s-5);
  display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5);
  color: var(--sub);
  font-size: var(--fs-13);
}
.hero-meta strong { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------- Sections */
.section {
  margin-top: var(--s-10);
  scroll-margin-top: 88px;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.section-head h2 {
  font-size: var(--fs-20);
  letter-spacing: -.01em;
  margin: 0;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.section-head .index {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.section-head .count {
  font-size: var(--fs-13);
  color: var(--sub);
  font-weight: 500;
}
.section-desc {
  color: var(--sub);
  font-size: var(--fs-13);
  margin: -6px 0 var(--s-4);
}

/* ---------------------------------------------------------- Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
  transition: transform var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease),
              border-color var(--t-base) var(--ease);
}
.card.interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--line-strong);
}
.card.flat { box-shadow: none; }

/* ---------------------------------------------------------- KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-3);
}
.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4) var(--s-4) calc(var(--s-4) + 2px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: border-color var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.kpi:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.kpi::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent) 100%);
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
}
.kpi.ok::after,
.kpi.warn::after,
.kpi.danger::after { opacity: 1; }
.kpi.ok::after     { background: linear-gradient(90deg, var(--ok) 0%, var(--brand) 100%); }
.kpi.warn::after   { background: linear-gradient(90deg, var(--warn) 0%, var(--accent) 100%); }
.kpi.danger::after { background: linear-gradient(90deg, var(--danger) 0%, var(--accent-2) 100%); }
.kpi .head {
  display: flex; align-items: center; gap: 8px;
  color: var(--sub);
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: -.005em;
}
.kpi .head .icon {
  width: 16px; height: 16px;
  color: var(--mute);
}
.kpi.ok .head .icon     { color: var(--ok); }
.kpi.warn .head .icon   { color: var(--warn); }
.kpi.danger .head .icon { color: var(--danger); }
.kpi .value {
  font-size: var(--fs-24);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  word-break: keep-all;
}
.kpi.danger .value { color: var(--danger); }
.kpi .sub {
  font-size: var(--fs-12);
  color: var(--mute);
  margin-top: 2px;
  word-break: keep-all;
}

/* ---------------------------------------------------------- Pills / Badges / Dots */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: -.005em;
  background: var(--surface-2);
  color: var(--sub);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .85;
}
.pill.ok     { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.pill.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.brand  { background: var(--brand-soft);  color: var(--brand);  border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.muted  { background: var(--surface-2);   color: var(--sub);    border-color: var(--line); }
.pill.lg     { padding: 5px 12px; font-size: var(--fs-13); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--sub);
}

/* legacy alias for older JS — same as pill */
.badge { /* deprecated; use .pill */
  display: inline-flex;
  align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--fs-12);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--sub);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.ok     { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.badge.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.brand  { background: var(--brand-soft);  color: var(--brand);  border-color: transparent; }
.badge.muted  { background: var(--surface-2);   color: var(--sub); }

/* ---------------------------------------------------------- Toolbar */
.toolbar {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
  margin: var(--s-4) 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.toolbar .search {
  flex: 1;
  min-width: 220px;
  position: relative;
}
.toolbar .search input {
  width: 100%;
  padding-left: 36px;
  background: var(--surface-2);
}
.toolbar .search .icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--mute);
  pointer-events: none;
}

/* ---------------------------------------------------------- Company cards (index page) */
.company-card {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: var(--s-4);
  align-items: stretch;
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: var(--s-3);
  box-shadow: var(--shadow-1);
  transition: transform var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease),
              border-color var(--t-base) var(--ease);
  text-decoration: none;
  color: inherit;
}
.company-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--line-strong);
  text-decoration: none;
}
.company-card .accent {
  border-radius: 4px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--accent) 100%);
}
.company-card.is-closed .accent { background: linear-gradient(180deg, var(--danger) 0%, var(--accent-2) 100%); }
.company-card.is-paused .accent { background: linear-gradient(180deg, var(--warn) 0%, var(--accent) 100%); }
.company-card.is-unknown .accent { background: var(--line-strong); }
.company-card .body { min-width: 0; }
.company-card .title {
  font-size: var(--fs-18);
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
}
.company-card .meta {
  margin-top: 4px;
  color: var(--sub);
  font-size: var(--fs-13);
  display: flex; flex-wrap: wrap; gap: 10px;
}
.company-card .meta .sep { color: var(--mute); }
.company-card .stats {
  margin-top: 10px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.company-card .stats .chip .icon {
  width: 12px; height: 12px;
  opacity: .8;
}
.company-card .action {
  align-self: center;
  color: var(--brand);
  font-weight: 600;
  font-size: var(--fs-13);
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .company-card { grid-template-columns: 6px 1fr; }
  .company-card .action { display: none; }
}

/* ---------------------------------------------------------- HISTORY timeline */
.history-frame {
  position: relative;
  background:
    radial-gradient(800px 200px at 100% -20%, var(--brand-soft), transparent 70%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4);
  overflow-x: auto;
  box-shadow: var(--shadow-1);
}
#history-timeline {
  width: 100%;
  min-height: 280px;
  display: block;
}
#history-timeline .axis-line { stroke: var(--line-strong); }
#history-timeline .axis-tick { stroke: var(--line); }
#history-timeline .axis-label { fill: var(--mute); font-family: var(--font-mono); font-size: 11px; }
#history-timeline .event-stem { stroke-opacity: .55; stroke-width: 1.4; }
#history-timeline .event-dot {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .15));
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
  transform-box: fill-box;
  transform-origin: center;
}
#history-timeline .event-dot:hover { transform: scale(1.25); }
#history-timeline .event-label {
  fill: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
  pointer-events: none;
}
.timeline-tip {
  position: absolute;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 11px;
  border-radius: 8px;
  font-size: var(--fs-12);
  pointer-events: none;
  display: none;
  max-width: 320px;
  line-height: 1.5;
  z-index: 80;
  box-shadow: var(--shadow-2);
}
.timeline-tip strong { font-weight: 700; }
.timeline-tip small { color: color-mix(in srgb, var(--bg) 60%, transparent); display: block; margin-top: 4px; }

.legend {
  display: flex; flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 12px;
  font-size: var(--fs-12);
  color: var(--sub);
}
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ---------------------------------------------------------- Gov registry */
.gov-list { display: grid; gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.gov-row {
  display: grid;
  grid-template-columns: 140px 92px 1fr 100px;
  gap: var(--s-3);
  align-items: start;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
}
.gov-label {
  font-weight: 700;
  font-size: var(--fs-13);
}
.gov-name { font-weight: 600; }
.gov-detail {
  color: var(--sub);
  font-size: var(--fs-12);
  margin-top: 4px;
  line-height: 1.55;
}
.gov-date {
  color: var(--mute);
  font-size: var(--fs-12);
  font-family: var(--font-mono);
  text-align: right;
}
@media (max-width: 720px) {
  .gov-row { grid-template-columns: 1fr; gap: 6px; }
  .gov-date { text-align: left; }
}

/* ---------------------------------------------------------- Facts cards (multi-source) */
.facts-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
}
.facts-card + .facts-card { margin-top: var(--s-3); }
.facts-card h3 {
  margin: 0 0 var(--s-2);
  font-size: var(--fs-13);
  color: var(--sub);
  font-weight: 700;
  letter-spacing: -.005em;
  display: flex; align-items: center; gap: 6px;
}
.facts-card h3 .icon { width: 14px; height: 14px; }
.facts-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: var(--s-3);
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: var(--fs-13);
}
.facts-row:last-child { border-bottom: 0; }
.facts-row .value {
  font-variant-numeric: tabular-nums;
  word-break: keep-all;
}
.facts-row .link a {
  font-size: var(--fs-12);
  color: var(--sub);
}
.facts-conflict {
  margin-top: var(--s-2);
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: var(--fs-12);
  display: inline-flex; align-items: center; gap: 6px;
}
.facts-conflict .icon { width: 14px; height: 14px; }

/* ---------------------------------------------------------- Tables */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.data-table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  font-size: var(--fs-12);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--sub);
  font-weight: 700;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  user-select: none;
}
.data-table th[data-sort] { cursor: pointer; }
.data-table th[data-sort]:hover { color: var(--brand); }
.data-table th[data-sort][data-dir="asc"]::after  { content: " ↑"; color: var(--brand); }
.data-table th[data-sort][data-dir="desc"]::after { content: " ↓"; color: var(--brand); }
.data-table tbody td {
  padding: 11px 12px;
  font-size: var(--fs-13);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--hover); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.rank-cell {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--sub);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}
.rank-cell.gold   { background: linear-gradient(135deg, #ffd778, #f5a623); color: #5b3a02; box-shadow: inset 0 -2px 4px rgba(0,0,0,.15); }
.rank-cell.silver { background: linear-gradient(135deg, #e2e6eb, #b2bcc9); color: #38445a; box-shadow: inset 0 -2px 4px rgba(0,0,0,.15); }
.rank-cell.bronze { background: linear-gradient(135deg, #e2a472, #b97a44); color: #4b2807; box-shadow: inset 0 -2px 4px rgba(0,0,0,.15); }

.sparkbar {
  display: inline-grid;
  grid-template-columns: 64px auto;
  gap: 8px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}
.sparkbar .track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--line);
}
.sparkbar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent) 100%);
}

/* ---------------------------------------------------------- Products grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--s-3);
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.product-card .top {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px;
}
.product-card h3 {
  margin: 0;
  font-size: var(--fs-16);
  font-weight: 700;
  letter-spacing: -.01em;
}
.product-card .price {
  color: var(--accent);
  font-weight: 700;
  font-size: var(--fs-13);
  font-variant-numeric: tabular-nums;
}
.product-card .metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
}
.product-card .metrics div .n {
  display: block;
  font-size: var(--fs-18);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.product-card .metrics div .l {
  font-size: 11px;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.product-card .pages {
  display: flex; flex-direction: column; gap: 4px;
  font-size: var(--fs-12);
  color: var(--sub);
}
.product-card .pages a { color: var(--ink-2); font-weight: 500; }
.product-card .signals {
  display: flex; flex-wrap: wrap; gap: 4px;
}

/* ---------------------------------------------------------- Wayback panel */
.wayback-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
}
.wayback-card canvas { width: 100% !important; }
.wayback-paths { padding-top: 4px; }
.wayback-paths ul { margin: 8px 0 0; padding: 0; list-style: none; }
.wayback-paths li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: var(--fs-13);
}
.wayback-paths li:last-child { border-bottom: 0; }
.wayback-paths li .n {
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- Evidence Grid */
.evidence-frame {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-3);
  box-shadow: var(--shadow-1);
}
.evidence-frame .gridjs-wrapper { box-shadow: none; border: 1px solid var(--line); border-radius: 8px; }
.evidence-frame .gridjs-table { font-size: var(--fs-13); }
.evidence-frame .gridjs-th { background: var(--surface-2); color: var(--sub); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.evidence-frame .gridjs-td { border-bottom: 1px solid var(--line); padding: 9px 12px; }
.evidence-frame .gridjs-tr:last-child .gridjs-td { border-bottom: 0; }
.evidence-frame .gridjs-tr:hover { background: var(--hover) !important; }
.evidence-frame .gridjs-search-input { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.evidence-frame .gridjs-pages button { border-color: var(--line); color: var(--sub); }
.evidence-frame .gridjs-pages button.gridjs-currentPage { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--s-3);
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--sub);
  border-radius: 999px;
  padding: 7px 11px;
  font: inherit;
  font-size: var(--fs-13);
  cursor: pointer;
}
.filter-chip:hover,
.filter-chip.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: transparent;
}
.evidence-dash {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4);
}
.dash-block {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--s-4);
}
.dash-block h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 var(--s-3);
  font-size: var(--fs-14);
}
.source-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.source-card {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  min-height: 76px;
}
.source-card:hover,
.source-card.active {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  background: var(--brand-soft);
}
.source-card .label,
.source-card .count,
.source-card .sub {
  display: block;
}
.source-card .label {
  font-size: var(--fs-12);
  color: var(--sub);
  margin-bottom: 6px;
}
.source-card .count {
  font-size: var(--fs-20);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.source-card .sub {
  color: var(--mute);
  font-size: 11px;
  margin-top: 3px;
}
@media (max-width: 820px) {
  .evidence-dash { grid-template-columns: 1fr; }
}

.conf-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.conf-dot::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.conf-high { color: var(--ok); font-weight: 600; }
.conf-mid  { color: var(--warn); font-weight: 600; }
.conf-low  { color: var(--mute); }

/* ---------------------------------------------------------- States */
.state {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: var(--s-8) var(--s-4);
  color: var(--sub);
  text-align: center;
}
.state .icon { width: 28px; height: 28px; color: var(--mute); margin-bottom: 10px; }
.state.error { border-color: var(--danger-soft); color: var(--danger); background: color-mix(in srgb, var(--danger-soft) 50%, var(--surface)); }

/* Skeleton */
@keyframes shimmer { 0% { background-position: -240px 0; } 100% { background-position: 240px 0; } }
.skel {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--hover) 50%, var(--surface-2) 100%);
  background-size: 480px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px;
  display: inline-block;
}

/* ---------------------------------------------------------- Sticky TOC */
.toc {
  position: sticky;
  top: 64px;
  align-self: start;
  display: none;
  font-size: var(--fs-12);
}
@media (min-width: 1200px) {
  .layout-with-toc { display: grid; grid-template-columns: 1fr 200px; gap: var(--s-8); }
  .toc { display: block; }
}
.toc-inner {
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.toc-title {
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--mute);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}
.toc a {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--sub);
  text-decoration: none;
}
.toc a:hover { background: var(--hover); color: var(--ink); }
.toc a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* ---------------------------------------------------------- Footer */
.app-footer {
  margin-top: var(--s-16);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
  color: var(--mute);
  font-size: var(--fs-12);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-3);
}
.app-footer code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ---------------------------------------------------------- Animations */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in-up var(--t-slow) var(--ease) both; }
.fade-in-1 { animation-delay: 40ms; }
.fade-in-2 { animation-delay: 80ms; }
.fade-in-3 { animation-delay: 120ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------- Hero lifeline */
.hero-lifeline {
  margin-top: var(--s-6);
  padding: 16px 18px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
}
.hero-lifeline .lf-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--mute); font-family: var(--font-mono);
  margin-bottom: 8px;
}
.hero-lifeline svg { display: block; width: 100%; height: 56px; overflow: visible; }
.hero-lifeline .lf-axis { stroke: var(--line); }
.hero-lifeline .lf-track {
  stroke: url(#lfGrad); stroke-width: 3; stroke-linecap: round;
}
.hero-lifeline .lf-node {
  fill: var(--surface); stroke-width: 2;
  transition: transform var(--t-fast) var(--ease);
  transform-box: fill-box; transform-origin: center;
}
.hero-lifeline .lf-node:hover { transform: scale(1.25); }
.hero-lifeline .lf-label {
  fill: var(--ink-2); font-size: 11px; font-weight: 600;
  font-family: var(--font-sans);
}
.hero-lifeline .lf-year {
  fill: var(--mute); font-size: 10px;
  font-family: var(--font-mono);
}

/* Travel motif - faint airplane path in hero corner */
.hero .motif {
  position: absolute;
  top: 20px; right: 24px;
  width: 220px; height: 220px;
  color: var(--brand);
  opacity: .08;
  pointer-events: none;
}
.hero .motif svg { width: 100%; height: 100%; }
[data-theme="dark"] .hero .motif { opacity: .12; }

/* Editorial big display number for sections (alternative to .index pill) */
.section-display {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: var(--s-5);
  align-items: start;
  margin-top: var(--s-12);
}
.section-display .num {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 700;
  line-height: .92;
  letter-spacing: -.04em;
  color: transparent;
  -webkit-text-stroke: 1px var(--line-strong);
  background-clip: text;
  -webkit-background-clip: text;
}
.section-display .num em {
  font-style: normal;
  color: var(--ink);
  -webkit-text-stroke: 0;
}
.section-display .label {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 10px;
  color: var(--mute);
  font-family: var(--font-mono);
  margin-top: 8px;
}
@media (max-width: 720px) {
  .section-display { grid-template-columns: 1fr; gap: var(--s-2); }
  .section-display .num { font-size: 40px; }
}

/* KPI sparkline area inside card */
.kpi .spark {
  margin-top: 6px;
  height: 28px;
  width: 100%;
  display: block;
}
.kpi .spark path.line { fill: none; stroke: var(--brand); stroke-width: 1.6; stroke-linejoin: round; }
.kpi .spark path.area { fill: url(#sparkGrad); opacity: .35; }
.kpi.ok .spark path.line { stroke: var(--ok); }
.kpi.warn .spark path.line { stroke: var(--warn); }
.kpi.danger .spark path.line { stroke: var(--danger); }

/* Callout — editorial highlight box */
.callout {
  position: relative;
  padding: var(--s-5) var(--s-5) var(--s-5) var(--s-8);
  background: linear-gradient(180deg, var(--brand-soft) 0%, transparent 100%);
  border: 1px solid var(--brand-soft);
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: var(--fs-15);
  line-height: 1.6;
}
.callout::before {
  content: "";
  position: absolute;
  left: var(--s-3); top: 0; bottom: 0;
  width: 3px; border-radius: 3px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--accent) 100%);
}
.callout strong { color: var(--ink); font-weight: 700; }
.callout .label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 6px;
}

/* Section header with display number */
.section-head.editorial {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: var(--s-3);
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.section-head.editorial .num {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: 1;
  color: var(--ink);
}
.section-head.editorial .num span { color: var(--mute); }
.section-head.editorial h2 {
  font-size: var(--fs-20);
  font-weight: 700;
  margin: 0;
  letter-spacing: -.01em;
}
.section-head.editorial .count {
  color: var(--sub);
  font-size: var(--fs-13);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Header bar mini divider */
.divider-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--mute);
  font-size: var(--fs-12);
}
.divider-dot::before {
  content: "";
  width: 14px; height: 1px;
  background: var(--line-strong);
}
.divider-dot::after {
  content: "";
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
}

/* ---------------------------------------------------------- Print */
@media print {
  body { background: #fff; color: #000; }
  .topbar, .toolbar, .toc, .app-footer, .theme-toggle, .hero .motif { display: none !important; }
  .hero { background: none; border-color: #ccc; }
  .card, .kpi, .company-card, .facts-card,
  .product-card, .wayback-card, .evidence-frame, .data-table { box-shadow: none !important; }
}
