:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-alt: #fafbfd;
  --border: #e4e8ef;
  --text: #172033;
  --muted: #667085;
  --primary: #1d4ed8;
  --primary-700: #1e40af;
  --primary-tint: #eef2ff;
  --ok: #047857;
  --ok-bg: #d1fae5;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-md: 0 4px 18px rgba(15,23,42,0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 13px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------- Auth -------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 15% 15%, #e2e8ff 0%, transparent 55%),
              radial-gradient(900px 500px at 85% 85%, #d1fae5 0%, transparent 55%),
              var(--bg);
}
.auth-shell { width: 100%; max-width: 420px; padding: 24px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand h1 { font-size: 20px; margin: 12px 0 4px; }
.auth-foot { text-align: center; margin-top: 16px; color: var(--muted); font-size: 12px; }

.auth-form label {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
  font-weight: 500;
  font-size: 13px;
}
.auth-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border 0.15s, box-shadow 0.15s;
  background: #fff;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.15);
}

/* -------- Layout -------- */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111a33 100%);
  color: #e2e8f0;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 6px 8px; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2b5dd1, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(45, 93, 209, 0.5);
}
.brand-mark.large { width: 56px; height: 56px; font-size: 20px; margin: 0 auto; }
.brand-title { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 11px; color: #94a3b8; letter-spacing: 0.4px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 500;
  font-size: 13px;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(43,93,209,0.2); color: #fff; }
.nav-ico { width: 18px; text-align: center; color: #94a3b8; }
.nav-link.active .nav-ico { color: #93bbff; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; background: rgba(255,255,255,0.05);
  border-radius: 9px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #334155; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.user-name { font-weight: 500; font-size: 13px; color: #fff; }
.user-role { font-size: 11px; color: #94a3b8; }

.logout-form { margin: 0; }

.content {
  padding: 28px 32px;
  max-width: 1400px;
  width: 100%;
}

.topbar {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 22px;
}
.topbar h1 { margin: 0 0 2px; font-size: 22px; }
.topbar .muted { font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; }

/* -------- Buttons -------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border 0.15s, color 0.15s;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-700); text-decoration: none; color: #fff; }
.btn-ghost {
  background: transparent; color: var(--muted); border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* -------- Stat cards -------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #2b5dd1, #7c3aed);
}
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; margin: 8px 0 4px; }
.stat-foot { font-size: 12px; color: var(--muted); }

/* -------- Panel -------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-narrow { max-width: 640px; }
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-body { padding: 18px 20px; }
.panel-body.no-pad { padding: 0; }

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

/* -------- Tables -------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td {
  padding: 11px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.tbl th {
  background: var(--surface-alt);
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.tbl tbody tr:hover { background: var(--surface-alt); }
.tbl td.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.tbl tbody tr:last-child td { border-bottom: none; }

/* -------- Pills -------- */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.pill-ok   { background: var(--ok-bg);   color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad  { background: var(--bad-bg);  color: var(--bad); }

/* -------- Forms -------- */
.send-form label {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
  font-weight: 500;
  font-size: 13px;
}
.send-form input, .send-form textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.send-form input:focus, .send-form textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.15);
}
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* -------- Flash -------- */
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}
.flash-info { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }

/* -------- Endpoints -------- */
.endpoints { display: flex; flex-direction: column; gap: 16px; }
.endpoint-label {
  font-size: 12px; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.endpoint code {
  display: inline-block;
  background: var(--primary-tint);
  color: var(--primary-700);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 4px;
}

/* -------- Pager -------- */
.pager {
  display: flex; align-items: center; gap: 12px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-alt);
}
