:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d212a;
  --border: #272c36;
  --text: #e6e8ee;
  --muted: #8b93a3;
  --accent: #5865f2;
  --accent-2: #7983f5;
  --green: #3ba55d;
  --amber: #e0a43a;
  --red: #e5484d;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  font-family: Inter, 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: 'JetBrains Mono', Consolas, monospace; font-size: 12px; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-weight: 700; font-size: 15px; }
.brand .dot { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #9b5cf6); display: grid; place-items: center; font-size: 14px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.active { background: rgba(88, 101, 242, 0.16); color: #fff; }
.nav .sep { margin: 10px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #5d6575; }
.sidebar .me { margin-top: auto; padding: 10px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sidebar .me form { margin-left: auto; }
.main { padding: 26px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; }
.status-pill.on i { background: var(--green); box-shadow: 0 0 0 3px rgba(59, 165, 93, 0.2); }

/* ---------- cards ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush h2 { padding: 16px 18px 0; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; display: flex; justify-content: space-between; align-items: center; }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
.stat .sub { color: var(--muted); font-size: 12px; }
.section { margin-top: 22px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.person { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); flex: none; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; }
.person .n { font-weight: 600; color: var(--text); }
.person .u { font-size: 12px; color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.support { background: rgba(59, 165, 93, 0.14); color: #6fd391; border-color: rgba(59, 165, 93, 0.35); }
.badge.lead_support { background: rgba(35, 170, 200, 0.14); color: #6fd2e8; border-color: rgba(35, 170, 200, 0.35); }
.badge.moderator { background: rgba(224, 164, 58, 0.14); color: #f0c46f; border-color: rgba(224, 164, 58, 0.35); }
.badge.admin, .badge.manager { background: rgba(229, 72, 77, 0.14); color: #ff8b8e; border-color: rgba(229, 72, 77, 0.35); }
.badge.developer { background: rgba(155, 92, 246, 0.16); color: #c4a2ff; border-color: rgba(155, 92, 246, 0.35); }
.badge.active, .badge.open, .badge.keep, .badge.removed-ok { background: rgba(59, 165, 93, 0.14); color: #6fd391; border-color: rgba(59, 165, 93, 0.35); }
.badge.former, .badge.left, .badge.deleted, .badge.remove, .badge.failed { background: rgba(229, 72, 77, 0.12); color: #ff8b8e; border-color: rgba(229, 72, 77, 0.3); }
.badge.closed, .badge.none, .badge.higher, .badge.exempt { background: var(--panel-2); color: var(--muted); }
.badge.grace, .badge.flagged { background: rgba(224, 164, 58, 0.14); color: #f0c46f; border-color: rgba(224, 164, 58, 0.35); }
.badge.met { background: rgba(59, 165, 93, 0.14); color: #6fd391; border-color: rgba(59, 165, 93, 0.35); }
.badge.missed, .badge.removed { background: rgba(229, 72, 77, 0.12); color: #ff8b8e; border-color: rgba(229, 72, 77, 0.3); }

/* ---------- progress ---------- */
.progress { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar { width: 90px; height: 6px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--amber); border-radius: 99px; }
.bar.done > span { background: var(--green); }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart .b { width: 100%; max-width: 38px; background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.chart .v { font-size: 11px; color: var(--text); }
.chart .l { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* ---------- forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a4150; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: rgba(229, 72, 77, 0.12); border-color: rgba(229, 72, 77, 0.4); color: #ff8b8e; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.icon { padding: 2px 6px; font-size: 12px; color: var(--muted); background: transparent; border-color: transparent; }
.btn.icon:hover { color: var(--text); border-color: var(--border); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font: inherit; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2); }
select[multiple] { min-height: 120px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 14px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > input, .inline > select { width: auto; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.check input { width: auto; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; }
.toolbar input[type='search'] { width: 260px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: #fff; border-bottom-color: var(--accent); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 14px; }
.notice { padding: 12px 14px; border-radius: 8px; background: rgba(224, 164, 58, 0.1); border: 1px solid rgba(224, 164, 58, 0.3); color: #f0c46f; margin-bottom: 16px; }
.notice.info { background: rgba(88, 101, 242, 0.1); border-color: rgba(88, 101, 242, 0.3); color: #aab1ff; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; justify-content: space-between; }
.timeline li:last-child { border-bottom: none; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
pre.json { white-space: pre-wrap; word-break: break-word; margin: 0; max-width: 380px; max-height: 120px; overflow: auto; color: var(--muted); }

/* ---------- dialog & toasts ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(440px, 92vw); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(2px); }
dialog form { padding: 20px; }
dialog h3 { margin: 0 0 4px; font-size: 16px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--green); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; animation: slide 0.2s ease-out; }
.toast.error { border-left-color: var(--red); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(800px 400px at 50% -10%, rgba(88, 101, 242, 0.25), transparent), var(--bg); }
.login .card { width: min(400px, 100%); text-align: center; padding: 34px; }
.login .brand { justify-content: center; font-size: 18px; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; padding: 11px 18px; width: 100%; justify-content: center; font-weight: 600; margin-top: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 4px 8px; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav .sep { display: none; }
  .sidebar .me { margin: 0 0 0 auto; border: none; padding: 4px; }
  .main { padding: 18px 16px 50px; }
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .toolbar input[type='search'] { width: 100%; }
}
