:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d1d1f; --muted: #71717a;
  --line: #e4e4e0; --accent: #0e7c5b; --go: #0e7c5b; --look: #b45309; --skip: #9f1239;
  --soft: #f0efe9;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#131315; --panel:#1d1d21; --ink:#ececef; --muted:#9b9ba3; --line:#2c2c31; --soft:#232327; }
}
* { box-sizing: border-box; }
body { margin:0; font:14px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif; background:var(--bg); color:var(--ink); }
header { display:flex; align-items:center; gap:14px; padding:12px 22px; border-bottom:1px solid var(--line); background:var(--panel); position:sticky; top:0; z-index:5; }
h1 { font-size:18px; margin:0; } h1 span { color:var(--accent); font-weight:400; }
nav { margin-left:auto; display:flex; gap:8px; }
button { border:1px solid var(--line); background:var(--panel); color:var(--ink); padding:7px 14px; border-radius:7px; cursor:pointer; font-size:13px; }
button.active, button:hover { border-color:var(--accent); color:var(--accent); }
button.ghost { border-color:transparent; color:var(--muted); }
button.primary { background:var(--accent); border-color:var(--accent); color:#fff; }
button.primary:hover { opacity:.9; color:#fff; }
button:disabled { opacity:.55; cursor:default; }
.dot { width:11px; height:11px; border-radius:50%; background:#a3a3a3; flex:none; }
.dot.ok { background:var(--go); } .dot.warn { background:var(--skip); }
section { padding:18px 22px; max-width:1200px; margin:0 auto; }
.hidden { display:none !important; }
.card { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:22px; }
.card.login { max-width:340px; margin:12vh auto; display:flex; flex-direction:column; gap:10px; }
input, select, textarea { border:1px solid var(--line); background:var(--panel); color:var(--ink); padding:7px 10px; border-radius:7px; font:inherit; }
textarea { width:100%; resize:vertical; background:var(--bg); }
.error { color:var(--skip); min-height:1em; margin:0; }
.muted { color:var(--muted); }

/* stats */
.stats { display:flex; gap:12px; flex-wrap:wrap; margin-bottom:14px; }
.stat { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:10px 16px; font-size:12px; color:var(--muted); display:flex; align-items:baseline; gap:8px; }
.stat b { font-size:20px; color:var(--ink); }
.stat.go b { color:var(--go); } .stat.look b { color:var(--look); }

/* first-time help */
.help-strip { background:var(--soft); border:1px solid var(--line); border-radius:10px; padding:4px 16px; margin-bottom:14px; font-size:13px; }
.help-strip .badge { min-width:0; padding:1px 7px; font-size:11px; }
.help-strip button { float:right; margin:6px 0 0 8px; }

/* filters */
.filters { display:flex; gap:14px; flex-wrap:wrap; align-items:end; margin-bottom:14px; }
.filters label { display:flex; flex-direction:column; gap:3px; font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.filters label.check { flex-direction:row; align-items:center; gap:6px; text-transform:none; font-size:13px; color:var(--ink); padding-bottom:8px; }
.filters button { height:34px; }

/* table */
table { width:100%; border-collapse:collapse; background:var(--panel); border:1px solid var(--line); border-radius:12px; overflow:hidden; }
th, td { text-align:left; padding:10px 12px; border-bottom:1px solid var(--line); vertical-align:top; }
th { font-size:12px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); background:var(--soft); }
.th-note { text-transform:none; letter-spacing:0; font-weight:400; }
.th-fit { width:78px; }
td.num, th.num { text-align:right; white-space:nowrap; }
tbody tr { cursor:pointer; } tbody tr:hover { background:color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.title-cell .t-title { font-weight:550; }
.sub { font-size:12px; color:var(--muted); margin-top:2px; font-weight:400; }
.src { font-size:11px; border:1px solid var(--line); border-radius:5px; padding:2px 6px; color:var(--muted); }
.empty { background:var(--panel); border:1px dashed var(--line); border-radius:12px; padding:28px; text-align:center; color:var(--muted); }

/* badges & pills */
.badge { display:inline-block; min-width:52px; text-align:center; padding:3px 8px; border-radius:6px; font-weight:600; font-size:12px; color:#fff; }
.badge.GO { background:var(--go); } .badge.LOOK { background:var(--look); } .badge.SKIP { background:var(--skip); }
.badge.NONE { background:#7c7c84; }
.pill { display:inline-block; font-size:11px; font-weight:600; padding:1px 8px; border-radius:99px; background:var(--soft); color:var(--muted); margin-left:6px; white-space:nowrap; }
.pill.soon { background:color-mix(in srgb, var(--skip) 12%, var(--panel)); color:var(--skip); }
.pill.gone { background:var(--soft); color:var(--muted); text-decoration:line-through; }

/* drawer */
#drawerBackdrop { position:fixed; inset:0; background:rgba(0,0,0,.25); z-index:9; }
#drawer { position:fixed; top:0; right:0; width:min(560px, 95vw); height:100vh; background:var(--panel); border-left:1px solid var(--line); padding:20px 24px; overflow-y:auto; z-index:10; box-shadow:-8px 0 30px rgba(0,0,0,.15); }
#drawer h2 { margin:10px 0 4px; font-size:17px; line-height:1.35; }
.drawer-head { display:flex; align-items:center; gap:10px; margin-top:8px; }
.verdict-word { font-weight:600; }
.orig-title { font-size:12px; color:var(--muted); margin:2px 0 10px; }
.summary { background:var(--soft); border-radius:10px; padding:10px 14px; margin:10px 0; }
.summary h3 { margin:0 0 4px; font-size:11px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); }
.summary p { margin:0; }
.flag { color:var(--look); font-weight:550; margin:6px 0; }
#drawer dl { display:grid; grid-template-columns:110px 1fr; gap:7px 12px; font-size:13px; margin:16px 0; }
#drawer dt { color:var(--muted); } #drawer dd { margin:0; overflow-wrap:anywhere; }
#drawer details { margin-top:8px; } #drawer summary { cursor:pointer; color:var(--muted); font-size:13px; }

/* score bars */
.scorebars { margin:14px 0; }
.bar-row { display:grid; grid-template-columns:120px 1fr 30px; align-items:center; gap:10px; font-size:12px; margin:5px 0; }
.bar { height:8px; background:var(--soft); border-radius:4px; overflow:hidden; }
.bar i { display:block; height:100%; background:var(--accent); border-radius:4px; }
.bar-row b { text-align:right; }

a { color:var(--accent); }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  section { padding:12px 10px; }
  header { padding:10px 12px; gap:10px; flex-wrap:wrap; }
  nav { gap:6px; }
  button { min-height:40px; }           /* comfortable touch targets */
  input:not([type="checkbox"]), select { min-height:40px; }
  input[type="checkbox"] { width:18px; height:18px; accent-color:var(--accent); }

  /* stats: two per row */
  .stats { gap:8px; }
  .stat { flex:1 1 40%; padding:8px 12px; justify-content:center; }

  .help-strip { font-size:12px; padding:4px 12px; }

  /* filters: two-column grid, full-width controls */
  .filters { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
  .filters label { width:100%; }
  .filters label input, .filters label select { width:100%; }
  .filters label.check { grid-column:1 / -1; padding-bottom:0; }
  .filters > button { width:100%; }

  /* table becomes stacked cards */
  #tenderTable { display:block; border:none; background:transparent; }
  #tenderTable thead { display:none; }
  #tenderTable tbody { display:block; }
  #tenderTable tbody tr {
    display:grid; grid-template-columns:1fr auto; gap:4px 10px;
    background:var(--panel); border:1px solid var(--line); border-radius:12px;
    padding:12px 14px; margin-bottom:10px;
  }
  #tenderTable td { display:block; padding:0; border:none; }
  #tenderTable td:nth-child(1) { grid-column:1; grid-row:1; }              /* fit badge */
  #tenderTable td:nth-child(5) { grid-column:2; grid-row:1; justify-self:end; } /* source */
  #tenderTable td:nth-child(2) { grid-column:1 / -1; grid-row:2; }         /* title + buyer */
  #tenderTable td:nth-child(3) { grid-column:1; grid-row:3; text-align:left; white-space:normal; font-weight:550; } /* value */
  #tenderTable td:nth-child(4) { grid-column:2; grid-row:3; justify-self:end; text-align:right; } /* deadline */
  #tenderTable td .sub { margin-top:3px; }

  /* drawer: full screen */
  #drawer { width:100vw; padding:16px; }
  #drawer dl { grid-template-columns:96px 1fr; }
  .bar-row { grid-template-columns:104px 1fr 28px; }

  .card { padding:16px; }
}

@media (max-width: 380px) {
  .stat { flex:1 1 100%; }
  .filters { grid-template-columns:1fr; }
}
