/* GPP Carry — Styles V4 (Sidebar Layout) */

:root {
  --bg-body: #0a0f1a;
  --bg-surface: #111827;
  --bg-input: #0f172a;
  --bg-hover: rgba(91, 126, 157, 0.05);
  --border: #1e293b;
  --border-hover: #334155;
  --gp: #5b7e9d;
  --gp-dark: #435060;
  --gp-light: #7ea8c4;
  --gp-muted: #4a6a85;
  --text-primary: #e2e8f0;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-muted: #64748b;
  --text-faint: #475569;
  --green: #10b981;
  --green-light: #34d399;
  --amber: #f59e0b;
  --red: #ef4444;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.mono { font-family: 'JetBrains Mono', monospace; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
* { scrollbar-width: thin; scrollbar-color: var(--border-hover) transparent; }

/* ── Header ── */
.app-header {
  flex-shrink: 0;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}
.header-inner {
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { height: 26px; width: auto; }
.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}
.header-title-group { line-height: 1; }
.header-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.header-subtitle { font-size: 0.625rem; color: var(--text-faint); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(91, 126, 157, 0.08);
  border: 1px solid rgba(91, 126, 157, 0.18);
  font-size: 0.625rem; font-weight: 500; color: var(--gp-light);
}
.pulse-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--gp-light);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.header-right { display: flex; align-items: center; gap: 12px; }
.header-badges { display: flex; align-items: center; gap: 8px; }
.conf-badge {
  padding: 3px 8px; border-radius: 999px;
  background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.18);
  font-size: 0.625rem; font-weight: 600; color: #f87171;
}
.gp-label { font-size: 0.625rem; color: var(--text-faint); font-family: 'JetBrains Mono', monospace; }

/* ── Tab Bar (in header) ── */
.tab-bar { display: flex; gap: 2px; }
.tab-btn {
  position: relative;
  padding: 6px 14px;
  background: transparent; border: none;
  color: var(--text-muted);
  font-size: 0.8125rem; font-weight: 500; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.tab-btn:hover { color: var(--text-tertiary); background: rgba(255,255,255,0.03); }
.tab-btn.active { color: var(--text-primary); background: rgba(91, 126, 157, 0.12); }

/* ── App Shell ── */
.app-shell {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ── */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-section-label {
  font-size: 0.5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  padding: 10px 14px 4px;
}

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

/* Global controls section */
.sidebar-global {
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--border);
}

.global-alloc-group { margin-top: 6px; }

.global-alloc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.global-alloc-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
}
.global-alloc-value-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
}

.range-bounds {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 0.5625rem;
  color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
}

.sidebar-help {
  font-size: 0.625rem;
  color: var(--text-faint);
  line-height: 1.4;
  margin-top: 6px;
}

/* Inline scenario save */
.scenario-save-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
}

.scenario-name-input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.75rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.scenario-name-input:focus {
  outline: none;
  border-color: var(--gp);
  box-shadow: 0 0 0 2px rgba(91, 126, 157, 0.12);
}
.scenario-name-input::placeholder { color: var(--text-faint); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
}
.scenario-name-input.shake {
  animation: shake 0.3s ease;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}

.btn-save {
  padding: 5px 10px;
  background: var(--gp-dark);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-save:hover { background: var(--gp); }

.btn-icon-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon-reset:hover { border-color: var(--gp); color: var(--gp-light); }

/* ── Accordion Items ── */
.sidebar-vehicles { flex: 1; }

.acc-item {
  border-bottom: 1px solid var(--border);
  position: relative;
}

.acc-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--item-color, var(--gp));
  opacity: 0;
  transition: opacity 0.2s;
}
.acc-item.is-open::before { opacity: 1; }
.acc-item:hover::before { opacity: 0.5; }

.acc-disabled { opacity: 0.4; }

.acc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px 9px 14px;
  cursor: default;
}
.acc-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}
.acc-chevron-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  color: var(--text-faint);
  flex-shrink: 0;
  border-radius: 3px;
  transition: color 0.15s, background 0.1s;
}
.acc-chevron-btn:hover { color: var(--text-tertiary); background: rgba(255,255,255,0.04); }
.acc-chevron-icon {
  display: block;
  transition: transform 0.2s ease;
  transform: rotate(-90deg);
}
.acc-chevron-btn.open .acc-chevron-icon { transform: rotate(0deg); }

.acc-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.acc-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acc-badge {
  font-size: 0.5rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--bg-input);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}
.acc-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.acc-carry {
  font-size: 0.8125rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -0.02em;
  color: var(--green);
}
.acc-carry.muted { color: var(--text-faint); font-weight: 500; }
.acc-toggle {
  width: 13px; height: 13px;
  accent-color: var(--gp);
  cursor: pointer;
  flex-shrink: 0;
}

/* Accordion body */
.acc-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease-out;
}
.acc-body.open { max-height: 560px; }

.acc-controls {
  padding: 4px 14px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.acc-control {}
.acc-control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.acc-control-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.acc-control-value {
  font-size: 0.6875rem;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  color: var(--gp-light);
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 3px;
}
.acc-control-value.sens-up { color: var(--green-light); }
.acc-control-value.sens-down { color: var(--red); }

.acc-slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.acc-slider-row .input-range { flex: 1; min-width: 0; }

.acc-slider-bounds {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 0.5rem;
  color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
}

.acc-override-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  cursor: pointer;
}
.acc-override-label {
  font-size: 0.5625rem;
  color: var(--text-faint);
  line-height: 1.3;
}
.override-check {
  width: 11px; height: 11px;
  accent-color: var(--gp);
  cursor: pointer;
  flex-shrink: 0;
}

.acc-vesting-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.acc-vesting-lbl {
  font-size: 0.5625rem;
  color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
  min-width: 26px;
  flex-shrink: 0;
}

/* ── Input Controls ── */
.input-range {
  -webkit-appearance: none; appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.input-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--gp);
  border: 2px solid #2d4a60;
  cursor: grab;
  transition: background 0.12s, box-shadow 0.12s, transform 0.1s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.input-range::-webkit-slider-thumb:hover {
  background: var(--gp-light);
  transform: scale(1.15);
  box-shadow: 0 0 8px rgba(91, 126, 157, 0.5);
}
.input-range::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.25);
  box-shadow: 0 0 12px rgba(91, 126, 157, 0.6);
}
.input-range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--gp); border: 2px solid #2d4a60;
  cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.input-range::-moz-range-thumb:active { cursor: grabbing; }
.input-range:disabled, .input-number:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.input-number {
  padding: 4px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  text-align: right;
  width: 62px;
  min-width: 62px;
}
.input-number:focus {
  outline: none;
  border-color: var(--gp);
  box-shadow: 0 0 0 2px rgba(91, 126, 157, 0.12);
}
.input-number-sm { width: 58px; min-width: 58px; font-size: 0.6875rem; padding: 3px 5px; }
.input-suffix { font-size: 0.6875rem; color: var(--text-muted); }

/* Hide number input spinner arrows */
.input-number::-webkit-inner-spin-button,
.input-number::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input-number { -moz-appearance: textfield; }

/* ── Main Content ── */
.main-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-body);
}

/* Compact KPI Row */
.kpi-row {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0;
}
.kpi-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 16px;
}
.kpi-sep {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}
.kpi-label {
  font-size: 0.5rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
  white-space: nowrap;
}
.kpi-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  line-height: 1;
}

/* ── Tab Panels ── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.main-body {
  padding: 20px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Charts ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.chart-card-header {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.chart-wrap { height: 240px; position: relative; }

/* ── Summary Table ── */
.summary-card { padding: 0; overflow: hidden; }
.summary-card .chart-card-header { padding: 12px 16px 10px; margin-bottom: 0; }

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.summary-table thead tr { background: var(--bg-input); }
.summary-table th {
  font-size: 0.5rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 7px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.th-right { text-align: right !important; }
.summary-table td {
  padding: 9px 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(30, 41, 59, 0.6);
  font-size: 0.8125rem;
  white-space: nowrap;
}
.summary-table td:not(:first-child) { text-align: right; }
.summary-table .summary-row:last-child td { border-bottom: none; }
.summary-table .summary-row:hover td { background: var(--bg-hover); }
.summary-row.row-disabled { opacity: 0.4; }
.summary-disabled { color: var(--text-faint); font-style: italic; }
.summary-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
  position: relative; top: -1px;
}

/* ── Scenarios ── */
.scenarios-layout { padding: 20px; max-width: 600px; }
.scenarios-header { margin-bottom: 16px; }
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; margin-bottom: 14px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-faint);
  font-size: 0.75rem; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: all 0.15s;
}
.btn-back:hover { border-color: var(--border-hover); color: var(--text-secondary); }

/* ── Toast ── */
#scenario-toast {
  display: none;
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; border: 1px solid var(--border-hover);
  color: var(--text-secondary); font-size: 0.8125rem; font-weight: 500;
  padding: 10px 20px; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 9998; white-space: nowrap;
}
#scenario-toast.toast-visible { display: block; animation: toast-in 0.2s ease; }
#scenario-toast.toast-fade-out { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}
.section-title {
  font-size: 0.875rem; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: 0.025em; margin-bottom: 4px;
}
.scenario-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.scenario-item:hover { border-color: var(--border-hover); }
.scenario-name { font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); }
.scenario-date { font-size: 0.6875rem; color: var(--text-faint); margin-left: 8px; }
.scenario-actions { display: flex; gap: 6px; }
.empty-state {
  color: var(--text-faint); font-size: 0.8125rem;
  padding: 32px; text-align: center;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px;
}

/* ── Shared Buttons ── */
.btn-primary {
  padding: 6px 12px; border: none; border-radius: 6px;
  background: var(--gp-dark); color: #fff;
  font-size: 0.75rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.15s;
}
.btn-primary:hover { background: var(--gp); }
.btn-ghost {
  padding: 5px 10px; border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--gp); color: var(--text-tertiary); }
.btn-sm { padding: 3px 9px; font-size: 0.6875rem; }
.btn-danger {
  background: transparent; border: 1px solid var(--red); color: var(--red);
  padding: 3px 9px; border-radius: 6px;
  font-size: 0.6875rem; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: all 0.15s;
}
.btn-danger:hover { background: var(--red); color: white; }

.positive { color: var(--green); }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .gp-label { display: none; }
}

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .charts-grid { grid-template-columns: 1fr; }
  .header-badges .gp-label { display: none; }
}

@media (max-width: 640px) {
  .status-badge { display: none; }
  .header-divider { display: none; }
  .header-subtitle { display: none; }
  .kpi-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 0;
  }
  .kpi-sep { display: none; }
  .kpi-item {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    align-items: flex-start;
  }
  .kpi-item:nth-child(4n) { border-right: none; }
  .kpi-item:nth-child(3), .kpi-item:nth-child(4) { border-bottom: none; }
  .kpi-label { font-size: 0.4375rem; }
  .kpi-value { font-size: 1rem; }
  .main-body { padding: 12px; }
  .scenarios-layout { padding: 12px; }
}
