:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #1b2437;
  --muted: #6b7688;
  --line: #e3e8f0;
  --primary: #2196f3;
  --primary-dark: #1565c0;
  --danger: #e5484d;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 15px; margin: 0 0 14px; }
code { background: #eef1f7; padding: 2px 6px; border-radius: 5px; font-size: 12px; }
a { color: var(--primary-dark); }
.muted { color: var(--muted); margin: 0; }
.row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline { display: inline-flex; align-items: center; gap: 8px; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: #101626;
  color: #cfd6e4;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand { font-weight: 800; font-size: 16px; color: #fff; line-height: 1.3; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a {
  color: #b7c0d2; text-decoration: none; padding: 10px 12px;
  border-radius: 9px; font-weight: 600;
}
.sidebar nav a:hover, .sidebar nav a.active { background: #1d2740; color: #fff; }
.sidebar .logout { margin-top: auto; color: #f2a3a6; text-decoration: none; font-weight: 600; }
.content { flex: 1; padding: 30px 34px; max-width: 1200px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; display: flex; flex-direction: column; gap: 6px;
}
.card span { color: var(--muted); font-size: 12px; font-weight: 600; }
.card strong { font-size: 24px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; margin-bottom: 18px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: 12px; color: #3f4a5e; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 11px;
  border: 1px solid #d5dbe6; border-radius: 9px; font: inherit; background: #fff; color: var(--text);
}
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcdcf7; border-color: var(--primary); }

.btn {
  display: inline-block; border: 0; background: var(--primary); color: #fff;
  padding: 10px 16px; border-radius: 9px; font-weight: 700; cursor: pointer;
  text-decoration: none; font-size: 13px; width: auto;
}
.btn:hover { background: var(--primary-dark); }
.btn.ghost { background: #eef3f9; color: #24507a; }
.btn.ghost:hover { background: #dfeaf6; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #c93a3f; }
.btn.small { padding: 6px 10px; font-size: 12px; }

.search { display: flex; gap: 10px; margin-bottom: 16px; }
.search input { max-width: 380px; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.alert.error { background: #fff0f1; color: #a52d3e; }
.alert.success { background: #ecfff5; color: #16714a; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.badge.active { background: #e4f7ec; color: #1a7f4b; }
.badge.suspended { background: #fff6e0; color: #96690a; }
.badge.revoked { background: #fde8e9; color: #b42318; }

.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f8fafc; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: #fafcff; }
td.empty, .empty { text-align: center; color: var(--muted); padding: 24px; }

.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { width: min(100%, 400px); background: #fff; padding: 32px; border-radius: 18px; box-shadow: 0 18px 50px rgba(27, 36, 55, .12); }
.auth-card h1 { text-align: center; }
.auth-card .muted { text-align: center; margin-bottom: 18px; }
.auth-card label { margin: 14px 0; }
.auth-card .btn { width: 100%; margin-top: 8px; padding: 12px; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
  .sidebar nav { grid-auto-flow: column; }
  .content { padding: 20px; }
}

.theme-toggle {
  margin-top: 10px;
  background: #1d2740;
  color: #cfe0f5;
  border: 0;
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
  width: 100%;
}
[data-theme="dark"] { color-scheme: dark; --bg: #0d1220; --panel: #151c2c; --text: #e6ebf5; --muted: #94a1b8; --line: #273149; }
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] code { background: #1f2940; color: #cfe0f5; }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: #0f1626; color: var(--text); border-color: #2c3852; }
[data-theme="dark"] th { background: #121a29; }
[data-theme="dark"] tbody tr:hover { background: #182134; }
[data-theme="dark"] .btn.ghost { background: #1e2a42; color: #bcd4ef; }
[data-theme="dark"] .btn.ghost:hover { background: #263553; }
[data-theme="dark"] .badge.active { background: #123a2a; color: #6ee7a8; }
[data-theme="dark"] .badge.suspended { background: #3a2f12; color: #f2c94c; }
[data-theme="dark"] .badge.revoked { background: #3a1a1c; color: #f2a3a6; }
[data-theme="dark"] .alert.error { background: #3a1a1c; color: #f2a3a6; }
[data-theme="dark"] .alert.success { background: #123a2a; color: #6ee7a8; }
[data-theme="dark"] .auth-card { background: var(--panel); box-shadow: 0 18px 50px rgba(0, 0, 0, .5); }
[data-theme="dark"] .card { background: var(--panel); }
[data-theme="dark"] .sidebar { background: #080c16; }
[data-theme="dark"] .sidebar nav a:hover, [data-theme="dark"] .sidebar nav a.active { background: #1a2338; }

.rep-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.rep-row input { margin-top: 0 !important; }
.rep-row .btn { flex: 0 0 auto; }

.logo-for-light { display: block; }
.logo-for-dark { display: none; }
[data-theme="dark"] .logo-for-light { display: none; }
[data-theme="dark"] .logo-for-dark { display: block; }
.brand-logo { display: block; max-width: 160px; max-height: 52px; object-fit: contain; margin: 0 auto 22px; }
.sidebar .brand-logo { margin-bottom: 22px; }
