/* ═══════════════════════════════════════════
   ModelCost — AI 费率计算器  Complete Styles
   ═══════════════════════════════════════════ */

/* ── CSS Variables: Light Theme ── */
:root {
  --brand-50:  #f5f3ff;
  --brand-100: #ede9fe;
  --brand-200: #ddd6fe;
  --brand-300: #c4b5fd;
  --brand-400: #a78bfa;
  --brand-500: #8b5cf6;
  --brand-600: #7c3aed;
  --brand-700: #6d28d9;
  --brand-800: #5b21b6;
  --brand-900: #4c1d95;

  --accent-cyan:    #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber:   #f59e0b;
  --accent-rose:    #f43f5e;
  --accent-sky:     #0ea5e9;

  --bg-base:     #f8f9fc;
  --bg-surface:  #ffffff;
  --bg-elevated: #f1f3f8;
  --bg-sidebar:  #ffffff;

  --text-primary:   #18181b;
  --text-secondary: #71717a;
  --text-muted:     #a1a1aa;
  --text-on-brand:  #ffffff;

  --border-default: #e4e4e7;
  --border-focus:   var(--brand-500);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.03);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.03);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --sidebar-width: 280px;
  --topbar-height: 60px;
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --bg-base:     #0c0c10;
  --bg-surface:  #18181f;
  --bg-elevated: #222230;
  --bg-sidebar:  #14141c;

  --text-primary:   #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted:     #71717a;

  --border-default: #2a2a3a;
  --border-focus:   var(--brand-400);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}

input, select, button, textarea {
  font-family: inherit;
  font-size: inherit;
}

a { color: var(--brand-500); text-decoration: none; }

::selection {
  background: var(--brand-200);
  color: var(--brand-900);
}
[data-theme="dark"] ::selection {
  background: var(--brand-700);
  color: var(--brand-100);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ════════════════════════════════
   TOP BAR
   ════════════════════════════════ */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  transition: background 0.3s;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar__logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}
.topbar__logo svg { width: 20px; height: 20px; }

.topbar__name {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar__tagline {
  font-size: 12px;
  color: var(--text-muted);
  display: none;
}
@media (min-width: 768px) {
  .topbar__tagline { display: inline; }
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Exchange Badge ── */
.exchange-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 6px 12px;
  border-radius: var(--radius-xl);
  white-space: nowrap;
}
.exchange-badge svg { width: 14px; height: 14px; color: var(--accent-cyan); }

@media (max-width: 640px) {
  .exchange-badge span { display: none; }
}

/* ════════════════════════════════
   BUTTONS
   ════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }

.btn--primary {
  background: var(--brand-600);
  color: var(--text-on-brand);
}
.btn--primary:hover { background: var(--brand-700); transform: translateY(-1px); }

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}
.btn--ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--brand-300);
}

.btn--danger {
  background: var(--accent-rose);
  color: white;
}
.btn--danger:hover { opacity: 0.9; }

.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--full { width: 100%; justify-content: center; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.icon-btn--danger:hover { color: var(--accent-rose); background: rgba(244,63,94,0.1); }

/* Theme toggle */
.icon-btn--theme { position: relative; }
.theme-icon--dark { display: none; }
[data-theme="dark"] .theme-icon--light { display: none; }
[data-theme="dark"] .theme-icon--dark { display: block; }

/* Spinning animation */
@keyframes spin { to { transform: rotate(360deg); } }
.spinning svg { animation: spin 0.8s linear infinite; }

/* ════════════════════════════════
   LAYOUT
   ════════════════════════════════ */
.layout {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
}

/* ════════════════════════════════
   SIDEBAR
   ════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: background 0.3s;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}
.sidebar__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.sidebar__title svg { width: 16px; height: 16px; color: var(--brand-500); }

.sidebar__search {
  padding: 8px 16px;
  position: relative;
}
.sidebar__search svg {
  position: absolute;
  left: 26px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}
.sidebar__search input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.sidebar__search input:focus { border-color: var(--brand-500); }
.sidebar__search input::placeholder { color: var(--text-muted); }

.sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.sidebar__footer {
  padding: 8px;
  border-top: 1px solid var(--border-default);
}

/* Model groups */
.model-group { margin-bottom: 2px; }

.model-group__header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  user-select: none;
}
.model-group__header:hover { background: var(--bg-elevated); }
.model-group__header .group-arrow {
  width: 14px;
  height: 14px;
  transition: transform 0.2s;
}
.model-group--collapsed .group-arrow { transform: rotate(-90deg); }
.model-group--collapsed .model-group__items { display: none; }

.model-group__count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 1px 6px;
  border-radius: 10px;
}

.model-group__items { padding-left: 4px; }

/* Model item */
.model-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: all 0.15s;
}
.model-item:hover { background: var(--bg-elevated); }
.model-item--active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
[data-theme="dark"] .model-item--active {
  background: rgba(139,92,246,0.15);
  color: var(--brand-300);
}

.model-item__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.model-item__badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 6px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 500;
}
.badge svg { width: 10px; height: 10px; }
.badge--tier { background: rgba(245,158,11,0.15); color: var(--accent-amber); }
.badge--currency { background: var(--bg-elevated); color: var(--text-muted); }
.badge--custom { background: rgba(139,92,246,0.12); color: var(--brand-500); }

/* Sidebar empty */
.sidebar-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.sidebar-empty svg { width: 24px; height: 24px; }

/* ════════════════════════════════
   MAIN CONTENT
   ════════════════════════════════ */
.main {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  max-width: 900px;
}
@media (min-width: 1400px) {
  .main { padding: 24px 40px; }
}

/* ── Card ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  transition: background 0.3s, border-color 0.3s;
}

.card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.card__title svg { width: 18px; height: 18px; color: var(--brand-500); }

.card__title--collapsible {
  cursor: pointer;
  justify-content: space-between;
  margin-bottom: 0;
  padding: 0;
  user-select: none;
}
.card__title--collapsible:hover { color: var(--brand-500); }

/* ── Model Banner ── */
.model-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.3s;
}

.model-banner__info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.model-banner__provider {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 4px;
}

.model-banner__name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.model-banner__badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}
.model-banner__badge--tier {
  background: rgba(245,158,11,0.15);
  color: var(--accent-amber);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.model-banner__badge--tier svg { width: 12px; height: 12px; }

.model-banner__actions {
  display: flex;
  gap: 6px;
}

/* ── Tier Card ── */
.tier-card {
  background: linear-gradient(135deg, rgba(245,158,11,0.06), rgba(245,158,11,0.02));
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 16px;
}

.tier-card__header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-amber);
  margin-bottom: 10px;
}
.tier-card__header svg { width: 16px; height: 16px; }

.tier-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.2s;
}
.tier-row svg { width: 14px; height: 14px; }

.tier-row--active {
  background: rgba(245,158,11,0.12);
  color: var(--text-primary);
  font-weight: 500;
}
.tier-row--active .tier-row__label { color: var(--accent-amber); }

.tier-row__label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tier-row__price {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "SF Mono", "Fira Code", monospace;
}

.tier-row__current {
  font-size: 10px;
  background: var(--accent-amber);
  color: white;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}

.tier-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  padding-left: 12px;
}

/* ── Params Grid ── */
.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.param-item {}

.param-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.param-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.param-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.param-input {
  width: 100%;
  padding: 10px 50px 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  font-family: "SF Mono", "Fira Code", monospace;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.param-input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.12);
}
/* remove spin buttons */
.param-input::-webkit-inner-spin-button,
.param-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.param-input { -moz-appearance: textfield; }

.param-unit {
  position: absolute;
  right: 12px;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Params Card Header ── */
.params-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ── Mode Switch ── */
.mode-switch {
  display: flex;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border-default);
}

.mode-switch__btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.mode-switch__btn svg { width: 14px; height: 14px; }
.mode-switch__btn:hover { color: var(--text-secondary); }

.mode-switch__btn--active {
  background: var(--bg-surface);
  color: var(--brand-600);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
[data-theme="dark"] .mode-switch__btn--active {
  background: var(--brand-700);
  color: var(--brand-100);
}

/* ── Common params separator ── */
.params-grid--common {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-default);
}

/* ── Computed Summary (Total Mode) ── */
.computed-summary {
  display: flex;
  gap: 16px;
  background: linear-gradient(135deg, rgba(139,92,246,0.06), rgba(14,165,233,0.06));
  border: 1px solid rgba(139,92,246,0.15);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  flex-wrap: wrap;
}

.computed-summary__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
}

.computed-summary__label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.computed-summary__value {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-600);
  font-family: "SF Mono", "Fira Code", monospace;
}
[data-theme="dark"] .computed-summary__value {
  color: var(--brand-300);
}

/* ── Cache Calculator Toggle ── */
.cache-calc-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 4px;
  vertical-align: middle;
  padding: 0;
}
.cache-calc-toggle svg { width: 12px; height: 12px; }
.cache-calc-toggle:hover {
  border-color: var(--brand-400);
  color: var(--brand-500);
  background: rgba(139,92,246,0.08);
}
.cache-calc-toggle--active {
  border-color: var(--brand-500);
  color: var(--brand-500);
  background: rgba(139,92,246,0.12);
}

/* ── Cache Calculator Panel ── */
.cache-calc {
  margin-top: 8px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  animation: slideUp 0.15s ease;
}

.cache-calc__row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.cache-calc__label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 72px;
  flex-shrink: 0;
}

.cache-calc__input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 13px;
  font-family: "SF Mono", "Fira Code", monospace;
  outline: none;
  transition: border-color 0.2s;
}
.cache-calc__input:focus { border-color: var(--brand-500); }

/* remove spin buttons on cache calc inputs */
.cache-calc__input::-webkit-inner-spin-button,
.cache-calc__input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.cache-calc__input { -moz-appearance: textfield; }

.cache-calc__result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-default);
  font-size: 13px;
  color: var(--text-secondary);
}
.cache-calc__result strong {
  color: var(--brand-600);
  font-size: 14px;
}
[data-theme="dark"] .cache-calc__result strong {
  color: var(--brand-300);
}

/* ── Form Hint (used in tier forms) ── */
.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ── Results Table ── */
.results-table-wrap { overflow-x: auto; }

.results-table {
  width: 100%;
  border-collapse: collapse;
}
.results-table th,
.results-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border-default);
}
.results-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.results-table th svg { width: 14px; height: 14px; display: inline-block; vertical-align: middle; }

.results-table td { font-family: "SF Mono", "Fira Code", monospace; font-size: 14px; }

.results-row__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-family: inherit !important;
  font-size: 13px !important;
}
.results-row__label svg { width: 14px; height: 14px; }

.results-row__usd { color: var(--accent-sky); font-weight: 500; }
.results-row__cny { color: var(--accent-emerald); font-weight: 500; }

.results-row--highlight { background: var(--bg-elevated); }
.results-row--highlight td { font-weight: 700; font-size: 16px !important; border-bottom: none; }
.highlight-cny { color: var(--accent-emerald) !important; }

.results-empty td {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  font-family: inherit !important;
}

/* ── Breakdown ── */
.results-breakdown {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-default);
}

.breakdown-chart-wrap { flex-shrink: 0; }

.breakdown-labels { flex: 1; }

.breakdown-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}

.breakdown-label__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.breakdown-label__name { color: var(--text-secondary); }
.breakdown-label__pct { font-weight: 600; color: var(--text-primary); margin-left: auto; }

.breakdown-label--note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--border-default);
}

/* ════════════════════════════════
   COMPARE TABLE
   ════════════════════════════════ */
.compare-content { margin-top: 16px; }
.compare-content[style*="display: none"] + .card__title .icon-btn svg {
  transform: rotate(0);
}

.compare-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.compare-hint { font-size: 12px; color: var(--text-muted); }

.compare-table-scroll { overflow-x: auto; }

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.compare-table th,
.compare-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-default);
  text-align: center;
  white-space: nowrap;
}
.compare-table th { font-size: 12px; }

.compare-th {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.compare-th__provider { font-size: 10px; color: var(--text-muted); font-weight: 400; }
.compare-th__name { font-weight: 600; color: var(--text-primary); }

.compare-row-label {
  text-align: left !important;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.compare-td--best {
  color: var(--accent-emerald) !important;
  font-weight: 600 !important;
  background: rgba(16,185,129,0.06);
}
.compare-td--best svg { width: 14px; height: 14px; display: inline-block; vertical-align: middle; margin-left: 4px; }

.compare-td--expensive { color: var(--accent-rose); }

.compare-diff-row { border-top: 2px solid var(--border-default); }
.compare-diff-row td { font-weight: 600; font-size: 13px; }

.compare-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px;
  color: var(--text-muted);
  font-size: 13px;
}
.compare-empty svg { width: 24px; height: 24px; }

.compare-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  margin-left: 4px;
  transition: all 0.15s;
}
.compare-remove-btn:hover { background: rgba(244,63,94,0.1); color: var(--accent-rose); }

/* ════════════════════════════════
   MODALS
   ════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
.modal--sm { max-width: 420px; }
.modal--lg { max-width: 760px; }

/* ── Language switcher ── */
.lang-switcher { position: relative; }
.lang-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lang-switcher__label {
  font-weight: 600;
  font-size: 12px;
  min-width: 18px;
  text-align: center;
}
.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 200;
}
.lang-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
}
.lang-menu__item:hover { background: var(--bg-hover, rgba(127,127,127,0.08)); }
.lang-menu__item--active { color: var(--brand-500); font-weight: 600; }
.lang-menu__short {
  display: inline-block;
  min-width: 24px;
  text-align: center;
  font-weight: 600;
  font-size: 11px;
  padding: 2px 4px;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.lang-menu__item--active .lang-menu__short {
  background: rgba(139, 92, 246, 0.12);
  color: var(--brand-500);
}
.lang-menu__name { flex: 1; }
.lang-menu__item svg { width: 14px; height: 14px; color: var(--brand-500); }

/* ── Help modal body ── */
.help-body {
  padding: 16px 20px 24px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
}
#helpModal .modal__title {
  color: var(--brand-500);
}
.help-section {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}
.help-section:last-child { margin-bottom: 4px; }
.help-section h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-500);
  margin: 0 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border-default);
}
.help-section ol,
.help-section ul {
  padding-left: 22px;
  margin: 4px 0;
}
.help-section li { margin-bottom: 6px; }
.help-section dl {
  margin: 4px 0;
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  gap: 6px 16px;
}
.help-section dt { font-family: "SF Mono", monospace; font-size: 13px; color: var(--text-primary); }
.help-section dd { color: var(--text-secondary); margin: 0; }
.help-section code {
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: "SF Mono", monospace;
  font-size: 12.5px;
  color: var(--brand-500);
}
.help-section strong { color: var(--text-primary); }
.help-hero {
  padding: 14px;
  border-radius: var(--radius-lg);
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.18);
}
.help-note {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}
.help-choice-grid {
  display: grid;
  gap: 12px;
  margin: 8px 0;
}
.help-choice-card {
  padding: 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-base);
}
.help-choice-card h5 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-primary);
}
.help-choice-card p {
  margin: 0;
  color: var(--text-secondary);
}
.help-choice-card p + p { margin-top: 8px; }
.help-glossary {
  margin: 8px 0;
  display: grid;
  gap: 10px 14px;
}
.help-glossary dt { font-family: "SF Mono", monospace; font-size: 13px; color: var(--text-primary); }
.help-glossary dd { margin: 0; color: var(--text-secondary); }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
}
.modal__title { font-size: 16px; font-weight: 600; }

.modal__form { padding: 20px; }
.modal__body { padding: 20px; }

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-default);
  margin-top: 16px;
}

/* Form elements */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }

.form-item { margin-bottom: 12px; }
.form-item label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.form-item input,
.form-item select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.form-item input:focus,
.form-item select:focus { border-color: var(--brand-500); }

.form-section { margin-top: 12px; }
.form-section__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-500);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border-default);
}

/* Tier input rows */
.tier-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.tier-input-row input {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.tier-input-row input:focus { border-color: var(--brand-500); }

/* ── Currency Modal ── */
.currency-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--border-default);
  font-size: 13px;
}
.currency-row__code { font-weight: 600; min-width: 40px; }
.currency-row__name { color: var(--text-secondary); }
.currency-row__rate { margin-left: auto; font-family: "SF Mono", monospace; font-size: 12px; color: var(--text-muted); }
.currency-row__protected { font-size: 11px; color: var(--text-muted); }

.add-currency-form {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.add-currency-form input {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.add-currency-form input:focus { border-color: var(--brand-500); }

/* ════════════════════════════════
   CONTEXT MENU
   ════════════════════════════════ */
.context-menu {
  position: fixed;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 160px;
  z-index: 2000;
  animation: slideUp 0.1s ease;
}

.context-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.context-menu__item:hover { background: var(--bg-elevated); }
.context-menu__item svg { width: 14px; height: 14px; }
.context-menu__item--danger { color: var(--accent-rose); }
.context-menu__item--danger:hover { background: rgba(244,63,94,0.08); }
.context-menu__divider { height: 1px; background: var(--border-default); margin: 4px 0; }

/* ════════════════════════════════
   TOAST
   ════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 72px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text-primary);
  pointer-events: auto;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast--show { transform: translateX(0); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }

.toast--success svg { color: var(--accent-emerald); }
.toast--error svg   { color: var(--accent-rose); }
.toast--info svg    { color: var(--accent-cyan); }
.toast--warning svg { color: var(--accent-amber); }

.toast--success { border-left: 3px solid var(--accent-emerald); }
.toast--error   { border-left: 3px solid var(--accent-rose); }
.toast--info    { border-left: 3px solid var(--accent-cyan); }
.toast--warning { border-left: 3px solid var(--accent-amber); }

/* ════════════════════════════════
   COMPARE MODEL PICKER MODAL
   ════════════════════════════════ */
.picker-list { max-height: 400px; overflow-y: auto; }
.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  transition: background 0.15s;
}
.picker-item:hover { background: var(--bg-elevated); }
.picker-item--selected { background: rgba(139,92,246,0.08); }
.picker-item__check {
  width: 18px; height: 18px;
  border: 2px solid var(--border-default);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.picker-item--selected .picker-item__check {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: white;
}
.picker-item__check svg { width: 12px; height: 12px; }
.picker-item__info { flex: 1; }
.picker-item__name { font-size: 13px; font-weight: 500; }
.picker-item__provider { font-size: 11px; color: var(--text-muted); }

/* ════════════════════════════════
   MOBILE RESPONSIVE
   ════════════════════════════════ */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 200;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--brand-600);
  color: white;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.sidebar-toggle svg { width: 20px; height: 20px; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    bottom: 0;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar--open { transform: translateX(0); }

  .sidebar-toggle { display: flex; }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    top: var(--topbar-height);
    background: rgba(0,0,0,0.4);
    z-index: 140;
    display: none;
  }
  .sidebar-backdrop--show { display: block; }

  .main { padding: 16px; }
  .model-banner { flex-direction: column; align-items: flex-start; }
  .params-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-row--3 { grid-template-columns: 1fr; }

  .results-breakdown { flex-direction: column; }
}

/* ════════════════════════════════
   MANAGE MODELS MODAL
   ════════════════════════════════ */
.manage-model-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--border-default);
  font-size: 13px;
}
.manage-model-row__name { flex: 1; font-weight: 500; }
.manage-model-row__provider { color: var(--text-muted); font-size: 12px; }
.manage-model-row__actions { display: flex; gap: 4px; }

/* ════════════════════════════════
   UTILITY
   ════════════════════════════════ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
