:root {
  --bg: #0a0e14;
  --bg-alt: #0e131c;
  --surface: #121822;
  --surface-2: #182131;
  --border: #232f42;
  --border-soft: #1b2534;
  --text: #e8eef7;
  --muted: #8695ab;
  --muted-2: #5f6d82;
  --accent: #4f8cff;
  --accent-dim: #1e3a6b;
  --ok: #2ecc8f;
  --warn: #f0b429;
  --err: #ff5f5f;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
input, select, textarea, button { font: inherit; color: inherit; }

/* ---------------- login ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1000px 600px at 50% -10%, #16233a 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 24px; letter-spacing: -.5px; margin-bottom: 4px; }
.login-card p.sub { color: var(--muted); margin-bottom: 24px; font-size: 13px; }

/* ---------------- shell ---------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 20px 20px 16px; font-size: 18px; font-weight: 650; letter-spacing: -.4px;
  display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border-soft);
}
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 12px var(--accent); }
.nav { padding: 12px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px;
  background: none; border: 0; border-radius: var(--radius-sm); color: var(--muted);
  cursor: pointer; text-align: left; font-size: 14px; transition: .12s;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.active { background: var(--accent-dim); color: #fff; font-weight: 550; }
.nav button .ico { width: 18px; text-align: center; opacity: .9; }
.nav .badge { margin-left: auto; background: var(--err); color: #fff; font-size: 11px;
  padding: 1px 7px; border-radius: 20px; font-weight: 600; }
.userbox { padding: 14px 16px; border-top: 1px solid var(--border-soft); font-size: 13px; }
.userbox .name { font-weight: 600; }
.userbox .role { color: var(--muted); font-size: 12px; }
.userbox button { margin-top: 10px; width: 100%; }

.main { flex: 1; min-width: 0; padding: 28px 32px 60px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; letter-spacing: -.4px; }
.page-head .desc { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-head .spacer { flex: 1; }

/* ---------------- primitives ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px;
}
.card > h3 { font-size: 15px; margin-bottom: 4px; letter-spacing: -.2px; }
.card > .hint { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }

.grid { display: grid; gap: 14px; }
.grid.g2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.g3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.g4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

label.f { display: block; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px;
  font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px; outline: none; transition: .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,140,255,.13); }
textarea { resize: vertical; min-height: 90px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
select option { background: var(--surface); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; font-weight: 550; font-size: 13.5px; transition: .12s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #6b9dff; }
.btn.danger { background: transparent; border-color: #4a2530; color: var(--err); }
.btn.danger:hover { background: #2a151b; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted-2); font-weight: 600; padding: 0 12px 10px; }
td { padding: 12px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.017); }
td.right, th.right { text-align: right; }
.tbl-wrap { overflow-x: auto; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; border: 1px solid transparent; }
.pill.ok   { background: rgba(46,204,143,.13); color: var(--ok); border-color: rgba(46,204,143,.25); }
.pill.err  { background: rgba(255,95,95,.13); color: var(--err); border-color: rgba(255,95,95,.25); }
.pill.warn { background: rgba(240,180,41,.13); color: var(--warn); border-color: rgba(240,180,41,.25); }
.pill.mute { background: rgba(134,149,171,.1); color: var(--muted); border-color: rgba(134,149,171,.2); }
.pill.info { background: rgba(79,140,255,.13); color: var(--accent); border-color: rgba(79,140,255,.28); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor;
  animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

.stat { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 14px 16px; }
.stat .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 22px; font-weight: 650; margin-top: 4px; letter-spacing: -.5px; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 500; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 30px; margin-bottom: 10px; opacity: .5; }

.console {
  background: #05080d; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; height: 420px; overflow-y: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.65;
}
.console .l { display: flex; gap: 10px; }
.console .t { color: var(--muted-2); flex: 0 0 auto; }
.console .m { white-space: pre-wrap; word-break: break-word; }
.console .warn .m { color: var(--warn); }
.console .error .m { color: var(--err); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px;
  overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px;
  color: var(--muted); cursor: pointer; font-size: 13.5px; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 550; }

.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column;
  gap: 10px; z-index: 90; }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow); max-width: 380px;
  animation: slide .2s ease; font-size: 13.5px; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
@keyframes slide { from { opacity: 0; transform: translateX(16px) } }

.modal-bg { position: fixed; inset: 0; background: rgba(4,7,12,.72); display: flex;
  align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 480px; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 17px; margin-bottom: 18px; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.err-text { color: var(--err); }
.ok-text { color: var(--ok); }
.hidden { display: none !important; }
.sep { height: 1px; background: var(--border-soft); margin: 18px 0; }
.chip { display: inline-block; background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 6px; padding: 2px 8px; font-size: 12px; margin: 2px 3px 2px 0; }

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav button { width: auto; }
  .nav .badge { margin-left: 6px; }
  .main { padding: 20px 16px 60px; }
}
