:root {
  --bg: #efeeea;
  --surface: #fbfbfa;
  --surface-2: #f4f3ef;
  --surface-3: #eae8e2;
  --text: #1b1b1f;
  --text-secondary: #4a4a52;
  --muted: #73737a;
  --faint: #9e9ea6;
  --line: rgba(27, 27, 31, 0.09);
  --line-strong: rgba(27, 27, 31, 0.16);
  --accent: #4c5fd5;
  --accent-hover: #3d4fc2;
  --accent-soft: rgba(76, 95, 213, 0.09);
  --accent-line: rgba(76, 95, 213, 0.24);
  --staging: #d97706;
  --staging-soft: rgba(217, 119, 6, 0.11);
  --prod: #b91c1c;
  --prod-soft: rgba(185, 28, 28, 0.10);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.10);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.11);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.10);
  --shadow-sm: 0 1px 2px rgba(27, 27, 31, 0.04);
  --shadow-md: 0 10px 28px rgba(27, 27, 31, 0.08);
  --shadow-lg: 0 24px 60px rgba(27, 27, 31, 0.14);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-w: 248px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.num, td.num, th.num {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* Environment Top Stripe */
.env-stripe {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 90;
  background: var(--staging);
  transition: background 0.2s ease;
}

body[data-env="production"] .env-stripe {
  background: var(--prod);
  height: 5px;
}

/* Shell Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
  padding-top: 4px;
}

body[data-env="production"] .app-shell {
  padding-top: 5px;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 4px;
  height: calc(100vh - 4px);
  z-index: 30;
}

body[data-env="production"] .sidebar {
  top: 5px;
  height: calc(100vh - 5px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.brand-name {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-tag {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
  font-weight: 600;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.sidebar-status-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--staging);
}

body[data-env="production"] .status-dot {
  background: var(--prod);
}

.status-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Column & Topbar */
.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 4px;
  z-index: 20;
  background: rgba(251, 251, 250, 0.90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 11px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

body[data-env="production"] .topbar {
  top: 5px;
  background: rgba(253, 248, 248, 0.92);
  border-bottom-color: rgba(185, 28, 28, 0.16);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.env-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  gap: 2px;
}

.env-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.env-btn:hover {
  color: var(--text);
}

.env-btn.active[data-env-opt="staging"] {
  background: #fff;
  color: #92400e;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.env-btn.active[data-env-opt="production"] {
  background: #fff;
  color: #991b1b;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(185, 28, 28, 0.28);
}

.env-indicator {
  width: 7px;
  height: 7px;
  border-radius: 999px;
}

.env-indicator-staging { background: var(--staging); }
.env-indicator-prod { background: var(--prod); }

.prod-live-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--prod);
  color: #fff;
}

.operator-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
}

.operator-avatar {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.operator-email {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

/* Viewport & Page Header */
.viewport {
  padding: 24px;
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.page-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Segmented Controls / Tabs */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  gap: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(0.5px);
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11.5px;
  border-radius: 6px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(185, 28, 28, 0.22);
}

.btn-danger-soft:hover:not(:disabled) {
  background: rgba(185, 28, 28, 0.16);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.mobile-nav-btn {
  display: none;
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* KPI Card */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-value {
  font-size: 25px;
  font-weight: 680;
  letter-spacing: -0.025em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Badges / Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(21, 128, 61, 0.20); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(180, 83, 9, 0.22); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(185, 28, 28, 0.22); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

/* Alert Banner */
.alert-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(180, 83, 9, 0.26);
  background: var(--warn-soft);
  color: #78350f;
}

.alert-banner.critical {
  border-color: rgba(185, 28, 28, 0.28);
  background: var(--danger-soft);
  color: #7f1d1d;
}

.alert-banner-title {
  font-weight: 650;
  font-size: 13.5px;
}

.alert-banner-body {
  font-size: 12.5px;
  margin-top: 2px;
  opacity: 0.92;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr.clickable {
  cursor: pointer;
}

tbody tr.clickable:hover {
  background: var(--surface-2);
}

th.num, td.num {
  text-align: right;
}

/* Forms & Filters */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.input, .select, .textarea {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-hint {
  font-size: 11.5px;
  color: var(--muted);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #d1d0ca;
  border-radius: 999px;
  transition: background 0.18s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-slider {
  background: var(--accent);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

/* Charts */
.chart-wrap {
  position: relative;
  width: 100%;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.chart-empty {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}

.chart-tooltip {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  background: rgba(27, 27, 31, 0.94);
  color: #fff;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: var(--shadow-md);
  max-width: 240px;
}

/* Horizontal Bars & Funnel */
.hbar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hbar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hbar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
}

.hbar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.funnel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.funnel-step {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  position: relative;
}

.funnel-step-label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 550;
}

.funnel-step-val {
  font-size: 20px;
  font-weight: 680;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.funnel-step-rate {
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
  margin-top: 4px;
}

/* Routing Chain Builder */
.chain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

.chain-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.chain-rank {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  flex-shrink: 0;
}

.chain-info {
  flex: 1;
  min-width: 0;
}

.chain-name {
  font-weight: 600;
  font-size: 13px;
}

.chain-sub {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Drawer & Modal */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 20, 24, 0.35);
  backdrop-filter: blur(2px);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  z-index: 70;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.drawer-header, .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-title, .modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.drawer-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 20, 24, 0.42);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop[hidden], .drawer[hidden], .drawer-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(640px, 100%);
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Feedback Expandable */
.feedback-row-detail {
  background: var(--surface-2);
}

.diag-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}

/* States & Toasts */
.loading-state, .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1b1b1f;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  max-width: 360px;
  border-left: 3px solid var(--accent);
}

.toast.ok { border-left-color: #22c55e; }
.toast.error { border-left-color: #ef4444; }

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

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kv-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.kv-label {
  font-size: 11px;
  color: var(--muted);
}

.kv-val {
  font-size: 13.5px;
  font-weight: 600;
  margin-top: 2px;
  word-break: break-word;
}

/* Responsive */
@media (max-width: 1080px) {
  .grid-6, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-nav-btn {
    display: inline-grid;
  }
  .grid-2, .grid-3, .grid-4, .grid-6, .form-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 10px 14px;
  }
  .viewport {
    padding: 16px;
  }
}
