:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --text: #17201d;
  --muted: #5d6965;
  --line: #dde2dc;
  --brand: #0f5c4d;
  --brand-ink: #ffffff;
  --brand-soft: #e3f0ec;
  --accent: #b8860b;
  --open: #157347;
  --open-bg: #e2f3e9;
  --closed: #56606b;
  --closed-bg: #eceff2;
  --cancel: #b42318;
  --cancel-bg: #fdecea;
  --soon: #9a5b00;
  --soon-bg: #fff2d6;
  --focus: #2f7dd1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 1px 1px rgba(16, 24, 20, .03);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #161d1a;
    --surface-2: #1d2622;
    --text: #e6ece9;
    --muted: #9aa8a2;
    --line: #2a3531;
    --brand: #3fb497;
    --brand-ink: #062019;
    --brand-soft: #173a31;
    --open: #5fd39a;
    --open-bg: #143324;
    --closed: #aab4bd;
    --closed-bg: #242c33;
    --cancel: #ff8a80;
    --cancel-bg: #3a1a18;
    --soon: #f5c062;
    --soon-bg: #3a2c10;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-bottom: 3rem; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0 0 .35rem; }
h2 { font-size: 1.05rem; margin: 0 0 .85rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 60px; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark svg { width: 32px; height: 32px; display: block; }
.brand-mark rect { fill: var(--brand); }
.brand-mark path { stroke: var(--brand-ink); stroke-width: 3; stroke-linecap: round; fill: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1rem; }
.brand-text small { color: var(--muted); font-size: .75rem; }
.nav { display: flex; gap: .25rem; }
.nav a { color: var(--muted); text-decoration: none; padding: .45rem .7rem; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current] { color: var(--brand); background: var(--brand-soft); }

/* Hero + stats */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; padding: 2rem 0 1.25rem; flex-wrap: wrap; }
.hero-slim { padding-bottom: 1rem; }
.lede { color: var(--muted); margin: 0; max-width: 46ch; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin: 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .95rem; min-width: 0; box-shadow: var(--shadow); }
@media (min-width: 861px) { .stat { min-width: 120px; } }
.stat dt { font-size: .75rem; color: var(--muted); }
.stat dd { margin: 0; font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat dd a { color: inherit; text-decoration: none; }
.stat dd a:hover { color: var(--brand); }

/* Cards & controls */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; font-weight: 600; min-width: 0; }
.field > span { color: var(--text); }
input, select {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px; padding: .6rem .75rem; min-height: 42px; width: 100%; min-width: 0;
}
select { appearance: none; padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23889590' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; }
input:focus, select:focus { border-color: var(--brand); outline: 2px solid color-mix(in srgb, var(--brand) 25%, transparent); outline-offset: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600;
  border-radius: 9px; padding: .55rem 1rem; min-height: 42px; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }

/* Filters */
.filters { display: flex; flex-direction: column; gap: 1rem; }
.search-row { display: flex; gap: .6rem; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem 1rem; }
.filter-actions { display: flex; align-items: flex-end; gap: .6rem; border-top: 1px solid var(--line); padding-top: .9rem; flex-wrap: wrap; }
.field-inline { flex-direction: row; align-items: center; gap: .6rem; }
.field-inline select { width: auto; }
.spacer { flex: 1; }

/* Results */
.results-head { display: flex; justify-content: space-between; align-items: baseline; margin: 1.4rem 0 .6rem; }
.results-head p { margin: 0; }
.small-link { font-size: .8rem; color: var(--muted); }
.tender-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.tender { display: flex; gap: 1.25rem; justify-content: space-between; padding: 1rem 1.2rem; transition: border-color .15s; }
.tender:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.tender-main { min-width: 0; flex: 1; }
.tender-title { font-size: 1.02rem; font-weight: 650; margin: .35rem 0 .25rem; overflow-wrap: anywhere; }
.tender-title a { color: var(--text); text-decoration: none; }
.tender-title a:hover { color: var(--brand); text-decoration: underline; }
.meta { margin: 0; color: var(--muted); font-size: .88rem; display: flex; flex-wrap: wrap; gap: 0 .5rem; }
.meta.big { font-size: .98rem; }
.meta .office { color: var(--text); font-weight: 500; }
.meta .dot::before { content: "·"; margin-right: .5rem; color: var(--line); }
.meta .loc { overflow-wrap: anywhere; }
.ref { margin: .3rem 0 0; font: .8rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--muted); overflow-wrap: anywhere; }
.tender-side { flex: none; width: 150px; display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: .1rem; }
.tender-side .label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tender-side time { font-weight: 700; font-variant-numeric: tabular-nums; }
.tender-side .time { font-size: .82rem; color: var(--muted); }

.badges { display: flex; flex-wrap: wrap; gap: .3rem; }
.badge { font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid transparent; }
.badge-outline { background: transparent; border-color: var(--line); }
.status-published { background: var(--open-bg); color: var(--open); }
.status-closed { background: var(--closed-bg); color: var(--closed); }
.status-cancelled { background: var(--cancel-bg); color: var(--cancel); }
.countdown { display: inline-block; font-size: .75rem; font-weight: 600; border-radius: 999px; padding: .1rem .5rem; margin-top: .3rem; }
.cd-ok { background: var(--open-bg); color: var(--open); }
.cd-soon { background: var(--soon-bg); color: var(--soon); }
.cd-urgent { background: var(--cancel-bg); color: var(--cancel); }
.cd-past { background: var(--closed-bg); color: var(--closed); }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1.2rem; }
.empty { text-align: center; padding: 2rem 1rem; }
.notice { border-radius: 10px; padding: .8rem 1rem; margin: 1rem 0; }
.notice-error { background: var(--cancel-bg); color: var(--cancel); }

/* Detail */
.crumbs { margin: 1.25rem 0 .75rem; font-size: .9rem; }
.detail { display: flex; flex-direction: column; gap: 1rem; }
.detail-head h1 { margin: .5rem 0 .4rem; font-size: clamp(1.3rem, 2.6vw, 1.75rem); overflow-wrap: anywhere; }
.detail-actions { margin-top: 1rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.dates { margin: 0; }
.date-row { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.date-row:last-child { border-bottom: 0; }
.date-row dt { color: var(--muted); }
.date-row dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.date-row.highlight dd { font-weight: 700; }
.date-row .countdown { margin: 0 0 0 .35rem; }
.description { white-space: pre-line; margin: 0; overflow-wrap: anywhere; }
.kv { margin: 0; display: grid; gap: .55rem; }
.kv div { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: .75rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.count { font-size: .75rem; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: .05rem .5rem; margin-left: .3rem; vertical-align: middle; }
.docs { list-style: none; margin: 0 0 .5rem; padding: 0; display: grid; gap: .5rem; }
.docs li { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 9px; }
.docs li.removed { opacity: .55; }
.docs svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--brand); stroke-width: 1.8; margin-top: .1rem; }
.docs div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }

.timeline, .change-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.timeline li, .change-list li { display: grid; grid-template-columns: 10.5rem minmax(0, 1fr) auto; gap: .75rem; align-items: baseline; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child, .change-list li:last-child { border-bottom: 0; }
.change-list { padding: .3rem 1.2rem; }
.change-body { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.tl-type { font-size: .75rem; font-weight: 650; padding: .12rem .5rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); justify-self: start; }
.type-new { background: var(--brand-soft); color: var(--brand); }
.type-deadline_changed, .type-schedule_changed, .type-amended, .type-new_document { background: var(--soon-bg); color: var(--soon); }
.type-cancelled, .type-missing, .type-document_removed { background: var(--cancel-bg); color: var(--cancel); }
.tl-body s { color: var(--muted); }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; font-size: .88rem; }
.chip:hover { border-color: var(--brand); text-decoration: none; }
.chip[aria-current] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.prose { max-width: 760px; }
.prose h2 { margin-top: 1.4rem; }
.prose ul { padding-left: 1.2rem; }

.footer { border-top: 1px solid var(--line); background: var(--surface); font-size: .85rem; }
.footer-inner { padding-top: 1.1rem; padding-bottom: 1.3rem; }
.footer p { margin: .2rem 0; }

@media (max-width: 860px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { width: 100%; }
}
@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .brand-text small { display: none; }
  .nav a { padding: .4rem .5rem; }
  .hero { padding-top: 1.25rem; }
  .stats { gap: .5rem; }
  .stat { padding: .5rem .6rem; }
  .stat dt { font-size: .7rem; line-height: 1.25; }
  .stat dd { font-size: 1.2rem; }
  .brand-text strong { font-size: .95rem; }
  .nav { gap: 0; }
  .nav a { font-size: .9rem; }
  .search-row .btn { padding: .55rem .8rem; }
  .filter-grid { grid-template-columns: minmax(0, 1fr); }
  .search-row .btn span, .hide-sm { display: none; }
  .card { padding: .9rem; }
  .tender { flex-direction: column; gap: .6rem; }
  .tender-side { width: auto; flex-direction: row; align-items: baseline; flex-wrap: wrap; text-align: left; gap: .4rem; border-top: 1px dashed var(--line); padding-top: .55rem; }
  .tender-side .countdown { margin: 0 0 0 auto; }
  .kv div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .timeline li, .change-list li { grid-template-columns: minmax(0, 1fr); gap: .25rem; }
  .change-list { padding: .2rem .9rem; }
  .field-inline { flex: 1 1 100%; }
  .field-inline select { flex: 1; }
}
