:root {
  --bg: #0b0d10;
  --panel: #14171b;
  --panel-2: #1a1e23;
  --border: #262b32;
  --text: #e8eaed;
  --text-dim: #8b929c;
  --text-faint: #5a6068;
  --orange: #ff7a30;
  --blue: #4d8dff;
  --green: #17c98a;
  --red: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--orange), #ff9a5a);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 16px;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 10px; color: var(--text-faint); letter-spacing: 0.08em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; color: var(--text-dim);
  font-size: 13.5px; font-weight: 500; cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); }
.nav-icon { width: 16px; text-align: center; }

.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }

.main { flex: 1; padding: 28px 36px; overflow-y: auto; max-height: 100vh; }

.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.page-sub { color: var(--text-dim); margin: 4px 0 0; font-size: 13px; }
.page-sub b { color: var(--text); }

.range-toggle { display: flex; background: var(--panel-2); border-radius: 8px; padding: 3px; gap: 2px; }
.range-toggle button {
  background: none; border: none; color: var(--text-dim); padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 600;
}
.range-toggle button.active { background: #fff; color: #0b0d10; }

.grid { display: grid; gap: 16px; }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1200px) { .grid-6 { grid-template-columns: repeat(3, 1fr); } .grid-3 { grid-template-columns: repeat(1, 1fr); } }
@media (max-width: 700px) { .grid-6 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-label { font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; margin-bottom: 10px; }
.card-value { font-size: 26px; font-weight: 800; line-height: 1; margin-bottom: 6px; }
.card-sub { font-size: 12px; color: var(--text-dim); }
.card-value.orange { color: var(--orange); }
.card-value.blue { color: var(--blue); }
.card-value.green { color: var(--green); }
.card-value.red { color: var(--red); }

.section-label { font-size: 11px; color: var(--text-faint); letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; margin: 26px 0 12px; }

.note { font-size: 12.5px; color: var(--text-faint); margin-top: 12px; line-height: 1.5; }

.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.green { background: rgba(23,201,138,0.15); color: var(--green); }
.badge.red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge.blue { background: rgba(77,141,255,0.15); color: var(--blue); }
.badge.gray { background: rgba(139,146,156,0.15); color: var(--text-dim); }
.badge.orange { background: rgba(255,122,48,0.15); color: var(--orange); }

.btn {
  background: var(--blue); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
}
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--red); }
.btn.small { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input, select.input, textarea.input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px; margin-bottom: 12px;
}
.input:focus, select.input:focus { outline: none; border-color: var(--blue); }
label.field-label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; display: block; font-weight: 600; }
.field { margin-bottom: 14px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 420px; max-width: 90vw; max-height: 85vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.hidden { display: none !important; }

.flex-between { display: flex; justify-content: space-between; align-items: center; }
.tag-row { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim); padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.tab-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--panel-2); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 10px; font-size: 13.5px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.error { border-color: var(--red); color: var(--red); }
.toast.success { border-color: var(--green); color: var(--green); }

.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.chart-bar { flex: 1; background: var(--orange); border-radius: 3px 3px 0 0; min-height: 2px; }
.chart-bar.blue { background: var(--blue); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-faint); }

.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 0%, #171b20 0%, #0b0d10 60%);
}
.login-card {
  width: 380px; max-width: 90vw; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 34px 30px;
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-title { font-size: 20px; font-weight: 800; margin: 18px 0 2px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.role-tabs { display: flex; gap: 6px; margin-bottom: 22px; background: var(--panel-2); padding: 4px; border-radius: 10px; }
.role-tab { flex: 1; text-align: center; padding: 9px 0; border-radius: 8px; font-size: 12.5px; font-weight: 700; color: var(--text-dim); background: none; border: none; }
.role-tab.active { background: var(--orange); color: #fff; }
.error-box { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #ff9d9d; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.demo-creds { margin-top: 20px; font-size: 11.5px; color: var(--text-faint); line-height: 1.6; border-top: 1px solid var(--border); padding-top: 14px; }
