:root {
  --bg: #efeae0;
  --raised: #f7f4ee;
  --ink: #1a1814;
  --muted: #6d655c;
  --line: #ddd4c6;
  --green: #1f6b4a;
  --green-soft: #e4f2ea;
  --amber: #8a5a12;
  --amber-soft: #f8ecd4;
  --rust: #8d3d32;
  --rust-soft: #f8e6e2;
  --blue: #234e70;
  --blue-soft: #e4eef5;
  --shadow: 0 24px 60px rgba(40, 30, 10, 0.08);
  color-scheme: light;
  font-family: "Segoe UI", Candara, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(1100px 420px at 0% -10%, #f8f4ec, transparent 55%),
    var(--bg);
}

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.hidden { display: none !important; }

.boot, .noscript {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

h1, h2, legend {
  font-family: Georgia, "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  font-weight: 500;
  letter-spacing: -0.03em;
}

h1 { font-size: 34px; line-height: 1; margin: 0; }
h2 { font-size: 28px; margin: 0; }

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.lede { margin: 8px 0 0; color: var(--muted); line-height: 1.45; }

.mono { font-family: Consolas, "Courier New", monospace; color: var(--ink); }

.primary, .quiet {
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid transparent;
}

.primary {
  background: var(--ink);
  color: #f7f4ee;
}

.primary:hover { background: #2a2621; }

.quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.quiet:hover { background: rgba(255, 255, 255, 0.55); }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card, dialog {
  width: min(440px, 100%);
  background: var(--raised);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px;
}

.gate-card h1 { margin-bottom: 8px; }

.field { display: grid; gap: 6px; margin-top: 16px; }

.field-label, legend {
  font-size: 13px;
  color: var(--muted);
}

legend { padding: 0; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 8px;
  padding: 9px 10px;
}

textarea { resize: vertical; }

.error {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--rust);
  font-size: 14px;
}

.gate .primary { margin-top: 14px; }

.app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 2px solid var(--ink);
}

.header-actions, .form-actions, .sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.new-count {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.banner {
  margin: 0;
  padding: 6px 10px;
  background: var(--amber-soft);
  color: var(--amber);
  border-radius: 999px;
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 380px;
  min-height: 0;
}

body[data-mode="buybox"] .workspace {
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar, #ledger, #detail, #buybox {
  min-height: 0;
  overflow: auto;
}

.sidebar {
  padding: 16px;
  border-right: 1px solid var(--line);
}

.filter {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
}

.filter.on { background: var(--ink); color: var(--raised); }

.filter .count { font-variant-numeric: tabular-nums; color: inherit; opacity: 0.75; }

.buybox-card {
  width: 100%;
  margin-top: 18px;
  text-align: left;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.buybox-card.on { box-shadow: inset 3px 0 0 var(--green); }

.buybox-regions { line-height: 1.35; }

.buybox-meta { color: var(--muted); font-size: 13px; }

.ledger-bar, .sheet-head {
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.ledger-bar { display: flex; align-items: center; gap: 12px; }

#search { max-width: 260px; }

.row {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "pill title"
    "pill meta";
  column-gap: 10px;
  row-gap: 2px;
  padding: 12px 16px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.row:hover { background: rgba(255, 255, 255, 0.45); }

.row[aria-pressed="true"] {
  background: var(--raised);
  box-shadow: inset 3px 0 0 var(--green);
}

.row.passed { opacity: 0.72; }

.pill {
  grid-area: pill;
  align-self: start;
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 999px;
}

.pill.new { background: var(--amber-soft); color: var(--amber); }
.pill.watching { background: var(--blue-soft); color: var(--blue); }
.pill.offer { background: var(--green-soft); color: var(--green); }
.pill.passed { background: var(--rust-soft); color: var(--rust); }

.row-title { grid-area: title; font-weight: 600; }

.row-meta { grid-area: meta; }

.row-meta, .meta { color: var(--muted); font-size: 13px; }

.empty {
  margin: 24px 16px;
  color: var(--muted);
}

#detail {
  background: var(--raised);
  border-left: 1px solid var(--line);
}

.detail-empty, #detail-body, .sheet { padding: 22px; }

.sheet { max-width: 720px; }

.why {
  margin: 16px 0;
  padding: 12px 14px;
  border-left: 3px solid var(--green);
  background: var(--green-soft);
}

.summary { line-height: 1.5; }

.segment {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0;
}

.segment button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 6px 10px;
}

.segment button.on {
  background: var(--ink);
  color: var(--raised);
  border-color: var(--ink);
}

.link {
  color: var(--blue);
  word-break: break-all;
}

fieldset {
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.checks { display: flex; flex-wrap: wrap; gap: 12px 16px; margin-top: 8px; }

.checks label { display: flex; gap: 6px; align-items: center; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.saved { color: var(--green); font-size: 14px; }

dialog {
  width: min(560px, calc(100% - 32px));
  padding: 0;
  border-radius: 12px;
}

dialog::backdrop { background: rgba(26, 24, 20, 0.45); }

.dialog-card { padding: 22px; }

@media (max-width: 960px) {
  .app { height: auto; min-height: 100vh; }
  header { flex-wrap: wrap; }
  .workspace, body[data-mode="buybox"] .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  #filters { display: flex; flex-wrap: wrap; gap: 8px; }
  .filter { width: auto; white-space: nowrap; }
  #detail { border-left: 0; border-top: 1px solid var(--line); }
  #search { max-width: none; }
  .split { grid-template-columns: 1fr; }
}
