:root {
  --bg: #14181F;
  --surface: #1C222C;
  --surface-raised: #212836;
  --border: #2A313D;
  --text: #EDEFF2;
  --text-muted: #8A93A3;
  --accent: #E8A93C;
  --accent-dim: #7A5F2A;
  --good: #4FAE7C;
  --bad: #D9614F;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.tabular { font-variant-numeric: tabular-nums; }

/* ---- Layout shell ---- */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 20px 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.brand .company {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
}
.brand .sub {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.nav a {
  display: block;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 14px;
  border-left: 2px solid transparent;
}
.nav a:hover { color: var(--text); text-decoration: none; background: rgba(255,255,255,0.02); }
.nav a.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: rgba(232,169,60,0.06);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px 0 20px;
  border-top: 1px solid var(--border);
}
.whoami { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.whoami strong { color: var(--text); display: block; font-size: 14px; }

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1100px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px 0;
}
.page-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 28px 0;
}

/* ---- Cards / stat row ---- */
.stat-row {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 20px;
  min-width: 160px;
  flex: 1;
}
.stat .label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat .value {
  font-size: 26px;
  font-weight: 700;
}
.stat .value.good { color: var(--good); }
.stat .value.bad { color: var(--bad); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 24px;
}
.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}
.panel-body { padding: 20px; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: none;
}
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.rank {
  display: inline-block;
  width: 22px;
  color: var(--text-muted);
}
.rank.top { color: var(--accent); font-weight: 700; }

.empty-row td {
  color: var(--text-muted);
  font-style: normal;
  padding: 20px;
}

/* ---- Forms ---- */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-family: var(--font);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}
.inline-form .form-row { margin-bottom: 0; flex: 1; min-width: 140px; }

button, .btn {
  background: var(--accent);
  color: #1A1508;
  border: none;
  padding: 9px 16px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
}
button:hover, .btn:hover { opacity: 0.9; text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-small { padding: 5px 10px; font-size: 12.5px; }

.flash-error {
  background: rgba(217,97,79,0.12);
  border: 1px solid var(--bad);
  color: #F0A99C;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 18px;
  font-size: 14px;
}

.pill {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.pill.admin { border-color: var(--accent-dim); color: var(--accent); }
.pill.active { border-color: var(--good); color: var(--good); }
.pill.inactive { border-color: var(--bad); color: var(--bad); }

/* ---- Login page ---- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 32px;
}
.login-card h1 {
  font-size: 18px;
  margin: 0 0 2px 0;
}
.login-card .sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 24px 0;
}
.login-card button { width: 100%; margin-top: 6px; padding: 10px; }

.section-gap { height: 8px; }

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .main { padding: 20px; }
}
