:root {
  --bg: #0b0d12; --bg2: #10131a; --panel: #151925; --panel2: #1b2130;
  --line: #262d3d; --text: #e8eaf0; --muted: #8b93a7;
  --accent: #4f8cff; --accent2: #8b5cf6; --danger: #ef5350; --ok: #37c871; --warn: #f5a623;
  --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 800px at 80% -10%, #1a2340 0%, var(--bg) 55%); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
h1 { font-size: 22px; margin: 0; } h2 { margin: 0; } h3 { margin: 0 0 4px; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 9px 15px;
  background: linear-gradient(180deg, var(--accent), #3b78f0); color: #fff; font-weight: 600;
  transition: transform .05s ease, filter .15s ease; }
button:hover { filter: brightness(1.08); } button:active { transform: translateY(1px); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
button.small { padding: 5px 10px; font-size: 13px; }
button.danger { background: linear-gradient(180deg, #f0655f, var(--danger)); }
button.link { background: none; color: var(--muted); padding: 5px 8px; font-weight: 600; }
button.link.danger { color: var(--danger); }
input, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #0d1017; color: var(--text); font: inherit; }
input:focus, select:focus { outline: 2px solid rgba(79,140,255,.5); border-color: transparent; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-row .logo-mark { height: 30px; width: auto; }
.brand-row .brand-name { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand-row .brand-name b { color: var(--accent); font-weight: 800; }
.brand-row.big .logo-mark { height: 46px; } .brand-row.big .brand-name { font-size: 22px; }

/* Auth */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-card { width: min(370px, 92vw); padding: 30px; display: flex; flex-direction: column; gap: 13px; }
.auth-card .logo { height: 34px; align-self: flex-start; }

/* Layout */
.layout { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; gap: 8px; padding: 18px 14px;
  background: linear-gradient(180deg, var(--bg2), var(--bg)); border-right: 1px solid var(--line); }
.sidebar .brand { height: 30px; align-self: flex-start; margin: 6px 8px 14px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; justify-content: flex-start;
  background: transparent; color: var(--muted); font-weight: 600; padding: 10px 12px; }
.nav-item:hover { background: var(--panel); color: var(--text); filter: none; }
.nav-item.active { background: var(--panel2); color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent); }
.nav-item .ico { font-size: 15px; }
.sidebar-foot { margin-top: auto; position: relative; }
.user-chip { width: 100%; display: flex; align-items: center; gap: 10px; background: transparent;
  border: 1px solid var(--line); color: var(--text); padding: 8px 10px; }
.user-chip:hover { background: var(--panel); filter: none; }
.user-chip .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; flex: 1; text-align: left; }
.user-chip .who small { font-size: 11px; }
.user-chip .caret { color: var(--muted); }
.user-menu { position: absolute; bottom: 56px; left: 0; right: 0; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: var(--shadow); }
.menu-item { width: 100%; text-align: left; background: transparent; color: var(--text); font-weight: 500; }
.menu-item:hover { background: var(--panel); filter: none; }

/* Main */
.main { padding: 26px 30px; overflow: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head p { margin: 2px 0 0; }
.table-card { padding: 6px 6px 4px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
thead th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.actions { text-align: right; white-space: nowrap; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* Avatar + owner cell */
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  color: #fff; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.owner { display: flex; align-items: center; gap: 9px; }
.owner .sub { color: var(--muted); font-size: 12px; }
.unassigned { color: var(--warn); }

/* Pills */
.pill { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: rgba(55,200,113,.15); color: var(--ok); }
.pill.off { background: rgba(239,83,80,.15); color: var(--danger); }
.pill.role { background: rgba(139,92,246,.16); color: #b79bff; }
.pill.role.user { background: rgba(79,140,255,.14); color: #8fb6ff; }

/* Modal */
.modal-root { position: fixed; inset: 0; background: rgba(4,6,12,.66); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { width: min(440px, 94vw); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.keybox { display: block; padding: 12px; background: #0d1017; border: 1px solid var(--line);
  border-radius: 10px; word-break: break-all; }
.field-list { display: flex; flex-direction: column; gap: 12px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }

/* Toasts */
.toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast { padding: 12px 15px; border-radius: 10px; box-shadow: var(--shadow); border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); max-width: 340px; animation: slidein .18s ease; }
.toast.ok { border-left: 3px solid var(--ok); } .toast.err { border-left: 3px solid var(--danger); }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; overflow: auto; }
  .sidebar-foot { margin: 0; } .nav { flex-direction: row; }
}
