:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e2e6ec;
  --text: #1a2233;
  --text-dim: #6b7280;
  --accent: #1e40af;
  --accent-2: #2563eb;
  --good: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --font-display: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .06);
  --ease: 150ms ease;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&family=IBM+Plex+Mono:wght@400;600&display=swap');

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-display); font-size: 13px; -webkit-font-smoothing: antialiased; }
h1, h2 { font-weight: 800; margin: 0; letter-spacing: -.01em; }

#app { display: flex; min-height: 100vh; }

#sidebar {
  width: 230px; flex: 0 0 230px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 0;
}
.nav-top-row { padding: 0 18px 18px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
.brand span { display: block; font-weight: 800; font-size: 13px; line-height: 1.3; }
.brand small { display: block; color: var(--text-dim); font-weight: 500; font-size: 10px; }

.nav-menu-row { padding: 14px 10px; position: relative; }
.nav-group { position: relative; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; color: var(--text-dim); font-weight: 600; transition: background var(--ease), color var(--ease); }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.nav-icon { font-size: 14px; }

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 24px;
  background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
#pageTitle { font-size: 16px; margin-right: 8px; }
.topbar-right { display: flex; gap: 10px; margin-left: auto; flex-wrap: wrap; }

input, select, button { font-family: inherit; font-size: 12px; }
input[type=date], select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
button { padding: 8px 14px; border-radius: 8px; border: none; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; transition: background var(--ease), transform var(--ease), box-shadow var(--ease); }
button:hover { background: var(--accent-2); box-shadow: var(--shadow-sm); }
button:active { transform: translateY(1px); }
button.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--bg); border-color: var(--accent); }

.export-btn-wrap { position: relative; }
.export-menu { display: none; position: absolute; top: 100%; left: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px; z-index: 10; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; min-width: 260px; }
.export-menu.open { display: block; }
.export-menu label { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 12px; cursor: pointer; }

#content { padding: 22px 24px; flex: 1; }
.view { display: none; }
.view.active { display: block; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow-sm); transition: box-shadow var(--ease); }
.panel:hover { box-shadow: var(--shadow-md); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 12px; }
.panel-subtitle { color: var(--text-dim); font-size: 11px; margin-top: 4px; max-width: 640px; }
.accent-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 8px; }
.decision-panel { border-left: 3px solid var(--accent); }
.coming-soon { color: var(--text-dim); text-align: center; padding: 60px 20px; font-weight: 600; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease); }
.kpi-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kpi-label { font-size: 10.5px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-family: var(--font-mono); font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.kpi-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.bb-grid.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.chart-box { position: relative; }
.chart-box-md { height: 220px; }
.chart-box-lg { height: 300px; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data-table th, table.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
table.data-table th { color: var(--text-dim); font-weight: 700; font-size: 10.5px; text-transform: uppercase; }
table.data-table tbody tr { transition: background var(--ease); }
table.data-table tbody tr:hover { background: var(--bg); cursor: pointer; }
.table-scroll { max-height: 360px; overflow-y: auto; }

.mono { font-family: var(--font-mono); }
.text-good { color: var(--good); } .text-bad { color: var(--bad); } .text-warn { color: var(--warn); }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 640px; width: 92%; max-height: 84vh; overflow-y: auto; position: relative; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none; font-size: 22px; color: var(--text-dim); cursor: pointer; padding: 0; }

#appFooter { text-align: center; padding: 16px; font-size: 14px; font-weight: 700; text-transform: uppercase; color: var(--text-dim); }

.insight-line { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.insight-line:last-child { border-bottom: none; }

@media (max-width: 680px) {
  #sidebar { display: none; }
  .grid-2, .bb-grid.three { grid-template-columns: 1fr; }
}
