:root {
  /* Deep navy structural colour (headings, dark buttons) */
  --navy: #16233B;
  --navy-800: #101B2E;
  --navy-700: #1E2E4A;
  --navy-600: #24406e;
  /* Bright yellow accent (Fastlegal LedgerSync theme) */
  --gold: #F2C94C;
  --gold-600: #E0B63C;
  --gold-ink: #9A7A12;         /* readable yellow-ish text on light */
  --gold-soft: #FBF0CC;
  /* Dark sidebar */
  --side-top: #14203A;
  --side-bot: #0B1220;
  --side-text: #C7CDD9;
  --side-muted: #7C879C;
  --panel: #1B2740;
  --panel-line: rgba(255,255,255,.07);
  /* Surfaces */
  --bg: #F4F5F8;
  --surface: #ffffff;
  --ink: #16233B;
  --muted: #667085;
  --line: #E6E8EE;
  --success: #1a8f5f;
  --danger: #c93a3f;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16,27,46,.06), 0 1px 3px rgba(16,27,46,.05);
  --shadow: 0 6px 20px rgba(16,27,46,.10);
  --sidebar-w: 258px;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg); line-height: 1.55; }
a { color: var(--navy-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { color: var(--navy); }
.container { width: min(1140px, 92%); margin: 0 auto; }

/* ---------- Brand lockup ---------- */
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; color: var(--navy); }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--navy);
  display: grid; place-items: center; color: var(--gold); font-weight: 900;
  font-family: var(--serif); font-size: 20px; flex: none;
}
.fl-logo { display: block; width: auto; height: 26px; max-width: 100%; object-fit: contain; }
.brand-div { width: 1px; height: 20px; background: var(--line); flex: none; }
.brand-sub { font-size: 15px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--navy); white-space: nowrap; }

/* Light contexts (public nav + mobile app top bar) */
.nav .fl-logo { height: 27px; max-width: 150px; }
.app-topbar .fl-logo { height: 22px; max-width: 130px; }
.app-topbar .brand-sub { font-size: 13px; }

/* Dark sidebar: the dark wordmark is inverted to white (matching the Fastlegal
   dark theme); "Tender" becomes a muted subtitle beneath it. */
.sidebar .brand { flex-direction: column; align-items: flex-start; gap: 6px; padding: 2px 6px 20px; }
.sidebar .fl-logo { height: 26px; max-width: 180px; filter: brightness(0) invert(1); }
.sidebar .brand-div { display: none; }
.sidebar .brand-sub { color: var(--side-muted); font-size: 12.5px; letter-spacing: .01em;
  text-transform: none; font-weight: 500; padding-left: 2px; }
.sidebar .brand .logo { background: rgba(255,255,255,.1); color: var(--gold); }

.side-sep { margin: 16px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #8fa0c0; font-weight: 800; }

/* Hamburger buttons */
.sb-toggle, .nav-toggle { background: transparent; border: none; cursor: pointer; padding: 8px; display: none;
  flex-direction: column; gap: 4px; width: 40px; height: 40px; align-items: center; justify-content: center; flex: none; }
.sb-toggle span, .nav-toggle span { display: block; width: 20px; height: 2px; border-radius: 2px; background: var(--navy); }

/* Mobile app top bar (signed-in) */
.app-topbar { display: none; align-items: center; gap: 8px; height: 58px; padding: 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 35; }
.app-topbar .brand-mobile { flex: 1; min-width: 0; }
.topbar-icon { width: 40px; height: 40px; display: grid; place-items: center; font-size: 20px; color: var(--navy);
  border-radius: 10px; text-decoration: none; flex: none; }
.topbar-icon:hover { background: var(--bg); text-decoration: none; }

/* ---------- Public top nav ---------- */
.nav { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.nav-inner { display: flex; align-items: center; gap: 22px; height: 66px; }
.nav-links { display: flex; gap: 22px; margin-left: 10px; }
.nav-links a { color: var(--navy); font-weight: 600; font-size: 15px; }
.nav-links a:hover { color: var(--gold-600); text-decoration: none; }
.nav-spacer { flex: 1; }
.nav-actions { display: flex; gap: 10px; align-items: center; }
.public .brand-text { color: var(--navy); }

/* ---------- Sidebar layout ---------- */
body.has-sidebar { background: var(--bg); }
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
  background: linear-gradient(180deg, var(--side-top) 0%, var(--side-bot) 100%);
  color: var(--side-text); display: flex; flex-direction: column; padding: 20px 14px; z-index: 40;
}
.sidebar .brand { color: #fff; padding: 6px 8px 18px; }
.sidebar .brand .logo { background: rgba(255,255,255,.08); }
.sidebar .brand-text { color: #fff; }
.side-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.side-nav a {
  display: flex; align-items: center; gap: 13px; padding: 11px 14px; border-radius: 11px;
  color: var(--side-text); font-weight: 600; font-size: 15px;
}
.side-nav a .i { width: 18px; text-align: center; color: var(--side-muted); font-size: 15px; }
.side-nav a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.side-nav a:hover .i { color: var(--side-text); }
.side-nav a.active { background: var(--gold); color: #14203A; font-weight: 700; box-shadow: 0 6px 16px rgba(242,201,76,.22); }
.side-nav a.active .i { color: #14203A; }
.side-foot { margin-top: auto; padding-top: 14px; }
.who { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px; color: #e6ebf5; font-size: 14px; }
.who .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #14203A;
  display: grid; place-items: center; font-weight: 800; flex: none; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .btn-ghost { background: var(--panel); color: #eef1f6; border-color: var(--panel-line); }
.sidebar .btn-ghost:hover { background: #22314f; border-color: rgba(255,255,255,.18); }
.fl-tag { margin-top: 12px; font-size: 12px; color: var(--side-muted); text-align: center; letter-spacing: .3px; }
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; }
.app-content { padding: 30px clamp(18px, 4vw, 44px); max-width: 1180px; }
.sb-scrim { display: none; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px;
  border-radius: 10px; font-weight: 700; font-size: 15px; border: 1px solid transparent; cursor: pointer;
  transition: .15s; white-space: nowrap; }
.btn:hover { text-decoration: none; }
/* Primary = bright yellow accent with dark text */
.btn-primary, .btn-gold { background: var(--gold); color: #14203A; }
.btn-primary:hover, .btn-gold:hover { background: var(--gold-600); }
/* Dark navy button for secondary emphasis */
.btn-dark { background: var(--navy); color: #fff; }
.btn-dark:hover { background: var(--navy-800); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--navy); background: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 14px; }

/* ---------- Hero (public) ---------- */
.hero { background:
    radial-gradient(1100px 380px at 85% -20%, rgba(242,201,76,.16), transparent 60%),
    linear-gradient(180deg, #ffffff, var(--bg)); padding: 76px 0 52px; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.08; margin: 0 0 16px; letter-spacing: -.5px; }
.hero .accent { color: var(--gold-ink); }
.hero p.lead { font-size: 19px; color: var(--muted); max-width: 640px; margin: 0 0 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.searchbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; max-width: 720px; }
.searchbar input[type=text] { flex: 1; min-width: 220px; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 30px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.stat .num { font-size: 30px; font-weight: 800; color: var(--navy); font-family: var(--serif); }
.stat .lbl { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.stat.live .num { color: var(--success); }
.stat.gold .num { color: var(--gold-ink); }

/* ---------- Sections / cards ---------- */
.section { padding: 40px 0; }
.section h2, .page-head h1 { margin: 0 0 4px; }
.section .sub, .page-head .sub { color: var(--muted); margin: 0 0 22px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 26px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 22px; }

/* ---------- Tender rows ---------- */
.tender { display: block; padding: 18px 20px; border-bottom: 1px solid var(--line); transition: .12s; border-left: 3px solid transparent; }
.tender:last-child { border-bottom: 0; }
.tender:hover { background: #fbfaf5; text-decoration: none; border-left-color: var(--gold); }
.tender .t-title { font-weight: 700; color: var(--navy); font-size: 16px; margin: 0 0 6px; }
.tender .t-org { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.tender .t-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13.5px; color: var(--muted); }
.tender .t-meta b { color: var(--ink); font-weight: 600; }

.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; }
.badge.live { background: #e3f5ec; color: #0c7a4f; }
.badge.expired { background: #eeece3; color: #8a7a4e; }
.badge.result { background: var(--gold-soft); color: #8a6d12; }
.badge.cancelled { background: #fbe6e6; color: #b02b30; }

/* ---------- Filters / chips ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--navy); font-weight: 700; font-size: 14px; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip:hover { text-decoration: none; border-color: var(--navy); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 6px; color: var(--navy); }
input, select, textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; font-family: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(42,78,136,.12); }
.field { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 40px 16px;
  background: radial-gradient(900px 500px at 50% -10%, rgba(22,48,92,.06), transparent 60%); }
.auth-card { width: min(440px, 100%); }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-card h1 { font-size: 26px; margin: 0 0 6px; }
.auth-card .sub { color: var(--muted); margin: 0 0 24px; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--muted); font-size: 14px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 15px; border-radius: 10px; font-size: 14.5px; margin-bottom: 16px; font-weight: 500; }
.alert.error { background: #fbe6e6; color: #a82429; }
.alert.success { background: #e3f5ec; color: #0c7a4f; }
.alert.info { background: var(--gold-soft); color: #7d6410; }

/* ---------- Detail ---------- */
.detail-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.kv { display: grid; grid-template-columns: 220px 1fr; }
.kv > div { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.kv .k { color: var(--muted); font-weight: 600; font-size: 14px; background: #faf9f4; }
.kv .v { font-size: 15px; }
table.docs { width: 100%; border-collapse: collapse; }
table.docs th, table.docs td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
table.docs th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Smart search ---------- */
.smart-hero { background: linear-gradient(135deg, var(--navy), var(--navy-700)); color: #fff; border-radius: 16px; padding: 34px; margin-bottom: 24px; }
.smart-hero h1 { color: #fff; margin: 0 0 6px; font-size: 26px; }
.smart-hero p { color: #c7d1e6; margin: 0 0 18px; }
.smart-form { display: flex; gap: 10px; flex-wrap: wrap; }
.smart-form input { flex: 1; min-width: 240px; padding: 14px 16px; font-size: 16px; border: none; }
.understood { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 0; }
.understood .tag { background: rgba(201,162,39,.2); color: var(--gold-soft); border: 1px solid rgba(201,162,39,.4); padding: 4px 12px; border-radius: 999px; font-size: 13px; }
.req-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.req-list .req { background: #faf9f4; border: 1px solid var(--line); border-radius: 8px; padding: 5px 11px; font-size: 13px; color: var(--navy); font-weight: 600; }
.result-card { padding: 20px; border-bottom: 1px solid var(--line); }
.result-card:last-child { border-bottom: 0; }
.result-card:hover { background: #fbfaf5; }
.result-card .rc-title { font-weight: 700; color: var(--navy); font-size: 17px; }
.examples { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.examples a { font-size: 13px; background: rgba(255,255,255,.1); color: #fff; padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.2); }
.examples a:hover { background: rgba(255,255,255,.2); text-decoration: none; }

/* ---------- Pagination ---------- */
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 26px; align-items: center; }
.pager a, .pager span { padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-weight: 700; color: var(--navy); }
.pager .disabled { color: var(--muted); opacity: .5; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: 14px; margin-top: 40px; background: var(--surface); }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.pill.on { background: #e3f5ec; color: #0c7a4f; }
.pill.off { background: #fbe6e6; color: #b02b30; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Horizontal-scroll wrapper for wide tables on small screens */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.docs { min-width: 520px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .app-content { padding: 24px clamp(16px, 4vw, 30px); }
}

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .admin-grid, .form-row, .dash-cols { grid-template-columns: 1fr !important; }
  .kv { grid-template-columns: 1fr; }
  .kv .k { border-bottom: 0; padding: 12px 14px 2px; background: transparent; color: var(--muted); }
  .kv .v { padding-top: 2px; }

  /* --- Signed-in app shell: off-canvas sidebar + sticky top bar --- */
  .app-main { margin-left: 0; }
  .app-topbar { display: flex; }
  .app-content { padding: 18px 16px 40px; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; width: 270px; overflow-y: auto; z-index: 60; }
  body.sb-open .sidebar { transform: translateX(0); box-shadow: 0 0 50px rgba(0,0,0,.35); }
  .sb-toggle { display: flex; }
  body.sb-open .sb-scrim { display: block; position: fixed; inset: 0; background: rgba(10,20,40,.45); z-index: 55; }

  /* --- Public nav: collapse to a dropdown --- */
  .nav-inner { height: 60px; flex-wrap: wrap; }
  .nav-toggle { display: flex; order: 3; margin-left: auto; }
  .nav-spacer { display: none; }
  .nav-links, .nav-actions {
    flex-basis: 100%; order: 4; flex-direction: column; gap: 4px; align-items: stretch;
    max-height: 0; overflow: hidden; transition: max-height .25s ease;
  }
  body.nav-open .nav-links, body.nav-open .nav-actions { max-height: 320px; padding-bottom: 8px; }
  .nav-links a { padding: 12px 6px; border-bottom: 1px solid var(--line); }
  .nav-actions { gap: 8px; padding-bottom: 14px; }
  .nav-actions .btn { width: 100%; }

  /* --- General mobile polish --- */
  .hero { padding: 48px 0 36px; }
  .searchbar { flex-direction: column; }
  .searchbar input, .searchbar .btn, .smart-form input, .smart-form .btn { width: 100%; }
  .smart-hero { padding: 22px; border-radius: 14px; }
  .hero-actions .btn { flex: 1; }
  .detail-head { flex-direction: column; }
  .detail-head > div[style*="text-align:right"] { text-align: left !important; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .filters .chip { white-space: nowrap; }
  .result-card form { width: 100%; }
  .result-card select, .result-card .btn { flex: 1; }
  .footer-inner { flex-direction: column; }
  .card-pad { padding: 18px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat .num { font-size: 26px; }
  h1 { font-size: 24px; }
  .tender .t-meta { gap: 10px; }
}
