/* =========================================================
   Bayanak prototype — base.css
   Tokens, reset, typography and shared components (§2, §4)
   ========================================================= */

:root {
  --ink: #0F2A3D;
  --ink-2: #3B5468;
  --muted: #6B7F90;
  --paper: #F6F8FA;
  --surface: #FFFFFF;
  --surface-2: #F0F4F7;
  --line: #DCE3EA;
  --brand: #0E7C66;
  --brand-dp: #0A5E4D;
  --brand-lt: #E3F3EF;
  --gold: #B8862B;
  --gold-lt: #FBF3E2;
  --info: #2563EB;
  --info-lt: #E8EFFD;
  --indigo: #4F46E5;
  --indigo-lt: #ECEBFD;
  --warn: #B45309;
  --warn-lt: #FDF1E3;
  --danger: #B91C1C;
  --danger-lt: #FCEAEA;
  --ok: #15803D;
  --ok-lt: #E6F4EA;
  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 1200px;
  --shadow: 0 1px 2px rgba(15, 42, 61, .06), 0 4px 16px rgba(15, 42, 61, .06);
  --shadow-lg: 0 12px 40px rgba(15, 42, 61, .18);
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 15px/1.55 var(--font);
  color: var(--ink);
  background: var(--paper);
}
img, svg { display: block; max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 .75em; }
ul, ol { margin: 0; padding-inline-start: 1.2em; }
table { border-collapse: collapse; width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: -3px; }
.icon.sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon.lg { width: 28px; height: 28px; }
.icon.xl { width: 44px; height: 44px; stroke-width: 1.4; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: 28px; letter-spacing: -.01em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.mono, code { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.lead { font-size: 17px; color: var(--ink-2); }
.strong { font-weight: 600; }
.right { text-align: end; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.strike { text-decoration: line-through; }
.fee { font-weight: inherit; }

/* ---------- Layout utilities ---------- */
.stack > * + * { margin-block-start: 16px; }
.stack-sm > * + * { margin-block-start: 8px; }
.stack-lg > * + * { margin-block-start: 28px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid > *, .stack > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }
.mt0 { margin-top: 0 !important; }
.mb0 { margin-bottom: 0 !important; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  font: 600 14px/1.2 var(--font);
  border: 1px solid transparent; border-radius: 8px;
  cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dp); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--ink-2); }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-lt); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991B1B; }
.btn-danger-outline { background: var(--surface); color: var(--danger); border-color: #E9B4B4; }
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn.is-disabled, .btn[aria-disabled="true"] {
  background: var(--surface-2); color: var(--muted); border-color: var(--line);
  cursor: not-allowed; pointer-events: none;
}
.disabled-wrap { display: inline-flex; flex-direction: column; gap: 4px; }
.disabled-why { font-size: 12px; color: var(--muted); display: flex; gap: 4px; align-items: center; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Status pills & flags (§2.3) ---------- */
.status-wrap { display: inline-flex; flex-direction: column; gap: 3px; }
.status-line { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.4; white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-new { background: #EEF1F4; color: #4A5C6B; }
.pill-awaiting { background: var(--info-lt); color: var(--info); }
.pill-selected { background: var(--indigo-lt); color: var(--indigo); }
.pill-paid { background: #DDF2EF; color: #0F766E; }
.pill-progress { background: var(--warn-lt); color: var(--warn); }
.pill-released { background: var(--surface); color: var(--ok); border-color: var(--ok); }
.pill-completed { background: var(--ok); color: #fff; }
.pill-completed::before { background: #fff; }
.pill-cancelled { background: #EEF1F4; color: var(--muted); text-decoration: line-through; }
.status-sub { font-size: 12px; color: var(--muted); }
.flag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 6px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.flag .icon { width: 13px; height: 13px; }
.flag-docs { background: var(--warn-lt); color: var(--warn); border: 1px dashed #E7B984; }
.flag-dispute { background: var(--danger-lt); color: var(--danger); border: 1px dashed #E9A8A8; }
.flag-rating { background: var(--gold-lt); color: var(--gold); border: 1px dashed #E3C78F; }
.flag-link { background: var(--surface-2); color: var(--ink-2); border: 1px dashed var(--line); }

/* ---------- Badges / tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2);
}
.badge-verified { background: var(--brand-lt); color: var(--brand-dp); }
.badge-ok { background: var(--ok-lt); color: var(--ok); }
.badge-warn { background: var(--warn-lt); color: var(--warn); }
.badge-danger { background: var(--danger-lt); color: var(--danger); }
.badge-info { background: var(--info-lt); color: var(--info); }
.badge-gold { background: var(--gold-lt); color: var(--gold); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; }
.tag-prio { display: inline-block; padding: 1px 7px; border-radius: 4px; font: 700 11px/1.5 var(--mono); background: #FDE68A; color: #78350F; vertical-align: 2px; }
.tag-prio.p2 { background: #DDD6FE; color: #4C1D95; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; color: var(--ink-2); }
a.chip:hover { text-decoration: none; border-color: var(--ink-2); }
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .x { color: var(--muted); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card-tight { padding: 14px 16px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card.is-accent { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-lt); }
.card.is-muted { background: var(--surface-2); }
.card.is-faded { opacity: .55; }
.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 8px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; } .kv dd { margin-bottom: 8px; } }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-size: 26px; font-weight: 600; font-family: var(--mono); letter-spacing: -.02em; }
.kpi .l { font-size: 13px; color: var(--muted); }
.divider-list > * + * { border-top: 1px solid var(--line); }

/* ---------- Alerts / disclaimer / gate ---------- */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid; font-size: 14px;
}
.alert .icon { margin-top: 2px; }
.alert p:last-child { margin-bottom: 0; }
.alert strong { display: block; margin-bottom: 2px; }
.alert-info { background: var(--info-lt); border-color: #BFD3FA; color: #1E3A8A; }
.alert-warning { background: var(--warn-lt); border-color: #F1CFA4; color: #7C3A0A; }
.alert-danger { background: var(--danger-lt); border-color: #F0B9B9; color: #7F1D1D; }
.alert-success { background: var(--ok-lt); border-color: #B5DEC2; color: #14532D; }
.alert-disclaimer { background: var(--surface-2); border-color: var(--line); border-inline-start: 4px solid var(--muted); color: var(--ink-2); font-size: 13px; }
.gate {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 18px 22px; border-radius: var(--radius);
  background: var(--ink); color: #fff;
}
.gate .icon { width: 28px; height: 28px; color: #F4C76B; }
.gate h3 { color: #fff; margin: 0 0 2px; }
.gate p { margin: 0; color: #C9D6E0; font-size: 14px; }
.gate .btn-primary { background: #F4C76B; color: var(--ink); }
.gate.gate-danger { background: #5B1414; }

/* ---------- Toast (static) ---------- */
.toast {
  position: fixed; inset-block-start: 76px; inset-inline-end: 24px; z-index: 50;
  display: flex; gap: 10px; align-items: center;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); font-size: 14px;
}
.toast .icon { color: #6EE7B7; }

/* ---------- Lifecycle stepper ---------- */
.stepper { display: flex; list-style: none; margin: 0; padding: 0; counter-reset: s; }
.stepper li { flex: 1; position: relative; text-align: center; font-size: 12px; color: var(--muted); padding-top: 26px; }
.stepper li::before {
  content: ""; position: absolute; top: 4px; inset-inline-start: 50%; transform: translateX(-50%);
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); z-index: 1;
}
[dir="rtl"] .stepper li::before { transform: translateX(50%); }
.stepper li::after { content: ""; position: absolute; top: 10px; inset-inline-start: 50%; width: 100%; height: 2px; background: var(--line); }
.stepper li:last-child::after { display: none; }
.stepper li.done { color: var(--ink-2); }
.stepper li.done::before { background: var(--brand); border-color: var(--brand); }
.stepper li.done::after { background: var(--brand); }
.stepper li.current { color: var(--ink); font-weight: 600; }
.stepper li.current::before { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-lt); background: var(--surface); width: 16px; height: 16px; top: 3px; }
.stepper.is-cancelled li { color: var(--muted); }
.stepper.is-cancelled li.done::before { background: var(--muted); border-color: var(--muted); }
.stepper.is-cancelled li.done::after { background: var(--muted); }
@media (max-width: 720px) {
  .stepper { flex-direction: column; gap: 0; }
  .stepper li { text-align: start; padding: 0 0 14px 30px; }
  .stepper li::before { inset-inline-start: 4px; transform: none; top: 2px; }
  .stepper li.current::before { top: 1px; }
  .stepper li::after { top: 16px; inset-inline-start: 11px; width: 2px; height: 100%; }
}

/* Wizard stepper */
.wizard { display: flex; gap: 6px; list-style: none; margin: 0 0 24px; padding: 0; flex-wrap: wrap; }
.wizard li { flex: 1 1 120px; padding: 10px 12px; border-top: 3px solid var(--line); font-size: 13px; color: var(--muted); }
.wizard li b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.wizard li.done { border-color: var(--brand); color: var(--ink-2); }
.wizard li.current { border-color: var(--ink); color: var(--ink); font-weight: 600; }

/* ---------- Timeline (structured events, BR-24) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; position: relative; padding-bottom: 18px; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 17px; top: 34px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.tl-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.tl-ico.ok { background: var(--ok-lt); color: var(--ok); border-color: #B5DEC2; }
.tl-ico.warn { background: var(--warn-lt); color: var(--warn); border-color: #F1CFA4; }
.tl-ico.danger { background: var(--danger-lt); color: var(--danger); border-color: #F0B9B9; }
.tl-ico.brand { background: var(--brand-lt); color: var(--brand); border-color: #BFE2D9; }
.tl-ico.pending { background: var(--surface); border-style: dashed; color: var(--muted); }
.tl-body { padding-top: 2px; }
.tl-event { font-weight: 600; font-size: 14px; }
.tl-meta { font-size: 12.5px; color: var(--muted); }
.tl-note { font-size: 13.5px; color: var(--ink-2); margin-top: 4px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; color: var(--ink-2); }

/* ---------- Broker card ---------- */
.broker-card { display: flex; flex-direction: column; gap: 12px; }
.broker-card .bc-head { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--ink); color: #fff; font-weight: 600; font-size: 15px; }
.avatar.sm { width: 32px; height: 32px; border-radius: 8px; font-size: 12px; }
.avatar.lg { width: 72px; height: 72px; border-radius: 16px; font-size: 24px; }
.avatar.round { border-radius: 50%; }
.av-1 { background: #0E7C66; } .av-2 { background: #1F4E79; } .av-3 { background: #7A4B1E; } .av-4 { background: #5B3F8C; } .av-5 { background: #8A8F96; } .av-6 { background: #6B7F90; }
.bc-name { font-weight: 600; font-size: 15px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bc-meta { font-size: 12.5px; color: var(--muted); }
.bc-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.bc-tags span { font-size: 12px; padding: 2px 8px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); }
.bc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; flex-wrap: wrap; }
.price-signal { font-size: 13px; color: var(--ink-2); }
.price-signal b { font-family: var(--mono); }
.save-heart { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); background: var(--surface); }
.save-heart.is-on { color: #DB2777; border-color: #F9A8D4; background: #FDF2F8; }
.save-heart.is-on .icon { fill: currentColor; }

/* ---------- Stars ---------- */
.stars { display: inline-flex; align-items: center; gap: 2px; color: var(--gold); font-size: 13px; }
.stars .icon { width: 14px; height: 14px; }
.stars .icon.on { fill: currentColor; }
.stars .icon.off { color: #D4DBE2; }
.stars .n { margin-inline-start: 4px; color: var(--ink); font-weight: 600; }
.stars .c { color: var(--muted); font-weight: 400; }
.star-input { display: inline-flex; gap: 4px; }
.star-input span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); color: #C7D0D9; background: var(--surface); }
.star-input span .icon { width: 20px; height: 20px; }
.star-input span.on { color: var(--gold); border-color: #E3C78F; background: var(--gold-lt); }
.star-input span.on .icon { fill: currentColor; }
.rate-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar.gold > i { background: var(--gold); }
.bar.warn > i { background: var(--warn); }

/* ---------- Countdown chip ---------- */
.countdown { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 6px; font: 600 12.5px/1.5 var(--mono); background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.countdown.warn { background: var(--warn-lt); color: var(--warn); border-color: #F1CFA4; }
.countdown.danger { background: var(--danger-lt); color: var(--danger); border-color: #F0B9B9; }
.countdown.ok { background: var(--ok-lt); color: var(--ok); border-color: #B5DEC2; }
.countdown.off { text-decoration: line-through; color: var(--muted); }

/* ---------- Fee breakdown ---------- */
.fee-box { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.fee-box .fr { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; font-size: 14px; }
.fee-box .fr + .fr { border-top: 1px dashed var(--line); }
.fee-box .fr span:last-child { font-family: var(--mono); }
.fee-box .fr.total { background: var(--brand-lt); font-weight: 600; font-size: 16px; border-top: 1px solid #BFE2D9; }
.fee-box .fr.note { background: var(--surface-2); font-size: 12.5px; color: var(--muted); }
.fee-box .fr.note span:last-child { font-family: var(--font); }

/* ---------- Quote compare ---------- */
.compare-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.compare { min-width: 900px; font-size: 13.5px; }
.compare th, .compare td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: start; }
.compare thead th { background: var(--surface); vertical-align: bottom; }
.compare tbody th { width: 170px; color: var(--muted); font-weight: 500; background: var(--surface-2); position: sticky; inset-inline-start: 0; }
.compare td.best { background: #F3FAF8; }
.compare td.awaiting, .compare th.awaiting { background: repeating-linear-gradient(135deg, #FAFBFC 0 8px, #F3F6F8 8px 16px); color: var(--muted); }
.compare td.expired, .compare th.expired { color: var(--muted); background: #F7F7F7; }
.compare .total { font: 600 16px var(--mono); }
.compare .money { font-family: var(--mono); }
.compare tfoot td { border-bottom: 0; }
.qh { display: flex; flex-direction: column; gap: 6px; }
.qh .best-tag { font-size: 11px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .06em; }
.yes { color: var(--ok); font-weight: 600; }
.no { color: var(--danger); }
.skeleton { display: block; height: 12px; border-radius: 4px; background: linear-gradient(90deg, #EEF1F4, #F6F8FA, #EEF1F4); margin: 4px 0; }
.skeleton.w60 { width: 60%; } .skeleton.w40 { width: 40%; } .skeleton.w80 { width: 80%; }

/* ---------- Document checklist ---------- */
.doc-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.doc-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; }
.doc-row + .doc-row { border-top: 1px solid var(--line); }
.doc-row .dname { font-weight: 600; font-size: 14px; }
.doc-row .dmeta { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.doc-row .dright { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.doc-row.is-alert { background: #FFFAF3; }
.dstat { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.dstat-missing { background: #EEF1F4; color: var(--ink-2); }
.dstat-uploaded { background: var(--info-lt); color: var(--info); }
.dstat-accepted { background: var(--ok-lt); color: var(--ok); }
.dstat-rejected { background: var(--danger-lt); color: var(--danger); }
.dstat-again { background: var(--warn-lt); color: var(--warn); }
.req-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.req-tag.req { color: var(--danger); }
.req-tag.opt { color: var(--muted); }
.req-tag.cond { color: var(--warn); }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); font-size: 13px; background: var(--surface-2); }
.dropzone .icon { margin: 0 auto 6px; }
.dropzone.sm { padding: 8px 12px; display: inline-flex; gap: 6px; align-items: center; }
.dropzone.sm .icon { margin: 0; }

/* ---------- Forms (visual only) ---------- */
.form { display: grid; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.field .req { color: var(--danger); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field .err { font-size: 12.5px; color: var(--danger); display: flex; gap: 4px; align-items: center; }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  font: 400 14.5px/1.4 var(--font); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.input::placeholder, .textarea::placeholder { color: #9AA9B6; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; padding-inline-end: 34px; }
[dir="rtl"] .select { background-position: 18px 18px, 13px 18px; }
.input.is-error { border-color: var(--danger); background: #FFFBFB; }
.input.is-ok { border-color: var(--ok); }
.input.is-locked { background: var(--surface-2); color: var(--ink-2); }
.input-group { display: flex; }
.input-group .input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line); border-inline-start: 0; border-start-end-radius: 8px; border-end-end-radius: 8px; background: var(--surface-2); font-size: 13px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check .box { width: 18px; height: 18px; flex: none; border: 1.5px solid #9AA9B6; border-radius: 4px; background: var(--surface); margin-top: 2px; display: grid; place-items: center; }
.check.is-on .box { background: var(--brand); border-color: var(--brand); color: #fff; }
.check.is-on .box .icon { width: 12px; height: 12px; stroke-width: 3; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
a.radio-card:hover { border-color: var(--ink-2); text-decoration: none; }
.radio-card .dot { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1.5px solid #9AA9B6; margin-top: 2px; }
.radio-card.is-on { border-color: var(--brand); background: var(--brand-lt); }
.radio-card.is-on .dot { border: 5px solid var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a, .seg span { padding: 8px 14px; font-size: 13.5px; color: var(--ink-2); border-inline-end: 1px solid var(--line); }
.seg > :last-child { border-inline-end: 0; }
.seg .is-on { background: var(--ink); color: #fff; }
.seg a:hover { text-decoration: none; background: var(--surface-2); }
.seg a.is-on:hover { background: var(--ink); }
.otp { display: flex; gap: 10px; }
.otp span { width: 48px; height: 56px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: 600 22px var(--mono); }
.otp.is-error span { border-color: var(--danger); color: var(--danger); background: #FFFBFB; }
.otp.is-expired span { color: var(--muted); background: var(--surface-2); }
.multi { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 8px; min-height: 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.multi .chip { padding: 3px 10px; font-size: 12.5px; background: var(--brand-lt); border-color: #BFE2D9; color: var(--brand-dp); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; margin-bottom: 20px; }
.tabs a { padding: 10px 14px; font-size: 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.is-on { color: var(--ink); border-color: var(--brand); font-weight: 600; }
.tabs .count { margin-inline-start: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { font-size: 14px; min-width: 640px; }
.table th, .table td { padding: 11px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); white-space: nowrap; }
.table thead th.sort::after { content: " \2195"; color: #A9B6C2; }
.table thead th.sorted::after { content: " \2193"; color: var(--ink); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFCFD; }
.table tr.is-warn td { background: #FFF8EE; }
.table tr.is-sel td { background: var(--brand-lt); }
.table .money { font-family: var(--mono); white-space: nowrap; }
.table .actions { white-space: nowrap; text-align: end; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 2px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; }
.pager .pages a, .pager .pages span { min-width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink-2); }
.pager .pages .is-on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.empty .illus { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center; background: var(--brand-lt); color: var(--brand); }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 18px; }

/* ---------- Modal (:target) ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 16px; background: rgba(15, 42, 61, .55); }
.modal:target, .modal.is-open { display: grid; }
.modal-box { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.modal-close:hover { background: var(--surface-2); text-decoration: none; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }

/* ---------- Notification item ---------- */
.notif-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.notif { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; padding: 14px 16px; align-items: start; color: var(--ink); position: relative; }
.notif + .notif { border-top: 1px solid var(--line); }
a.notif:hover { background: #FAFCFD; text-decoration: none; }
.notif .n-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.notif .n-ico.warn { background: var(--warn-lt); color: var(--warn); }
.notif .n-ico.danger { background: var(--danger-lt); color: var(--danger); }
.notif .n-ico.ok { background: var(--ok-lt); color: var(--ok); }
.notif .n-ico.info { background: var(--info-lt); color: var(--info); }
.notif .n-ico.gold { background: var(--gold-lt); color: var(--gold); }
.notif .n-title { font-weight: 600; font-size: 14px; }
.notif .n-sub { font-size: 13px; color: var(--muted); }
.notif .n-time { font-size: 12px; color: var(--muted); white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.notif.is-unread { background: #FBFDFF; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--info); }
.group-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }

/* ---------- Doc thumbnail ---------- */
.pdf-thumb { width: 92px; height: 116px; flex: none; border-radius: 6px; border: 1px solid var(--line); background: linear-gradient(var(--surface), var(--surface)) padding-box; position: relative; padding: 14px 10px; display: flex; flex-direction: column; gap: 5px; box-shadow: var(--shadow); }
.pdf-thumb i { display: block; height: 4px; border-radius: 2px; background: #DCE3EA; }
.pdf-thumb i:nth-child(2) { width: 70%; } .pdf-thumb i:nth-child(4) { width: 55%; }
.pdf-thumb b { position: absolute; inset-block-end: 8px; inset-inline-start: 8px; font: 700 10px var(--mono); color: #fff; background: var(--danger); padding: 1px 5px; border-radius: 3px; }
.doc-viewer { border: 1px solid var(--line); border-radius: var(--radius); background: #E9EEF2; min-height: 260px; display: grid; place-items: center; padding: 20px; }
.doc-viewer .page { width: 180px; height: 230px; background: #fff; box-shadow: var(--shadow); padding: 18px 14px; display: flex; flex-direction: column; gap: 8px; }
.doc-viewer .page i { display: block; height: 5px; border-radius: 2px; background: #DCE3EA; }
.doc-viewer .page i.h { height: 10px; width: 60%; background: #B9C6D2; }
.doc-viewer .page i.s { width: 45%; }

/* ---------- Prototype chrome ---------- */
.proto-pill {
  position: fixed; inset-block-end: 16px; inset-inline-end: 16px; z-index: 200;
  display: flex; align-items: center; gap: 2px; padding: 4px;
  border-radius: 999px; background: #111827; color: #fff; box-shadow: var(--shadow-lg);
  font: 600 12px/1 var(--font);
}
.proto-pill .lbl { padding: 6px 10px; color: #FBBF24; text-transform: uppercase; letter-spacing: .08em; font-size: 10.5px; }
.proto-pill a { padding: 7px 11px; border-radius: 999px; color: #E5E7EB; }
.proto-pill a:hover { background: #374151; text-decoration: none; }
.proto-pill a.is-on { background: #fff; color: #111827; }
.proto-prio { position: fixed; inset-block-start: 10px; inset-inline-end: 50%; transform: translateX(50%); z-index: 199; padding: 4px 12px; border-radius: 999px; font: 700 11px/1.4 var(--mono); background: #FDE68A; color: #78350F; box-shadow: var(--shadow); }
.proto-prio.p2 { background: #DDD6FE; color: #4C1D95; }
@media (max-width: 640px) {
  .proto-pill { inset-inline: 8px; justify-content: space-between; }
  .proto-pill .lbl { display: none; }
  .proto-pill a { padding: 7px 8px; }
  .toast { inset-inline: 12px; }
}
@media print { .proto-pill, .proto-prio { display: none; } }
