@font-face { font-family: "Inter"; src: url("/assets/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --navy: #062f52;
  --blue: #0876b9;
  --blue-dark: #065f96;
  --copper: #f7931e;
  --ink: #062f52;
  --muted: #475d72;
  --line: #d5dee7;
  --bg: #f3f6f9;
  --card: #fff;
  --topbar: 56px;
  --side: 208px;
  --panel: 660px;
  --warn-bg: #fdf1dc;
  --warn-ink: #6d4200;
  --ok-bg: #e2f4ea;
  --ok-ink: #11593a;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); min-height: 100vh; }
a { color: var(--blue); }
button, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; line-height: 1.3; }
h3 { font-size: 14px; font-weight: 650; }
.num { text-align: end; white-space: nowrap; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar); display: flex; align-items: center; gap: 12px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line); }
.logo { height: 34px; width: auto; display: block; }
.brand { font-weight: 650; font-size: 15px; }
.chip-sample { margin-inline-start: 4px; padding: 2px 10px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-ink); font-size: 12px; font-weight: 600; white-space: nowrap; }
.clock { margin-inline-start: auto; color: var(--muted); white-space: nowrap; }

/* Shell and side navigation */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: calc(100vh - var(--topbar)); }
.side { background: var(--navy); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); }
.side a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px; color: #dbe7f1; text-decoration: none; font-weight: 500; }
.side a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.side a[aria-current="page"] { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 650; }
.side a::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.side a[aria-current="page"]::before { background: var(--copper); }
main { min-width: 0; }
.loading { padding: 24px; color: var(--muted); }

/* Pages without a panel */
.page { padding: 24px; max-width: 1100px; }
.page > h1 { margin-bottom: 16px; }
.page > p { margin-bottom: 16px; }

/* RFQ workspace: list and detail panel side by side */
.workspace { display: grid; grid-template-columns: 1fr; height: calc(100vh - var(--topbar)); }
.workspace.has-panel { grid-template-columns: minmax(0, 1fr) var(--panel); }
.list { padding: 24px; overflow: auto; min-width: 0; }
.list > h1 { margin-bottom: 16px; }
.panel { background: var(--card); border-inline-start: 1px solid var(--line); overflow: auto; min-width: 0; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 650; line-height: 1.25; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-inline-end: 4px; }

/* Tables */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: #f9fbfc; white-space: nowrap; }
th.num { text-align: end; }
td { padding: 10px 12px; border-bottom: 1px solid #e8eef3; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
.rfq-table tbody tr { cursor: pointer; }
.rfq-table tbody tr:hover { background: #f5f9fc; }
.rfq-table tbody tr.selected { background: #e9f3fa; }
.rfq-table .id { font-weight: 650; white-space: nowrap; }
.rfq-table .job { min-width: 220px; max-width: 300px; }
.has-panel .rfq-table .opt, .has-panel .rfq-table .due { display: none; }
.has-panel .rfq-table { table-layout: fixed; }
.has-panel .rfq-table th.id { width: 100px; }
.has-panel .rfq-table th.stage { width: 204px; }
.has-panel .rfq-table .job { max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rfq-table .job small { display: none; }
.rfq-table td[data-label="Received"], .rfq-table td.due { white-space: nowrap; }
.sub { display: block; color: var(--muted); font-size: 12px; }

/* Stage pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stage-waiting-for-estimator { background: #fdf1dc; color: #6d4200; }
.stage-waiting-for-supplier-quotes { background: #e3eefa; color: #0b4a7a; }
.stage-draft-ready { background: #e2f4ea; color: #11593a; }
.stage-clarification-sent { background: #dff2f2; color: #0b5656; }
.stage-urgent { background: #fde6e3; color: #9a1b0f; }
.stage-outside-scope { background: #e9edf1; color: #3d4955; }

/* Detail panel */
.panel-head { padding: 16px 20px 0; position: sticky; top: 0; background: var(--card); z-index: 5; border-bottom: 1px solid var(--line); }
.panel-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.panel-top .id { font-weight: 650; }
.panel-top .close { margin-inline-start: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; color: var(--ink); text-decoration: none; }
.btn:hover { background: #f3f7fa; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn.danger { color: #9a1b0f; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.back { display: none; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 12px 0 14px; }
.facts .wide { grid-column: span 2; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; font-weight: 500; }
.tabs { display: flex; gap: 4px; margin-top: 4px; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 12px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--blue); }
.panel-body { padding: 18px 20px 32px; display: flex; flex-direction: column; gap: 20px; }
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: 8px; background: var(--ok-bg); color: var(--ok-ink); font-weight: 500; }
.banner .btn { margin-inline-start: auto; min-height: 30px; padding: 3px 10px; }
.note { padding: 10px 12px; border-radius: 8px; background: #f3f6f9; border: 1px solid var(--line); }

/* BOQ */
.boq th, .boq td { padding: 8px 8px; }
.boq .no { width: 28px; color: var(--muted); }
.boq tr.changed td { background: #eef8f2; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 4px; background: #e9eff5; color: #28445c; font-size: 12px; font-weight: 600; }
.chip.supplier { background: #e3eefa; color: #0b4a7a; }
.chip.provisional, .chip.rate_only { background: var(--warn-bg); color: var(--warn-ink); }
.item-note { color: var(--muted); font-size: 12px; margin-inline-start: 6px; }
.totals { align-self: flex-end; width: min(100%, 340px); }
.totals div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 8px; font-weight: 700; font-size: 16px; }

/* Suppliers tab */
.pick { background: var(--ok-bg); color: var(--ok-ink); border-radius: 8px; padding: 12px 14px; }
.pick h3 { margin-bottom: 4px; }
.pick p { color: #0c3e29; }
.supplier-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.supplier-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; min-width: 0; }
.supplier-card.picked { border: 2px solid var(--blue); padding: 11px; }
.supplier-card h3 { margin-bottom: 2px; overflow-wrap: anywhere; }
.supplier-card .picked-mark { color: var(--blue-dark); font-weight: 650; font-size: 12px; display: block; min-height: 18px; }
.supplier-card dl { margin: 8px 0 0; }
.supplier-card dt { color: var(--muted); font-size: 12px; margin-top: 8px; }
.supplier-card dd { margin: 0; overflow-wrap: anywhere; }
.supplier-card dd.strong { font-weight: 700; font-size: 15px; }
.flags { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.flags li { background: var(--warn-bg); color: var(--warn-ink); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.flags li::before { content: "Flag: "; font-weight: 700; }
.estimator-flags li::before { content: ""; }

/* Clarifications */
.clar { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.clar li { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.clar .head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.clar .cid { font-weight: 700; }
.state { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.state.resolved, .state.confirmed { color: var(--ok-ink); }
.state.resolved::before, .state.confirmed::before { background: #1c8a5a; }
.state.flagged { color: var(--warn-ink); }
.state.flagged::before { background: var(--copper); }
.clar .uses { margin-top: 6px; color: var(--muted); }
.clar .uses b { color: var(--ink); font-weight: 600; }

/* Response drafts */
.draft { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.draft header { padding: 10px 14px; background: #f9fbfc; border-bottom: 1px solid var(--line); }
.draft header h3 { margin-bottom: 2px; }
.draft header p { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.draft .text { padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.draft textarea { width: 100%; min-height: 260px; border: 0; padding: 12px 14px; resize: vertical; display: block; background: #fffdf7; }
.draft footer { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.draft .status { font-weight: 600; }
.draft .status.approved { color: var(--ok-ink); }

.reply h3 { margin-bottom: 8px; }
.reply label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.reply textarea { width: 100%; min-height: 110px; padding: 10px 12px; border: 1px solid #9fb2c3; border-radius: 6px; background: #fff; resize: vertical; }
.reply textarea:disabled { background: #eef2f6; color: #3c4f61; }
.reply .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.reply .hint { color: var(--muted); }
.result { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.result .source { font-weight: 600; }
.result ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.result ol li { display: grid; grid-template-columns: 34px 1fr; gap: 8px; }
.result .ref { font-weight: 700; }
.result .change-total { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding-top: 10px; border-top: 1px solid var(--line); font-weight: 650; font-size: 15px; }

/* Settings and plain tables */
.settings { background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin: 0; }
.settings div { display: grid; grid-template-columns: 260px 1fr; gap: 16px; padding: 12px 16px; border-bottom: 1px solid #e8eef3; }
.settings div:last-child { border-bottom: 0; }
.settings dt { font-weight: 600; }
.settings dd { margin: 0; }

/* Phone: table becomes cards, panel is full screen */
@media (max-width: 1099px) {
  .workspace.has-panel { grid-template-columns: 1fr; }
  .workspace.has-panel .list { display: none; }
  .btn.back { display: inline-flex; }
  .panel .close { display: none; }
  .supplier-cards { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { height: auto; }
  .workspace.has-panel { height: calc(100vh - var(--topbar)); }
}

@media (max-width: 760px) {
  :root { --topbar: 52px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .logo { height: 28px; }
  .brand { font-size: 14px; }
  .clock { display: none; }
  .shell { grid-template-columns: 1fr; align-content: start; }
  .side { align-self: start; position: static; height: auto; flex-direction: row; padding: 6px; gap: 4px; overflow: hidden; }
  .side a { flex: 1 1 0; justify-content: center; padding: 10px 4px; font-size: 13px; min-height: 44px; text-align: center; }
  .side a::before { display: none; }
  .side a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--copper); }
  .workspace { height: auto; }
  .workspace.has-panel { height: auto; }
  .list, .page { padding: 16px 12px; }
  .panel-head { padding: 12px 12px 0; }
  .panel-body { padding: 14px 12px 28px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 20px; }
  .btn { min-height: 44px; }
  .tabs { overflow: hidden; }
  .tabs button { flex: 1 1 0; padding: 10px 2px; min-width: 0; font-size: 13px; }
  .settings div { grid-template-columns: 1fr; gap: 2px; }

  /* Cards instead of tables */
  .table-wrap { background: none; border: 0; overflow: visible; }
  table.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; }
  table.cards tr { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
  table.cards td { border: 0; padding: 3px 0; display: flex; gap: 10px; justify-content: space-between; text-align: start; }
  table.cards td.num { text-align: end; }
  table.cards td[data-label]::before { content: attr(data-label); color: var(--muted); flex: none; }
  table.cards td.title { display: block; font-weight: 600; padding: 4px 0; }
  table.cards td.title::before { content: none; }
  table.cards td.title > span { text-align: start; }
  table.cards td > span { min-width: 0; overflow-wrap: anywhere; text-align: end; }
  .rfq-table.cards tr { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; }
  .rfq-table.cards td { grid-column: 1 / -1; }
  .rfq-table.cards td.id { grid-column: 1; grid-row: 1; align-self: center; }
  .rfq-table.cards td.stage { grid-column: 2; grid-row: 1; justify-self: end; }
  .rfq-table.cards td.job small { display: block; }
  .rfq-table.cards td.job { order: -1; display: block; max-width: none; font-weight: 600; padding: 6px 0; }
  .rfq-table.cards td[data-label="Location"] { display: none; }
  .has-panel .rfq-table .due { display: flex; }
  .boq.cards tr { display: grid; grid-template-columns: 26px 1fr; }
  .boq.cards td { grid-column: 1 / -1; }
  .boq.cards td.no { grid-column: 1; grid-row: 1; padding-top: 4px; }
  .boq.cards td.title { grid-column: 2; grid-row: 1; }
  .boq.cards tr.changed { background: #eef8f2; }
  .boq.cards tr.changed td { background: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .tabs button { transition: background-color .12s; }
}
