/* ASAN Invest - component sheet. Vocabulary is fixed: views compose these classes, they do not invent new ones. */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

:where(a) { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
:where(a):hover { color: var(--brand-hover); }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--r-control);
}

::selection { background: var(--brand-soft-2); color: var(--ink); }

::placeholder { color: var(--ink-3); opacity: 1; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--s-6); top: -100px; z-index: var(--z-tooltip);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--r-control); padding: var(--s-4) var(--s-6); box-shadow: var(--shadow-2);
}
.skip-link:focus-visible { top: var(--s-4); }

/* ============================================================ TYPE */

.h1, .h2, .h3, .h4 { margin: 0; font-weight: 600; letter-spacing: -0.018em; text-wrap: balance; color: var(--ink); }
.h1 { font-size: var(--t-2xl); line-height: 1.2; letter-spacing: -0.024em; }
.h2 { font-size: var(--t-xl); line-height: 1.25; }
.h3 { font-size: var(--t-md); line-height: 1.35; }
.h4 { font-size: var(--t-sm); line-height: 1.4; font-weight: 600; }

.display {
  margin: 0; font-weight: 700; font-size: clamp(2rem, 1.1rem + 3.4vw, 3.25rem);
  line-height: 1.06; letter-spacing: -0.03em; text-wrap: balance; color: var(--ink);
}

.lede { margin: 0; font-size: var(--t-md); line-height: 1.6; color: var(--ink-2); max-width: 60ch; text-wrap: pretty; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.small { font-size: var(--t-xs); }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }

.label {
  display: block; font-size: var(--t-xs); font-weight: 600; color: var(--ink-2);
  letter-spacing: 0.01em; margin-bottom: var(--s-3);
}

.overline {
  font-size: var(--t-2xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3);
}

.prose { max-width: var(--prose); color: var(--ink-2); text-wrap: pretty; }
.prose > * + * { margin-top: var(--s-5); }
.prose h3 { color: var(--ink); font-size: var(--t-md); font-weight: 600; margin-top: var(--s-8); }
.prose ul, .prose ol { padding-left: 1.25em; margin: 0; }
.prose li + li { margin-top: var(--s-3); }
.prose strong { color: var(--ink); font-weight: 600; }

/* ============================================================ LAYOUT PRIMITIVES */

.container { width: 100%; max-width: var(--content-max); margin-inline: auto; padding-inline: var(--s-8); }
.band { width: 100%; max-width: var(--band-max); margin-inline: auto; padding-inline: var(--s-8); }

.stack { display: flex; flex-direction: column; gap: var(--s-6); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-9); }

.row { display: flex; align-items: center; gap: var(--s-4); }
.row-top { display: flex; align-items: flex-start; gap: var(--s-4); }
.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--s-5); }
.push { margin-left: auto; }

.grid { display: grid; gap: var(--s-6); }
/* Self-sufficient: each also sets display+gap, so it works whether or not .grid is present too.
   (An earlier pass shipped bare class="g-2" in several views; rather than hunt every call site,
   the primitive itself no longer depends on a companion class.) */
.g-2 { display: grid; gap: var(--s-6); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { display: grid; gap: var(--s-6); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { display: grid; gap: var(--s-6); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { display: grid; gap: var(--s-6); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s-8); align-items: start; }
.split-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-9); align-items: center; }

.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ============================================================ APP SHELL */

.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: var(--s-6);
  padding-inline: var(--s-7);
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand-mark { display: flex; align-items: center; gap: var(--s-4); text-decoration: none; color: var(--ink); flex: none; }
.brand-mark:hover { color: var(--ink); }
.brand-glyph {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--brand); color: var(--ink-on-brand);
  display: grid; place-items: center; font-weight: 700; font-size: var(--t-sm); letter-spacing: -0.03em;
}
.brand-name { font-weight: 700; font-size: var(--t-md); letter-spacing: -0.025em; line-height: 1; }
.brand-sub { font-size: var(--t-2xs); color: var(--ink-3); line-height: 1; margin-top: 3px; }

.topnav { display: flex; align-items: center; gap: var(--s-2); }
.topnav a {
  padding: var(--s-3) var(--s-5); border-radius: var(--r-control);
  font-size: var(--t-sm); font-weight: 500; color: var(--ink-2); text-decoration: none;
  white-space: nowrap; transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }

.body-area { flex: 1; display: flex; min-height: 0; }

.rail {
  width: var(--rail-w); flex: none; background: var(--surface-2);
  border-right: 1px solid var(--line);
  padding: var(--s-6) var(--s-5); overflow-y: auto;
  position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h));
}
.rail-group + .rail-group { margin-top: var(--s-7); }
.rail-title {
  font-size: var(--t-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); padding-inline: var(--s-4); margin-bottom: var(--s-3);
}
.nav-item {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-4); border-radius: var(--r-control);
  font-size: var(--t-sm); font-weight: 500; color: var(--ink-2); text-decoration: none;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav-item + .nav-item { margin-top: var(--s-1); }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item .icon { flex: none; }
.nav-item .push { font-variant-numeric: tabular-nums; font-size: var(--t-2xs); color: var(--ink-3); }

.rail-collapse {
  width: 100%; border: 0; background: none; cursor: pointer; font: inherit;
  color: var(--ink-3); margin-bottom: var(--s-5); justify-content: flex-start;
}
.rail-collapse:hover { background: var(--surface-3); color: var(--ink); }
.rail-collapse span { font-size: var(--t-2xs); }

/* Collapsed rail: icons only, chosen by the user and remembered across sessions. */
.rail[data-collapsed="true"] { width: var(--rail-w-collapsed); padding-inline: var(--s-3); }
.rail[data-collapsed="true"] .rail-title,
.rail[data-collapsed="true"] .nav-item span:not(.badge-count),
.rail[data-collapsed="true"] .push { display: none; }
.rail[data-collapsed="true"] .nav-item { justify-content: center; padding-inline: 0; }

.main { flex: 1; min-width: 0; }
.page { padding: var(--s-8) var(--s-8) var(--s-12); max-width: var(--content-max); margin-inline: auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-6); margin-bottom: var(--s-8); flex-wrap: wrap; }
.page-head .lede { margin-top: var(--s-3); }

.breadcrumb { display: flex; align-items: center; gap: var(--s-3); font-size: var(--t-xs); color: var(--ink-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.breadcrumb a { color: var(--ink-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--brand); text-decoration: underline; }

/* ============================================================ PANELS */

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-5);
  padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line);
}
.panel-body { padding: var(--s-6); }
.panel-body-flush { padding: 0; }
.panel-foot { padding: var(--s-5) var(--s-6); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-panel) var(--r-panel); }
.panel-quiet { background: var(--surface-2); }

/* ============================================================ BUTTONS */

.btn {
  --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-3);
  min-height: 38px; padding: 0 var(--s-6);
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
  border-radius: var(--r-control); font-size: var(--t-sm); font-weight: 500; line-height: 1;
  cursor: pointer; white-space: nowrap; text-decoration: none; position: relative;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { --btn-bg: var(--brand); --btn-fg: var(--ink-on-brand); --btn-bd: var(--brand); font-weight: 600; }
.btn-primary:hover { --btn-bg: var(--brand-hover); --btn-bd: var(--brand-hover); }
.btn-primary:active { --btn-bg: var(--brand-active); }

.btn-secondary { --btn-bg: var(--brand-soft); --btn-fg: var(--brand); --btn-bd: var(--brand-border); font-weight: 600; }
.btn-secondary:hover { --btn-bg: var(--brand-soft-2); }

.btn-ghost { --btn-bg: transparent; --btn-fg: var(--ink-2); --btn-bd: transparent; }
.btn-ghost:hover { --btn-bg: var(--surface-2); --btn-fg: var(--ink); }

.btn-danger { --btn-bg: var(--bad); --btn-fg: oklch(1 0 0); --btn-bd: var(--bad); font-weight: 600; }
.btn-danger:hover { --btn-bg: oklch(0.45 0.185 25); }
/* The dark ramp lifts --bad to a light red, so white text on it drops to roughly 2.3:1.
   Dark ink on the same fill clears AA in both directions. */
[data-theme="dark"] .btn-danger { --btn-fg: oklch(0.17 0.02 262); }
[data-theme="dark"] .btn-danger:hover { --btn-bg: oklch(0.80 0.140 25); }
[data-theme="dark"] .badge-count { color: oklch(0.17 0.02 262); }

.btn-sm { min-height: 30px; padding: 0 var(--s-5); font-size: var(--t-xs); }
.btn-lg { min-height: 46px; padding: 0 var(--s-8); font-size: var(--t-md); }
.btn-icon { padding: 0; width: 38px; flex: none; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }

.btn[data-loading="true"] { color: transparent; pointer-events: none; }
.btn[data-loading="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 15px; height: 15px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  color: var(--btn-fg); animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================ PILLS, CHIPS, BADGES */

.pill {
  display: inline-flex; align-items: center; gap: var(--s-3);
  padding: 3px var(--s-4); border-radius: var(--r-pill);
  font-size: var(--t-2xs); font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill-info { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-border); }
.pill-ok   { background: var(--ok-soft);   color: var(--ok);   border-color: var(--ok-border); }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.pill-bad  { background: var(--bad-soft);  color: var(--bad);  border-color: var(--bad-border); }
.pill-plain::before { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-5); border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: var(--t-xs); font-weight: 500; color: var(--ink-2); cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.chip:hover { border-color: var(--brand-border); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--ink-on-brand); }

.badge-count {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: var(--r-pill); background: var(--bad); color: oklch(1 0 0);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1;
}

.avatar {
  width: 32px; height: 32px; border-radius: var(--r-pill); flex: none;
  display: grid; place-items: center; background: var(--brand-soft-2); color: var(--brand);
  font-size: var(--t-2xs); font-weight: 700; letter-spacing: 0.01em;
}
.avatar-lg { width: 48px; height: 48px; font-size: var(--t-sm); }

/* ============================================================ FORMS */

.field { display: block; }
.field + .field { margin-top: var(--s-6); }
/* Inside a grid or a flex stack the gap already does the spacing. Leaving the sibling margin
   on pushes every field after the first down by 16px, so a two-column form loses its baseline. */
.grid > .field + .field,
.stack > .field + .field,
.stack-sm > .field + .field,
.stack-lg > .field + .field,
.row > .field + .field { margin-top: 0; }
.field-req { color: var(--bad); margin-left: 2px; }

.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: var(--s-4) var(--s-5);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  font-size: var(--t-sm); line-height: 1.4;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 26%, transparent);
}
.textarea { min-height: 96px; resize: vertical; }
.select {
  appearance: none; padding-right: var(--s-9); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236b7280' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--s-5) center; background-size: 15px;
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }
.field[data-invalid="true"] .input,
.field[data-invalid="true"] .select,
.field[data-invalid="true"] .textarea { border-color: var(--bad); }

.hint { display: block; font-size: var(--t-xs); color: var(--ink-3); margin-top: var(--s-3); }
.error-text { display: flex; align-items: center; gap: var(--s-3); font-size: var(--t-xs); color: var(--bad); margin-top: var(--s-3); font-weight: 500; }

.check {
  display: flex; align-items: flex-start; gap: var(--s-4); cursor: pointer;
  font-size: var(--t-sm); color: var(--ink-2); line-height: 1.45;
}
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--brand); flex: none; cursor: pointer; }
.check + .check { margin-top: var(--s-4); }
/* Self-sufficient: a label is inline by default, and an inline element with padding and a
   border fragments across line boxes. The card variant must carry its own display. */
.check-card {
  display: flex; align-items: flex-start; gap: var(--s-4); cursor: pointer;
  font-size: var(--t-sm); color: var(--ink-2); line-height: 1.45;
  padding: var(--s-5); border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background: var(--surface); transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.check-card input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--brand); flex: none; cursor: pointer; }
.check-card + .check-card { margin-top: var(--s-4); }
.check-card:has(input:checked) span { color: var(--ink); }
.check-card:hover { border-color: var(--brand-border); }
.check-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

.fieldset { border: 0; padding: 0; margin: 0; }
.fieldset legend { padding: 0; font-size: var(--t-sm); font-weight: 600; color: var(--ink); margin-bottom: var(--s-5); }

.file-drop {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-control);
  padding: var(--s-8); text-align: center; background: var(--surface-2);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.file-drop:hover { border-color: var(--brand); background: var(--brand-soft); }

/* ============================================================ TABLES */

.table-wrap { border: 1px solid var(--line); border-radius: var(--r-panel); overflow: auto; background: var(--surface); }
.table-scroll { overflow-x: auto; }
/* Dense tables scroll rather than crushing columns into two-character stacks. */
.table-scroll > .table { min-width: 900px; }
@media (max-width: 760px) { .table-scroll > .table.table-stack { min-width: 0; } }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th {
  text-align: left; padding: var(--s-4) var(--s-6);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: var(--t-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3);
  white-space: nowrap;
}
.table td { padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr[aria-selected="true"] { background: var(--brand-soft); }
.table td.num, .table th.num { font-variant-numeric: tabular-nums; text-align: right; }
.table .cell-strong { color: var(--ink); font-weight: 500; }
.table a { font-weight: 500; text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* ============================================================ TABS */

.tabs { display: flex; gap: var(--s-2); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  padding: var(--s-4) var(--s-5); border: 0; background: none; cursor: pointer;
  font-size: var(--t-sm); font-weight: 500; color: var(--ink-2); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ============================================================ STATS */

.stat { padding: var(--s-6); border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
.stat-label { font-size: var(--t-xs); color: var(--ink-2); font-weight: 500; }
.stat-value { font-size: var(--t-2xl); font-weight: 700; letter-spacing: -0.03em; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: var(--s-3); }
.stat-note { font-size: var(--t-xs); color: var(--ink-3); margin-top: var(--s-3); }
.stat-delta { font-size: var(--t-xs); font-weight: 600; }
.stat-delta-up { color: var(--ok); }
.stat-delta-down { color: var(--bad); }

/* ============================================================ PROGRESS / SLA */

.progress { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; border-radius: var(--r-pill); background: var(--brand); transition: width var(--mid) var(--ease); }
.progress-bar[data-tone="ok"] { background: var(--ok); }
.progress-bar[data-tone="warn"] { background: var(--warn); }
.progress-bar[data-tone="bad"] { background: var(--bad); }

.sla { display: flex; flex-direction: column; gap: var(--s-3); min-width: 132px; }
.sla-text { font-size: var(--t-2xs); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============================================================ TIMELINE */

.timeline { position: relative; padding-left: var(--s-8); }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: var(--s-7); }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: calc(-1 * var(--s-8) + 1px); top: 4px;
  width: 14px; height: 14px; border-radius: 50%; background: var(--surface);
  border: 2px solid var(--line-strong);
}
.tl-item[data-state="done"] .tl-dot { background: var(--ok); border-color: var(--ok); }
.tl-item[data-state="current"] .tl-dot { background: var(--brand); border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.tl-item[data-state="blocked"] .tl-dot { background: var(--bad); border-color: var(--bad); }
.tl-title { font-size: var(--t-sm); font-weight: 600; color: var(--ink); }
.tl-meta { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; }
.tl-body { font-size: var(--t-sm); color: var(--ink-2); margin-top: var(--s-3); }

/* ============================================================ KEY-VALUE */

.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: var(--s-4) var(--s-6); font-size: var(--t-sm); }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; }

/* ============================================================ EMPTY / SKELETON / NOTICE */

.empty { text-align: center; padding: var(--s-11) var(--s-8); }
.empty-glyph {
  width: 44px; height: 44px; border-radius: var(--r-panel); margin: 0 auto var(--s-6);
  background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-3);
}
.empty-title { font-size: var(--t-md); font-weight: 600; color: var(--ink); }
.empty-text { font-size: var(--t-sm); color: var(--ink-2); margin: var(--s-3) auto 0; max-width: 46ch; text-wrap: pretty; }
.empty .btn { margin-top: var(--s-6); }

.skeleton { background: var(--surface-3); border-radius: var(--r-control); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--surface) 70%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.sk-line { height: 11px; }
.sk-line + .sk-line { margin-top: var(--s-4); }

.notice {
  display: flex; align-items: flex-start; gap: var(--s-5);
  padding: var(--s-5) var(--s-6); border-radius: var(--r-panel);
  border: 1px solid var(--brand-border); background: var(--brand-soft);
  font-size: var(--t-sm); color: var(--ink-2);
}
.notice .icon { color: var(--brand); flex: none; margin-top: 1px; }
.notice-title { font-weight: 600; color: var(--ink); display: block; margin-bottom: 2px; }
.notice-warn { border-color: var(--warn-border); background: var(--warn-soft); }
.notice-warn .icon { color: var(--warn); }
.notice-bad { border-color: var(--bad-border); background: var(--bad-soft); }
.notice-bad .icon { color: var(--bad); }
.notice-ok { border-color: var(--ok-border); background: var(--ok-soft); }
.notice-ok .icon { color: var(--ok); }

/* ============================================================ MODAL (closes via its own controls only) */

.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-backdrop);
  background: oklch(0.2 0.03 262 / 0.45); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: var(--s-6);
  animation: fade var(--fast) var(--ease);
}
.modal {
  position: relative; z-index: var(--z-modal);
  width: min(640px, 100%); max-height: min(86dvh, 800px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow-3); animation: rise var(--mid) var(--ease);
}
.modal-wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-5); padding: var(--s-6); border-bottom: 1px solid var(--line); }
.modal-body { padding: var(--s-6); overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-4); padding: var(--s-5) var(--s-6); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-panel) var(--r-panel); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.99); } }

/* ============================================================ TOAST */

.toasts { position: fixed; bottom: var(--s-7); right: var(--s-7); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--s-4); pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: var(--s-4); pointer-events: auto;
  min-width: 300px; max-width: 400px; padding: var(--s-5) var(--s-6);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow-3); font-size: var(--t-sm); color: var(--ink-2);
  animation: toast-in var(--mid) var(--ease);
}
.toast .icon { flex: none; margin-top: 1px; }
.toast[data-tone="ok"] .icon { color: var(--ok); }
.toast[data-tone="bad"] .icon { color: var(--bad); }
.toast[data-tone="info"] .icon { color: var(--brand); }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } }

/* ============================================================ DROPDOWN */

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-dropdown);
  min-width: 190px; padding: var(--s-3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow-3);
}
.menu-item {
  display: flex; align-items: center; gap: var(--s-4); width: 100%;
  padding: var(--s-4) var(--s-4); border: 0; border-radius: var(--r-control);
  background: none; text-align: left; font-size: var(--t-sm); color: var(--ink-2); cursor: pointer; text-decoration: none;
}
.menu-item:hover { background: var(--surface-2); color: var(--ink); }
.menu-sep { height: 1px; background: var(--line); margin: var(--s-3) 0; }

/* ============================================================ CONTROLS: language + theme */

.lang-switch { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-control); flex: none; }
.lang-switch button {
  padding: var(--s-2) var(--s-4); border: 0; border-radius: 5px; background: none; cursor: pointer;
  font-size: var(--t-2xs); font-weight: 600; color: var(--ink-3); letter-spacing: 0.02em;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.lang-switch button:hover { color: var(--ink); }
.lang-switch button[aria-pressed="true"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-1); }

/* ============================================================ COMMAND PALETTE */

.kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface-2); color: var(--ink-2);
  font-family: var(--mono); font-size: 11px; line-height: 1.5; text-align: center; white-space: nowrap;
}

.palette-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: oklch(0.2 0.03 262 / 0.42); backdrop-filter: blur(2px);
  display: flex; justify-content: center; align-items: flex-start;
  padding: max(8vh, var(--s-9)) var(--s-6) var(--s-6);
  animation: fade var(--fast) var(--ease);
}
.palette {
  width: min(620px, 100%); max-height: 68dvh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-panel);
  box-shadow: var(--shadow-3); overflow: hidden; animation: rise var(--mid) var(--ease);
}
.palette-search {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line);
}
.palette-search .icon { color: var(--ink-3); }
.palette-input { flex: 1; min-width: 0; border: 0; background: none; font-size: var(--t-md); color: var(--ink); }
.palette-input:focus { outline: none; }
.palette-list { overflow-y: auto; padding: var(--s-3); }
.palette-item {
  display: flex; align-items: center; gap: var(--s-4); width: 100%;
  padding: var(--s-4) var(--s-4); border: 0; border-radius: var(--r-control);
  background: none; text-align: left; cursor: pointer; color: var(--ink-2);
}
.palette-item .icon { color: var(--ink-3); flex: none; }
.palette-item[aria-selected="true"] { background: var(--brand-soft); color: var(--brand); }
.palette-item[aria-selected="true"] .icon { color: var(--brand); }
.palette-label {
  flex: 1; min-width: 0; font-size: var(--t-sm); font-weight: 500; color: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.palette-label-mono { font-weight: 400; }
.palette-hint { flex: none; font-size: var(--t-2xs); color: var(--ink-3); font-family: var(--mono); }
.palette-foot {
  display: flex; gap: var(--s-6); padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--line); background: var(--surface-2);
  font-size: var(--t-2xs); color: var(--ink-3);
}
.palette-foot span { display: inline-flex; align-items: center; gap: var(--s-2); }

.palette-trigger {
  display: inline-flex; align-items: center; gap: var(--s-3);
  height: 34px; padding: 0 var(--s-4) 0 var(--s-5);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-control);
  color: var(--ink-3); font-size: var(--t-xs); cursor: pointer;
  transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.palette-trigger:hover { border-color: var(--brand-border); color: var(--ink-2); }
.palette-trigger .icon { width: 15px; height: 15px; }

@media (max-width: 900px) { .palette-trigger span { display: none; } .palette-trigger { padding-inline: var(--s-4); } }
@media (max-width: 560px) { .palette-trigger { display: none; } }

/* ============================================================ ICONS */

.icon { width: 18px; height: 18px; flex: none; stroke-width: 1.75; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* ============================================================ BRAND: ŞƏBƏKƏ */

/* A band carrying the lattice. Kept at a whisper: the ornament is a watermark, not a texture
   the eye has to fight. It fades out toward the content so text never sits on a busy field. */
.shebeke-band { position: relative; isolation: isolate; }
.shebeke-band::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: var(--shebeke);
  background-position: center top;
  opacity: 0.5;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 0%, transparent 72%);
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 0%, transparent 72%);
}
[data-theme="dark"] .shebeke-band::before { opacity: 0.7; }

.shebeke-edge { position: relative; }
.shebeke-edge::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background-image: var(--shebeke-strip);
  background-repeat: repeat-x; background-size: auto 3px; opacity: 0.9;
}

/* Hero window */
.shebeke-window { width: 100%; max-width: 420px; height: auto; display: block; margin-inline: auto; }
.shebeke-window .lattice rect {
  stroke-dasharray: 1;
  animation: lattice-in 900ms var(--ease) both;
}
@keyframes lattice-in { from { opacity: 0; transform: scale(0.985); } }

.window-node { cursor: pointer; }
.window-node .node-halo { fill: var(--surface); stroke: var(--brand); stroke-width: 1.5; opacity: 0.55; transition: all var(--mid) var(--ease); }
.window-node .node-star { fill: var(--brand); opacity: 0.75; transition: all var(--mid) var(--ease); }
.window-node:hover .node-halo,
.window-node:focus-visible .node-halo,
.window-node[data-active="true"] .node-halo { opacity: 1; r: 24; fill: var(--brand-soft); }
.window-node:hover .node-star,
.window-node:focus-visible .node-star,
.window-node[data-active="true"] .node-star { opacity: 1; }
.window-node:focus { outline: none; }
.window-node:focus-visible .node-halo { stroke-width: 2.5; }

/* Sector artwork */
.sector-art { width: 100%; height: auto; color: var(--brand); opacity: 0.85; }
.sector-tile {
  display: grid; place-items: center; padding: var(--s-6);
  background: var(--brand-soft); border-radius: var(--r-panel);
  background-image: var(--shebeke); background-blend-mode: multiply;
}
[data-theme="dark"] .sector-tile { background-blend-mode: screen; }

/* Buta terminal mark */
.buta-rule { display: flex; align-items: center; gap: var(--s-5); color: var(--brand); opacity: 0.45; margin: var(--s-9) 0; }
.buta-rule span { flex: 1; height: 1px; background: currentColor; }

.seal-glyph { display: block; }

/* ============================================================ LANDING SURFACES */

.hero { padding: var(--s-12) 0 var(--s-11); border-bottom: 1px solid var(--line); background: var(--surface); }
/* Top-aligned: the headline must sit at the top of the band, not float halfway down it
   when the companion panel happens to be taller. */
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: var(--s-11); align-items: start; }
.hero-copy > * + * { margin-top: var(--s-6); }
.hero-actions { display: flex; gap: var(--s-4); flex-wrap: wrap; }

.section { padding: var(--s-12) 0; }
.section-alt { background: var(--surface); border-block: 1px solid var(--line); }
.section-head { max-width: 62ch; margin-bottom: var(--s-9); }
.section-head .lede { margin-top: var(--s-4); }

.flow-step { display: flex; gap: var(--s-6); align-items: flex-start; }
.flow-num {
  width: 30px; height: 30px; border-radius: var(--r-pill); flex: none;
  display: grid; place-items: center; background: var(--brand); color: var(--ink-on-brand);
  font-size: var(--t-xs); font-weight: 700; font-variant-numeric: tabular-nums;
}

.agency-item { display: flex; align-items: center; gap: var(--s-5); padding: var(--s-5) var(--s-6); }
.agency-item + .agency-item { border-top: 1px solid var(--line); }
.agency-glyph {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
}

.link-card {
  display: block; padding: var(--s-6); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-panel); text-decoration: none; color: inherit;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.link-card:hover { border-color: var(--brand-border); box-shadow: var(--shadow-2); transform: translateY(-1px); color: inherit; }

.auth-wrap { min-height: calc(100dvh - var(--topbar-h)); display: grid; place-items: center; padding: var(--s-9) var(--s-6); }
.auth-card { width: min(440px, 100%); }

/* ============================================================ WIZARD */

.steps { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: var(--s-4); }
.step-dot {
  width: 26px; height: 26px; border-radius: var(--r-pill); flex: none; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink-3);
  font-size: var(--t-2xs); font-weight: 700; font-variant-numeric: tabular-nums;
}
.step-label { font-size: var(--t-xs); font-weight: 500; color: var(--ink-3); white-space: nowrap; }
.step[data-state="current"] .step-dot { background: var(--brand); border-color: var(--brand); color: var(--ink-on-brand); }
.step[data-state="current"] .step-label { color: var(--ink); font-weight: 600; }
.step[data-state="done"] .step-dot { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok); }
.step[data-state="done"] .step-label { color: var(--ink-2); }
.step-bar { width: 28px; height: 1px; background: var(--line-strong); flex: none; }

/* ============================================================ UTILITIES */

.mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
.mt-7 { margin-top: var(--s-7); } .mt-8 { margin-top: var(--s-8); } .mt-9 { margin-top: var(--s-9); }
.mb-5 { margin-bottom: var(--s-5); } .mb-6 { margin-bottom: var(--s-6); } .mb-8 { margin-bottom: var(--s-8); }
.hidden { display: none !important; }
.full { width: 100%; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* ============================================================ RESPONSIVE: structural, never fluid type */

@media (max-width: 1180px) {
  .rail { width: var(--rail-w-collapsed); padding-inline: var(--s-3); }
  .rail .rail-title, .rail .nav-item span:not(.badge-count), .rail .push { display: none; }
  .nav-item { justify-content: center; padding-inline: 0; }
  .hero-grid { gap: var(--s-9); }
}

@media (max-width: 1000px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .hero-grid, .split-even { grid-template-columns: minmax(0, 1fr); gap: var(--s-9); }
  .topnav { display: none; }
}

@media (max-width: 760px) {
  .container, .band, .page { padding-inline: var(--s-6); }
  .page { padding-top: var(--s-7); }
  .g-2, .g-3, .g-4, .g-auto { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .rail[data-open="true"] {
    display: block; position: fixed; inset: var(--topbar-h) auto 0 0; width: var(--rail-w);
    z-index: var(--z-modal); box-shadow: var(--shadow-3); padding-inline: var(--s-5);
  }
  .rail[data-open="true"] .rail-title, .rail[data-open="true"] .nav-item span { display: block; }
  .rail[data-open="true"] .nav-item { justify-content: flex-start; padding-inline: var(--s-4); }
  .hero { padding: var(--s-10) 0 var(--s-9); }
  .section { padding: var(--s-10) 0; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: var(--s-2) 0; }
  .kv dd { margin-bottom: var(--s-4); }
  .toasts { left: var(--s-5); right: var(--s-5); bottom: var(--s-5); }
  .toast { min-width: 0; max-width: none; }

  /* Tables become stacked cards. The table box itself must become a block too, otherwise
     table layout keeps sizing to its widest cell and the whole page scrolls sideways. */
  .table-stack, .table-stack tbody { display: block; width: 100%; }
  .table-stack thead { display: none; }
  .table-stack tbody tr { display: block; padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); }
  .table-stack tbody td {
    display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-5);
    padding: var(--s-2) 0; border: 0; text-align: right; overflow-wrap: anywhere; min-width: 0;
  }
  .table-stack tbody td:empty { display: none; }
  .table-stack tbody td::before {
    content: attr(data-th); flex: none; max-width: 44%;
    font-size: var(--t-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--ink-3); text-align: left;
  }
  .table-stack tbody td[data-th=""]::before { display: none; }
  .table-stack tbody td[style] { min-width: 0 !important; }

  /* Chrome compaction: at phone width the identity block and the account name are noise. */
  .topbar { padding-inline: var(--s-5); gap: var(--s-4); }
  .brand-sub { display: none; }
  .topbar .menu-wrap .btn span.nowrap { display: none; }
  .lang-switch button { padding: var(--s-2) var(--s-3); }
}

/* Phone chrome budget: rail toggle + glyph + language + theme + account has to fit in 375px,
   so the wordmark and the bell step aside. Language never does; it is a core control here. */
@media (max-width: 560px) {
  .topbar { padding-inline: var(--s-4); gap: var(--s-3); }
  .brand-name { display: none; }
  .topbar > .row > a.btn-icon[href="#/cabinet"] { display: none; }
  .topbar .menu-wrap .btn { padding-inline: var(--s-3); gap: var(--s-2); }
  .page-head { gap: var(--s-5); }
  .page-head > .row, .page-head > .btn { width: 100%; }
  .page-head .btn { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; scroll-behavior: auto !important;
  }
}
