:root {
  --bg-dark: #080c14;
  --bg-card: #0f172a;
  --bg-card-hover: #17223b;
  --bg-editor: #070b12;
  --border-color: #1e293b;
  --border-glow: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.25);
  --accent-rose: #f43f5e;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, "Courier New", monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(16, 185, 129, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(6, 182, 212, 0.05) 0%, transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
  overflow-x: hidden;
}

/* Mandatory CSS constraints */
input, select, textarea {
  min-width: 0;
  font-family: inherit;
}

.brand {
  min-width: 0;
}

.brand-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-switcher {
  flex-shrink: 0;
}

.app-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 60px 20px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 0 20px var(--accent-emerald-glow);
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-pro-tag {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--accent-emerald);
  letter-spacing: 0.05em;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 9999px;
  font-size: 12px;
  color: #a7f3d0;
  font-weight: 500;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.lang-switcher {
  display: flex;
  background: #1e293b;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  border: 1px solid #334155;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  color: #fff;
}

.lang-btn.active {
  background: #334155;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Top Key Metrics HUD */
.hud-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.hud-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.hud-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
}

.hud-card.highlight {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08) 0%, var(--bg-card) 100%);
}

.hud-card.gold {
  border-color: rgba(245, 158, 11, 0.35);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, var(--bg-card) 100%);
}

.hud-card.accent {
  border-color: rgba(6, 182, 212, 0.35);
  background: linear-gradient(180deg, rgba(6, 182, 212, 0.08) 0%, var(--bg-card) 100%);
}

.hud-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hud-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-value {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
}

.hud-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.badge-reduction {
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: -0.01em;
}

.badge-reduction.positive {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-reduction.zero {
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-muted);
  border: 1px solid rgba(100, 116, 139, 0.3);
}

.hud-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* Filters Card */
.filters-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

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

.filters-heading {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.preset-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-preset {
  background: #1e293b;
  border: 1px solid #334155;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-preset:hover {
  background: #273549;
  color: #fff;
  border-color: #475569;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.filter-toggle-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: #0b1120;
  border: 1px solid #1e293b;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.filter-toggle-item:hover {
  border-color: var(--border-glow);
  background: #0d1527;
}

.switch-wrap {
  position: relative;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}

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

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 22px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

.switch-wrap input:checked + .switch-slider {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald-glow);
}

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

.filter-info {
  min-width: 0;
}

.filter-title {
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 2px;
}

.filter-desc {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.35;
}

/* Quick Samples Bar */
.samples-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

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

.btn-sample {
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-sample:hover {
  background: #273549;
  border-color: var(--accent-cyan);
  color: #fff;
  transform: translateY(-1px);
}

/* View Switcher Tabs */
.view-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.view-tabs {
  display: flex;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.view-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-tab-btn:hover {
  color: #fff;
}

.view-tab-btn.active {
  background: #1e293b;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Main Editor Section */
.editor-section {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.editor-section.mode-split {
  grid-template-columns: 1fr 1fr;
}

.editor-section.mode-single {
  grid-template-columns: 1fr;
}

.editor-section.mode-diff {
  grid-template-columns: 1fr;
}

.editor-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #0b1120;
  border-bottom: 1px solid #1e293b;
  gap: 12px;
  flex-wrap: wrap;
}

.editor-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #e2e8f0;
}

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

.badge-stat {
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: 6px;
  background: #1e293b;
  color: var(--text-muted);
}

.badge-stat.accent {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-sm-action {
  background: transparent;
  border: 1px solid #334155;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-sm-action:hover {
  background: #1e293b;
  color: #fff;
  border-color: #475569;
}

.editor-textarea {
  width: 100%;
  height: 380px;
  background: var(--bg-editor);
  color: #e2e8f0;
  border: none;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
}

.editor-textarea:focus {
  background: #080d16;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  background: #0b1120;
  border-top: 1px solid #1e293b;
  flex-wrap: wrap;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 10px var(--accent-emerald-glow);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

.btn-secondary {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #273549;
  color: #fff;
}

/* Diff Viewer */
.diff-container {
  height: 440px;
  background: var(--bg-editor);
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 12px 0;
}

.diff-placeholder {
  color: var(--text-dim);
  text-align: center;
  padding: 60px 20px;
  font-size: 14px;
}

.diff-lines {
  display: flex;
  flex-direction: column;
}

.diff-row {
  display: flex;
  padding: 2px 16px;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-row .line-num {
  width: 24px;
  flex-shrink: 0;
  font-weight: 700;
  user-select: none;
}

.diff-row .diff-text {
  flex-grow: 1;
}

.diff-row.add {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.diff-row.del {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
  text-decoration: line-through;
}

.diff-row.mod-del {
  background: rgba(244, 63, 94, 0.12);
  color: #fca5a5;
}

.diff-row.mod-add {
  background: rgba(16, 185, 129, 0.12);
  color: #86efac;
}

.diff-row.same {
  color: #94a3b8;
}

/* Multi-Model Breakdown Section */
.models-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.models-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 16px;
  flex-wrap: wrap;
}

.models-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.volume-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.volume-select {
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
}

.models-desc {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 18px;
  line-height: 1.5;
}

.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px;
}

.model-card {
  background: #0b1120;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.model-card:hover {
  border-color: #38bdf8;
  transform: translateY(-2px);
  background: #0d1527;
}

.model-card.active-model {
  border-color: var(--accent-emerald);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08) 0%, #0b1120 100%);
  box-shadow: 0 0 14px var(--accent-emerald-glow);
}

.model-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.model-icon {
  font-size: 16px;
}

.model-price-tag {
  font-size: 11px;
  font-family: var(--font-mono);
  background: #1e293b;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--text-muted);
}

.model-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #070b12;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  gap: 6px;
}

.mstat-item {
  display: flex;
  flex-direction: column;
}

.mstat-lbl {
  font-size: 10.5px;
  color: var(--text-dim);
  font-weight: 500;
}

.mstat-val {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.mstat-val.before {
  color: var(--text-muted);
}

.mstat-val.after {
  color: #34d399;
}

.mstat-arrow {
  color: var(--text-dim);
  font-size: 13px;
}

.mstat-pct {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 6px;
}

.model-savings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.savings-label {
  color: var(--text-muted);
}

.savings-amount {
  font-size: 14px;
  font-weight: 800;
  color: #fbbf24;
  font-family: var(--font-mono);
}

/* Educational / ROI Section */
.educational-section {
  margin-bottom: 30px;
}

.edu-heading {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
}

.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.edu-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.edu-icon {
  font-size: 26px;
  margin-bottom: 10px;
}

.edu-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 8px;
}

.edu-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Portal Return Link & Footer */
.portal-backlink-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  margin-top: 20px;
  flex-wrap: wrap;
}

.portal-backlink {
  color: var(--accent-emerald);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.portal-backlink:hover {
  color: #34d399;
  text-decoration: underline;
}

.portal-sub {
  font-size: 13px;
  color: var(--text-dim);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--accent-emerald);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 15px var(--accent-emerald-glow);
  transform: translateY(100px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Responsive Adjustments */
@media (max-width: 900px) {
  .hud-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .editor-section.mode-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .hud-grid {
    grid-template-columns: 1fr;
  }
  .app-container {
    padding: 16px 12px 50px 12px;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
  .editor-textarea {
    height: 300px;
  }
  .diff-container {
    height: 320px;
  }
}
