/* SIGNAL — Spec Plate design system (Blue Crane Works).
   Square geometry, hairline structure, Archivo + IBM Plex Mono.
   Color is information: gold = brand only (never data), green = strong band,
   slate = review band, red = deadline urgency. Light is the primary theme;
   dark follows the OS via prefers-color-scheme. */

:root {
  --ground: #F4F3EF;
  --surface: #FFFFFF;
  --ink: #1C1B16;
  --ink-2: #5C5849;
  --ink-3: #8A8574;
  --line: #D8D5C9;
  --line-strong: #1C1B16;
  --gold: #B8920A;
  --gold-ink: #8A6D06;
  --good: #1E7A44;
  --good-tint: #E4F0E8;
  --review: #6E7480;
  --review-tint: #ECEDEF;
  --urgent: #B42318;
  --urgent-tint: #F7E7E5;
  --row-hover: #FAF9F5;

  --font-sans: 'Archivo', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Cascadia Mono', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #14130F;
    --surface: #1D1B15;
    --ink: #ECE9DD;
    --ink-2: #A8A392;
    --ink-3: #7A7565;
    --line: #383426;
    --line-strong: #ECE9DD;
    --gold: #D6AE1E;
    --gold-ink: #D6AE1E;
    --good: #55B97E;
    --good-tint: #1E2E24;
    --review: #9AA0AC;
    --review-tint: #262932;
    --urgent: #E5766B;
    --urgent-tint: #362019;
    --row-hover: #232017;
  }
}

* { box-sizing: border-box; border-radius: 0; }

/* Keep the hidden attribute working on elements whose class sets a display
   (e.g. .auth-form is display:flex; author rules beat the UA's [hidden]). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
}

h1, h2, h3 { margin: 0; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, label:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* ---- top bar / brand ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 20px 14px;
  border-bottom: 2px solid var(--line-strong);
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.38em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark span { color: var(--gold); }
.wordmark small {
  display: block;
  letter-spacing: 0.14em;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-3);
  margin-top: 2px;
  text-transform: uppercase;
}

.topbar__side { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.chip {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: var(--surface);
  white-space: nowrap;
}
.chip--pending { color: var(--ink-3); }
.chip--green { color: var(--good); border-color: var(--good); background: var(--good-tint); }
.chip--amber { color: var(--gold-ink); border-color: var(--gold); background: var(--surface); cursor: help; }

.btn-quiet {
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 5px 12px;
  cursor: pointer;
}
.btn-quiet:hover { color: var(--ink); border-color: var(--ink-3); }

/* ---- layout ---- */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

/* ---- identity strip ---- */

.identity {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
}
.identity b { color: var(--ink); font-weight: 600; }
.identity .identity__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---- stat tiles ---- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 26px 0 0;
  border: 1px solid var(--line);
  background: var(--surface);
}
.stat { padding: 14px 16px 12px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.stat__value {
  font-size: 30px;
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.stat__value--good { color: var(--good); }
.stat__value--urgent { color: var(--urgent); }

/* ---- filter row ---- */

.deskrow {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 34px 0 10px;
  flex-wrap: wrap;
}

.deskrow h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.deskrow h2 .count { color: var(--ink-3); font-weight: 500; }

.filters { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

.seg { display: flex; }
.seg button {
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left-width: 0;
  padding: 5px 12px;
  cursor: pointer;
}
.seg button:first-child { border-left-width: 1px; }
.seg button[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--gold);
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.filter select {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 5px 10px;
  font-size: 12.5px;
  font-family: var(--font-sans);
}

/* ---- match rows ---- */

.matches {
  border: 1px solid var(--line);
  background: var(--surface);
}

.match {
  display: grid;
  grid-template-columns: 5px 108px minmax(0, 1fr) 170px 46px;
  gap: 0 16px;
  align-items: stretch;
  border-top: 1px solid var(--line);
}
.match:first-child { border-top: 0; }
.match:hover { background: var(--row-hover); }

.match__stripe { background: var(--review); }
.match[data-band="strong"] .match__stripe { background: var(--good); }

.match__band {
  align-self: center;
  justify-self: start;
  margin-left: 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  color: var(--ink);
  background: var(--review-tint);
  border: 1px solid var(--review);
  white-space: nowrap;
}
.match[data-band="strong"] .match__band { background: var(--good-tint); border-color: var(--good); }

.match__body { padding: 13px 0 12px; min-width: 0; }
.match__title { font-size: 15px; font-weight: 600; }
.match__title a { color: inherit; text-decoration: none; }
.match__title a:hover {
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
}
.match__buyer { font-size: 12.5px; color: var(--ink-2); margin: 1px 0 0; }

.match__why {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  margin: 6px 0 0;
  overflow-wrap: break-word;
}
.match__why .ai { color: var(--gold-ink); font-weight: 600; }

.match__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--ink-3);
  border: 1px solid var(--line);
  padding: 1px 7px;
}

.badge--danger {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--urgent);
  background: var(--urgent-tint);
  border: 1px solid var(--urgent);
  padding: 2px 7px;
}

.match__close {
  align-self: center;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.match__date { font-size: 12.5px; color: var(--ink-2); }
.match__days {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.match__days--urgent {
  border-color: var(--urgent);
  color: var(--urgent);
  background: var(--urgent-tint);
}

.watch-toggle {
  align-self: center;
  justify-self: end;
  margin-right: 14px;
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-3);
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.watch-toggle:hover { border-color: var(--gold); color: var(--gold); }
.watch-toggle.is-watched { color: var(--gold); border-color: var(--gold); }

/* Dense mode: long lists collapse each row to one line; click a row to open it.
   Applied by app.js when the visible list is large. */
.matches.is-dense .match__body { padding: 8px 0 7px; }
.matches.is-dense .match__title { font-size: 13.5px; }
.matches.is-dense .match:not(.is-open) .match__body {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.matches.is-dense .match:not(.is-open) .match__title {
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.matches.is-dense .match:not(.is-open) .match__buyer {
  flex: 1 0 auto;
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
}
.matches.is-dense .match:not(.is-open) .match__why,
.matches.is-dense .match:not(.is-open) .match__tags,
.matches.is-dense .match:not(.is-open) .badge--danger { display: none; }
.matches.is-dense .match { cursor: pointer; }
.matches.is-dense .match__band { font-size: 9px; padding: 2px 6px; }
.matches.is-dense .match__date { font-size: 11.5px; }

.empty {
  color: var(--ink-3);
  text-align: center;
  padding: 48px 0;
}

/* ---- footer ---- */

.pagefoot {
  margin-top: 30px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ---- forms (shared: auth + onboarding) ---- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-2);
}

.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="password"],
.field select {
  background: var(--ground);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 8px 10px;
  font-size: 14px;
  font-family: var(--font-sans);
}
.field input:focus, .field select:focus { outline: 2px solid var(--gold); outline-offset: 0; }
.field input[type="range"] { accent-color: var(--gold); }
.field output { font-family: var(--font-mono); color: var(--gold-ink); }

.field-hint {
  color: var(--ink-3);
  text-transform: none;
  letter-spacing: normal;
  font-family: var(--font-sans);
  font-size: 12px;
}

.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }

.form-error {
  color: var(--urgent);
  background: var(--urgent-tint);
  border: 1px solid var(--urgent);
  padding: 10px 14px;
  font-size: 13px;
  margin: 0;
}

.form-notice {
  color: var(--good);
  background: var(--good-tint);
  border: 1px solid var(--good);
  padding: 10px 14px;
  font-size: 13px;
  margin: 0 0 4px;
}

.auth-resend {
  align-self: flex-start;
  margin: 4px 0;
}

.btn-primary {
  align-self: flex-start;
  background: var(--gold);
  color: #1A1400;
  border: 1px solid var(--gold);
  padding: 11px 24px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- login / signup ---- */

.auth-page {
  padding: 48px 20px 64px;
  max-width: 420px;
  margin: 0 auto;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 2px solid var(--line-strong);
  padding: 24px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.auth-tab:hover { color: var(--ink); }
.auth-tab.is-active { color: var(--ink); font-weight: 600; border-bottom-color: var(--gold); }

.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-form .btn-primary { margin-top: 16px; align-self: stretch; text-align: center; }

/* ---- onboarding ---- */

.onboarding {
  padding: 24px 20px 64px;
  max-width: 720px;
  margin: 0 auto;
}

.onboard-intro h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.onboard-intro p { color: var(--ink-2); margin: 0 0 28px; line-height: 1.5; max-width: 60ch; }

.onboard-form { display: flex; flex-direction: column; gap: 24px; }

.onboard-fieldset {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 18px 20px;
  margin: 0;
}

.onboard-fieldset legend {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-ink);
  font-weight: 600;
  padding: 0 6px;
}

.trade-groups { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.trade-group__title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 8px;
}
.trade-group__options { display: flex; flex-wrap: wrap; gap: 8px; }

.trade-chip {
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 6px 12px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.trade-chip:hover { border-color: var(--ink-3); color: var(--ink); }
.trade-chip.is-selected {
  color: var(--ink);
  font-weight: 600;
  border-color: var(--gold);
  box-shadow: inset 0 -2px 0 var(--gold);
}
.trade-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.certs-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.certs-list:empty { margin-bottom: 0; }

.cert-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  padding: 4px 6px 4px 12px;
}
.cert-tag__remove {
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
}
.cert-tag__remove:hover { color: var(--urgent); }

.certs input[type="text"] {
  background: var(--ground);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 8px 10px;
  font-size: 14px;
  font-family: var(--font-sans);
  width: 100%;
}

/* ---- responsive ---- */

@media (max-width: 720px) {
  .match { grid-template-columns: 5px minmax(0, 1fr) 46px; }
  .match__band { grid-column: 2; margin: 12px 0 0 0; }
  .match__body { grid-column: 2; padding-top: 8px; }
  .match__close { grid-column: 2; text-align: left; padding-bottom: 12px; align-self: start; }
  .watch-toggle { grid-row: 1; grid-column: 3; margin-top: 12px; align-self: start; }
}
