/* ========== tokens ========== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --border-strong: #c3c9d2;
  --text: #17202b;
  --text-2: #4a5563;
  --text-3: #6f7a88;
  --brand: #0f4c5c;
  --brand-2: #157a8c;
  --brand-soft: #e3f1f3;
  --topbar: #0f4c5c;
  --accent: #e0a526;
  --ok: #1d7a46;
  --ok-soft: #e1f3e8;
  --warn: #9a6200;
  --warn-soft: #fdf1d8;
  --err: #b42318;
  --err-soft: #fde7e5;
  --info-soft: #e7eefb;
  --best: #d9f2e2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419; --surface: #171d24; --surface-2: #1e252e; --border: #2b343f; --border-strong: #3a4552;
    --text: #e6eaef; --text-2: #b4bdc8; --text-3: #8893a1; --brand: #5fb8c9; --brand-2: #7ccad8;
    --brand-soft: #16343b; --topbar: #0c2a31; --ok: #5cc98a; --ok-soft: #173325; --warn: #e6b450; --warn-soft: #3a2d12;
    --err: #f2867b; --err-soft: #3d1c19; --info-soft: #1a2638; --best: #1c3d2a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419; --surface: #171d24; --surface-2: #1e252e; --border: #2b343f; --border-strong: #3a4552;
  --text: #e6eaef; --text-2: #b4bdc8; --text-3: #8893a1; --brand: #5fb8c9; --brand-2: #7ccad8;
  --brand-soft: #16343b; --topbar: #0c2a31; --ok: #5cc98a; --ok-soft: #173325; --warn: #e6b450; --warn-soft: #3a2d12;
  --err: #f2867b; --err-soft: #3d1c19; --info-soft: #1a2638; --best: #1c3d2a; color-scheme: dark;
}

/* ========== base ========== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--text-3); }
.small { font-size: .85em; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ========== top bar ========== */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.25rem; background: var(--topbar); color: #fff; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; }
.brand-mark { color: var(--accent); }
.topnav { display: flex; align-items: center; gap: .75rem; }
.topnav .btn { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }
.topnav-link { color: #fff; text-decoration: none; }
.topnav-user { color: rgba(255,255,255,.75); font-size: .85em; }
.topnav-tag { background: var(--accent); color: #1b1300; font-weight: 600; font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; }
@media (max-width: 600px) {
  .topbar { padding: .6rem 16px; gap: .5rem; }
  .brand, .topnav-link { white-space: nowrap; }
  .topnav-user { display: none; }
}

/* ========== layout ========== */
.app { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.loading { padding: 3rem; text-align: center; color: var(--text-3); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem; margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.error-card { border-color: var(--err); background: var(--err-soft); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin: .25rem 0 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: .75rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .app { padding: 1rem 16px 3rem; } }

/* ========== admin shell ========== */
.admin-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.admin-nav { position: sticky; top: 4.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
.admin-nav-title { font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: .25rem .5rem .5rem; }
.admin-nav nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav-link { display: block; padding: .45rem .6rem; border-radius: 6px; color: var(--text-2); text-decoration: none; }
.admin-nav-link:hover { background: var(--surface-2); }
.admin-nav-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.admin-nav-foot { border-top: 1px solid var(--border); margin-top: .75rem; padding-top: .75rem; display: grid; gap: .35rem; }
@media (max-width: 900px) { .admin-layout { grid-template-columns: 1fr; } .admin-nav { position: static; } }

/* ========== buttons & forms ========== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .9rem; border-radius: 7px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-2); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); background: var(--err); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: .25rem .6rem; font-size: .85em; }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--text-3); }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.field-label { font-weight: 500; font-size: .9em; color: var(--text-2); }
.field-hint { font-size: .8em; color: var(--text-3); }
.input, select.input, textarea.input { width: 100%; padding: .5rem .65rem; border: 1px solid var(--border-strong); border-radius: 7px;
  background: var(--surface); color: var(--text); font: inherit; }
textarea.input { min-height: 7rem; resize: vertical; }
.input:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: var(--brand-2); }
.checkbox { display: inline-flex; gap: .4rem; align-items: center; cursor: pointer; }

/* ========== auth ========== */
.auth-wrap { display: flex; justify-content: center; padding-top: 3rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 1.35rem; }
.auth-card .sub { color: var(--text-2); }

/* ========== tables ========== */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 8px; max-width: 100%; }
table.data { width: 100%; border-collapse: collapse; font-size: .9em; }
table.data th, table.data td { padding: .5rem .65rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { background: var(--surface-2); font-weight: 600; color: var(--text-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.best { background: var(--best); font-weight: 600; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
.table-scroll { max-height: 65vh; }

/* bid sheet grid */
.sheet-table td { padding: .3rem .5rem; }
.cell-input { width: 100%; min-width: 7rem; padding: .3rem .45rem; border: 1px solid var(--border); border-radius: 5px; background: var(--surface);
  color: var(--text); font: inherit; font-variant-numeric: tabular-nums; }
.cell-input.num { text-align: right; }
.cell-input:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; }
.cell-input.saving { border-color: var(--accent); }
.cell-input.saved { border-color: var(--ok); }
.cell-input.error { border-color: var(--err); background: var(--err-soft); }
.cell-input:disabled { background: var(--surface-2); color: var(--text-2); }

/* ========== pills, stats, notices ========== */
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-err { background: var(--err-soft); color: var(--err); }
.pill-info { background: var(--brand-soft); color: var(--brand); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; }
.stat-label { font-size: .8rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.stat-sub { font-size: .85em; color: var(--text-2); }
.notice { border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; background: var(--info-soft); border: 1px solid var(--border); }
.notice-warn { background: var(--warn-soft); border-color: transparent; color: var(--text); }
.notice-err { background: var(--err-soft); border-color: transparent; }
.notice-ok { background: var(--ok-soft); border-color: transparent; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--text-2); }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: .75rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.check-dot { width: 1.3rem; height: 1.3rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem;
  background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border-strong); flex: none; }
.check-dot.done { background: var(--ok); color: #fff; border-color: var(--ok); }

/* ========== tabs ========== */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tab { padding: .6rem 1rem; border: 0; background: none; font: inherit; font-weight: 500; color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ========== hero (supplier landing) ========== */
.hero { background: linear-gradient(135deg, var(--brand) 0%, #0b3540 100%); color: #fff; border-radius: 14px; padding: 2rem; margin-bottom: 1.25rem; }
.hero h1 { font-size: 2rem; margin-bottom: .35rem; }
.hero p { color: rgba(255,255,255,.85); max-width: 60ch; }
.hero .meta { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 1rem; }
.hero .meta div { font-size: .9em; }
.hero .meta strong { display: block; font-size: 1.1em; }

/* ========== pager, modal, toasts ========== */
.pager { display: flex; align-items: center; gap: .75rem; justify-content: flex-end; padding-top: .75rem; }
.pager-info { color: var(--text-3); font-size: .9em; }
.modal-overlay { position: fixed; inset: 0; background: rgba(10, 15, 20, .5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.modal-wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 1rem 1.25rem; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--border); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: .5rem; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: .7rem 1rem; border-radius: 8px; background: var(--text); color: var(--surface); box-shadow: var(--shadow); transition: opacity .35s, transform .35s; }
.toast-error { background: var(--err); color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-warn { background: var(--accent); color: #1b1300; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ========== bars (analysis) ========== */
.bar { height: .55rem; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--brand-2); }

/* ========== admin bidders table ========== */
.ops-toolbar { flex-wrap: wrap; margin-bottom: .75rem; }
.ops-toolbar input[type=search] { max-width: 280px; }
.ops-pills { display: flex; flex-wrap: wrap; gap: .25rem; }
.ops-actions { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-end; }
