/* ==========================================
   CS BUSINESS VALUE CALCULATOR — STYLES
   ========================================== */

:root {
  --bg: #0d0f14;
  --bg2: #13161e;
  --bg3: #1a1e29;
  --border: #252b3b;
  --border-light: #2f3650;
  --text: #e8eaf0;
  --text-muted: #7a82a0;
  --text-dim: #4a5270;
  --accent: #5b9cf6;
  --accent2: #38e8b0;
  --accent3: #f06060;
  --accent-glow: rgba(91,156,246,0.15);
  --accent2-glow: rgba(56,232,176,0.12);
  --sidebar-w: 220px;
  --radius: 12px;
  --radius-sm: 8px;
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── App Layout ── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 16px;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 10;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 36px; padding: 0 4px;
}
.brand-icon {
  font-size: 24px; color: var(--accent);
  line-height: 1;
}
.brand span {
  font-family: var(--font-head);
  font-size: 15px; font-weight: 700;
  line-height: 1.3; letter-spacing: 0.3px;
}
.brand small { font-weight: 400; color: var(--text-muted); font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}
.nav-item:hover { color: var(--text); background: var(--bg3); }
.nav-item.active {
  color: var(--accent);
  background: var(--accent-glow);
}
.nav-icon { font-size: 10px; opacity: 0.6; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.3s;
}
.status-dot.ok { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }
.status-dot.warn { background: #f5a623; }
.status-dot.error { background: var(--accent3); }

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 40px 48px;
  max-width: 1200px;
}

/* ── Sections ── */
.section { display: none; animation: fadeIn 0.3s ease; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.section-header { margin-bottom: 32px; }
.section-header h1 {
  font-family: var(--font-head);
  font-size: 28px; font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 4px;
}
.section-header p { color: var(--text-muted); font-size: 14px; }

/* ── Cards ── */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-light); }
.card.span-2 { grid-column: span 2; }
.card.span-full { grid-column: span 2; }

.card-title {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}

/* ── Form Fields ── */
.field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}
.field:last-child { margin-bottom: 0; }
.field label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.field-row {
  display: flex; gap: 16px; flex-wrap: wrap;
}
.field-row .field { flex: 1; min-width: 160px; }
.field-row.vertical { flex-direction: column; }
.field.narrow { flex: 0 0 140px; }

input[type="text"],
input[type="number"],
select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
select { appearance: none; cursor: pointer; }

.input-percent {
  display: flex; align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.input-percent input {
  border: none; box-shadow: none; background: transparent;
  flex: 1;
}
.input-percent:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-percent span {
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 13px;
  border-left: 1px solid var(--border);
  background: var(--bg);
  height: 100%;
  display: flex; align-items: center;
}
.input-percent.small input { padding: 8px 10px; }

/* ── Toggle ── */
.toggle-group { display: flex; flex-direction: column; gap: 12px; }
.toggle-item {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--text);
  cursor: pointer;
}
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: 0.2s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: 0.2s;
}
input:checked + .slider { background: var(--accent); border-color: var(--accent); }
input:checked + .slider::before { transform: translateX(18px); background: #fff; }

/* ── Channel Rows ── */
.channel-inputs { display: flex; flex-direction: column; gap: 10px; }
.channel-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.channel-row.inactive { opacity: 0.3; pointer-events: none; }
.ch-label {
  font-size: 13px; color: var(--text-muted); min-width: 110px;
}
.channel-row input {
  width: 100px; text-align: right; padding: 7px 10px;
}

/* ── Automation Grid ── */
.auto-grid { display: flex; flex-direction: column; gap: 10px; }
.auto-row {
  display: grid;
  grid-template-columns: 130px 1fr 100px;
  gap: 12px;
  align-items: center;
}
.auto-row.header {
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.auto-row.inactive { opacity: 0.3; pointer-events: none; }

/* ── Location Grid ── */
.location-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 100px;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}
.location-grid .loc-header {
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.5px;
  grid-column: span 3; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr 1fr 100px; gap: 10px;
}
.location-grid .loc-row.inactive { opacity: 0.3; pointer-events: none; }

/* ── Checks Bar ── */
.checks-bar {
  display: flex; gap: 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.check-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.check-icon { font-size: 10px; }
.check-label { color: var(--text-muted); }
.check-value { font-weight: 600; color: var(--text); font-family: var(--font-head); }
.check-item.ok .check-icon::before { content: '●'; color: var(--accent2); }
.check-item.warn .check-icon::before { content: '●'; color: #f5a623; }
.check-item.inactive .check-icon::before { content: '○'; color: var(--text-dim); }

/* ── Required / Optional Labels ── */
.required { color: var(--accent); font-size: 11px; font-weight: 600; }
.optional { color: var(--text-dim); font-size: 11px; font-weight: 400; }

/* ── Nav Footer ── */
.nav-footer {
  display: flex; justify-content: flex-end; gap: 12px;
  padding-top: 24px; margin-top: 8px;
  border-top: 1px solid var(--border);
}
.btn-next, .btn-back, .btn-export {
  font-family: var(--font-head);
  font-size: 13px; font-weight: 700;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  letter-spacing: 0.3px;
}
.btn-next {
  background: var(--accent);
  color: #fff;
}
.btn-next:hover { background: #4a8ee8; box-shadow: 0 4px 18px rgba(91,156,246,0.35); }
.btn-back {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-back:hover { color: var(--text); border-color: var(--border-light); }
.btn-export {
  background: var(--accent2-glow);
  color: var(--accent2);
  border: 1px solid rgba(56,232,176,0.3);
}
.btn-export:hover { background: rgba(56,232,176,0.2); }

/* ── Results ── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.kpi {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}
.kpi.accent { border-color: rgba(56,232,176,0.4); background: var(--accent2-glow); }
.kpi-label { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.3px; }
.kpi-value {
  font-family: var(--font-head);
  font-size: 22px; font-weight: 800;
  color: var(--text);
}
.kpi.accent .kpi-value { color: var(--accent2); }

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.chart-card { min-height: 280px; }
canvas { max-width: 100%; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  font-family: var(--font-head);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 10px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.data-table th:first-child { text-align: left; }
.data-table td {
  padding: 10px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.data-table td:first-child { text-align: left; color: var(--text-muted); font-size: 12px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.highlight td { color: var(--accent2); font-weight: 600; }
.data-table tr.total td { font-weight: 700; color: var(--text); }

/* ── Narrative ── */
.narrative { font-size: 13px; color: var(--text-muted); line-height: 1.8; }
.narrative p { margin-bottom: 8px; }
.narrative strong { color: var(--text); }

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

/* ── Print ── */
@media print {
  .sidebar, .nav-footer { display: none; }
  .main { margin-left: 0; padding: 20px; }
  .section { display: block !important; page-break-before: always; }
  .section:first-of-type { page-break-before: auto; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ccc; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  :root { --sidebar-w: 60px; }
  .brand span, .nav-item span:not(.nav-icon), .sidebar-status span { display: none; }
  .nav-item { justify-content: center; }
  .main { padding: 24px 20px; }
  .card-grid { grid-template-columns: 1fr; }
  .card.span-2 { grid-column: span 1; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .results-grid { grid-template-columns: 1fr; }
}
