:root {
  --c-bg: #f4f6fb;
  --c-card: #fff;
  --c-ink: #0a1222;
  --c-muted: #5b6880;
  --c-line: #e3e8f2;
  --c-brand: #2b5ce6;
  --c-brand-soft: #e8eeff;
  --c-accent: #10b981;
  --c-danger: #d64545;
  --c-warn: #b7791f;
  --c-radius: 12px;
  --c-font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --c-display: 'Space Grotesk', 'Inter', sans-serif;
  --c-side: 244px;
  --shadow: 0 16px 40px -28px rgba(10, 18, 34, .45);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--c-font); background: var(--c-bg); color: var(--c-ink);
  -webkit-font-smoothing: antialiased; line-height: 1.55;
}
button, input, select, textarea { font: inherit; }
a { color: var(--c-brand); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--c-brand) 50%, white); outline-offset: 2px; }

/* login */
.login-shell { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%); background: #fff; border: 1px solid var(--c-line);
  border-radius: 18px; padding: 30px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand svg { width: 36px; height: 36px; }
.login-brand b { display: block; font-family: var(--c-display); font-size: 19px; letter-spacing: -.02em; }
.login-brand small { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--c-muted); }
.login-card h1 { font-family: var(--c-display); font-size: 24px; letter-spacing: -.03em; margin: 0 0 6px; }
.login-card p.sub { color: var(--c-muted); font-size: 13.5px; margin: 0 0 20px; }
.login-card .field { margin-bottom: 12px; }
.login-card .muted-link { font-size: 12.5px; color: var(--c-muted); text-decoration: none; display: inline-block; margin-top: 14px; }
.login-card .muted-link:hover { color: var(--c-ink); }

/* app shell */
.shell { display: grid; grid-template-columns: var(--c-side) 1fr; min-height: 100vh; }
.side {
  background: #0b1425; color: #cfd8e8; padding: 18px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; color: #fff; text-decoration: none; }
.side .brand svg { width: 30px; height: 30px; }
.side .brand b { font-family: var(--c-display); font-size: 16px; display: block; line-height: 1.2; }
.side .brand small { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: #8291ab; }
.side .group { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #64748b; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; color: #b9c4d8; border-radius: 9px;
  padding: 9px 10px; font-size: 13.5px; cursor: pointer;
}
.nav-item:hover { background: #16233b; color: #fff; }
.nav-item[aria-current="page"] { background: var(--c-brand); color: #fff; font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex: none; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid #1e2a44; font-size: 11.5px; color: #7f8da6; }
.side-foot a { color: #a9b6cc; text-decoration: none; display: block; margin-top: 6px; }
.side-foot a:hover { color: #fff; }

.main { min-width: 0; padding: 22px 26px 48px; }
.topline { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.topline h1 { font-family: var(--c-display); font-size: 24px; letter-spacing: -.03em; margin: 0; }
.topline p { margin: 2px 0 0; font-size: 13px; color: var(--c-muted); }
.topline .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 9px; background: #fff; border: 1px solid var(--c-line); border-radius: 999px; padding: 5px 12px 5px 6px; font-size: 12.5px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--c-brand); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; }

.card { background: var(--c-card); border: 1px solid var(--c-line); border-radius: var(--c-radius); box-shadow: 0 1px 2px rgba(10,18,34,.04); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--c-line); }
.card-head h2 { font-size: 15px; margin: 0; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.cards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--c-line); border-radius: var(--c-radius); padding: 16px; }
.stat small { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--c-muted); font-weight: 700; }
.stat b { display: block; font-family: var(--c-display); font-size: 28px; letter-spacing: -.03em; margin-top: 4px; }
.stat span { font-size: 12px; color: var(--c-muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--c-muted); padding: 10px 14px; border-bottom: 1px solid var(--c-line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid #eef2f9; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfe; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 26px; text-align: center; color: var(--c-muted); font-size: 13px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #eef2fa; color: #40506b; white-space: nowrap; }
.tag.green { background: #e3f8f0; color: #0b7a56; }
.tag.blue { background: #e8eeff; color: #1e45ba; }
.tag.red { background: #fdecec; color: #9b2c2c; }
.tag.amber { background: #fdf3dd; color: #8a5c0b; }
.tag.gray { background: #eef0f4; color: #5b6880; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent;
  background: var(--c-brand); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background .15s, box-shadow .15s;
}
.btn:hover { background: #1e45ba; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--c-ink); border-color: var(--c-line); }
.btn.ghost:hover { background: #f7f9fd; }
.btn.small { min-height: 31px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.danger { background: #fdecec; color: #9b2c2c; border-color: #f6d5d5; }
.btn.danger:hover { background: #fbdada; }

.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: #333f57; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--c-line); border-radius: 8px; padding: 9px 11px;
  font-size: 13.5px; background: #fbfcff; color: var(--c-ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px rgba(43,92,230,.13); }
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { font-size: 11.5px; color: var(--c-muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { background: #fdecec; color: #8f2222; border-radius: 8px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 12px; display: none; }
.form-error.show { display: block; }

dialog {
  border: 1px solid var(--c-line); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 28px));
  box-shadow: 0 40px 90px -40px rgba(10,18,34,.6); color: var(--c-ink);
}
dialog::backdrop { background: rgba(10, 18, 34, .45); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--c-line); }
.dialog-head h2 { font-size: 16px; margin: 0; }
.dialog-head .spacer { flex: 1; }
.icon-btn { border: 0; background: #f1f4fa; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: #40506b; font-size: 16px; line-height: 1; }
.dialog-body { padding: 18px; max-height: 66vh; overflow: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--c-line); background: #fbfcff; }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 80; max-width: 380px;
  background: #0b1425; color: #fff; padding: 12px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 20px 40px -20px rgba(0,0,0,.6); opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #7f1d1d; }

.theme-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.theme-option { border: 2px solid var(--c-line); border-radius: 12px; padding: 10px; cursor: pointer; background: #fff; text-align: left; }
.theme-option[aria-pressed="true"] { border-color: var(--c-brand); box-shadow: 0 0 0 3px rgba(43,92,230,.12); }
.theme-swatch { height: 40px; border-radius: 8px; margin-bottom: 8px; display: flex; overflow: hidden; }
.theme-swatch i { flex: 1; }
.theme-option b { font-size: 12px; display: block; }
.theme-option small { font-size: 10.5px; color: var(--c-muted); }

.hero-strip { background: #0b1425; color: #fff; border-radius: var(--c-radius); padding: 22px; display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin-bottom: 18px; }
.hero-strip h2 { font-family: var(--c-display); font-size: 22px; margin: 0; letter-spacing: -.02em; }
.hero-strip p { margin: 4px 0 0; color: #aebbd2; font-size: 13px; }
.hero-strip .spacer { flex: 1; }

.skeleton { background: linear-gradient(90deg, #eef2f9 25%, #f7f9fd 50%, #eef2f9 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; height: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (max-width: 1080px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } .theme-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; gap: 4px; }
  .side .brand { padding: 4px 10px 4px 4px; }
  .side .brand small { display: none; }
  .side .group, .side-foot { display: none; }
  .nav-item { width: auto; white-space: nowrap; padding: 8px 11px; }
  .main { padding: 16px 14px 40px; }
  .row2 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .cards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat b { font-size: 22px; }
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
  .topline h1 { font-size: 20px; }
  .user-chip span.name { display: none; }
}
