/* Costing Portal. No framework; all styling lives here because the
   content security policy forbids inline styles. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #5b6875;
  --line: #dde3e9;
  --line-soft: #ebeff3;
  --brand: #0b4a7d;
  --brand-dark: #083a62;
  --brand-tint: #e8f1f8;
  --ok: #17693a;
  --ok-tint: #e1f4e7;
  --warn: #8a5300;
  --warn-tint: #fdf0d3;
  --bad: #a32020;
  --bad-tint: #fbe4e4;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--brand); }
code, .mono { font-family: var(--mono); font-size: 0.9em; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.6rem 1.5rem; background: var(--brand); color: #fff; flex-wrap: wrap;
}
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 650; font-size: 1.05rem; letter-spacing: 0.01em; }
.topbar nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.topbar nav a { opacity: 0.88; padding: 0.2rem 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover, .topbar nav a.current { opacity: 1; border-bottom-color: #fff; }
.topbar .who { opacity: 0.8; font-size: 0.85rem; }
.topbar form { margin: 0; }
.linklike {
  background: none; border: 0; padding: 0; font: inherit; color: inherit;
  cursor: pointer; opacity: 0.88;
}
.linklike:hover { opacity: 1; text-decoration: underline; }

.container { max-width: 1180px; margin: 1.5rem auto 3rem; padding: 0 1.5rem; }
.narrow { max-width: 460px; }
.medium { max-width: 720px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.page-head p { margin: 0; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 0 1rem 2rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 1.25rem; }

/* ---------- Text helpers ---------- */
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 650; }

/* ---------- Notices ---------- */
.notice {
  border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius);
  padding: 0.65rem 0.9rem; margin-bottom: 1rem; background: var(--surface);
}
.notice.info { border-left-color: var(--brand); background: var(--brand-tint); }
.notice.success { border-left-color: var(--ok); background: var(--ok-tint); }
.notice.error { border-left-color: var(--bad); background: var(--bad-tint); }
.notice.warn { border-left-color: var(--warn); background: var(--warn-tint); }
.notice > :last-child { margin-bottom: 0; }

.badge {
  display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 650; letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--line-soft); color: var(--muted); white-space: nowrap;
}
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }
.badge.brand { background: var(--brand-tint); color: var(--brand); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 0.5rem 0.95rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: var(--line-soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #e3b5b5; }
.btn.danger:hover { background: var(--bad-tint); }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
a:focus-visible, summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }

/* ---------- Forms ---------- */
label { display: block; font-size: 0.88rem; font-weight: 550; margin-bottom: 0.2rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="file"], select, textarea {
  width: 100%; padding: 0.5rem 0.65rem; border: 1px solid #c4cdd6; border-radius: 6px;
  font: inherit; color: var(--ink); background: #fff;
}
textarea { min-height: 5.5rem; resize: vertical; }
.field { margin-bottom: 0.9rem; }
.field .help { color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }
.field .error, .field-error { color: var(--bad); font-size: 0.85rem; margin-top: 0.2rem; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
.check { display: flex; align-items: flex-start; gap: 0.5rem; font-weight: 400; font-size: 0.92rem; }
.check input { margin-top: 0.25rem; }
.checks { display: flex; gap: 1.25rem; flex-wrap: wrap; }
fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1.1rem 0.4rem; margin: 0 0 1.1rem;
}
legend { padding: 0 0.4rem; font-weight: 650; }
.fields { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.search-row { display: flex; gap: 0.6rem; }
.search-row input { flex: 1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
th {
  background: #f7f9fb; color: var(--muted); font-size: 0.74rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
tbody tr:hover { background: #fafcfd; }
tfoot td, tr.total td { font-weight: 650; border-top: 2px solid var(--line); }
td.empty { text-align: center; color: var(--muted); padding: 1.5rem; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1.25rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* ---------- Costing result ---------- */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.step { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; background: #fbfcfd; }
.step.final { border-color: var(--brand); background: var(--brand-tint); }
.step .label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 650; }
.step .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0.15rem 0; }
.step .sub { font-size: 0.85rem; color: var(--muted); }
blockquote.rationale {
  margin: 0.5rem 0 0; padding: 0.6rem 0.9rem; border-left: 4px solid var(--brand);
  background: #f7f9fb; border-radius: 0 6px 6px 0; white-space: pre-wrap;
}
.delta-up { color: var(--bad); }
.delta-down { color: var(--ok); }

details > summary { cursor: pointer; font-weight: 550; color: var(--brand); }
details[open] > summary { margin-bottom: 0.6rem; }
.row-edit { background: #f7f9fb; border: 1px solid var(--line); border-radius: 6px; padding: 0.7rem; margin-top: 0.4rem; min-width: 260px; }

/* ---------- Misc ---------- */
.qr { display: flex; justify-content: center; margin: 1rem 0; }
.qr svg { width: 260px; max-width: 100%; height: auto; }
.secret { font-family: var(--mono); font-size: 1.05rem; letter-spacing: 0.08em; word-break: break-all; text-align: center; }
.htmx-indicator { display: none; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.pill-list { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; margin: 0; }
pre.json {
  background: #0f1b26; color: #d6e2ee; padding: 1rem; border-radius: var(--radius);
  overflow: auto; max-height: 28rem; font-size: 0.82rem;
}
textarea.json { font-family: var(--mono); font-size: 0.82rem; min-height: 26rem; }

@media (max-width: 640px) {
  .container { padding: 0 0.9rem; }
  .topbar { padding: 0.6rem 0.9rem; }
  .search-row { flex-direction: column; }
}
@media print {
  .topbar, .footer, .no-print { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* A figure withheld from this user: a placeholder, blurred. The real value is not in the page. */
.masked { filter: blur(4px); user-select: none; color: var(--muted); }
.request { border-top: 1px solid var(--line, #ddd); padding: 1rem 0; }
.request h3 { margin: 0 0 0.5rem; }
.request .actions { margin-top: 0.75rem; display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
fieldset.plain { border: 0; padding: 0; margin: 0.5rem 0; }
textarea { width: 100%; font: inherit; padding: 0.5rem; }

.card.invitation { border-left: 4px solid var(--brand); }
.card.invitation input[readonly] { font-family: ui-monospace, monospace; font-size: 0.85rem; }
