/* Amanah UI: shell and shared components. Colours, sizes and type come only from amanah-tokens.css
   (generated from design/tokens.json). A test fails the build on a raw hex colour in this file. */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  font-size: var(--t-body-staff);
  line-height: var(--t-body-staff-lh);
  color: var(--text);
  background: var(--surface-app);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--primary); }
button { font: inherit; color: inherit; }
.ar { font-family: var(--font-arabic); direction: rtl; unicode-bidi: isolate; }
.money, .tabular { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
h1:focus, main:focus { outline: none; }
.skip-link { position: absolute; left: var(--s-2); top: -100px; z-index: 100; background: var(--surface-card); color: var(--primary); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); box-shadow: var(--e-2); }
.skip-link:focus { top: var(--s-2); }

/* Eight-point star pattern on brand surfaces (stroke is white at 7%, encoded in the data URI). */
.pattern {
  background-color: var(--surface-brand);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='white' stroke-opacity='0.07' stroke-width='1'%3E%3Cpath d='M28 8l6 14 14 6-14 6-6 14-6-14-14-6 14-6z'/%3E%3Crect x='18' y='18' width='20' height='20' transform='rotate(45 28 28)'/%3E%3C/g%3E%3C/svg%3E");
}
.rail.pattern { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='white' stroke-opacity='0.035' stroke-width='1'%3E%3Cpath d='M28 8l6 14 14 6-14 6-6 14-6-14-14-6 14-6z'/%3E%3Crect x='18' y='18' width='20' height='20' transform='rotate(45 28 28)'/%3E%3C/g%3E%3C/svg%3E"); background-color: var(--surface-rail); }
.mark { color: var(--accent); flex-shrink: 0; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.rail {
  width: var(--size-rail); flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  background-color: var(--surface-rail); color: var(--text-on-brand);
  display: flex; flex-direction: column; padding: var(--s-5) var(--s-3) var(--s-3); overflow-y: auto;
  transition: width var(--m-base) ease;
}
.rail-org { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-1) var(--s-2) var(--s-4); border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: var(--s-2); }
.rail-org-text { display: flex; flex-direction: column; min-width: 0; }
.rail-org-text b { font-size: var(--t-small); line-height: var(--t-small-lh); }
.rail-org-text span { font-size: var(--t-label); opacity: .7; }
.rail-nav { flex: 1; }
.rail-group { font-size: var(--t-label); line-height: var(--t-label-lh); text-transform: uppercase; letter-spacing: .8px; opacity: .6; padding: var(--s-3) var(--s-3) var(--s-1); }
.rail-item {
  display: flex; align-items: center; gap: var(--s-3); min-height: 36px; padding: 0 var(--s-3);
  border-radius: 10px; color: var(--text-on-brand); text-decoration: none; opacity: .85; font-size: 13.5px;
  transition: background var(--m-fast) ease;
}
.rail-item:hover { background: rgba(255,255,255,.08); opacity: 1; }
.rail-item.on { background: rgba(255,255,255,.14); opacity: 1; font-weight: var(--fw-semibold); }
.rail-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-badge { margin-left: auto; font-size: var(--t-label); line-height: 1; background: var(--accent); color: var(--surface-rail); padding: 3px 7px; border-radius: var(--r-pill); font-weight: var(--fw-bold); }
.rail-collapse { display: flex; align-items: center; gap: var(--s-3); min-height: 36px; flex-shrink: 0; padding: 0 var(--s-3); margin-top: var(--s-3); border: 0; border-radius: 10px; background: none; color: var(--text-on-brand); opacity: .7; cursor: pointer; }
.rail-collapse:hover { opacity: 1; background: rgba(255,255,255,.08); }
.rail-scrim { display: none; }

/* Collapsed rail: icons only, 72 px. Remembered per browser (amanah.js). */
html[data-rail="collapsed"] .rail { width: var(--size-rail-collapsed); }
html[data-rail="collapsed"] .rail-org-text,
html[data-rail="collapsed"] .rail-group,
html[data-rail="collapsed"] .rail-label,
html[data-rail="collapsed"] .rail-badge { display: none; }
html[data-rail="collapsed"] .rail-item, html[data-rail="collapsed"] .rail-collapse { justify-content: center; padding: 0; }
html[data-rail="collapsed"] .rail-org { justify-content: center; padding-left: 0; padding-right: 0; }
html[data-rail="collapsed"] .rail-collapse .ic { transform: rotate(180deg); }

.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--size-top-bar); display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-6);
  background: var(--surface-card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar .topbar-menu { display: none; }
.topbar-org { display: flex; align-items: baseline; gap: var(--s-2); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; margin-right: var(--s-2); }
.topbar .chip { flex-shrink: 0; }
.topbar-org b { font-size: var(--t-h3); line-height: var(--t-h3-lh); }
.topbar-branch-name { color: var(--text-muted); font-size: var(--t-small); }
.topbar-spacer { flex: 1; }
.topbar-search { display: flex; align-items: center; gap: var(--s-2); height: 38px; padding: 0 var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-sunken); color: var(--text-muted); flex: 0 1 320px; min-width: 150px; }
.topbar-search input { border: 0; background: transparent; font: inherit; color: inherit; flex: 1; min-width: 0; outline: none; }
.topbar-search kbd { font: inherit; font-size: var(--t-label); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; background: var(--surface-card); }
.icon-btn { width: var(--size-touch-target); height: var(--size-touch-target); display: grid; place-items: center; border: 0; border-radius: var(--r-pill); background: none; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--surface-sunken); }

.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: var(--s-2); min-height: var(--size-touch-target); padding: 0 var(--s-2) 0 var(--s-1); border-radius: var(--r-md); cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--surface-sunken); }
.avatar { width: 34px; height: 34px; border-radius: var(--r-pill); display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: var(--fw-bold); font-size: var(--t-small); }
.usermenu-text { display: flex; flex-direction: column; line-height: 1.25; white-space: nowrap; }
.usermenu-text b { font-size: var(--t-small); }
.usermenu-text span { font-size: var(--t-label); color: var(--text-muted); }
.usermenu-panel { position: absolute; right: 0; top: calc(100% + var(--s-2)); width: 260px; background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--e-2); padding: var(--s-2); z-index: 30; }
.usermenu-head { display: flex; flex-direction: column; gap: 2px; padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: 1px solid var(--border); margin-bottom: var(--s-2); }
.usermenu-head span { color: var(--text-muted); font-size: var(--t-small); }
.usermenu-mfa { display: flex; align-items: center; gap: var(--s-1); }
.usermenu-item { display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: var(--size-touch-target); padding: 0 var(--s-3); border: 0; border-radius: var(--r-sm); background: none; cursor: pointer; text-align: left; }
.usermenu-item:hover { background: var(--surface-sunken); }

.trackbar { display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: 0 var(--s-6); border-bottom: 1px solid var(--border); background: var(--surface-app); }
.trackbar ol { display: flex; flex-wrap: wrap; gap: var(--s-2); list-style: none; margin: 0; padding: 0; font-size: var(--t-small); color: var(--text-muted); }
.trackbar li + li::before { content: "›"; margin-right: var(--s-2); }
.trackbar a { color: var(--text-muted); text-decoration: none; }
.trackbar a:hover { color: var(--primary); text-decoration: underline; }
.trackbar [aria-current="page"] { color: var(--text); font-weight: var(--fw-medium); }
.trackbar-actions { margin-left: auto; display: flex; gap: var(--s-2); }

.content { flex: 1; width: 100%; max-width: var(--size-content-max); padding: var(--s-6) var(--s-6) var(--s-10); outline: none; }

/* The rail already shows the SACCO: below 1280 px the top bar drops it to make room. */
@media (max-width: 1279px) {
  .topbar-org { display: none; }
}

/* Below 1024 px the rail is off-canvas. */
@media (max-width: 1023px) {
  .rail { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform var(--m-base) ease; width: var(--size-rail) !important; }
  html[data-rail-open] .rail { transform: none; box-shadow: var(--e-3); }
  html[data-rail-open] .rail-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(6,54,43,.4); }
  html[data-rail="collapsed"] .rail-org-text, html[data-rail="collapsed"] .rail-group,
  html[data-rail="collapsed"] .rail-label, html[data-rail="collapsed"] .rail-badge { display: revert; }
  .rail-collapse { display: none; }
  .topbar .topbar-menu { display: grid; }
  .rail-item, .rail-collapse { min-height: var(--size-touch-target); }
  .topbar { padding: 0 var(--s-3); }
  .trackbar, .content { padding-left: var(--s-4); padding-right: var(--s-4); }
}
@media (max-width: 720px) {
  .topbar-search, .topbar-branch-name { display: none; }
  .usermenu-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar { gap: var(--s-2); }
  .topbar .chip { padding: 0 var(--s-2); }
  .chip-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap; }
.eyebrow { font-size: var(--t-label); line-height: var(--t-label-lh); text-transform: uppercase; letter-spacing: .8px; color: var(--accent-text); font-weight: var(--fw-semibold); margin-bottom: var(--s-1); }
.page-header h1 { font-size: var(--t-h1); line-height: var(--t-h1-lh); font-weight: 650; }
.subtitle { color: var(--text-muted); margin-top: var(--s-1); }
.page-header-actions { display: flex; gap: var(--s-2); }

/* ---------- Cards, KPI tiles ---------- */
.panel { background: var(--surface-card); border-radius: 14px; padding: var(--s-5); box-shadow: var(--e-1); }
.panel h2 { font-size: var(--t-h3); line-height: var(--t-h3-lh); margin-bottom: var(--s-3); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.panel-head h2 { margin-bottom: 0; }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.kpi { display: flex; flex-direction: column; gap: var(--s-1); background: var(--surface-card); border-radius: 14px; padding: var(--s-4); box-shadow: var(--e-1); color: var(--text); text-decoration: none; }
.kpi-link:hover { box-shadow: var(--e-2); }
.kpi-label { font-size: var(--t-label); line-height: var(--t-label-lh); color: var(--text-muted); }
.kpi-value { font-size: var(--t-h2); line-height: var(--t-h2-lh); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-detail { font-size: var(--t-label); color: var(--primary); }

/* ---------- Dashboard grid, bars, alerts ---------- */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); margin-bottom: var(--s-4); }
@media (max-width: 1023px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.small { font-size: var(--t-small); line-height: var(--t-small-lh); }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.bar-row { display: grid; grid-template-columns: minmax(96px, 160px) minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); font-size: var(--t-small); line-height: var(--t-small-lh); }
.bar-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.bar-label { text-decoration: none; }
a.bar-label:hover { text-decoration: underline; }
.bar-track { height: 10px; display: block; background: var(--surface-sunken); border-radius: 0 4px 4px 0; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; }
.bar-value { color: var(--text); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; min-width: 64px; }
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.alert-row { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); font-size: var(--t-small); line-height: var(--t-small-lh); }
.alert-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.alert-error { color: var(--status-error-fg); background: var(--status-error-bg); }
.alert-warn { color: var(--status-warn-fg); background: var(--status-warn-bg); }
.alert-info { color: var(--status-progress-fg); background: var(--status-progress-bg); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { color: var(--text); font-weight: var(--fw-bold); text-decoration: none; }
.alert-title:hover { text-decoration: underline; }
.stages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: var(--s-2); }
.stage { display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-sunken); color: var(--text); text-decoration: none; }
a.stage:hover { box-shadow: var(--e-1); }
.stage-label { font-size: var(--t-label); line-height: var(--t-label-lh); color: var(--text-muted); }
.stage-count { font-size: var(--t-h3); line-height: var(--t-h3-lh); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.stage-amount { font-size: var(--t-label); line-height: var(--t-label-lh); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.rule-code { font-size: var(--t-label); line-height: var(--t-label-lh); color: var(--text-muted); background: var(--surface-sunken); border-radius: var(--r-sm); padding: 2px 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Status chip (word + shape, never colour alone) ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--t-label); line-height: var(--t-label-lh); font-weight: var(--fw-semibold); white-space: nowrap; }
.chip-shape { font-size: 10px; line-height: 1; }
.chip-ok { color: var(--status-ok-fg); background: var(--status-ok-bg); }
.chip-progress { color: var(--status-progress-fg); background: var(--status-progress-bg); }
.chip-warn { color: var(--status-warn-fg); background: var(--status-warn-bg); }
.chip-error { color: var(--status-error-fg); background: var(--status-error-bg); }
.chip-neutral { color: var(--status-neutral-fg); background: var(--status-neutral-bg); }

/* ---------- Note ---------- */
.note { display: flex; gap: var(--s-2); align-items: flex-start; padding: var(--s-3); border-radius: 10px; font-size: var(--t-small); line-height: var(--t-small-lh); }
.note .ic { margin-top: 1px; flex-shrink: 0; }
.note-info { background: var(--status-progress-bg); color: var(--status-progress-fg); }
.note-warn { background: var(--status-warn-bg); color: var(--status-warn-fg); }
.note-error { background: var(--status-error-bg); color: var(--status-error-fg); }

/* ---------- State card ---------- */
.state-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-2); padding: var(--s-10) var(--s-6); background: var(--surface-card); border-radius: var(--r-lg); box-shadow: var(--e-1); }
.state-card h2 { font-size: var(--t-h2); line-height: var(--t-h2-lh); }
.state-card p { color: var(--text-muted); max-width: 52ch; }
.state-icon { width: 56px; height: 56px; border-radius: var(--r-pill); display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-muted); margin-bottom: var(--s-2); }
.state-error .state-icon { background: var(--status-error-bg); color: var(--status-error-fg); }
.state-noaccess .state-icon { background: var(--status-warn-bg); color: var(--status-warn-fg); }
.state-soon .state-icon { background: var(--accent-soft); color: var(--accent-text); }
.state-actions { margin-top: var(--s-3); display: flex; gap: var(--s-2); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: var(--size-touch-target); padding: 0 var(--s-5); border: 0; border-radius: var(--r-md); font-weight: var(--fw-semibold); cursor: pointer; text-decoration: none; transition: background var(--m-fast) ease; }
.btn-sm { min-height: 36px; padding: 0 var(--s-4); font-size: var(--t-small); }
.btn-block { width: 100%; min-height: var(--size-button); }
.btn-primary { background: var(--primary); color: var(--text-on-brand); }
.btn-primary:hover { background: var(--primary-pressed); }
.btn-secondary { background: var(--primary-soft); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: var(--text-on-brand); }
.btn[disabled] { background: var(--text-disabled); color: var(--surface-card); cursor: not-allowed; }
.spinner { width: 14px; height: 14px; border-radius: var(--r-pill); border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Skeleton ---------- */
.skeleton { display: grid; gap: var(--s-2); }
.skeleton-line { display: block; height: 12px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-sunken), var(--sand-200), var(--surface-sunken)); background-size: 200% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Sign-in (split layout from the prototype) ---------- */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(440px, 1fr); }
.signin-brand { color: var(--text-on-brand); padding: var(--s-10) var(--s-12); display: flex; flex-direction: column; justify-content: space-between; gap: var(--s-8); }
.signin-brand-head { display: flex; align-items: center; gap: var(--s-3); }
.signin-brand-head small { display: block; font-size: var(--t-label); opacity: .75; }
.signin-brand-mid { max-width: 460px; }
.signin-brand-mid h1 { font-size: 34px; line-height: 1.15; letter-spacing: -.6px; }
.signin-brand-mid p { opacity: .85; margin-top: var(--s-3); font-size: 16px; line-height: 1.55; }
.signin-brand-mid ul { list-style: none; margin: var(--s-6) 0 0; padding: 0; display: grid; gap: var(--s-3); }
.signin-brand-mid li { display: flex; align-items: center; gap: var(--s-3); }
.signin-brand-mid li .ic { color: var(--accent); }
.signin-brand-foot { font-size: var(--t-label); opacity: .7; }
.signin-form { display: grid; place-items: center; padding: var(--s-10) var(--s-6); background: var(--surface-app); }
.authcard { width: 100%; max-width: 420px; background: var(--surface-card); border-radius: var(--r-lg); padding: var(--s-8); box-shadow: var(--e-2); }
.authcard h2 { font-size: var(--t-h1); line-height: var(--t-h1-lh); letter-spacing: -.3px; }
.authcard .sub { color: var(--text-muted); font-size: var(--t-small); margin: var(--s-1) 0 var(--s-5); }
.authcard .secured { margin-top: var(--s-5); text-align: center; font-size: var(--t-label); color: var(--text-muted); display: flex; justify-content: center; align-items: center; gap: var(--s-1); }
.persona { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border: 1.5px solid var(--border); border-radius: var(--r-md); margin-bottom: var(--s-2); cursor: pointer; }
.persona:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.persona input { accent-color: var(--primary); width: 18px; height: 18px; flex-shrink: 0; }
.persona b { display: block; }
.persona span { font-size: var(--t-small); color: var(--text-muted); }
.field-check { display: flex; align-items: center; gap: var(--s-2); margin: var(--s-3) 0 var(--s-4); font-size: var(--t-small); }
@media (max-width: 900px) { .signin { grid-template-columns: 1fr; } .signin-brand { display: none; } }

/* Splash: brief brand moment on first visit, then the sign-in card (CSS only, skipped under reduced motion). */
.splash { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; color: var(--text-on-brand); text-align: center; animation: splash-out var(--m-slow) ease 1.4s forwards; }
.splash-word { font-size: 40px; font-weight: var(--fw-bold); letter-spacing: -.6px; margin-top: var(--s-5); }
.splash-word span { font-weight: var(--fw-regular); opacity: .8; }
.splash .ar { font-size: 20px; color: var(--accent); }
.splash .mark { animation: mark-in .7s cubic-bezier(.2,.8,.2,1) both; }
.splash-load { height: 3px; width: 220px; margin: var(--s-8) auto 0; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
.splash-load span { display: block; height: 100%; background: var(--accent); animation: load 1.3s ease-in-out both; }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }
@keyframes mark-in { from { opacity: 0; transform: scale(.7) rotate(-45deg); } to { opacity: 1; transform: none; } }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { .splash { display: none; } }

/* Blazor reconnect / error UI */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; padding: var(--s-3) var(--s-6); background: var(--status-warn-bg); color: var(--status-warn-fg); box-shadow: var(--e-2); }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-small); line-height: var(--t-small-lh); }
.tbl th { text-align: left; font-size: var(--t-label); line-height: var(--t-label-lh); color: var(--text-muted); font-weight: var(--fw-semibold); padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: var(--s-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl a.row-link { color: var(--text); font-weight: var(--fw-semibold); text-decoration: none; }
.tbl a.row-link:hover { text-decoration: underline; }
.tbl tbody tr:hover { background: var(--surface-sunken); }
.cell-sub { display: block; color: var(--text-muted); font-size: var(--t-label); line-height: var(--t-label-lh); }

/* ---------- Toolbar, tabs, pager ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.toolbar .search { display: flex; align-items: center; gap: var(--s-2); flex: 1 1 320px; max-width: 480px; height: 40px; padding: 0 var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-card); color: var(--text-muted); }
.toolbar .search input { border: 0; background: transparent; font: inherit; color: var(--text); flex: 1; min-width: 0; outline: none; }
.tabs { display: flex; gap: var(--s-1); flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: var(--s-1); height: 36px; padding: 0 var(--s-3); border-radius: var(--r-pill); color: var(--text-muted); text-decoration: none; font-size: var(--t-small); font-weight: var(--fw-semibold); }
.tab:hover { background: var(--surface-sunken); color: var(--text); }
.tab[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.tab-count { font-variant-numeric: tabular-nums; font-weight: var(--fw-regular); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); margin-top: var(--s-4); font-size: var(--t-small); color: var(--text-muted); }
.pager-links { display: flex; gap: var(--s-2); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .field-label { font-size: var(--t-small); line-height: var(--t-small-lh); font-weight: var(--fw-semibold); color: var(--text); }
.field input, .field select, .field textarea { font: inherit; color: var(--text); background: var(--surface-card); border: 1.5px solid var(--border); border-radius: var(--r-md); min-height: var(--size-touch-target); padding: 0 var(--s-3); }
.field textarea { padding: var(--s-2) var(--s-3); min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--focus-ring); outline-offset: 1px; border-color: var(--primary); }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-hint { font-size: var(--t-label); line-height: var(--t-label-lh); color: var(--text-muted); }
.field-error { font-size: var(--t-label); line-height: var(--t-label-lh); color: var(--status-error-fg); }
.form-section { font-size: var(--t-h3); line-height: var(--t-h3-lh); margin: var(--s-6) 0 var(--s-3); }
.form-section:first-child { margin-top: 0; }
.form-actions { display: flex; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-6); flex-wrap: wrap; }
.form-actions .right { display: flex; gap: var(--s-2); margin-left: auto; }
.check { display: flex; align-items: flex-start; gap: var(--s-2); font-size: var(--t-small); line-height: var(--t-small-lh); }
.check input { accent-color: var(--primary); width: 18px; height: 18px; margin-top: 0; flex-shrink: 0; }
.narrow { max-width: 880px; }

/* ---------- Stepper ---------- */
.stepper { list-style: none; margin: 0 0 var(--s-5); padding: 0; display: flex; gap: var(--s-2); flex-wrap: wrap; }
.stepper li { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-small); color: var(--text-muted); }
.stepper li + li::before { content: ""; width: 24px; height: 1px; background: var(--border); }
.step-no { width: 26px; height: 26px; border-radius: var(--r-pill); display: grid; place-items: center; background: var(--surface-sunken); font-weight: var(--fw-bold); font-size: var(--t-label); }
.stepper li[aria-current="step"] { color: var(--text); font-weight: var(--fw-semibold); }
.stepper li[aria-current="step"] .step-no { background: var(--primary); color: var(--text-on-brand); }
.stepper li.done .step-no { background: var(--primary-soft); color: var(--primary); }

/* ---------- Key/value lists, document tiles ---------- */
.kv { display: flex; justify-content: space-between; gap: var(--s-4); padding: var(--s-2) 0; border-bottom: 1px solid var(--border); font-size: var(--t-small); line-height: var(--t-small-lh); }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--text-muted); }
.kv > :last-child { text-align: right; font-weight: var(--fw-semibold); }
.docs { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.doc { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); font-size: var(--t-small); line-height: var(--t-small-lh); }
.doc-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-sunken); color: var(--text-muted); }
.doc.have .doc-icon { background: var(--status-ok-bg); color: var(--status-ok-fg); }
.doc-body { flex: 1; min-width: 0; }
.doc-body b { display: block; }
.doc-actions { display: flex; gap: var(--s-2); align-items: center; }
.upload-btn { position: relative; overflow: hidden; }
.upload-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.member-head { display: flex; align-items: center; gap: var(--s-4); }
.member-head .avatar { width: 56px; height: 56px; font-size: var(--t-h3); }
.back-link { display: inline-flex; align-items: center; gap: var(--s-1); font-size: var(--t-small); color: var(--primary); text-decoration: none; margin-bottom: var(--s-2); }
.back-link:hover { text-decoration: underline; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-decoration: underline; }

/* ---------- Pipeline board ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: var(--s-3); overflow-x: auto; padding-bottom: var(--s-2); }
.kcol { background: var(--surface-sunken); border-radius: var(--r-md); padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); min-height: 160px; }
.kcol-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2); font-size: var(--t-small); font-weight: var(--fw-bold); }
.kcol-head span:last-child { color: var(--text-muted); font-weight: var(--fw-regular); font-variant-numeric: tabular-nums; }
.kcol-sum { font-size: var(--t-label); line-height: var(--t-label-lh); color: var(--text-muted); margin-top: calc(-1 * var(--s-1)); font-variant-numeric: tabular-nums; }
.kcard { display: flex; flex-direction: column; gap: 2px; background: var(--surface-card); border-radius: var(--r-md); padding: var(--s-3); box-shadow: var(--e-1); color: var(--text); text-decoration: none; font-size: var(--t-small); line-height: var(--t-small-lh); }
.kcard:hover { box-shadow: var(--e-2); }
.kcard-ref { font-size: var(--t-label); line-height: var(--t-label-lh); color: var(--text-muted); }
.kcard-amount { margin-top: var(--s-1); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.kcol-empty { font-size: var(--t-label); color: var(--text-muted); padding: var(--s-2) 0; }

/* ---------- Contract stage timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--s-3); padding-bottom: var(--s-4); position: relative; font-size: var(--t-small); line-height: var(--t-small-lh); }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.timeline .dot { width: 28px; height: 28px; border-radius: var(--r-pill); display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-muted); font-size: var(--t-label); font-weight: var(--fw-bold); }
.timeline li.done .dot { background: var(--status-ok-bg); color: var(--status-ok-fg); }
.timeline li.current .dot { background: var(--primary); color: var(--text-on-brand); }
.timeline li.locked .dot { background: var(--status-warn-bg); color: var(--status-warn-fg); }
.timeline b { display: block; }
.price-total { font-size: var(--t-h3); }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: var(--s-4); align-items: start; }
@media (max-width: 1023px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }
.field input.num-input { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Choice cards (pick one), audit checks ---------- */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s-3); }
.choice { display: flex; gap: var(--s-2); align-items: flex-start; padding: var(--s-3); border: 1.5px solid var(--border); border-radius: var(--r-md); background: var(--surface-card); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--primary); box-shadow: var(--e-1); }
.choice input { margin-top: 3px; }
.choice b { display: block; font-size: var(--t-small); }
.choice span { color: var(--text-muted); font-size: var(--t-label); }
.check-yes { color: var(--green-700); font-weight: 600; }
.check-no { color: var(--red-600); font-weight: 600; }
.check-wait { color: var(--text-muted); }
