:root {
  --bg: #0b0d1a;
  --bg2: #11142a;
  --glass: rgba(30, 34, 60, 0.55);
  --glass-brd: rgba(255,255,255,0.10);
  --ink: #e8eaf6;
  --muted: #9aa0c4;
  --accent: #7c8cff;
  --accent2: #4f46e5;
  --ok: #37d399;
  --warn: #ffb020;
  --bad: #ff5d6c;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0,0,0,0.45);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(79,70,229,0.25), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(124,140,255,0.18), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.err { color: var(--bad); font-size: 13px; }

/* buttons */
.btn {
  border: 1px solid var(--glass-brd);
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: .15s;
}
.btn:hover { background: rgba(255,255,255,0.12); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { border-color: rgba(255,93,108,0.5); color: #ffb3ba; }
.btn.danger:hover { background: rgba(255,93,108,0.15); }

/* ---- login ---- */
.login-body { display: grid; place-items: center; }
.login-card { width: min(380px, 92vw); padding: 30px; border-radius: 22px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.brand.small { gap: 10px; margin-bottom: 18px; }
.brand h1 { font-size: 22px; margin: 0; }
.brand p { margin: 2px 0 0; }
#loginForm { display: grid; gap: 14px; }
#loginForm label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
#loginForm input {
  padding: 11px 12px; border-radius: 10px; border: 1px solid var(--glass-brd);
  background: rgba(0,0,0,0.25); color: var(--ink); font-size: 15px;
}
#loginForm input:focus { outline: 2px solid var(--accent); }

/* ---- app shell ---- */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; gap: 14px; padding: 14px; }
.sidebar { border-radius: var(--radius); padding: 16px 12px; display: flex; flex-direction: column; }
.tabs { display: grid; gap: 4px; margin-top: 8px; flex: 1; overflow-y: auto; }
.tab {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; border: none; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 14px; text-align: left;
}
.tab:hover { background: rgba(255,255,255,0.06); color: var(--ink); }
.tab.active { background: linear-gradient(135deg, rgba(124,140,255,0.25), rgba(79,70,229,0.20)); color: #fff; }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.tab .kind { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; opacity: .6; }
.sidebar-foot { margin-top: 10px; }

.content { display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.topbar { border-radius: var(--radius); padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; }
.topbar h2 { margin: 0; font-size: 18px; }
.view { flex: 1; overflow-y: auto; padding-right: 4px; }

/* cards + tables */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { border-radius: 14px; padding: 16px; }
.card h4 { margin: 0 0 8px; font-size: 15px; }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.row:last-child { border-bottom: none; }
.row .k { color: var(--muted); }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok  { background: rgba(55,211,153,0.15); color: var(--ok); }
.pill.bad { background: rgba(255,93,108,0.15); color: var(--bad); }
.pill.warn{ background: rgba(255,176,32,0.15); color: var(--warn); }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,0.07); }
table.data th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: rgba(17,20,42,0.9); }
table.data tr:hover td { background: rgba(255,255,255,0.03); }

.section-note { color: var(--muted); font-size: 13px; margin: -4px 0 14px; }
.empty { color: var(--muted); text-align: center; padding: 40px; }
.spinner { text-align: center; padding: 40px; color: var(--muted); }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar select, .toolbar input {
  padding: 8px 10px; border-radius: 9px; border: 1px solid var(--glass-brd);
  background: rgba(0,0,0,0.25); color: var(--ink); font-size: 13px;
}
pre.term {
  background: #05060f; border: 1px solid var(--glass-brd); border-radius: 10px;
  padding: 14px; overflow: auto; font-size: 12.5px; color: #b8f5d0; max-height: 340px;
}

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  padding: 12px 18px; border-radius: 12px; background: var(--glass);
  border: 1px solid var(--glass-brd); backdrop-filter: blur(14px);
  box-shadow: var(--shadow); font-size: 14px; z-index: 50;
}
.toast.bad { border-color: rgba(255,93,108,0.5); }
.toast.ok  { border-color: rgba(55,211,153,0.5); }

/* modal */
.modal-host { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: grid; place-items: center; z-index: 60; }
.modal { width: min(460px, 92vw); border-radius: 18px; padding: 0; overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--glass-brd); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; display: grid; gap: 12px; }
.modal-body label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.modal-body input, .modal-body select {
  padding: 10px 12px; border-radius: 9px; border: 1px solid var(--glass-brd);
  background: rgba(0,0,0,0.25); color: var(--ink); font-size: 14px;
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; }
  .tabs { grid-auto-flow: column; grid-template-columns: none; }
}
