/* Landed — design system.
   Register: product. The tool disappears into the task.
   Scene: Malé, late, 61 days left on a 90-day contract, checking whether a quote still
   hits the pour date. Dark surface, dense data, risk legible at a glance. */

@font-face {
  font-family: "Plex Sans";
  src: url("/static/fonts/plex-sans-var.ttf") format("truetype-variations");
  font-weight: 100 700;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/static/fonts/plex-mono.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/static/fonts/plex-mono-medium.otf") format("opentype");
  font-weight: 500;
  font-display: swap;
}

:root {
  /* Surfaces: near-black tinted toward deep water, not neutral grey, not navy. */
  --bg:         oklch(0.155 0.018 235);
  --surface:    oklch(0.196 0.017 235);
  --surface-2:  oklch(0.238 0.016 235);
  --surface-3:  oklch(0.280 0.015 235);
  --line:       oklch(0.312 0.014 235);
  --line-soft:  oklch(0.252 0.012 235);

  --ink:        oklch(0.966 0.004 235);
  --ink-2:      oklch(0.802 0.010 235);
  --ink-3:      oklch(0.648 0.013 235);

  --accent:     oklch(0.800 0.135 195);
  --accent-dim: oklch(0.800 0.135 195 / 0.14);
  --accent-ink: oklch(0.175 0.035 195);

  /* Signal ramp. Reserved for schedule and compliance risk. Never decorative. */
  --ok:         oklch(0.744 0.130 165);
  --ok-dim:     oklch(0.744 0.130 165 / 0.14);
  --warn:       oklch(0.818 0.140 78);
  --warn-dim:   oklch(0.818 0.140 78 / 0.14);
  --late:       oklch(0.665 0.185 25);
  --late-dim:   oklch(0.665 0.185 25 / 0.16);

  --sans: "Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "Plex Mono", ui-monospace, SFMono-Regular, monospace;

  /* Fixed scale, ratio ~1.15. Product UI, not fluid display type. */
  --t-xs: 0.6875rem;
  --t-sm: 0.8125rem;
  --t-md: 0.9375rem;
  --t-lg: 1.0625rem;
  --t-xl: 1.3125rem;
  --t-2xl: 1.625rem;

  --sp-1: 0.25rem; --sp-2: 0.5rem;  --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.5rem;  --sp-6: 2rem;    --sp-7: 3rem;

  --r-sm: 4px; --r-md: 7px; --r-lg: 11px;

  --dur: 170ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --z-sticky: 100; --z-dropdown: 200; --z-backdrop: 300; --z-modal: 400; --z-toast: 500;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Every figure is mono and tabular so columns of money align on the decimal. */
.num, td.num, .money { font-family: var(--mono); font-variant-numeric: tabular-nums; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.011em; text-wrap: balance; }
h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }
p  { margin: 0 0 var(--sp-3); max-width: 68ch; text-wrap: pretty; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

.rail {
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  padding: var(--sp-4) var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-5);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  z-index: var(--z-sticky);
}
.brand { display: flex; align-items: baseline; gap: var(--sp-2); padding: 0 var(--sp-2);
  text-decoration: none; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; }
.brand span { font-size: var(--t-xs); color: var(--ink-3); font-family: var(--mono); }

.rail-foot { margin-top: auto; display: flex; flex-direction: column;
  align-items: flex-start; gap: var(--sp-2); padding: var(--sp-2); }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-5); }
.login-card {
  width: min(380px, 100%); background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: var(--sp-6);
}
.code-block {
  font-family: var(--mono); font-size: var(--t-sm); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--sp-3); overflow-x: auto; color: var(--accent);
}

/* ---------------------------------------------------------------- composer */
.composer {
  position: sticky; bottom: var(--sp-4); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--sp-3); margin-bottom: var(--sp-4);
  box-shadow: 0 8px 28px oklch(0.10 0.02 235 / 0.5);
}
.composer textarea {
  border: 0; background: transparent; font-family: var(--sans);
  font-size: var(--t-md); resize: none; padding: var(--sp-2);
}
.composer textarea:focus { box-shadow: none; }
.composer textarea:hover { border: 0; }
.composer-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); padding: 0 var(--sp-2);
}

/* Working state: the agent's actual steps, not a spinner that hides them. */
.msg.working { border-color: var(--accent); background: var(--accent-dim); }
.dots { display: inline-flex; gap: 4px; }
.dots i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: 0.18s; }
.dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.msg.working .trace li { list-style: none; margin-left: calc(var(--sp-5) * -1); }
.msg.working .trace li::before { content: "✓ "; color: var(--ok); }
.msg.working .trace li:last-child::before { content: "▸ "; color: var(--accent); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--ink-2); font-size: var(--t-sm); text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav .count {
  font-family: var(--mono); font-size: var(--t-xs);
  background: var(--surface-3); color: var(--ink-2);
  padding: 1px var(--sp-2); border-radius: 999px;
}
.nav a[aria-current="page"] .count { background: var(--accent); color: var(--accent-ink); }
.nav .count[data-tone="late"] { background: var(--late); color: oklch(0.16 0.02 25); }

.main { padding: var(--sp-5) var(--sp-6); max-width: 1500px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap;
}
.page-head .sub { color: var(--ink-3); font-size: var(--t-sm); margin: var(--sp-1) 0 0; }

/* Headline figures sit in a single dense strip, not a row of floating stat cards. */
.strip {
  display: flex; flex-wrap: wrap; gap: 0;
  border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden; margin-bottom: var(--sp-5);
}
.strip > div {
  padding: var(--sp-3) var(--sp-5);
  border-right: 1px solid var(--line-soft);
  border-top: 1px solid var(--line-soft);
  flex: 1 1 168px;
}
/* Only the first row's cells sit against the panel edge, so no stray top rule. */
.strip > div:nth-child(-n+4) { border-top: 0; }
.strip > div:last-child { border-right: 0; }
.strip dt { font-size: var(--t-xs); color: var(--ink-3); margin-bottom: 2px; }
.strip dd {
  margin: 0; font-family: var(--mono); font-size: var(--t-lg);
  font-variant-numeric: tabular-nums; font-weight: 500;
}
.strip dd small { font-size: var(--t-xs); color: var(--ink-3); font-weight: 400; }

/* ---------------------------------------------------------------- panel */
.panel {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-lg); margin-bottom: var(--sp-5); overflow: hidden;
}
.panel > header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line-soft);
}
.panel > header h2 { font-size: var(--t-md); }
.panel > header .hint { font-size: var(--t-xs); color: var(--ink-3); }
.panel-body { padding: var(--sp-4); }

/* ---------------------------------------------------------------- table */
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.scroll-x { overflow-x: auto; }
th {
  text-align: left; font-weight: 500; color: var(--ink-3); font-size: var(--t-xs);
  padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--surface);
}
td { padding: var(--sp-3); border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--dur) var(--ease); }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.t-strong { color: var(--ink); font-weight: 500; }
.t-dim { color: var(--ink-3); }
.t-sm { font-size: var(--t-xs); }

/* The winning row. One accent rail on the left of a table row is a table convention,
   not the banned decorative side-stripe on a card. */
tr.is-best td { background: var(--accent-dim); }
tr.is-best td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.is-blocked td { opacity: 0.55; }
tr.is-blocked .money { text-decoration: line-through; text-decoration-color: var(--late); }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 2px var(--sp-2); border-radius: var(--r-sm);
  font-size: var(--t-xs); font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
}
.badge[data-tone="ok"]      { background: var(--ok-dim);     color: var(--ok);     border-color: var(--ok); }
.badge[data-tone="warn"]    { background: var(--warn-dim);   color: var(--warn);   border-color: var(--warn); }
.badge[data-tone="late"]    { background: var(--late-dim);   color: var(--late);   border-color: var(--late); }
.badge[data-tone="accent"]  { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.badge[data-tone="mute"]    { background: var(--surface-2);  color: var(--ink-3);  border-color: var(--line); }

/* An estimated number must never look like a measured one. */
.est {
  border-bottom: 1px dashed var(--warn); cursor: help;
  text-decoration: none; color: inherit;
}

/* The flip marker: quoted rank -> landed rank. The signature moment of the tool. */
.flip {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--mono); font-size: var(--t-xs);
  color: var(--warn); white-space: nowrap;
}
.flip .was { color: var(--ink-3); text-decoration: line-through; }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-family: var(--sans); font-size: var(--t-sm); font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--ink-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.45; cursor: not-allowed; transform: none; background: var(--surface-2);
}
.btn[data-variant="primary"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.btn[data-variant="primary"]:hover { background: oklch(0.845 0.135 195); }
.btn[data-variant="danger"] { color: var(--late); border-color: var(--late); background: var(--late-dim); }
.btn[data-size="sm"] { padding: var(--sp-1) var(--sp-3); font-size: var(--t-xs); }

input[type="text"], input[type="number"], input[type="date"], input[type="file"],
input[type="password"], input[type="email"], input[type="search"],
select, textarea {
  width: 100%; padding: var(--sp-2) var(--sp-3);
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-md);
  font-family: var(--sans); font-size: var(--t-sm);
  transition: border-color var(--dur) var(--ease);
}
textarea { font-family: var(--mono); font-size: var(--t-sm); line-height: 1.6; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }
label { display: block; font-size: var(--t-xs); color: var(--ink-3); margin-bottom: var(--sp-1); }
.field { margin-bottom: var(--sp-3); }
.row { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .shrink { flex: 0 0 auto; }

/* ---------------------------------------------------------------- messages */
.msg {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  margin-bottom: var(--sp-3); border: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.msg[data-dir="out"] { background: var(--surface-2); }
.msg[data-dir="in"]  { background: var(--bg); }
.msg .meta {
  display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap;
  font-size: var(--t-xs); color: var(--ink-3); margin-bottom: var(--sp-2);
}
.msg pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: var(--t-sm); line-height: 1.6; color: var(--ink-2);
}

/* Supplier text is untrusted. It is visually quarantined so it never reads as system copy. */
.msg[data-dir="in"] pre {
  border-left: 1px solid var(--line); padding-left: var(--sp-3); color: var(--ink-2);
}

/* ---------------------------------------------------------------- states */
/* Agent trace: what it actually did, not a spinner that hides the work. */
.trace { margin: var(--sp-2) 0 0; padding-left: var(--sp-5); font-size: var(--t-sm); }
.trace li { margin-bottom: var(--sp-1); color: var(--ink-2); }
.trace code {
  font-family: var(--mono); font-size: var(--t-xs);
  background: var(--surface-3); padding: 1px var(--sp-2);
  border-radius: var(--r-sm); color: var(--accent); margin-right: var(--sp-2);
}

.reply { font-size: var(--t-sm); line-height: 1.62; color: var(--ink); }
.reply p { margin: 0 0 var(--sp-2); max-width: 74ch; }
.reply ul { margin: 0 0 var(--sp-3); padding-left: var(--sp-5); }
.reply li { margin-bottom: var(--sp-1); max-width: 72ch; }
.reply strong { color: var(--ink); font-weight: 600; }
.reply code {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--surface-3); padding: 1px 5px; border-radius: var(--r-sm);
}

.examples { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; }
.examples .btn { text-align: left; max-width: 340px; }

/* Research brief: an option's grade must be readable before its price. */
.alt {
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); margin-bottom: var(--sp-3); background: var(--surface-2);
}
.alt header { display: flex; align-items: center; gap: var(--sp-2);
  flex-wrap: wrap; margin-bottom: var(--sp-2); }
.alt h4 { margin: 0; font-size: var(--t-sm); font-weight: 600; }
.alt .why { font-size: var(--t-sm); color: var(--ink-2); margin-bottom: var(--sp-2); max-width: 76ch; }
.alt .risk { font-size: var(--t-xs); color: var(--warn); margin-bottom: 2px; }
.alt .ask { font-size: var(--t-xs); color: var(--ink-3); }

.empty { padding: var(--sp-7) var(--sp-5); text-align: center; color: var(--ink-3); }
.empty h3 { color: var(--ink-2); margin-bottom: var(--sp-2); }
.empty p { margin: 0 auto var(--sp-4); max-width: 46ch; font-size: var(--t-sm); }

.notice {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: var(--t-sm); margin-bottom: var(--sp-4);
}
.notice[data-tone="warn"] { border-color: var(--warn); background: var(--warn-dim); color: var(--ink); }
.notice[data-tone="late"] { border-color: var(--late); background: var(--late-dim); color: var(--ink); }
.notice[data-tone="ok"]   { border-color: var(--ok);   background: var(--ok-dim);   color: var(--ink); }
.notice b { color: var(--ink); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; border-radius: var(--r-sm); height: 1em;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -135% 0; } }

.bar { height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px;
  transition: width 400ms var(--ease); }
.bar > i[data-tone="ok"]   { background: var(--ok); }
.bar > i[data-tone="warn"] { background: var(--warn); }
.bar > i[data-tone="late"] { background: var(--late); }

details > summary {
  cursor: pointer; font-size: var(--t-xs); color: var(--ink-3);
  padding: var(--sp-1) 0; list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; }
details[open] > summary::before { content: "▾ "; }
details > summary:hover { color: var(--ink-2); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--sp-4); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2) var(--sp-4); font-size: var(--t-sm); }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center;
          overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .nav { flex-direction: row; }
  .main { padding: var(--sp-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .skeleton { animation: none; background: var(--surface-2); }
}
