:root {
  /* Primitive tokens extracted from bklit.com via Dembrandt, adapted for a data-heavy app. */
  --color-ink-950: #090b0c;
  --color-ink-800: #242525;
  --color-ink-700: #3e3e3e;
  --color-ink-600: #52555b;
  --color-ink-500: #757575;
  --color-neutral-000: #ffffff;
  --color-neutral-050: #f5f5f5;
  --color-neutral-075: #f1f1f1;
  --color-neutral-100: #eaeaea;
  --color-neutral-150: #e4e4e4;
  --color-neutral-200: #d6d3d1;
  --color-blue-950: #182034;
  --color-green-700: #146c43;
  --color-green-050: #eff8f3;
  --color-amber-700: #8a5a12;
  --color-amber-050: #fff7e8;
  --color-red-700: #9f3434;
  --color-red-050: #fff1f1;
  --color-blue-050: #f0f2f5;

  /* Semantic tokens. */
  --color-background: var(--color-neutral-050);
  --color-grid: rgb(9 11 12 / 3.5%);
  --color-surface: var(--color-neutral-000);
  --color-surface-alt: var(--color-neutral-075);
  --color-surface-muted: var(--color-neutral-100);
  --color-foreground: var(--color-ink-950);
  --color-muted-foreground: var(--color-ink-600);
  --color-subtle-foreground: var(--color-ink-500);
  --color-border: var(--color-neutral-150);
  --color-border-strong: var(--color-neutral-200);
  --color-primary: var(--color-ink-950);
  --color-primary-hover: var(--color-ink-700);
  --color-primary-foreground: var(--color-neutral-000);
  --color-accent: var(--color-blue-950);
  --color-success: var(--color-green-700);
  --color-success-surface: var(--color-green-050);
  --color-warning: var(--color-amber-700);
  --color-warning-surface: var(--color-amber-050);
  --color-danger: var(--color-red-700);
  --color-danger-surface: var(--color-red-050);
  --color-info: var(--color-blue-950);
  --color-info-surface: var(--color-blue-050);
  --color-ring: var(--color-ink-950);

  /* Typography tokens. */
  --font-sans: Geist, Inter, "Segoe UI", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 24px;
  --text-2xl: 36px;

  /* Spacing tokens: Bklit uses an 8px-centered scale with 32px/64px section rhythm. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Component tokens. */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-panel: 4px;
  --radius-pill: 999px;
  --button-radius: var(--radius-xs);
  --button-bg: var(--color-primary);
  --button-fg: var(--color-primary-foreground);
  --button-border: var(--color-primary);
  --button-bg-hover: var(--color-primary-hover);
  --button-secondary-bg: rgb(255 255 255 / 80%);
  --button-secondary-fg: var(--color-foreground);
  --button-secondary-border: var(--color-border);
  --input-bg: rgb(255 255 255 / 82%);
  --input-border: var(--color-border);
  --input-border-focus: var(--color-foreground);
  --panel-bg: rgb(255 255 255 / 86%);
  --panel-border: var(--color-border);
  --panel-shadow: 0 0 0 1px rgb(9 11 12 / 2%);
  --chrome-bg: rgb(245 245 245 / 88%);
  --chrome-surface-bg: rgb(255 255 255 / 76%);
  --interactive-hover-bg: rgb(255 255 255 / 70%);
  --pressed-shadow: inset 0 0 0 999px rgb(0 0 0 / 8%);
  --status-success-border: rgb(20 108 67 / 18%);
  --status-warning-border: rgb(138 90 18 / 20%);
  --status-danger-border: rgb(159 52 52 / 18%);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-medium: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--color-background);
  background-image:
    linear-gradient(var(--color-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--color-foreground);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.43;
}

a {
  color: inherit;
}

button,
select,
input {
  font: inherit;
}

button,
.button,
select,
input {
  min-height: 36px;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 64px;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-6);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 36px;
  border: 1px solid var(--color-foreground);
  border-radius: var(--radius-xs);
  background: var(--color-primary);
  color: var(--color-primary-foreground);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
}

.brand-name {
  color: var(--color-foreground);
  font-size: var(--text-md);
  line-height: 1;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  flex-wrap: wrap;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--color-muted-foreground);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.nav-link:hover {
  border-color: var(--color-border);
  background: var(--interactive-hover-bg);
  color: var(--color-foreground);
}

.nav-link.active {
  border-color: var(--color-foreground);
  background: var(--color-surface);
  color: var(--color-foreground);
  font-weight: 600;
}

.nav-link.disabled {
  opacity: 0.55;
}

.main-area {
  min-width: 0;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 var(--space-6);
  background: var(--chrome-surface-bg);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(14px);
}

.topbar-label,
.muted {
  color: var(--color-muted-foreground);
}

.topbar-label,
.small {
  font-size: var(--text-xs);
}

.topbar-title {
  margin-top: 2px;
  font-size: var(--text-md);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-actions form {
  margin: 0;
}

.content {
  padding: var(--space-6);
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: flex-start;
  margin-bottom: var(--space-4);
}

h1 {
  margin: 0;
  font-size: var(--text-xl);
  line-height: 1.08;
  font-weight: 700;
}

p {
  margin: 6px 0 0;
}

.inline-link {
  margin-left: var(--space-2);
  color: var(--color-accent);
  font-weight: 600;
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--space-4);
}

.auth-card {
  width: min(100%, 360px);
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(16px);
}

.auth-brand {
  margin-bottom: var(--space-4);
}

.auth-form {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.auth-form label {
  display: grid;
  gap: var(--space-1);
  color: var(--color-muted-foreground);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
}

.auth-form .button {
  width: 100%;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 92px;
  padding: 0 var(--space-3);
  border: 1px solid var(--button-border);
  border-radius: var(--button-radius);
  background: var(--button-bg);
  color: var(--button-fg);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.button.secondary {
  border-color: var(--button-secondary-border);
  background: var(--button-secondary-bg);
  color: var(--button-secondary-fg);
}

.button.compact {
  min-width: auto;
  padding: 0 var(--space-2);
}

.button:hover {
  border-color: var(--button-bg-hover);
  background: var(--button-bg-hover);
}

.button.secondary:hover {
  border-color: var(--color-foreground);
  background: var(--color-surface);
}

.button:active {
  box-shadow: var(--pressed-shadow);
}

.button:disabled,
.button[disabled] {
  opacity: 0.58;
  cursor: not-allowed;
}

.button:disabled:hover,
.button[disabled]:hover {
  background: var(--color-primary);
}

.button.secondary:disabled:hover,
.button.secondary[disabled]:hover {
  background: var(--color-surface);
}

.button-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-pill);
  flex: 0 0 auto;
  animation: button-spinner-rotate 800ms linear infinite;
}

.button.is-loading .button-spinner {
  display: inline-block;
}

.sync-form {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: flex-end;
}

.sync-pending-note {
  display: none;
  color: var(--color-muted-foreground);
  font-size: 12px;
  white-space: nowrap;
}

.sync-form.is-submitting .sync-pending-note {
  display: inline-block;
}

@keyframes button-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

.alert {
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-left-width: 3px;
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
}

.alert.warning {
  border-left-color: var(--color-warning);
}

.alert.success {
  border-left-color: var(--color-success);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.summary-item {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--panel-shadow);
  transition: border-color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
}

.summary-item:hover {
  border-color: var(--color-foreground);
  background: var(--color-surface);
}

.summary-item.active {
  border-color: var(--color-foreground);
  box-shadow: inset 0 0 0 1px var(--color-foreground);
}

.summary-item span {
  color: var(--color-muted-foreground);
  font-size: 12px;
}

.summary-item strong {
  font-variant-numeric: tabular-nums;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
}

.filter-panel label {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  color: var(--color-muted-foreground);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 650;
  text-transform: uppercase;
}

.filter-panel input,
.filter-panel select {
  width: 100%;
  color: var(--color-foreground);
}

.filter-actions {
  display: flex;
  align-items: end;
  gap: var(--space-2);
}

.section {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.account-switch-section {
  gap: var(--space-3);
}

.account-switch-form {
  display: flex;
  align-items: end;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
}

.account-switch-form label {
  display: grid;
  gap: var(--space-1);
  min-width: min(420px, 100%);
  color: var(--color-muted-foreground);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 650;
  text-transform: uppercase;
}

.account-switch-form select {
  width: 100%;
  color: var(--color-foreground);
}

.service-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: var(--space-3);
}

.service-panel-form {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
}

.service-panel-form label {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  color: var(--color-muted-foreground);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 650;
  text-transform: uppercase;
}

.service-panel-form select,
.service-panel-form .input,
.account-name-input {
  width: 100%;
}

h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.metric {
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
}

.metric-label {
  color: var(--color-muted-foreground);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
}

.metric-value {
  margin-top: var(--space-1);
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.dashboard-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(10px);
}

.overview-primary {
  min-width: 0;
}

.overview-value {
  margin-top: var(--space-1);
  font-size: var(--text-2xl);
  line-height: 1.08;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.overview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
  color: var(--color-muted-foreground);
  font-size: 12px;
}

.overview-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
}

.overview-side {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

.overview-side-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 42px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  background: var(--color-surface-alt);
}

.overview-side-item span {
  color: var(--color-muted-foreground);
  font-size: 12px;
}

.overview-side-item strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.allocation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.allocation-card {
  display: grid;
  align-content: start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-left-width: 3px;
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.allocation-card:hover {
  border-top-color: var(--color-border-strong);
  border-right-color: var(--color-border-strong);
  border-bottom-color: var(--color-border-strong);
}

.allocation-card.positive {
  border-left-color: var(--color-success);
}

.allocation-card.negative {
  border-left-color: var(--color-danger);
}

.allocation-card.neutral {
  border-left-color: var(--color-info);
}

.allocation-card.system {
  border-left-color: var(--color-warning);
  background: var(--panel-bg);
}

.allocation-card-header,
.allocation-card-body,
.allocation-comparison,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.allocation-card-header {
  align-items: flex-start;
}

.allocation-card-header h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 650;
}

.allocation-card-header .tag {
  margin-top: var(--space-1);
}

.allocation-target,
.allocation-weight {
  font-variant-numeric: tabular-nums;
}

.allocation-weight span {
  color: var(--color-muted-foreground);
  font-size: 12px;
}

.allocation-target strong,
.allocation-weight strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.allocation-card-body {
  align-items: start;
}

.allocation-card .metric-label {
  color: var(--color-muted-foreground);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.2;
}

.allocation-money {
  margin-top: var(--space-1);
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.allocation-comparison {
  align-items: center;
}

.allocation-target {
  display: flex;
  align-items: center;
  gap: 9px;
}

.allocation-target-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.allocation-target strong,
.allocation-difference strong {
  font-size: 14px;
  font-weight: 700;
}

.allocation-difference {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.allocation-difference span {
  display: block;
  color: var(--color-muted-foreground);
  font-size: 12px;
}

.allocation-meter {
  position: relative;
  overflow: hidden;
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-muted);
}

.allocation-meter-fill {
  display: block;
  width: var(--actual);
  height: 100%;
  border-radius: inherit;
  background: var(--color-info);
}

.allocation-card.positive .allocation-meter-fill {
  background: var(--color-success);
}

.allocation-card.negative .allocation-meter-fill {
  background: var(--color-danger);
}

.allocation-card.system .allocation-meter-fill {
  background: var(--color-warning);
}

.allocation-meter-target {
  position: absolute;
  top: -4px;
  left: var(--target);
  width: 3px;
  height: 20px;
  background: var(--color-foreground);
  transform: translateX(-2px);
}

.allocation-delta {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  color: var(--color-muted-foreground);
  font-variant-numeric: tabular-nums;
}

.allocation-delta strong {
  color: var(--color-foreground);
  font-size: 14px;
  font-weight: 700;
}

.allocation-weight {
  display: grid;
  gap: 1px;
  margin-right: auto;
  text-align: left;
}

.allocation-card-header .allocation-weight {
  margin: 0;
  text-align: right;
}

.allocation-card-footer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

.allocation-card-footer span {
  display: block;
  overflow: hidden;
  color: var(--color-muted-foreground);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.allocation-card-footer strong {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.delta-indicator {
  position: relative;
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--color-info-surface);
}

.delta-indicator::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 9px;
  width: 8px;
  height: 8px;
  border-left: 2px solid var(--color-info);
  border-top: 2px solid var(--color-info);
  transform: rotate(45deg);
}

.allocation-card.positive .delta-indicator {
  background: var(--color-success-surface);
}

.allocation-card.positive .delta-indicator::before {
  border-color: var(--color-success);
}

.allocation-card.negative .delta-indicator {
  background: var(--color-danger-surface);
}

.allocation-card.negative .delta-indicator::before {
  top: 7px;
  border-color: var(--color-danger);
  transform: rotate(225deg);
}

.allocation-card.system .delta-indicator {
  background: var(--color-warning-surface);
}

.allocation-card.system .delta-indicator::before {
  border-color: var(--color-warning);
}

.section-heading {
  align-items: flex-end;
  margin-bottom: var(--space-3);
}

.section-heading p {
  margin: 0;
}

.allocation-table-wrap table {
  min-width: 840px;
}

.favorites-table {
  width: 100%;
  min-width: 1060px;
  table-layout: fixed;
  font-size: 12px;
}

.favorites-table th,
.favorites-table td {
  overflow: hidden;
  padding: 8px 6px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorites-table th:first-child,
.favorites-table td:first-child {
  text-align: left;
  white-space: normal;
}

.favorites-table td:first-child strong,
.favorites-table td:first-child .small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-col-instrument {
  width: 205px;
}

.favorite-col-currency {
  width: 52px;
}

.favorite-col-type {
  width: 52px;
}

.favorite-col-maturity {
  width: 80px;
}

.favorite-col-yield {
  width: 76px;
}

.favorite-col-price {
  width: 76px;
}

.favorite-col-rub-price {
  width: 92px;
}

.favorite-col-nkd {
  width: 72px;
}

.favorite-col-coupons {
  width: 84px;
}

.favorite-col-coupon-type {
  width: 98px;
}

.favorite-col-flags {
  width: 90px;
}

.favorite-col-offer {
  width: 83px;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.sort-link:hover,
.sort-link.active {
  color: var(--color-foreground);
}

.sort-link span {
  min-width: 10px;
  font-size: 11px;
}

.favorite-coupon-row td {
  padding: 0;
  background: var(--color-surface-alt);
}

.coupon-details {
  padding: 6px 8px;
}

.coupon-details summary::-webkit-details-marker {
  display: none;
}

.coupon-details summary::marker {
  content: "";
}

.coupon-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-weight: 650;
  list-style: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.coupon-summary:hover {
  border-color: var(--color-border);
  background: var(--color-surface);
}

.coupon-summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--color-muted-foreground);
  border-bottom: 2px solid var(--color-muted-foreground);
  transform: rotate(-45deg);
  transition: transform var(--transition-fast);
}

.coupon-details[open] .coupon-summary::before {
  transform: rotate(45deg);
}

.coupon-summary-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-alt);
  font-size: 12px;
}

.coupon-form {
  display: grid;
  gap: var(--space-2);
  width: min(100%, 340px);
  padding: 0 0 var(--space-2);
}

.coupon-toolbar {
  display: flex;
  justify-content: flex-start;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.coupon-window {
  overflow-y: auto;
  max-height: 408px;
  width: min(100%, 320px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
}

.coupon-window.expanded {
  max-height: none;
}

.coupon-table {
  width: 100%;
  table-layout: fixed;
}

.coupon-table th:first-child,
.coupon-table td:first-child {
  width: 124px;
}

.coupon-table th:last-child,
.coupon-table td:last-child {
  width: 172px;
}

.coupon-table th,
.coupon-table td {
  height: 34px;
  padding: 6px 8px;
  text-align: center;
  white-space: nowrap;
}

.coupon-amount-field {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}

.coupon-amount-input {
  width: 82px;
  min-height: 30px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.coupon-amount-input[readonly] {
  border-color: transparent;
  background: transparent;
}

.coupon-empty {
  margin: 4px 0 6px;
  padding: 12px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  color: var(--color-muted-foreground);
  text-align: center;
}

.categories-table {
  min-width: 900px;
}

.category-name-input,
.category-description-input {
  width: 100%;
}

.category-description-input {
  margin-top: var(--space-2);
}

.categories-add-section {
  margin-top: var(--space-4);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  text-align: left;
}

tbody tr {
  transition: background-color var(--transition-fast);
}

tbody tr:hover {
  background: var(--color-surface-alt);
}

th {
  background: var(--color-surface-alt);
  color: var(--color-muted-foreground);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 650;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row-warning {
  background: var(--color-warning-surface);
}

.tag,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
}

.tag.success,
.status.success {
  border-color: var(--status-success-border);
  background: var(--color-success-surface);
  color: var(--color-success);
}

.tag.warning,
.status.warning {
  border-color: var(--status-warning-border);
  background: var(--color-warning-surface);
  color: var(--color-warning);
}

.tag.danger {
  border-color: var(--status-danger-border);
  background: var(--color-danger-surface);
  color: var(--color-danger);
}

.error-list {
  display: grid;
  gap: var(--space-4);
}

.error-panel {
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
}

.error-panel-header,
.technical-block-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: flex-start;
}

.technical-block {
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface-alt);
}

.technical-block-header {
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-muted-foreground);
  font-size: 12px;
  font-weight: 650;
}

.technical-block pre {
  overflow-x: auto;
  margin: 0;
  padding: var(--space-3);
  white-space: pre-wrap;
  word-break: break-word;
  font: var(--text-xs)/1.5 var(--font-mono);
}

.empty-state {
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
}

.inline-form {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

select {
  width: min(280px, 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  background: var(--input-bg);
  padding: 0 var(--space-2);
}

.input {
  min-height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  background: var(--input-bg);
  padding: 0 var(--space-2);
}

select:focus-visible,
.input:focus-visible,
.coupon-amount-input:focus-visible {
  border-color: var(--input-border-focus);
}

.input.narrow {
  width: 72px;
}

.percent-input,
.money-input {
  width: 150px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-3);
}

.scenario-form {
  display: grid;
  gap: var(--space-2);
  max-width: 440px;
  margin-bottom: var(--space-4);
}

.top-up-calculator {
  scroll-margin-top: 72px;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.candidate-card {
  position: relative;
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
}

.candidate-rank {
  color: var(--color-muted-foreground);
  font-size: 12px;
  font-weight: 700;
}

.candidate-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.candidate-card-header h2 {
  font-size: 17px;
  line-height: 1.2;
}

.candidate-score {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--status-success-border);
  border-radius: var(--radius-xs);
  background: var(--color-success-surface);
  color: var(--color-success);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.candidate-facts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-2);
}

.candidate-facts div {
  min-width: 0;
}

.candidate-facts span {
  display: block;
  color: var(--color-muted-foreground);
  font-size: 11px;
}

.candidate-facts strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.candidate-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  color: var(--color-muted-foreground);
  font-size: 12px;
}

.candidates-rejected {
  margin-top: var(--space-4);
}

.rejected-table-wrap {
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
}

.rejected-table {
  width: max-content;
  min-width: 0;
  table-layout: auto;
}

.rejected-table th,
.rejected-table td {
  white-space: nowrap;
}

.manual-rating-form {
  display: grid;
  gap: var(--space-3);
}

.manual-rating-select {
  width: 132px;
}

.manual-rating-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: flex-end;
}

.manual-rating-actions p {
  margin: 0;
}

@media (max-width: 1120px) {
  .candidate-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .service-form-grid {
    grid-template-columns: 1fr;
  }
}

.rating-refresh-form {
  max-width: 520px;
}

.rating-refresh-button {
  justify-self: start;
}

.refresh-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.refresh-progress[hidden] {
  display: none;
}

.refresh-progress-track {
  overflow: hidden;
  width: min(100%, 280px);
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-muted);
}

.refresh-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--color-primary);
  transition: width var(--transition-medium);
}

.refresh-progress-label {
  min-width: 36px;
  color: var(--color-muted-foreground);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.manual-rating-value {
  color: var(--color-danger);
  font-weight: 750;
}

.manual-rating-tag {
  background: var(--color-danger-surface);
  color: var(--color-danger);
}

.empty {
  padding: var(--space-6);
  color: var(--color-muted-foreground);
  text-align: center;
}

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

@media (max-width: 780px) {
  .allocation-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    align-items: stretch;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
  }

  .nav-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .topbar,
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .dashboard-overview,
  .allocation-card-header,
  .allocation-card-body,
  .allocation-comparison,
  .section-heading {
    grid-template-columns: 1fr;
  }

  .dashboard-overview {
    display: grid;
  }

  .allocation-card-header,
  .allocation-card-body,
  .allocation-comparison,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .allocation-difference {
    text-align: left;
  }

  .allocation-money {
    font-size: 20px;
  }

  .allocation-card {
    padding: 16px;
  }

  .allocation-card-header {
    width: 100%;
  }

  .allocation-meter {
    height: 14px;
  }

  .overview-value {
    font-size: 28px;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    grid-template-columns: 1fr;
  }

  .candidate-grid,
  .candidate-facts {
    grid-template-columns: 1fr;
  }

  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }
}

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