/*
 * Components (docs/ARCHITECTURE.md §11.7). Tokens only: no colour literals (they live in tokens.css).
 * Sections: boot · brand · buttons · forms · cards and headers · data display · feedback · navigation parts ·
 * tables · overlays · charts · shell pages.
 */

/* ---------- boot splash ---------- */
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); color: var(--color-text-muted); }
.boot-mark { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--color-border); border-top-color: var(--color-primary); animation: spin 0.9s linear infinite; }
.boot .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .boot-mark { animation-duration: 2.4s; } }

/* ---------- brand mark ---------- */
.brand-mark { display: block; flex: none; }
.brand-mark-tile { fill: var(--color-ink-3); }
.brand-mark-ring { stroke: var(--color-ink-accent); }
.brand-mark-lens { fill: var(--color-ink-strong); }
.brand-mark-tick { stroke: var(--color-ink-accent); }
.sidebar .brand-mark-tile { fill: var(--color-ink-2); }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--color-surface); --btn-fg: var(--color-text); --btn-bd: var(--color-border-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--touch-target); padding: 0 var(--space-4); border-radius: var(--radius-sm);
  border: 1px solid var(--btn-bd); background: var(--btn-bg); color: var(--btn-fg);
  font-size: var(--text-md); font-weight: var(--weight-medium); line-height: 1.2; white-space: nowrap; text-decoration: none;
  transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast);
  user-select: none;
}
.btn:hover { --btn-bg: var(--color-surface-3); text-decoration: none; }
.btn:active { --btn-bg: var(--color-border); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn-primary { --btn-bg: var(--color-primary); --btn-fg: var(--color-primary-contrast); --btn-bd: var(--color-primary); }
.btn-primary:hover { --btn-bg: var(--color-primary-hover); --btn-bd: var(--color-primary-hover); }
.btn-primary:active { --btn-bg: var(--color-primary-active); --btn-bd: var(--color-primary-active); }
.btn-danger { --btn-bg: var(--color-danger); --btn-fg: var(--color-primary-contrast); --btn-bd: var(--color-danger); }
.btn-danger:hover { --btn-bg: var(--color-danger-hover); --btn-bd: var(--color-danger-hover); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--color-text-muted); }
.btn-ghost:hover { --btn-bg: var(--color-surface-3); --btn-fg: var(--color-text); }
.btn-link { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--color-primary-ink); min-height: 0; padding: 0 var(--space-1); }
.btn-link:hover { --btn-bg: transparent; text-decoration: underline; }
.btn-sm { min-height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn-lg { min-height: 44px; padding: 0 var(--space-5); font-size: var(--text-lg); }
@media (pointer: coarse) { .btn-sm { min-height: var(--touch-target); } }
.btn-icon { padding: 0; width: var(--touch-target); }
.btn-icon.btn-sm { width: 30px; }
@media (pointer: coarse) { .btn-icon.btn-sm { width: var(--touch-target); } }
.btn-block { display: flex; width: 100%; }
.btn-badge {
  position: absolute; top: 2px; right: 2px; min-width: 16px; padding: 0 4px; border-radius: var(--radius-pill);
  background: var(--color-danger); color: var(--color-primary-contrast); font-size: 10px; font-weight: var(--weight-bold); line-height: 16px; text-align: center;
}
.btn.is-copied { --btn-fg: var(--color-success-ink); --btn-bd: var(--color-success); }
.btn.is-busy { cursor: progress; }
.spinner {
  --spinner-size: 16px; display: inline-block; width: var(--spinner-size); height: var(--spinner-size); flex: none;
  border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; opacity: 0.8; animation: spin 0.7s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-5); }
.form-grid > .is-wide, .form-grid > .form-error, .form-grid > .form-actions { grid-column: 1 / -1; }
@media (max-width: 767px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.form-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.form-error { padding: var(--space-3); border-radius: var(--radius-sm); background: var(--color-danger-bg); color: var(--color-danger-ink); font-size: var(--text-sm); }
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field-label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text); }
.field-required { color: var(--color-danger-ink); }
.field-hint { margin: 0; font-size: var(--text-sm); color: var(--color-text-muted); }
.field-error { margin: 0; font-size: var(--text-sm); color: var(--color-danger-ink); }
.field.has-error .input { border-color: var(--color-danger); }
.input {
  width: 100%; min-height: var(--touch-target); padding: 6px var(--space-3); border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-text); font-size: var(--text-md);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.input::placeholder { color: var(--color-text-subtle); }
.input:hover { border-color: var(--color-neutral); }
.input:focus, .input:focus-visible { border-color: var(--color-primary); outline: 2px solid var(--color-focus); outline-offset: -1px; }
.input:disabled, .input[readonly] { background: var(--color-surface-2); color: var(--color-text-muted); }
.input[aria-invalid="true"] { border-color: var(--color-danger); }
.textarea { resize: vertical; min-height: 84px; line-height: var(--leading-normal); }
select.input { appearance: none; padding-right: var(--space-7); background-image: linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%), linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input[type="search"]::-webkit-search-cancel-button { display: none; }
.input-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.input-wrap .input { flex: 1 1 auto; }
.input-wrap.has-action .input { padding-right: calc(var(--touch-target) + 2px); }
.input-wrap.has-icon .input { padding-left: 34px; }
.input-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--color-text-subtle); pointer-events: none; display: inline-flex; }
.input-action { position: absolute; right: 0; top: 0; bottom: 0; height: auto; width: var(--touch-target); min-height: 0; }
.search-input .input { min-width: 180px; }
.color-input { display: flex; align-items: center; gap: var(--space-3); }
.color-swatch { width: 44px; height: var(--touch-target); padding: 2px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); background: var(--color-surface); }

/* password strength */
.password-input { display: flex; flex-direction: column; gap: var(--space-2); }
.strength { display: flex; align-items: center; gap: var(--space-3); min-height: 18px; }
.strength-bar { display: flex; gap: 4px; flex: 0 0 120px; }
.strength-seg { height: 4px; flex: 1; border-radius: 2px; background: var(--color-border); }
.strength[data-level="0"] .strength-seg.is-on, .strength[data-level="1"] .strength-seg.is-on { background: var(--color-danger); }
.strength[data-level="2"] .strength-seg.is-on { background: var(--color-warning); }
.strength[data-level="3"] .strength-seg.is-on { background: var(--color-info); }
.strength[data-level="4"] .strength-seg.is-on { background: var(--color-success); }
.strength-label { font-size: var(--text-sm); color: var(--color-text-muted); }

/* checkbox and toggle (also the checklist box) */
.check { position: relative; display: inline-flex; flex: none; width: 20px; height: 20px; margin-top: 1px; }
.check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.check-box {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 5px;
  border: 1.5px solid var(--color-border-strong); background: var(--color-surface); color: transparent;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}
.check input:hover + .check-box { border-color: var(--color-primary); }
.check input:checked + .check-box, .check input:indeterminate + .check-box { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-primary-contrast); }
.check input:indeterminate + .check-box::after { content: ""; position: absolute; width: 10px; height: 2px; background: var(--color-primary-contrast); border-radius: 1px; }
.check input:indeterminate + .check-box svg { display: none; }
.check input:focus-visible + .check-box { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.check input:disabled + .check-box { opacity: 0.5; }
.checkbox, .toggle, .checklist-item { display: flex; align-items: flex-start; gap: var(--space-3); }
.checklist-text { display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; }
.checklist-label { font-weight: var(--weight-medium); }
.checklist-hint { font-size: var(--text-sm); color: var(--color-text-muted); }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.toggle .check { width: 38px; height: 22px; margin-top: 0; }
.toggle-track { position: relative; width: 38px; height: 22px; border-radius: var(--radius-pill); background: var(--color-border-strong); transition: background var(--motion-fast); }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--color-surface); box-shadow: var(--shadow-1); transition: transform var(--motion-fast) var(--ease-out); }
.check input:checked + .toggle-track { background: var(--color-primary); }
.check input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.check input:focus-visible + .toggle-track { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* combobox / listbox */
.combobox { position: relative; }
.combobox .input { padding-right: var(--space-7); }
.combo-chevron { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); display: inline-flex; }
.combo-spin { position: absolute; right: calc(var(--touch-target) + 4px); top: 50%; transform: translateY(-50%); color: var(--color-text-muted); display: inline-flex; }
.employee-picker .input { padding-right: calc(var(--touch-target) + 26px); }
.listbox {
  position: absolute; z-index: var(--z-popover); top: calc(100% + 4px); left: 0; right: 0; max-height: 280px; overflow-y: auto;
  margin: 0; padding: var(--space-1); list-style: none; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-2);
}
.listbox-option { display: flex; align-items: center; gap: var(--space-2); padding: 7px var(--space-3); border-radius: var(--radius-sm); cursor: pointer; }
.listbox-option.is-active, .listbox-option:hover { background: var(--color-primary-bg); }
.listbox-option.is-selected { font-weight: var(--weight-semibold); }
.listbox-option[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.listbox-hint { margin-left: auto; font-size: var(--text-sm); color: var(--color-text-muted); }
.employee-option-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listbox-empty { padding: var(--space-3); color: var(--color-text-muted); font-size: var(--text-sm); }

/* pagers and ranges */
.pager { display: inline-flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.pager-center { position: relative; display: inline-flex; }
.pager-current { min-width: 190px; gap: var(--space-2); }
.pager-text { font-weight: var(--weight-semibold); }
.pager-native { position: absolute; left: 0; bottom: 0; width: 100%; height: 1px; opacity: 0; pointer-events: none; }
.range-picker { display: flex; flex-direction: column; gap: var(--space-1); }
.range-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.range-row .input { width: auto; }
.range-sep { color: var(--color-text-muted); }

/* ---------- cards and headers ---------- */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); min-width: 0; display: flex; flex-direction: column; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5) 0; }
.card-heading { min-width: 0; }
.card-title { font-size: var(--text-lg); }
.card-subtitle { margin: 2px 0 0; font-size: var(--text-sm); color: var(--color-text-muted); }
.card-actions { display: flex; align-items: center; gap: var(--space-2); flex: none; flex-wrap: wrap; }
.card-body { padding: var(--space-4) var(--space-5) var(--space-5); min-width: 0; flex: 1 1 auto; }
.card-flush > .card-body { padding: 0; }
.card-flush > .card-header { padding-bottom: var(--space-3); }
.card-footer { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-toned { border-color: var(--tone); }
@media (max-width: 767px) {
  .card-header { padding: var(--space-4) var(--space-4) 0; }
  .card-body { padding: var(--space-3) var(--space-4) var(--space-4); }
}

.page-header { display: flex; flex-direction: column; gap: var(--space-2); }
.page-header-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-header-text { min-width: 0; }
.page-title { font-size: var(--text-2xl); letter-spacing: -0.02em; }
.page-subtitle { margin: 4px 0 0; color: var(--color-text-muted); max-width: 70ch; }
.page-meta { margin-top: var(--space-2); display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.page-header-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); list-style: none; margin: 0; padding: 0; font-size: var(--text-sm); color: var(--color-text-muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: var(--space-1); color: var(--color-text-subtle); }
.breadcrumbs a { color: var(--color-text-muted); }
.breadcrumbs a:hover { color: var(--color-primary-ink); }
@media (max-width: 767px) { .page-title { font-size: var(--text-xl); } .page-header-actions { width: 100%; } }

/* ---------- data display ---------- */
.kpi {
  position: relative; display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; padding: var(--space-4) var(--space-5);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); color: inherit;
}
.kpi-link { transition: border-color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast); }
.kpi-link:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-2); text-decoration: none; }
.kpi-link:focus-visible { outline-offset: 2px; }
.kpi-label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-muted); }
.kpi-marker { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); flex: none; }
.kpi-value { font-size: var(--text-3xl); font-weight: var(--weight-semibold); letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--color-text); }
.kpi-sub { font-size: var(--text-sm); color: var(--color-text-muted); }
.kpi-spark { margin-top: var(--space-2); min-height: 28px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--radius-pill); max-width: 100%;
  background: var(--tone-bg, var(--color-neutral-bg)); color: var(--tone-ink, var(--color-neutral-ink));
  font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 20px; white-space: nowrap;
}
.badge > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 4px; border-radius: var(--radius-pill);
  background: var(--tone-bg); color: var(--tone-ink); font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap; line-height: 20px;
}
.status-code {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--tone-ink); color: var(--tone-bg); font-size: 11px; font-weight: var(--weight-bold); line-height: 1;
}
.status-pill-sm { font-size: var(--text-xs); padding-right: 8px; line-height: 18px; }
.status-pill-sm .status-code { width: 18px; height: 18px; font-size: 10px; }
.flag-icons { display: inline-flex; align-items: center; gap: 2px; }
.flag-icon { display: inline-flex; padding: 2px; border-radius: 4px; color: var(--tone-ink); }
.flag-more { font-size: var(--text-xs); color: var(--color-text-muted); }

.avatar {
  --avatar-size: 32px; position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--avatar-size); height: var(--avatar-size); border-radius: 50%; overflow: hidden; color: var(--color-text);
  font-size: calc(var(--avatar-size) * 0.38); font-weight: var(--weight-semibold); background: var(--avatar-1); user-select: none;
}
.avatar-2 { background: var(--avatar-2); } .avatar-3 { background: var(--avatar-3); } .avatar-4 { background: var(--avatar-4); }
.avatar-5 { background: var(--avatar-5); } .avatar-6 { background: var(--avatar-6); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.has-image .avatar-initials { visibility: hidden; }
.employee-cell { display: inline-flex; align-items: center; gap: var(--space-3); min-width: 0; max-width: 100%; }
.employee-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.employee-name { font-weight: var(--weight-medium); color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.employee-name { color: var(--color-text); }
a.employee-name:hover { color: var(--color-primary-ink); }
.employee-sub { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.kv { margin: 0; display: grid; gap: var(--space-3) var(--space-6); grid-template-columns: minmax(0, 1fr); }
.kv-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kv-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 767px) { .kv-cols-2, .kv-cols-3 { grid-template-columns: minmax(0, 1fr); } }
.kv-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv-item dt { font-size: var(--text-sm); color: var(--color-text-muted); }
.kv-item dd { margin: 0; font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.kv-hint { display: block; font-size: var(--text-sm); font-weight: var(--weight-normal); color: var(--color-text-muted); }

.progress-wrap { display: flex; align-items: center; gap: var(--space-3); }
.progress-label, .progress-value { font-size: var(--text-sm); color: var(--color-text-muted); white-space: nowrap; }
.progress { --tone: var(--color-primary); display: block; flex: 1 1 auto; min-width: 120px; height: 8px; border-radius: var(--radius-pill); background: var(--color-surface-3); overflow: hidden; }
.progress-sm { height: 5px; }
.progress-fill { display: block; height: 100%; width: var(--progress, 0%); border-radius: inherit; background: var(--tone); transition: width var(--motion-base) var(--ease-out); }

.score-ring { --ring-size: 96px; position: relative; display: inline-flex; width: var(--ring-size); height: var(--ring-size); flex: none; }
.score-ring-track { stroke: var(--color-surface-3); }
.score-ring-value { stroke: var(--tone); }
.score-ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.score-ring-number { font-size: calc(var(--ring-size) * 0.3); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.score-ring.is-small .score-ring-grade { display: none; }
.score-ring-grade { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--tone-ink); }

.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin: 0; padding: 0; list-style: none; font-size: var(--text-sm); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--color-text-muted); }
.legend-box { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone); }
.legend-line { width: 16px; height: 2px; border-radius: 1px; background: var(--tone); }
.legend-code { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 4px; background: var(--tone-bg); color: var(--tone-ink); font-size: 11px; font-weight: var(--weight-bold); }
.legend-value { margin-left: var(--space-1); color: var(--color-text); font-weight: var(--weight-semibold); }

/* ---------- feedback ---------- */
.banner {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  background: var(--tone-bg); color: var(--tone-ink); border: 1px solid var(--tone);
}
.banner-icon { display: inline-flex; margin-top: 2px; color: var(--tone-ink); }
.banner-body { flex: 1 1 auto; min-width: 0; }
.banner-title { margin: 0; font-weight: var(--weight-semibold); }
.banner-text { margin: 0; font-size: var(--text-sm); }
.banner-title + .banner-text { margin-top: 2px; }
.banner-links { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 0 var(--space-2); font-size: var(--text-sm); }
.banner-link { padding: 0; border: 0; background: none; color: inherit; font-weight: var(--weight-semibold); text-decoration: underline; text-underline-offset: 2px; }
.banner-link:hover { text-decoration-thickness: 2px; }
.banner-action { flex: none; }
.banner .btn-ghost { --btn-fg: var(--tone-ink); }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: var(--space-8) var(--space-5); color: var(--color-text-muted); }
.empty-state.is-compact { padding: var(--space-5) var(--space-4); }
.empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; background: var(--color-surface-3); color: var(--color-text-muted); margin-bottom: var(--space-1); }
.is-compact .empty-icon { width: 40px; height: 40px; }
.empty-icon.tone-danger { background: var(--color-danger-bg); color: var(--color-danger-ink); }
.empty-title { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--color-text); }
.empty-text { margin: 0; max-width: 46ch; }
.empty-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; margin-top: var(--space-3); }

.skeleton { display: flex; flex-direction: column; gap: var(--space-3); }
.sk { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--color-surface-3) 25%, var(--color-border) 37%, var(--color-surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
.sk-w-full { width: 100%; } .sk-w-lg { width: 78%; } .sk-w-md { width: 52%; } .sk-w-sm { width: 30%; }
.sk-xl { height: 30px; width: 40%; } .sk-input { height: 36px; border-radius: var(--radius-sm); }
.skeleton-table { gap: 0; }
.sk-row { display: flex; align-items: center; gap: var(--space-5); padding: 14px var(--space-4); border-bottom: 1px solid var(--color-border); }
.sk-row > .sk { flex: 1 1 0; width: auto; }
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); }
.sk-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
.sk-chart { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding: var(--space-3); }
.sk-col { flex: 1; height: var(--sk-h, 50%); border-radius: 4px 4px 0 0; }
.sk-field { display: flex; flex-direction: column; gap: var(--space-2); }

.selection-bar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); background: var(--color-ink); color: var(--color-ink-strong); }
.selection-bar .btn-ghost { --btn-fg: var(--color-ink-text); }
.selection-bar .btn-ghost:hover { --btn-bg: var(--color-ink-3); --btn-fg: var(--color-ink-strong); }
.selection-count { font-weight: var(--weight-semibold); }
.selection-actions { display: flex; gap: var(--space-2); flex: 1 1 auto; flex-wrap: wrap; }

.stepper { display: flex; gap: var(--space-2); margin: 0; padding: 0; list-style: none; counter-reset: none; }
.step { position: relative; display: flex; align-items: center; gap: var(--space-3); flex: 1 1 0; min-width: 0; color: var(--color-text-muted); }
.step + .step::before { content: ""; position: absolute; left: calc(-1 * var(--space-2) - 12px); top: 50%; width: 24px; height: 2px; background: var(--color-border); }
.step-marker { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--color-border-strong); background: var(--color-surface); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.step-marker svg { display: none; }
.step.is-active { color: var(--color-text); }
.step.is-active .step-marker { border-color: var(--color-primary); background: var(--color-primary); color: var(--color-primary-contrast); }
.step.is-done .step-marker { border-color: var(--color-success); background: var(--color-success); color: var(--color-primary-contrast); }
.step.is-done .step-number { display: none; }
.step.is-done .step-marker svg { display: block; }
.step-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.step-label { font-weight: var(--weight-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-desc { font-size: var(--text-sm); color: var(--color-text-muted); }
@media (max-width: 767px) {
  .stepper { gap: var(--space-1); }
  .step { flex-direction: column; align-items: flex-start; gap: var(--space-1); }
  .step + .step::before { display: none; }
  .step-text .step-desc { display: none; }
}
/* UX-7: on a phone only the current step keeps a visible label; the others stay readable to screen readers */
@media (max-width: 480px) {
  .step { flex: none; }
  .step.is-active { flex: 1 1 auto; }
  .step:not(.is-active) .step-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .stepper { gap: var(--space-3); align-items: center; }
}

/* ---------- tabs, segmented, filters ---------- */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--touch-target); padding: 0 var(--space-4); border: 0; background: none; color: var(--color-text-muted); font-weight: var(--weight-medium); white-space: nowrap; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab:hover { color: var(--color-text); background: var(--color-surface-3); }
.tab.is-active { color: var(--color-primary-ink); }
.tab.is-active::after { content: ""; position: absolute; left: var(--space-3); right: var(--space-3); bottom: -1px; height: 2px; border-radius: 2px; background: var(--color-primary); }
.tab:disabled { opacity: 0.5; }
.tab-badge { min-width: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--color-surface-3); color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 20px; text-align: center; }
.tab.is-active .tab-badge { background: var(--color-primary-bg); color: var(--color-primary-ink); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--color-surface-3); max-width: 100%; overflow-x: auto; }
.segment { display: inline-flex; align-items: center; gap: var(--space-2); min-height: calc(var(--touch-target) - 6px); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--color-text-muted); font-weight: var(--weight-medium); white-space: nowrap; }
.segment:hover { color: var(--color-text); }
.segment[aria-checked="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-1); }
.segment-count { font-size: var(--text-xs); padding: 0 6px; border-radius: var(--radius-pill); background: var(--color-surface-3); font-variant-numeric: tabular-nums; }
.segmented-sm .segment { min-height: 26px; padding: 0 var(--space-2); font-size: var(--text-sm); }

.filter-bar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.filter-bar-items { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; min-width: 0; }
.filter-bar-toggle { display: none; }
.filter-bar-items .input, .filter-bar-items .combobox, .filter-bar-items .search-input { width: auto; min-width: 160px; }
@media (max-width: 767px) {
  .filter-bar.has-sheet .filter-bar-slot { display: none; }
  .filter-bar-toggle { display: inline-flex; }
}
.sheet { position: fixed; inset: 0; z-index: var(--z-overlay); display: flex; align-items: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: var(--color-overlay); }
.sheet-panel { position: relative; width: 100%; max-height: 88vh; display: flex; flex-direction: column; background: var(--color-surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-2); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
.sheet-title { font-size: var(--text-lg); }
.sheet-body { padding: var(--space-4); overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.sheet-body .filter-bar-items, .sheet-body { flex-direction: column; align-items: stretch; }
.sheet-body .input, .sheet-body .combobox, .sheet-body .search-input { width: 100%; }
.sheet-foot { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-border); }

/* ---------- copy field, code block ---------- */
.copy-field { display: flex; flex-direction: column; gap: var(--space-1); }
.copy-field-row { display: flex; gap: var(--space-2); align-items: stretch; }
.copy-field.is-multiline .copy-field-row { flex-direction: column; }
.copy-input { flex: 1 1 auto; min-width: 0; font-size: var(--text-sm); }
.copy-field-actions { display: flex; gap: var(--space-1); align-items: center; }
.code-block { border-radius: var(--radius-md); background: var(--color-ink); color: var(--color-ink-text); overflow: hidden; }
.code-block-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-ink-line); }
.code-block-label { font-size: var(--text-sm); color: var(--color-ink-muted); }
.code-block .btn { --btn-bg: var(--color-ink-2); --btn-fg: var(--color-ink-text); --btn-bd: var(--color-ink-line); }
.code-block .btn:hover { --btn-bg: var(--color-ink-3); }
.code-block-pre { margin: 0; padding: var(--space-4); overflow: auto; max-height: 340px; font-size: var(--text-sm); line-height: 1.6; tab-size: 2; }
.code-block-pre.is-wrapped { white-space: pre-wrap; overflow-wrap: anywhere; }
.code-block-pre:focus-visible { outline-color: var(--color-ink-accent); outline-offset: -2px; }

/* ---------- floating layers ---------- */
.popover { position: fixed; z-index: var(--z-popover); min-width: 200px; max-width: 92vw; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-2); }
.popover:focus { outline: none; }
.menu { padding: var(--space-1); min-width: 220px; display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 36px; padding: 6px var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--color-text); text-align: left; font-weight: var(--weight-medium); }
.menu-item:hover, .menu-item:focus-visible { background: var(--color-surface-3); text-decoration: none; outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--color-focus); }
.menu-item-danger { color: var(--color-danger-ink); }
.menu-item[disabled], .menu-item[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.menu-icon-space { width: 16px; flex: none; }
.menu-label { display: flex; flex-direction: column; min-width: 0; }
.menu-hint { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: var(--weight-normal); }
.menu-divider { height: 1px; margin: var(--space-1) 0; background: var(--color-border); }
.menu-heading { padding: 6px var(--space-3); font-size: var(--text-xs); color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-1); }
.tooltip { position: fixed; z-index: var(--z-toast); max-width: 280px; padding: 5px 9px; border-radius: var(--radius-sm); background: var(--color-ink); color: var(--color-ink-strong); font-size: var(--text-sm); pointer-events: none; box-shadow: var(--shadow-1); }

/* ---------- navigation parts (top bar) ---------- */
.topbar-search { position: relative; }
.topbar-search .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--color-text-subtle); display: inline-flex; pointer-events: none; }
.topbar-search-input { padding-left: 34px; min-height: 36px; background: var(--color-surface-2); }
.bell.has-alerts { color: var(--color-text); }
.bell[data-tone="danger"] .btn-badge { background: var(--color-danger); }
.bell[data-tone="warning"] .btn-badge { background: var(--color-warning-ink); }
.user-button { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 0 var(--space-2) 0 var(--space-1); border: 0; border-radius: var(--radius-pill); background: none; color: var(--color-text); font-weight: var(--weight-medium); }
.user-button:hover { background: var(--color-surface-3); }
.user-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alerts-popover { width: 380px; }
.alerts-head { display: flex; align-items: baseline; justify-content: space-between; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
.alerts-list { list-style: none; margin: 0; padding: var(--space-1); max-height: 380px; overflow-y: auto; }
.alert-item { display: flex; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); color: var(--color-text); }
.alert-item:hover { background: var(--color-surface-3); text-decoration: none; }
.alert-item-icon { display: inline-flex; margin-top: 2px; color: var(--tone-ink); }
.alert-item-text { display: flex; flex-direction: column; min-width: 0; }
.alert-item-message { font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.alert-item-meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.alerts-more { margin: 0; padding: var(--space-2) var(--space-4); text-align: center; }
.sidebar-close { position: absolute; top: 10px; right: 10px; color: var(--color-ink-text); }
.sidebar-close:hover { --btn-bg: var(--color-ink-2); --btn-fg: var(--color-ink-strong); }

/* ---------- tables ---------- */
/* positioned: absolutely placed .sr-only labels inside the scroller must not escape it and widen the page */
.table-wrap { overflow-x: auto; max-width: 100%; position: relative; }
/* a table inside a flex card must scroll in its own wrapper, never widen the card (K2) */
.data-table { min-width: 0; max-width: 100%; }
.card > .data-table, .card-body > .data-table { width: 100%; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-md); }
.table th, .table td { padding: 12px var(--space-4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--color-border); }
.table thead th { position: relative; padding-top: 10px; padding-bottom: 10px; background: var(--color-surface-2); font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-muted); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-dense th, .table-dense td { padding: 7px var(--space-3); }
.table-sticky thead th { position: sticky; top: var(--topbar-height); z-index: 2; }
/* inside the overflow wrapper the scrollport is the wrapper itself: no topbar offset (B10) */
.table-wrap .table-sticky thead th { top: 0; }
.table .align-right { text-align: right; font-variant-numeric: tabular-nums; }
.table .align-center { text-align: center; }
.table tbody tr:hover td { background: var(--color-surface-2); }
.table tbody tr.is-selected td { background: var(--color-primary-bg); }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.col-select { width: 44px; padding-right: 0 !important; }
.cell-primary { min-width: 0; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: inherit; }
.th-sort svg { opacity: 0; transition: opacity var(--motion-fast); }
.th-sort:hover svg { opacity: 0.5; }
.th-sort.is-sorted { color: var(--color-text); }
.th-sort.is-sorted svg { opacity: 1; }
.th-sort.is-desc svg { transform: rotate(180deg); }
.align-right .th-sort { flex-direction: row-reverse; }
.data-table.is-loading .table { opacity: 0.55; transition: opacity var(--motion-base); }
.skeleton-row td { padding: 0 !important; }
.table-more { display: flex; justify-content: center; padding: var(--space-3); border-top: 1px solid var(--color-border); }
.table-empty { border-top: 0; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-border); font-size: var(--text-sm); color: var(--color-text-muted); }
.pagination-buttons { display: inline-flex; gap: var(--space-2); }
@media (max-width: 1199px) { .hide-below-md { display: none; } }
/* wide report tables: secondary columns drop out before the table needs a scrollbar (K2) */
@media (max-width: 1359px) { .hide-below-ml { display: none; } }
@media (max-width: 1499px) { .hide-below-lg { display: none; } }
@media (max-width: 767px) {
  .hide-below-sm { display: none; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { position: relative; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
  .table-cards tbody tr:last-child { border-bottom: 0; }
  .table-cards td { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 4px 0; border: 0; text-align: right; }
  .table-cards td[data-label]::before { content: attr(data-label); flex: none; font-size: var(--text-sm); color: var(--color-text-muted); text-align: left; }
  .table-cards td.cell-empty { display: none; }
  .table-cards td.cell-primary { justify-content: flex-start; text-align: left; padding-bottom: var(--space-2); }
  .table-cards td.cell-primary::before { display: none; }
  .table-cards td.col-select { position: absolute; top: var(--space-3); right: var(--space-3); width: auto; padding: 0; }
  .table-cards tbody tr:hover td { background: none; }
  .table-cards tbody tr.is-selected { background: var(--color-primary-bg); }
}

/* ---------- modals and drawers ---------- */
.layer { position: fixed; inset: 0; z-index: var(--z-overlay); display: flex; }
.layer-modal { align-items: center; justify-content: center; padding: var(--space-4); }
.modal-scrim, .drawer-scrim { position: absolute; inset: 0; background: var(--color-overlay); animation: fade-in var(--motion-base) var(--ease-out); }
@keyframes fade-in { from { opacity: 0; } }
.modal {
  position: relative; display: flex; flex-direction: column; width: 100%; max-width: 560px; max-height: calc(100vh - 2 * var(--space-4));
  background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); animation: pop-in var(--motion-base) var(--ease-out);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal-sm { max-width: 440px; } .modal-lg { max-width: 760px; } .modal-xl { max-width: 1040px; }
.modal-header, .drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-3); }
.modal-title, .drawer-title { font-size: var(--text-xl); }
.modal-subtitle, .drawer-subtitle { margin: 2px 0 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.modal-body, .drawer-body { padding: 0 var(--space-5) var(--space-5); overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.modal-description, .drawer-description { color: var(--color-text-muted); }
.modal-error, .drawer-error { padding: 0 var(--space-5); }
.modal-error:not(:empty), .drawer-error:not(:empty) { padding-bottom: var(--space-3); }
.modal-footer, .drawer-footer { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-actions, .drawer-actions { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }
.confirm-message { margin-bottom: var(--space-3); }
.layer-drawer { justify-content: flex-end; }
.drawer {
  --drawer-width: 560px; position: relative; display: flex; flex-direction: column; width: min(var(--drawer-width), 100%); height: 100%;
  background: var(--color-surface); box-shadow: var(--shadow-2); animation: slide-in var(--motion-base) var(--ease-out);
}
@keyframes slide-in { from { transform: translateX(32px); opacity: 0; } }
.drawer-footer { border-radius: 0; }
@media (max-width: 767px) {
  .layer-modal { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .drawer { width: 100%; }
  .modal-header, .drawer-header { padding: var(--space-4) var(--space-4) var(--space-3); }
  .modal-body, .drawer-body { padding: 0 var(--space-4) var(--space-4); }
}
html.has-overlay { overflow: hidden; }

/* ---------- toasts ---------- */
.toast-region { position: fixed; z-index: var(--z-toast); right: var(--space-4); bottom: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); width: min(380px, calc(100vw - 2 * var(--space-4))); pointer-events: none; }
.toast-live { display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); pointer-events: auto;
  border-radius: var(--radius-md); background: var(--color-ink); color: var(--color-ink-strong); box-shadow: var(--shadow-2); border-left: 4px solid var(--tone);
  animation: toast-in var(--motion-base) var(--ease-out);
}
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--motion-base), transform var(--motion-base); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.toast-icon { display: inline-flex; margin-top: 1px; color: var(--tone); }
.toast.tone-warning .toast-icon, .toast.tone-info .toast-icon { color: var(--color-ink-strong); }
.toast-body { flex: 1 1 auto; min-width: 0; }
.toast-title { margin: 0; font-weight: var(--weight-semibold); }
.toast-text { margin: 0; overflow-wrap: anywhere; }
.toast-action { padding: 0 var(--space-2); border: 0; background: none; color: var(--color-ink-accent); font-weight: var(--weight-semibold); align-self: center; white-space: nowrap; }
.toast-close { display: inline-flex; padding: 4px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--color-ink-muted); }
.toast-close:hover { color: var(--color-ink-strong); background: var(--color-ink-3); }
.toast a:focus-visible, .toast button:focus-visible { outline-color: var(--color-ink-accent); }
@media (max-width: 767px) { .toast-region { right: var(--space-3); left: var(--space-3); bottom: var(--space-3); width: auto; } }

/* ---------- charts ---------- */
.chart { position: relative; margin: 0; min-width: 0; }
.chart-surface { width: 100%; min-width: 0; }
.chart-svg { display: block; overflow: visible; max-width: none; }
.chart-svg:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 4px; border-radius: 4px; }
.mark { fill: var(--tone); }
.mark-band { fill: var(--tone-bg); stroke: var(--tone); stroke-width: 1; }
.mark-tick { fill: var(--tone); }
.mark-line { fill: none; stroke: var(--tone); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mark-line.is-thin { stroke-width: 1.5; }
.mark-line.is-step { stroke-linejoin: miter; }
.mark-area { fill: var(--tone); fill-opacity: 0.1; stroke: none; }
.mark-dot { fill: var(--tone); stroke: var(--chart-surface); stroke-width: 2; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-baseline { stroke: var(--chart-axis); stroke-width: 1; }
.chart-row-track { stroke: var(--chart-grid); stroke-width: 1; }
.chart-tick { fill: var(--chart-label); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-tick-strong { fill: var(--color-text); font-weight: var(--weight-medium); }
.chart-row-label, .chart-panel-label { fill: var(--chart-label); font-size: 11px; }
.chart-value { fill: var(--color-text); font-size: 11px; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.chart-crosshair { stroke: var(--chart-crosshair); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart-marker { stroke: var(--color-text); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart-marker-label { fill: var(--color-text); font-size: 11px; font-weight: var(--weight-semibold); }
.chart-threshold { stroke: var(--tone); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart-hover-band { fill: var(--color-text); fill-opacity: 0.05; pointer-events: none; }
.chart-column .mark { transition: opacity var(--motion-fast); }
.chart-empty { display: flex; align-items: center; justify-content: center; min-height: var(--chart-h, 160px); color: var(--color-text-muted); font-size: var(--text-sm); border: 1px dashed var(--color-border); border-radius: var(--radius-md); }
.chart-legend, .chart-donut-legend { margin-top: var(--space-3); }
.chart-donut { display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap; }
.chart-donut-ring { position: relative; display: inline-flex; flex: none; }
.chart-donut-track { stroke: var(--color-surface-3); }
.chart-donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.chart-donut-value { font-size: var(--text-2xl); font-weight: var(--weight-semibold); line-height: 1.1; font-variant-numeric: tabular-nums; }
.chart-donut-label { font-size: var(--text-xs); color: var(--color-text-muted); }
.chart-donut-legend { flex-direction: column; gap: var(--space-2); margin: 0; min-width: 160px; }
.chart-donut-legend .legend-item { gap: var(--space-2); }
.chart-donut-legend .legend-value { margin-left: auto; padding-left: var(--space-4); }
.chart-tooltip {
  position: fixed; z-index: var(--z-toast); display: none; padding: 7px 10px; border-radius: var(--radius-sm); background: var(--color-ink); color: var(--color-ink-strong);
  font-size: var(--text-sm); box-shadow: var(--shadow-2); pointer-events: none; max-width: 280px;
}
.chart-tooltip.is-visible { display: block; }
.chart-tooltip-title { font-weight: var(--weight-semibold); margin-bottom: 3px; color: var(--color-ink-strong); }
.chart-tooltip-row { display: flex; align-items: center; gap: 8px; }
.chart-tooltip-key { width: 8px; height: 8px; border-radius: 50%; background: var(--tone); flex: none; box-shadow: 0 0 0 1.5px var(--color-ink-strong); }
.chart-tooltip-key.is-box { border-radius: 2px; }
.chart-tooltip-value { font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.chart-tooltip-label { color: var(--color-ink-text); }
.chart-spark { min-height: 28px; }
.chart-with-table { display: flex; flex-direction: column; gap: var(--space-2); align-items: flex-start; }
.chart-with-table > .chart { width: 100%; }
.chart-table { width: 100%; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.chart-table-toggle { margin-left: -4px; }

/* calendar heatmap */
.cal-grid { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-weekday { text-align: center; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-text-muted); padding-bottom: 2px; }
.cal-slot { display: block; min-width: 0; }
.cal-cell {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; width: 100%; min-height: 52px; padding: 5px 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--color-surface-2); color: var(--color-text-muted); font: inherit; text-align: left;
}
.cal-cell.is-blank { background: none; }
.cal-cell.has-tone { background: var(--tone-bg); color: var(--tone-ink); border-color: var(--tone-bg); }
button.cal-cell { cursor: pointer; }
button.cal-cell:hover { border-color: var(--tone, var(--color-border-strong)); }
button.cal-cell:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.cal-daynum { font-size: var(--text-xs); font-weight: var(--weight-medium); }
.cal-code { align-self: flex-end; font-size: var(--text-sm); font-weight: var(--weight-bold); }
.cal-value { align-self: flex-end; font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
@media (max-width: 767px) { .cal-cell { min-height: 42px; padding: 3px 4px; } }

/* ---------- shell pages ---------- */
.bare-card .field + .field, .bare-card .form > .field { margin-top: 0; }
.login-form .btn { margin-top: var(--space-2); }
.login-help { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--color-border); font-size: var(--text-sm); color: var(--color-text-muted); }
.login-help p + p { margin-top: var(--space-1); }
.trust-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-6); align-items: start; }
.trust-qr { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); text-align: center; max-width: 200px; }
.trust-qr .qr { display: block; width: 168px; height: 168px; }
.trust-qr p { font-size: var(--text-sm); color: var(--color-text-muted); }
.qr-light { fill: var(--color-surface); }
.qr-dark { fill: var(--color-ink); }
.trust-fingerprint { margin: var(--space-4) 0; }
.os-tabs { margin-top: var(--space-5); }
.os-steps { margin: var(--space-4) 0 0; padding-left: var(--space-6); display: flex; flex-direction: column; gap: var(--space-3); }
.os-steps li { padding-left: var(--space-1); }
.os-steps li::marker { color: var(--color-primary-ink); font-weight: var(--weight-semibold); }
.trust-after { margin-top: var(--space-5); }
@media (max-width: 767px) {
  .trust-hero { grid-template-columns: minmax(0, 1fr); }
  .trust-qr { max-width: none; flex-direction: row; text-align: left; }
  .trust-qr .qr { width: 120px; height: 120px; flex: none; }
}
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); align-items: start; max-width: 980px; }
@media (max-width: 899px) { .account-grid { grid-template-columns: minmax(0, 1fr); } }
.notice-page { max-width: 560px; margin: var(--space-8) auto 0; }

/* ---------- responsive chrome buttons (declared after .btn so they win over its display) ---------- */
.btn.topbar-menu, .btn.sidebar-close { display: none; }
@media (max-width: 767px) {
  .btn.topbar-menu, .btn.sidebar-close { display: inline-flex; }
}

/* UX-8: on a phone a banner's actions wrap under the message instead of squeezing it to one word per line */
@media (max-width: 600px) {
  .banner { flex-wrap: wrap; }
  .banner-body { flex: 1 1 calc(100% - 40px); }
  .banner-action { flex: 1 1 100%; }
}
