/* Brand colours (--brand, --brand-2, --brand-dark, --tint, --line, --bg) are set per client
   in app/client.py and served from /brand.css, which loads after this file.
   The values here are only fallbacks. */
:root {
  --brand: #2F4BD8; --brand-2: #5268DE; --brand-dark: #2338A2; --grey: #B2B3B5;
  --bg: #F7F8FD; --card: #FFFFFF; --line: #E2E6F9; --text: #1B1D26; --muted: #646876;
  --tint: #EAEDFB; --ok: #1E7F4F; --ok-bg: #E8F5EE; --err: #8A1020; --err-bg: #FDECEE;
  --warn-bg: #FFF4D6; --warn: #6B4E00; --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
.lede { color: var(--muted); margin: 0 0 20px; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar { background: var(--brand); color: #fff; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 22px; }
.brandmark { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 15px; white-space: nowrap; }
.brandmark img { height: 32px; width: 32px; border-radius: 6px; display: block; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; padding: 7px 12px; border-radius: 7px; opacity: .85; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.1); opacity: 1; }
.nav a.active { background: rgba(255,255,255,.16); opacity: 1; }
.spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.userbox a { color: #fff; opacity: .85; }
.linkbtn { background: none; border: 0; color: #fff; opacity: .85; font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.16); white-space: nowrap; }
.pill.demo { background: #F6C343; color: #3A2D00; }
@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .nav { order: 3; width: 100%; }
}

/* ---------- layout ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 24px; }
@media (max-width: 860px) { .page { padding: 16px; } }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.two-col { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
@media (max-width: 960px) { .two-col { grid-template-columns: 1fr; } .sticky { position: static !important; } }
.sticky { position: sticky; top: 24px; }
.narrow { max-width: 560px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.card > h2 { margin: 0; padding: 14px 18px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card > h2 .n { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; display: grid; place-items: center; }
.card .body { padding: 18px; }

/* ---------- forms ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid .full { grid-column: 1 / -1; }
.grid.tight { gap: 14px; }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; } }
label, .label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--text); }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); font-weight: 400; margin: 0; }
.check input { width: auto; }
.field-error { color: var(--err); font-size: 12px; margin-top: 4px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--tint); }
.btn.danger { background: #fff; color: var(--err); border: 1px solid #F1C6CC; }
.btn.block { width: 100%; padding: 13px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- forms in progress ---------- */
.narrow-wide { max-width: 820px; }
.busy-msg { align-self: center; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); font-size: 12px; }
.center { text-align: center; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FBFAFD; white-space: nowrap; }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.total td { font-weight: 700; background: var(--tint); }
table.data tr.sub td { font-weight: 600; }
table.data tr.inactive td { color: var(--muted); }
table.data a.rowlink { font-weight: 600; text-decoration: none; }
table.data a.rowlink:hover { text-decoration: underline; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--tint); color: var(--brand); white-space: nowrap; }
.badge.grey { background: #EEEEF1; color: var(--muted); }
.badge.demo { background: var(--warn-bg); color: var(--warn); }
.empty { padding: 32px 18px; text-align: center; color: var(--muted); }

.search { display: flex; gap: 8px; }
.search input { width: 280px; }
@media (max-width: 600px) { .search { width: 100%; } .search input { width: 100%; } }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--muted); }

/* ---------- detail ---------- */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.prose p { margin: 0 0 10px; }
.prose ul, .prose ol { margin: 0 0 10px; padding-left: 20px; }
.pre { white-space: pre-wrap; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); margin: 18px 0 8px; }
.section-title:first-child { margin-top: 0; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--brand); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 28px; }
.auth-card img { width: 56px; height: 56px; display: block; margin: 0 auto 14px; border-radius: 10px; }
.auth-card h1 { font-size: 20px; text-align: center; margin-bottom: 2px; }
.auth-card .center { margin: 0 0 20px; }
.auth-card .stack > * + * { margin-top: 14px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px; letter-spacing: .04em; padding: 14px; background: var(--tint); border-radius: 8px; text-align: center; user-select: all; }

/* ---------- footer ---------- */
.credit { max-width: 1240px; margin: 0 auto; padding: 8px 24px 28px; color: var(--muted); font-size: 11px; text-align: right; }
.two-col > .card { margin-bottom: 20px; }

/* ---------- document forms ---------- */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; max-width: 900px; }
.choice { display: grid; gap: 6px; padding: 20px; text-decoration: none; color: var(--text); margin: 0; transition: border-color .15s, box-shadow .15s; }
.choice:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--tint); }
.choice-name { font-weight: 600; font-size: 16px; color: var(--brand); }
.chip-check { display: inline-flex; margin: 0; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-check span { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; font-size: 13px; color: var(--text); font-weight: 400; }
.chip-check input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-check input:focus-visible + span { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.cat { border-top: 1px solid var(--line); }
.cat:first-of-type { border-top: 0; }
.cat h3 { margin: 0; padding: 12px 18px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); background: var(--tint); }
.prod { display: grid; grid-template-columns: 1fr auto 76px; gap: 16px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.prod.active { background: #FBFBFE; box-shadow: inset 3px 0 0 var(--brand); }
.prod .name { font-weight: 500; }
.prod .desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.prod .price { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; white-space: nowrap; }
.prod .qty { text-align: center; padding: 7px 6px; }
@media (max-width: 600px) { .prod { grid-template-columns: 1fr 76px; } .prod .price { grid-column: 1; grid-row: 2; } }
.summary .row { display: flex; justify-content: space-between; padding: 6px 0; font-variant-numeric: tabular-nums; }
.summary .row.total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
.summary ul { list-style: none; padding: 0; margin: 0 0 12px; max-height: 320px; overflow: auto; }
.summary li { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 4px 0; }
.summary .muted { margin-top: 10px; }
.page-head .search select { width: auto; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.card .table-wrap + .table-wrap { border-top: 1px solid var(--line); margin-top: 14px; }
