:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232636;
  --border: #2e3150;
  --accent: #5b6af0;
  --accent-h: #7b8bf8;
  --text: #e2e4f0;
  --text-muted: #8890b0;
  --danger: #e05555;
  --success: #3dba7a;
  --warn: #e0a030;
  --info: #4aaddb;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 12px rgba(0,0,0,.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Topnav ────────────────────────────────────────────────────────────── */
.topnav {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.topnav .brand { font-weight: 700; font-size: 15px; color: var(--accent-h); white-space: nowrap; }
.topnav .nav-links { display: flex; gap: 4px; flex: 1; }
.topnav .nav-links a {
  padding: 6px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px;
}
.topnav .nav-links a:hover, .topnav .nav-links a.active { background: var(--surface2); color: var(--text); text-decoration: none; }
.topnav .nav-user { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 13px; }

/* ── Main ──────────────────────────────────────────────────────────────── */
main { max-width: 1260px; margin: 0 auto; padding: 32px 24px; }
h1 { font-size: 22px; font-weight: 700; margin-bottom: 24px; color: var(--text); }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 16px; margin-top: 32px; color: var(--text); }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; }

/* ── Grid ───────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Stat cards ─────────────────────────────────────────────────────────── */
.stat { padding: 20px; text-align: center; }
.stat-number { font-size: 36px; font-weight: 700; color: var(--accent-h); }
.stat-label { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr:hover td { background: var(--surface2); }
.table-actions { display: flex; gap: 8px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
label { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number],
select, textarea {
  width: 100%; padding: 9px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,106,240,.15);
}
textarea { min-height: 100px; resize: vertical; font-family: inherit; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn, button[type=submit] {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer; border: none;
  background: var(--accent); color: #fff;
  transition: background .15s;
}
.btn:hover, button[type=submit]:hover { background: var(--accent-h); text-decoration: none; }
.btn-secondary { background: var(--surface2); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #ff6b6b; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link { background: none; border: none; color: var(--text-muted); padding: 0; cursor: pointer; font-size: 13px; }
.btn-link:hover { color: var(--text); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.badge-open       { background: #1e2e4a; color: #4aaddb; }
.badge-progress   { background: #2a2510; color: #e0a030; }
.badge-wait       { background: #1e1e3a; color: #9090e0; }
.badge-done       { background: #0d2a1a; color: #3dba7a; }
.badge-cancelled  { background: #2a1515; color: #e05555; }
.badge-info       { background: #0d1f2a; color: var(--info); }
.badge-low        { background: #0d2a1a; color: var(--success); }
.badge-normal     { background: #1e1e3a; color: #9090e0; }
.badge-high       { background: #2a2510; color: var(--warn); }
.badge-critical   { background: #2a1515; color: var(--danger); }
.badge-default    { background: var(--surface2); color: var(--text-muted); }
.badge-active     { background: #0d2a1a; color: #3dba7a; }
.badge-trial      { background: #2a2510; color: #e0a030; }
.badge-suspended  { background: #2a1515; color: #e05555; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.alert-error   { background: rgba(224,85,85,.15); border: 1px solid rgba(224,85,85,.3); color: #ff9090; }
.alert-success { background: rgba(61,186,122,.15); border: 1px solid rgba(61,186,122,.3); color: #5de09a; }
.alert-info    { background: rgba(74,173,219,.1); border: 1px solid rgba(74,173,219,.3); color: #7acde8; }

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-wrap {
  max-width: 420px; margin: 80px auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 36px;
  box-shadow: var(--shadow);
}
.login-wrap .brand { text-align: center; font-size: 22px; font-weight: 700; color: var(--accent-h); margin-bottom: 8px; }
.login-wrap .tagline { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 13px; }

/* ── Message list ───────────────────────────────────────────────────────── */
.message-list { display: flex; flex-direction: column; gap: 8px; }
.message-item { background: var(--surface2); border-radius: var(--radius-sm); padding: 12px 16px; }
.message-meta { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }
.message-body { white-space: pre-wrap; }

/* ── Misc ───────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex { display: flex; align-items: center; gap: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.token-mono { font-family: monospace; background: var(--surface2); padding: 2px 6px; border-radius: 3px; font-size: 13px; word-break: break-all; }
code { font-family: monospace; background: var(--surface2); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.empty-state { text-align: center; padding: 48px; color: var(--text-muted); }
