/* Nalomi Panel - dark, calm, readable. All colours live in the tokens below. */
:root {
  --bg: #0b0d17;
  --bg-2: #10131f;
  --card: #151929;
  --card-2: #1b2033;
  --line: #262c44;
  --text: #e7e9f5;
  --muted: #8d93b0;
  --faint: #5d6380;
  --accent: #8e7cff;
  --accent-2: #b3a8ff;
  --accent-bg: rgba(142, 124, 255, 0.14);
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, 0.12);
  --info: #60a5fa;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 85% -10%, rgba(142, 124, 255, 0.10), transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: rgba(16, 19, 31, 0.85); backdrop-filter: blur(8px);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; font-weight: 700; font-size: 18px; }
.brand .moon {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #5b4bd6); box-shadow: 0 6px 20px rgba(142, 124, 255, 0.35);
}
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-bg); color: var(--text); }
.nav a.active svg { color: var(--accent-2); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .spacer { flex: 1; }
.me {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--line);
}
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--card-2); flex: none; object-fit: cover; }
.me .who { flex: 1; min-width: 0; }
.me .who b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who span { font-size: 12px; color: var(--muted); text-transform: capitalize; }

.main { padding: 28px 34px 60px; max-width: 1400px; width: 100%; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
.topbar .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.menu-btn { display: none; }

/* ------------------------------------------------------------- building blocks */
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.section-head h2 { font-size: 15px; margin: 0; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.card.flat { background: var(--card); }
.card h3 { margin: 0 0 4px; font-size: 16px; }

.stat .label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -0.02em; }
.stat .detail { color: var(--muted); font-size: 13px; }
.spark { width: 100%; height: 46px; margin-top: 10px; display: block; }
.spark path.area { opacity: 0.18; }
.bar { height: 6px; border-radius: 6px; background: var(--card-2); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: var(--accent); transition: width 0.4s ease; }
.bar.ok > i { background: var(--ok); } .bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--card-2); color: var(--muted); white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.plain::before { display: none; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin: 12px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); font-weight: 600; font-size: 14px; transition: 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #7d6af0; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn-row.tight { margin-top: 0; }
select.btn { appearance: auto; }

.service-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.service-head .unit { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.icon-box {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--accent-bg); color: var(--accent-2);
}
.icon-box svg { width: 20px; height: 20px; }
.title-row { display: flex; align-items: center; gap: 12px; min-width: 0; }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.list td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: rgba(255, 255, 255, 0.015); }
.table-wrap { overflow-x: auto; }
.card > table.list td:first-child, .card > table.list th:first-child { padding-left: 0; }
.card > table.list td:last-child, .card > table.list th:last-child { padding-right: 0; }
td.right { text-align: right; }
.small { font-size: 12px; }

.logs {
  background: #070910; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: 12.5px/1.55 var(--mono); color: #c9cde3; padding: 12px 14px; height: 420px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}
.logs .err { color: var(--bad); } .logs .wrn { color: var(--warn); }

.empty { color: var(--muted); text-align: center; padding: 26px 10px; }
.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--accent-bg); border: 1px solid rgba(142, 124, 255, 0.3); font-size: 14px; margin-bottom: 18px;
}
.notice.warn { background: var(--warn-bg); border-color: rgba(251, 191, 36, 0.3); }

/* ------------------------------------------------------------- login */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
}
.login .card { width: 100%; max-width: 400px; text-align: center; padding: 36px 30px; box-shadow: var(--shadow); }
.login .moon { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px; font-size: 28px;
  display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), #5b4bd6); }
.login h1 { margin: 0 0 6px; font-size: 22px; }
.login p { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.btn.discord { width: 100%; padding: 12px; background: #5865f2; border-color: #5865f2; color: #fff; font-size: 15px; }
.btn.discord:hover { background: #4752c4; }
.btn.wide { width: 100%; margin-top: 10px; }
.login .msg { margin-top: 16px; font-size: 14px; }
.login .msg.bad { color: var(--bad); }

/* ------------------------------------------------------------- toast + dialog */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 50; }
.toast {
  background: var(--card-2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); max-width: 380px; font-size: 14px;
  animation: slide 0.2s ease;
}
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

dialog {
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; max-width: 420px; width: calc(100% - 32px); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(5, 6, 12, 0.7); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 8px; }
dialog p { color: var(--muted); margin: 0 0 18px; }
dialog .btn-row { justify-content: flex-end; }
dialog pre { background: #070910; padding: 10px; border-radius: 8px; max-height: 220px; overflow: auto; font: 12px var(--mono); white-space: pre-wrap; }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { color: transparent !important; background: linear-gradient(90deg, var(--card-2), #222842, var(--card-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 18px 16px 50px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 20px; }
}
@media (max-width: 520px) {
  .grid.stats { grid-template-columns: 1fr; }
  .stat .value { font-size: 24px; }
  .logs { height: 320px; }
}
