:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface2: #f9f9f7;
  --border: #e4e4e0;
  --border2: #d0d0ca;
  --text: #1a1a18;
  --text2: #5a5a56;
  --text3: #9a9a94;
  --accent: #2d6a4f;
  --accent-light: #eaf4ef;
  --accent-hover: #245c43;
  --green: #1D9E75;
  --green-bg: #e8f7f2;
  --red: #c0392b;
  --red-bg: #fdf0ee;
  --amber: #b87314;
  --amber-bg: #fdf3e3;
  --blue: #2471a3;
  --blue-bg: #eaf3fb;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --nav-w: 220px;
  --radius: 8px;
  --radius-lg: 12px;
}

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

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

/* ── Sidebar ─────────────────────────────────────── */
.sidenav {
  width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidenav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-icon { font-size: 22px; }
.logo-name { font-size: 14px; font-weight: 600; color: var(--text); }
.logo-sub  { font-size: 11px; color: var(--text3); }

.nav-links {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover  { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--accent-light); color: var(--accent); }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidenav-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav-user { font-size: 12px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Main ────────────────────────────────────────── */
.main-content {
  margin-left: var(--nav-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.page-body { padding: 24px 28px; }

/* ── Login ───────────────────────────────────────── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  width: 100%;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .icon { font-size: 36px; }
.login-logo h2 { font-size: 20px; font-weight: 600; margin-top: 8px; }
.login-logo p  { font-size: 13px; color: var(--text3); margin-top: 4px; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { background: var(--bg); }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  width: 100%;
  justify-content: center;
  padding: 10px;
  font-size: 14px;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }

.btn-logout {
  font-family: var(--font);
  font-size: 11px;
  color: var(--text3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
}

.btn-logout:hover { color: var(--red); }

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 5px;
}

input[type=text], input[type=password], input[type=number],
input[type=email], select, textarea {
  font-family: var(--font);
  font-size: 13px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type=checkbox] { width: auto; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
}

.card-body { padding: 18px; }

/* ── KPI Grid ────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kpi-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
.kpi-value { font-size: 21px; font-weight: 600; font-family: var(--mono); letter-spacing: -0.02em; }

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

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--surface2);
  padding: 8px 10px;
  text-align: right;
  font-weight: 600;
  font-size: 11px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th.th-left { text-align: left; }

.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f0f0ec;
  vertical-align: middle;
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
}

.data-table td.td-label {
  font-family: var(--font);
  text-align: left;
  white-space: nowrap;
}

.data-table td.td-label.group {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 14px;
  border-bottom: none;
}

.data-table tr:hover td:not(.group) { background: #fafaf8; }

.data-table tr.tr-sub td {
  background: var(--surface2);
  font-weight: 600;
  border-top: 1px solid var(--border2);
  border-bottom: 1px solid var(--border2);
}

.data-table tr.tr-total td {
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 14px;
  border: none;
}

.data-table td input.cell-input {
  width: 80px;
  text-align: right;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  padding: 3px 6px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.data-table td input.cell-input:hover  { border-color: var(--border2); background: var(--bg); }
.data-table td input.cell-input:focus  { border-color: var(--accent); background: var(--accent-light); }

/* ── Colors ──────────────────────────────────────── */
.pos  { color: var(--green); }
.neg  { color: var(--red); }
.warn { color: var(--amber); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }

/* ── Alerts ──────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
}

.alert-error   { background: var(--red-bg);   color: var(--red);   border-color: #f5c6c4; }
.alert-success { background: var(--green-bg); color: #0f6e56;      border-color: #9fe1cb; }
.alert-info    { background: var(--blue-bg);  color: var(--blue);  border-color: #b5d4f4; }

/* ── Misc ────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toolbar label { font-size: 12px; color: var(--text2); }
.toolbar select { width: auto; }

.chart-container { position: relative; height: 200px; }

.scenario-list { display: flex; flex-direction: column; gap: 10px; }

.scenario-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.scenario-item.active { border-color: var(--accent); background: var(--accent-light); }

.scenario-name { font-weight: 600; font-size: 14px; }
.scenario-meta { font-size: 12px; color: var(--text3); }

.sep { width: 1px; height: 14px; background: var(--border2); }

.text-muted { color: var(--text3); font-size: 12px; }

.flex-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.flex-1   { flex: 1; min-width: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

@media (max-width: 768px) {
  .sidenav { width: 100%; position: static; height: auto; flex-direction: row; }
  .main-content { margin-left: 0; }
}
