:root {
  --navy-950: #071426;
  --navy-900: #0B1F3A;
  --navy-800: #132F54;
  --navy-700: #1E4474;
  --amber-500: #F59E0B;
  --amber-600: #D97706;
  --amber-100: #FEF3C7;
  --green-500: #10B981;
  --green-600: #059669;
  --green-100: #D1FAE5;
  --red-500: #EF4444;
  --red-600: #DC2626;
  --red-100: #FEE2E2;
  --blue-500: #3B82F6;
  --blue-600: #2563EB;
  --blue-100: #DBEAFE;
  --slate-50: #F8FAFC;
  --slate-100: #F1F5F9;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --slate-500: #64748B;
  --slate-700: #334155;
  --slate-900: #0F172A;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--slate-100);
  color: var(--slate-900);
  line-height: 1.45;
  font-size: 14px;
}

/* Topbar */
.topbar {
  background: linear-gradient(135deg, var(--navy-950) 0%, var(--navy-800) 100%);
  color: #fff;
  padding: 14px 24px;
  border-bottom: 4px solid var(--amber-600);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(7, 20, 38, 0.25);
}

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

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--amber-500), var(--amber-600));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: var(--navy-950);
  letter-spacing: -0.5px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

.brand h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.brand .sub {
  font-size: 11.5px;
  color: #CBD5E1;
}

.topbar-kpis {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.top-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 6px 12px;
  min-width: 115px;
}

.top-chip .lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #94A3B8;
  display: block;
}

.top-chip .val {
  font-size: 14px;
  font-weight: 800;
  color: #FCD34D;
}

.top-chip.green .val {
  color: #6EE7B7;
}

/* Nav Tabs */
.nav-tabs {
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
  padding: 0 24px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.nav-btn {
  border: none;
  background: transparent;
  padding: 13px 16px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--slate-500);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  color: var(--navy-900);
  background: var(--slate-50);
}

.nav-btn.active {
  color: var(--navy-900);
  border-bottom-color: var(--amber-600);
  background: #FFFBEB;
}

.nav-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--slate-200);
  color: var(--slate-700);
  font-weight: 700;
}

.nav-btn.active .nav-badge {
  background: var(--amber-600);
  color: #fff;
}

/* Layout */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 22px 40px 22px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

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

/* Control Bar (Global Config) */
.config-bar {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-left: 5px solid var(--navy-900);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 14px;
  align-items: end;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--slate-500);
  margin-bottom: 5px;
}

.field select,
.field input[type="number"],
.field input[type="text"],
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--slate-300);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-900);
  background: var(--slate-50);
}

.field select:focus,
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue-600);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.range-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--amber-600);
  cursor: pointer;
}

.range-val {
  min-width: 78px;
  text-align: right;
  font-weight: 800;
  font-size: 13px;
  color: var(--navy-900);
  background: var(--amber-100);
  padding: 4px 8px;
  border-radius: 5px;
}

/* Grids & Cards */
.grid-2 {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  margin-bottom: 16px;
}

.grid-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 1040px) {
  .grid-2, .grid-equal, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--slate-200);
}

.card-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--navy-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-sub {
  font-size: 12px;
  color: var(--slate-500);
}

/* Metric Tiles */
.metric-tile {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-top: 3px solid var(--navy-900);
  border-radius: 8px;
  padding: 12px 14px;
}

.metric-tile.amber { border-top-color: var(--amber-600); background: #FFFBEB; }
.metric-tile.green { border-top-color: var(--green-600); background: #ECFDF5; }
.metric-tile.blue { border-top-color: var(--blue-600); background: #EFF6FF; }
.metric-tile.red { border-top-color: var(--red-600); background: #FEF2F2; }

.metric-tile .m-lbl {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--slate-500);
  letter-spacing: 0.4px;
}

.metric-tile .m-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy-900);
  margin: 2px 0;
}

.metric-tile .m-sub {
  font-size: 11px;
  color: var(--slate-700);
}

/* Buttons */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--navy-900);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-700); }

.btn-amber {
  background: var(--amber-600);
  color: #fff;
}
.btn-amber:hover { background: #B45309; }

.btn-green {
  background: var(--green-600);
  color: #fff;
}
.btn-green:hover { background: #047857; }

.btn-red {
  background: var(--red-600);
  color: #fff;
}
.btn-red:hover { background: #B91C1C; }

.btn-outline {
  background: #fff;
  color: var(--navy-900);
  border: 1px solid var(--slate-300);
}
.btn-outline:hover { background: var(--slate-100); }

.btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
}

/* Pills */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pill-navy { background: var(--slate-200); color: var(--navy-900); }
.pill-amber { background: var(--amber-100); color: #92400E; }
.pill-green { background: var(--green-100); color: #065F46; }
.pill-red { background: var(--red-100); color: #991B1B; }
.pill-blue { background: var(--blue-100); color: #1E40AF; }

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

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

th {
  background: var(--navy-900);
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 11.5px;
}

td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--slate-200);
  vertical-align: top;
}

tr:hover td {
  background: var(--slate-50);
}

tr.row-edge td {
  background: #FFFBEB;
}

tr.row-edge:hover td {
  background: #FEF3C7;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

/* Blueprint Canvas */
.blueprint-stage {
  background: #081A30;
  border: 2px solid var(--navy-700);
  border-radius: 8px;
  padding: 10px;
  position: relative;
  overflow: hidden;
}

.blueprint-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 11px;
  color: #CBD5E1;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

/* Stack Light & Live Twin */
.twin-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  background: var(--navy-950);
  color: #fff;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.stack-light {
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(255,255,255,0.08);
  padding: 8px 14px;
  border-radius: 30px;
}

.lamp {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  opacity: 0.22;
  border: 2px solid rgba(255,255,255,0.25);
  transition: all 0.2s;
}

.lamp.green { background: #10B981; }
.lamp.amber { background: #F59E0B; }
.lamp.red { background: #EF4444; }
.lamp.on { opacity: 1; box-shadow: 0 0 14px currentColor; transform: scale(1.1); }
.lamp.green.on { box-shadow: 0 0 14px #10B981; }
.lamp.amber.on { box-shadow: 0 0 14px #F59E0B; }
.lamp.red.on { box-shadow: 0 0 16px #EF4444; }

.state-badge {
  font-family: Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 6px;
  background: #1E293B;
  border: 1px solid #475569;
  color: #38BDF8;
}

.state-badge.run { background: #064E3B; border-color: #10B981; color: #6EE7B7; }
.state-badge.warn { background: #78350F; border-color: #F59E0B; color: #FDE68A; }
.state-badge.trip { background: #7F1D1D; border-color: #EF4444; color: #FECACA; }

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--slate-200);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--green-500);
  transition: width 0.25s ease, background 0.25s ease;
}

/* Code / JSON Console */
.console-box {
  background: #0B1220;
  color: #E2E8F0;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 11.5px;
  line-height: 1.45;
  padding: 12px 14px;
  border-radius: 8px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid #1E293B;
}

/* Agent Cards */
.agent-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 1040px) {
  .agent-flow { grid-template-columns: 1fr; }
}

.agent-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-left: 4px solid var(--slate-300);
  border-radius: 8px;
  padding: 12px 14px;
  transition: all 0.25s ease;
}

.agent-card.running {
  border-left-color: var(--amber-500);
  background: #FFFBEB;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.agent-card.done {
  border-left-color: var(--green-600);
  background: #F0FDF4;
}

.agent-card h4 {
  font-size: 13px;
  font-weight: 800;
  color: var(--navy-900);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.agent-card p {
  font-size: 11.5px;
  color: var(--slate-700);
  margin-bottom: 6px;
}

.agent-out {
  font-family: Consolas, monospace;
  font-size: 11px;
  background: rgba(15, 23, 42, 0.05);
  padding: 6px 8px;
  border-radius: 5px;
  color: var(--navy-900);
  min-height: 36px;
}

/* Toggle Switch */
.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  margin-bottom: 8px;
}

.switch-row label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--slate-900);
  cursor: pointer;
}

.switch-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--amber-600);
  cursor: pointer;
}

/* Alert Banner */
.alert-strip {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.alert-strip.info { background: var(--blue-100); color: #1E40AF; border: 1px solid #93C5FD; }
.alert-strip.warn { background: var(--amber-100); color: #92400E; border: 1px solid #FCD34D; }
.alert-strip.danger { background: var(--red-100); color: #991B1B; border: 1px solid #FCA5A5; }
.alert-strip.success { background: var(--green-100); color: #065F46; border: 1px solid #6EE7B7; }

/* Diff Columns */
.diff-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.diff-list li {
  padding: 7px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  font-size: 12.3px;
  border-left: 3px solid var(--navy-900);
  background: var(--slate-50);
}

.diff-list li.added {
  background: #ECFDF5;
  border-left-color: var(--green-600);
}

.diff-list li.changed {
  background: #FFFBEB;
  border-left-color: var(--amber-600);
}

.diff-list li.improve {
  background: #EFF6FF;
  border-left-color: var(--blue-600);
}

/* Print Quote Modal */
@media print {
  .topbar, .nav-tabs, .config-bar, .no-print { display: none !important; }
  body { background: #fff; }
}
