/* =============================================================================
   Design principles
   - One primary action per view (search / open tender / read about)
   - Clear hierarchy: title → context → content
   - WCAG-friendly contrast; distinct hues for brand vs deadline vs start
   - Mobile: touch targets ≥ 44px; laptop: density + grid
   ============================================================================= */

:root,
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f1419;
  --panel: #1a2332;
  --panel-elevated: #222d3f;
  --line: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --brand: #38bdf8;
  --brand-hover: #7dd3fc;
  --on-brand: #0f1419;
  --close: #fb923c;
  --start: #a8b4c4;
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', monospace;
  --shadow: 0 8px 24px rgb(0 0 0 / 0.28);
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand) 45%, transparent);
  --bottom-nav-h: 3.75rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
}

[data-theme='light'] {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-elevated: #ffffff;
  --line: #cbd5e1;
  --text: #0f172a;
  --muted: #475569;
  --brand: #0284c7;
  --brand-hover: #0369a1;
  --on-brand: #ffffff;
  --close: #c2410c;
  --start: #64748b;
  --shadow: 0 8px 24px rgb(15 23 42 / 0.08);
}

* { box-sizing: border-box; }

html {
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font: 1rem/1.55 var(--font);
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--brand);
  text-underline-offset: 0.15em;
}
a:hover { color: var(--brand-hover); }

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.wrap {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 0 calc(var(--bottom-nav-h) + var(--space-5));
}

/* ----- Header ----- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: var(--space-3) var(--space-4) var(--space-2);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 2.75rem;
}

.logo {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.desktop-nav { display: none; }

.desktop-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.desktop-nav a:hover,
.desktop-nav a.is-active {
  color: var(--brand);
}

/* Appearance picker — segmented Light / Dark (same on mobile + desktop) */
.theme-picker {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}

.theme-picker-label {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  line-height: 1;
}

.theme-segment {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  gap: 2px;
}

.theme-segment-btn {
  margin: 0;
  padding: 0.4rem 0.7rem;
  min-height: 2rem;
  min-width: 3.25rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.theme-segment-btn:hover {
  color: var(--text);
}

.theme-segment-btn[aria-pressed='true'] {
  background: var(--panel-elevated);
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

[data-theme='light'] .theme-segment-btn[aria-pressed='true'] {
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.1);
}

.mobile-chips {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-bottom: var(--space-1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mobile-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  min-height: 2.25rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.chip b {
  font-family: var(--mono);
  font-weight: 500;
  margin-left: 0.15rem;
}

.chip.is-on {
  border-color: var(--brand);
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, var(--panel));
}

.sidebar { display: none; }

.layout { display: block; }
.layout--single .content { max-width: 42rem; margin: 0 auto; }

.content { padding: 0 var(--space-4); }

/* ----- Hero (home) ----- */
.hero { margin: var(--space-4) 0 var(--space-5); }

.hero h1 {
  margin: 0 0 var(--space-2);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.stats {
  margin: 0 0 var(--space-4);
  font-size: 0.875rem;
  color: var(--muted);
}

.stats strong { color: var(--text); }

.search {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.search input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.btn {
  min-height: 2.75rem;
  padding: 0 1.1rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--brand);
  color: var(--on-brand);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}

.search .btn-primary,
.search .btn-ghost { width: 100%; }

/* ----- Panels & list ----- */
.panel { margin-bottom: var(--space-6); }

.panel h2 {
  margin: 0 0 var(--space-2);
  font-size: 1.05rem;
  font-weight: 700;
}

.lede,
.summary,
.hint,
.empty,
.faq p {
  font-size: 0.9rem;
  color: var(--muted);
}

.summary { margin: 0 0 var(--space-4); }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
  transition: border-color 0.15s ease;
}

.card:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.bank {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand);
}

.dates-mobile {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.1rem 0.25rem;
  font-size: 0.7rem;
  text-align: right;
  max-width: 58%;
}
.dates-desktop { display: none; }

.date { font-family: var(--mono); font-size: 0.75rem; font-weight: 600; }
.date-close { color: var(--close); }
.date-start { color: var(--start); }
.date-sep { color: var(--muted); margin: 0 0.2rem; }

.card h3,
.card-title {
  margin: 0 0 var(--space-2);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
}

.card-title {
  color: var(--text);
  text-decoration: none;
  display: block;
}

.card-title:hover { color: var(--brand); }

.place {
  margin: 0 0 var(--space-2);
  font-size: 0.8125rem;
  color: var(--muted);
}

.meta { margin: 0; }

/* Pagination */
.desktop-pager { display: none; }

.pager-mobile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-2) 0;
  position: sticky;
  bottom: var(--bottom-nav-h);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
}

.pg-mobile {
  flex: 1;
  max-width: 42%;
  text-align: center;
  min-height: 2.75rem;
  line-height: 2.75rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.875rem;
  text-decoration: none;
  background: var(--brand);
  color: var(--on-brand);
}

.pg-mobile.disabled {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  line-height: 2.65rem;
}

.pg-mobile.count {
  flex: 0 1 auto;
  max-width: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.4;
  min-height: auto;
}

/* Bottom nav */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  height: var(--bottom-nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--bottom-nav-h);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-top: 2px solid transparent;
}

.bottom-nav a.is-active {
  color: var(--brand);
  border-top-color: var(--brand);
}

/* FAQ */
.faq details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: var(--space-2);
}

.faq summary {
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker { display: none; }
.faq p { margin: 0; padding: 0 var(--space-4) var(--space-4); }

/* About prose */
.page-header { margin-bottom: var(--space-5); }

.eyebrow {
  margin: 0 0 var(--space-2);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
}

.page-header h1 {
  margin: 0 0 var(--space-2);
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.tagline {
  margin: 0;
  font-size: 1.05rem;
  color: var(--muted);
}

.prose section { margin-bottom: var(--space-5); }

.prose h2 {
  margin: 0 0 var(--space-3);
  font-size: 1.05rem;
}

.prose p,
.prose li {
  color: var(--muted);
  font-size: 0.9375rem;
}

.prose strong { color: var(--text); }

.prose ol,
.prose ul {
  margin: 0;
  padding-left: 1.25rem;
}

.prose .bank-list li { margin-bottom: var(--space-1); }

.back-link {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.foot {
  margin-top: var(--space-6);
  padding: var(--space-4) 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* =============================================================================
   Laptop (≥ 1024px)
   ============================================================================= */
@media (min-width: 1024px) {
  html { scroll-padding-top: 4.5rem; }

  .wrap {
    max-width: 72rem;
    padding: 0 var(--space-5) var(--space-6);
  }

  .page-about .wrap { padding-bottom: var(--space-6); }

  .topbar {
    margin: 0 calc(-1 * var(--space-5)) var(--space-5);
    padding: var(--space-4) var(--space-5);
  }

  .topbar-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--space-4);
  }

  .logo {
    flex: unset;
    justify-self: start;
  }

  .desktop-nav {
    display: flex;
    justify-content: center;
    gap: var(--space-5);
  }

  .theme-picker {
    justify-self: end;
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
  }

  .theme-segment-btn {
    min-height: 2.125rem;
    padding: 0.35rem 0.85rem;
    font-size: 0.8125rem;
  }

  .mobile-chips { display: none; }
  .bottom-nav { display: none; }

  .page-home .layout {
    display: grid;
    grid-template-columns: 13.5rem 1fr;
    gap: var(--space-5);
    align-items: start;
  }

  .sidebar {
    display: block;
    position: sticky;
    top: 5.25rem;
    padding: var(--space-4);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

  .sidebar-title {
    margin: 0 0 var(--space-3);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
  }

  .sidebar-banks {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .bank-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid transparent;
  }

  .bank-link b {
    font-family: var(--mono);
    font-size: 0.7rem;
  }

  .bank-link:hover {
    background: color-mix(in srgb, var(--brand) 8%, transparent);
    color: var(--text);
  }

  .bank-link.is-on {
    border-color: var(--brand);
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 10%, var(--panel));
  }

  .content { padding: 0; }

  .hero {
    margin: 0 0 var(--space-5);
    padding: var(--space-5);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

  .hero h1 { font-size: 1.75rem; }

  .search {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
  }

  .search input {
    flex: 1;
    min-width: 14rem;
    min-height: 2.65rem;
  }

  .search .btn-primary,
  .search .btn-ghost {
    width: auto;
    min-height: 2.65rem;
  }

  .list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .card-head { display: none; }

  .dates-mobile { display: none; }

  .dates-desktop {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem 0.35rem;
  }

  .pager-mobile { display: none; }

  .desktop-pager {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: center;
    margin-top: var(--space-5);
    position: static;
    background: none;
    backdrop-filter: none;
  }

  .pg {
    min-width: 2.5rem;
    padding: 0.5rem 0.7rem;
    text-align: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
  }

  .pg:hover {
    border-color: var(--brand);
    color: var(--brand);
  }

  .pg.is-on {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--on-brand);
  }

  .page-about .page-header h1 { font-size: 2rem; }
}

@media (min-width: 1280px) {
  .page-home .list {
    grid-template-columns: repeat(3, 1fr);
  }
}
