/* Tender Hub. Tokens first; spacing on a 4px scale; one accent (deep teal). */
:root {
  --bg: #f4f5f2; --surface: #ffffff; --surface-2: #eef1ee; --ink: #17212b; --muted: #55616d; --line: #d9ded9;
  --accent: #0b5d5b; --accent-hover: #084846; --on-accent: #ffffff; --accent-soft: #dcefec;
  --urgent-bg: #fde4e1; --urgent-ink: #8f1d12; --soon-bg: #fdefc8; --soon-ink: #6b4400;
  --ok-bg: #dff3e3; --ok-ink: #17502a; --info-bg: #e1ecf8; --info-ink: #1d3f6e; --closed-bg: #e6e8ea; --closed-ink: #4b5560;
  --error: #b42318; --shadow: 0 1px 2px rgba(23, 33, 43, .06);
  --r-sm: 4px; --r-md: 8px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10161b; --surface: #182129; --surface-2: #1f2a33; --ink: #e7ecef; --muted: #9eabb6; --line: #2d3a45;
    --accent: #55c7bf; --accent-hover: #7ad6cf; --on-accent: #06211f; --accent-soft: #15393a;
    --urgent-bg: #4a1d19; --urgent-ink: #ffc9c2; --soon-bg: #45340c; --soon-ink: #ffe2a0;
    --ok-bg: #153a22; --ok-ink: #b9ecc6; --info-bg: #1a2f4b; --info-ink: #c6dcfa; --closed-bg: #2a333b; --closed-ink: #b4bec7;
    --error: #ff9488; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #10161b; --surface: #182129; --surface-2: #1f2a33; --ink: #e7ecef; --muted: #9eabb6; --line: #2d3a45;
  --accent: #55c7bf; --accent-hover: #7ad6cf; --on-accent: #06211f; --accent-soft: #15393a;
  --urgent-bg: #4a1d19; --urgent-ink: #ffc9c2; --soon-bg: #45340c; --soon-ink: #ffe2a0;
  --ok-bg: #153a22; --ok-ink: #b9ecc6; --info-bg: #1a2f4b; --info-ink: #c6dcfa; --closed-bg: #2a333b; --closed-ink: #b4bec7;
  --error: #ff9488; --shadow: none;
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.25; text-wrap: balance; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--error); }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--s2); top: var(--s2); z-index: 10; background: var(--surface); padding: var(--s2) var(--s3); }

/* Controls */
button, input, select { font: inherit; color: inherit; }
button, .linkbtn { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 14px; cursor: pointer; min-height: 36px; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary, .linkbtn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled), .linkbtn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }
button.link { background: none; border: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; }
button.small { padding: 2px 10px; min-height: 28px; font-size: 13px; }
.linkbtn { display: inline-flex; align-items: center; text-decoration: none; }
input, select { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 10px; min-height: 36px; }
input::placeholder { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: var(--s2) var(--s4); display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 700; font-size: 17px; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--accent); color: var(--on-accent); font-size: 15px; }
.topnav { display: flex; gap: var(--s1); flex-wrap: wrap; }

/* Search band */
.searchband { background: var(--surface); border-bottom: 1px solid var(--line); }
.searchband-inner { max-width: 1280px; margin: 0 auto; padding: var(--s5) var(--s4); display: grid; gap: var(--s3); }
.searchbar { display: flex; gap: var(--s2); max-width: 820px; }
.searchbar input { flex: 1; min-height: 46px; font-size: 16px; padding: 10px 14px; border-color: var(--muted); }
.searchbar button { min-height: 46px; padding: 0 var(--s5); }
.examples { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; font-size: 13px; }
.chip { border-radius: 999px; padding: 2px 12px; min-height: 28px; font-size: 13px; background: var(--surface-2); border-color: transparent; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); margin-top: var(--s2); }
.stat { display: grid; gap: 2px; text-align: left; padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--bg); }
.stat:hover:not(:disabled) { border-color: var(--accent); }
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); }

/* Layout */
.layout { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: var(--s5); padding: var(--s5) var(--s4); max-width: 1280px; margin: 0 auto; align-items: start; }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4); display: grid; gap: var(--s4); position: sticky; top: var(--s4); max-height: calc(100vh - 32px); overflow: auto; }
.filters-head { display: flex; justify-content: space-between; align-items: baseline; }
.fgroup { display: grid; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--line); }
.fgroup label { display: grid; gap: var(--s1); font-size: 13px; color: var(--muted); }
.check { display: flex !important; align-items: center; gap: var(--s2); color: var(--ink) !important; font-size: 14px !important; }
.check input { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.filters-done, .filters-toggle { display: none; }

/* Toolbar and active filters */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.summary { font-weight: 600; }
.toolbar-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.inline { display: flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--muted); }
.inline select { width: auto; }
.active { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.active:empty { display: none; }
.fchip { border-radius: 999px; padding: 2px 10px 2px 12px; min-height: 28px; font-size: 13px; background: var(--accent-soft); border-color: transparent; display: inline-flex; gap: var(--s2); align-items: center; max-width: 100%; }
.fchip span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fchip .x { font-weight: 700; }

/* Result cards */
.results { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: var(--s3); }
.results.loading { opacity: .55; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4); box-shadow: var(--shadow); display: grid; gap: var(--s2); }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: var(--s3); }
.card-title { all: unset; cursor: pointer; font-weight: 600; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-title:hover { color: var(--accent); text-decoration: underline; }
.card-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.org { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.badge { flex: none; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge.urgent { background: var(--urgent-bg); color: var(--urgent-ink); }
.badge.soon { background: var(--soon-bg); color: var(--soon-ink); }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.closed { background: var(--closed-bg); color: var(--closed-ink); }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2) var(--s4); margin: var(--s1) 0 0; padding: var(--s3) 0 0; border-top: 1px solid var(--line); }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.tags { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); }
.tag { font-size: 12px; padding: 1px 8px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); }
.tag.good { background: var(--ok-bg); color: var(--ok-ink); }
.tag.info { background: var(--info-bg); color: var(--info-ink); }
.tag.warn { background: var(--soon-bg); color: var(--soon-ink); }

.empty { text-align: center; padding: var(--s6) var(--s4); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-md); display: grid; gap: var(--s3); justify-items: center; margin-top: var(--s3); }
.empty[hidden] { display: none; }
.empty p { color: var(--muted); max-width: 52ch; }
.pager { display: flex; justify-content: center; align-items: center; gap: var(--s4); padding: var(--s5) 0 var(--s6); }

/* Dialogs */
dialog { width: min(860px, 94vw); max-height: 90vh; border: 1px solid var(--line); border-radius: var(--r-md); padding: 0; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10, 16, 20, .55); }
dialog article { padding: var(--s5); display: grid; gap: var(--s4); }
.dialog-head { display: flex; justify-content: space-between; gap: var(--s3); align-items: start; }
.dialog-head h2 { font-size: 19px; overflow-wrap: anywhere; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: var(--s1); }
.idrow { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; padding: var(--s2) var(--s3); background: var(--surface-2); border-radius: var(--r-sm); }
.idrow code { overflow-wrap: anywhere; }
.keyfacts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.keyfact { border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s2) var(--s3); min-width: 0; }
.keyfact .k { font-size: 12px; color: var(--muted); }
.keyfact .v { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fields { display: grid; grid-template-columns: minmax(140px, 230px) 1fr; gap: var(--s2) var(--s4); margin: 0; }
.fields dt { color: var(--muted); font-size: 13px; }
.fields dd { margin: 0; overflow-wrap: anywhere; }
.dialog-foot { display: grid; gap: var(--s3); justify-items: start; border-top: 1px solid var(--line); padding-top: var(--s4); }
.tablewrap { overflow-x: auto; }
.sources { width: 100%; border-collapse: collapse; font-size: 14px; }
.sources th, .sources td { text-align: left; padding: var(--s2); border-bottom: 1px solid var(--line); }
.sources th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sources .num { text-align: right; font-variant-numeric: tabular-nums; }

.saveform { display: grid; gap: var(--s3); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); }
.saveform label { display: grid; gap: var(--s1); font-size: 13px; color: var(--muted); }
.savedlist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.savedlist li { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s2) var(--s3); }
.savedlist .grow { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }

/* Sign-in */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: var(--s4); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s6); width: min(400px, 100%); display: grid; gap: var(--s3); box-shadow: var(--shadow); }
.login-card form { display: grid; gap: var(--s3); margin-top: var(--s2); }
.login-card label { display: grid; gap: var(--s1); font-size: 13px; color: var(--muted); }
.login-card button { min-height: 42px; }

/* Smaller screens */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: var(--s4); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { display: none; position: static; max-height: none; }
  .filters.open { display: grid; }
  .filters-toggle { display: inline-flex; align-items: center; }
  .filters-done { display: block; }
  .facts, .keyfacts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields { grid-template-columns: 1fr; }
  .fields dt { margin-top: var(--s2); }
}
@media (max-width: 520px) {
  .searchbar { flex-direction: column; }
  .card-head { flex-direction: column-reverse; align-items: start; }
  h1 { font-size: 19px; }
}
@media (prefers-reduced-motion: no-preference) {
  .results { transition: opacity .12s ease; }
}
