/* Prism dashboard: deep black, lilac accents, quiet and minimal. */
@font-face { font-family: 'Lato'; src: url('fonts/Lato-Regular.ttf') format('truetype'); font-weight: 400; }
@font-face { font-family: 'Lato'; src: url('fonts/Lato-Bold.ttf') format('truetype'); font-weight: 700; }

:root {
  --bg: #050506;
  --side: #09090b;
  --surface: #0f0f12;
  --surface-2: #15151a;
  --line: #1f1e25;
  --line-2: #2a2833;
  --text: #ece8f1;
  --muted: #8d8798;
  --faint: #5d5866;
  --lilac: #c8a2c8;
  --lilac-strong: #d9b6e3;
  --lilac-soft: rgba(200, 162, 200, 0.14);
  --lilac-line: rgba(200, 162, 200, 0.35);
  --danger: #ef6b7b;
  --danger-soft: rgba(239, 107, 123, 0.12);
  --ok: #8fd3a8;
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 'Lato', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--lilac); }
::selection { background: var(--lilac-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid var(--bg); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side {
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 22px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }
.brand img { width: 30px; height: 30px; border-radius: 50%; }
.nav-label { color: var(--faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.2px; padding: 16px 10px 6px; }
.nav button {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 9px 10px; border-radius: var(--radius-sm); font: inherit; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav button:hover { background: var(--surface); color: var(--text); }
.nav button.active { background: var(--lilac-soft); color: var(--lilac-strong); }
.nav button .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; flex: none; }
.server-pick { margin: 4px 0 2px; }
.side-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.side-foot img { width: 30px; height: 30px; border-radius: 50%; }
.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { color: var(--faint); font-size: 12px; }

main { padding: 34px 40px 60px; max-width: 1060px; width: 100%; }
.topbar { display: none; }
h1 { font-size: 26px; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.2px; }
.lead { color: var(--muted); margin: 0 0 26px; }
h2 { font-size: 15px; margin: 0; font-weight: 700; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; }

.rows { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.row .actions { display: flex; gap: 6px; flex: none; }
.empty { color: var(--faint); padding: 18px 14px; text-align: center; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.on { color: var(--ok); border-color: rgba(143, 211, 168, 0.3); background: rgba(143, 211, 168, 0.08); }
.pill.off { color: var(--danger); border-color: rgba(239, 107, 123, 0.3); background: var(--danger-soft); }
.swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25); flex: none; display: inline-block; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); font: inherit; font-size: 14px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--lilac-line); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--lilac); border-color: var(--lilac); color: #140f17; font-weight: 700; }
.btn.primary:hover { background: var(--lilac-strong); border-color: var(--lilac-strong); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: rgba(239, 107, 123, 0.5); background: var(--danger-soft); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
label.field > small { display: block; color: var(--faint); font-size: 12.5px; margin-top: 5px; }
input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 9px 12px; font: inherit; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--lilac); box-shadow: 0 0 0 3px var(--lilac-soft); }
textarea { resize: vertical; min-height: 120px; }
textarea.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.6; min-height: 420px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input[type=color] { width: 44px; height: 36px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--bg); padding: 3px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; cursor: pointer; }
.switch .txt { min-width: 0; }
.switch .txt small { display: block; color: var(--faint); font-size: 12.5px; }
.switch input { appearance: none; width: 40px; height: 23px; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; flex: none; transition: background 0.15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #d8d3dd; transition: transform 0.15s; }
.switch input:checked { background: var(--lilac); }
.switch input:checked::after { transform: translateX(17px); background: #140f17; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.right { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
pre.log { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; height: 380px; overflow: auto;
  font: 12.5px/1.55 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; color: #c9c3d1; white-space: pre-wrap; margin: 0; }
.checklist { max-height: 330px; overflow-y: auto; }
.checklist .row { cursor: pointer; padding: 9px 12px; }
.checklist input[type=checkbox] { accent-color: var(--lilac); width: 16px; height: 16px; }

/* ---------- dialogs and toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; z-index: 50; overflow-y: auto; backdrop-filter: blur(3px); }
.dialog { background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; width: min(560px, 100%); padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.dialog h3 { margin: 0 0 6px; font-size: 18px; }
.dialog p { color: var(--muted); margin: 0 0 16px; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--surface-2); border: 1px solid var(--lilac-line); color: var(--text); padding: 11px 16px; border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); max-width: 380px; animation: up 0.18s ease-out; }
.toast.err { border-color: rgba(239, 107, 123, 0.5); }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login .box { width: min(420px, 100%); text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 50%; margin-bottom: 18px; box-shadow: 0 0 60px rgba(200, 162, 200, 0.25); }
.login h1 { margin-bottom: 8px; }
.login code { background: var(--surface-2); border: 1px solid var(--line-2); color: var(--lilac-strong); padding: 2px 8px; border-radius: 6px; }
.login .note { margin-top: 18px; color: var(--danger); }

.spin { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--lilac); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 30px 0; }
.loading.boot { justify-content: center; height: 100vh; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-102%); transition: transform 0.2s; height: 100%; max-width: 300px; }
  .side.open { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, 0.6); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--side); position: sticky; top: 0; z-index: 30; }
  .topbar b { flex: 1; }
  main { padding: 22px 18px calc(50px + env(safe-area-inset-bottom)); }
  .topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
  .side { padding-top: calc(22px + env(safe-area-inset-top)); }
  input, select, textarea { font-size: 16px; } /* stops iPhone zooming into fields */
  .two, .three { grid-template-columns: 1fr; }
}

/* tickets */
.checks { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 4px 0; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.row.block { display: block; }
.qrow { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: end; margin-top: 8px; }
@media (max-width: 640px) { .qrow { grid-template-columns: 1fr; } }

/* settings pages */
.picklist select { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface-2, #1a1620); border: 1px solid var(--line); color: inherit; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent, #c8a2c8); }
.switches { display: grid; gap: 4px; }
.row.rule { display: grid; grid-template-columns: 1fr 1fr 1fr auto; align-items: end; gap: 10px; }
.response { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.savebar { margin: 4px 0 24px; }
@media (max-width: 640px) { .row.rule { grid-template-columns: 1fr; } .response { grid-template-columns: 1fr; } }
.switches.cmds { margin: 8px 0 0 18px; padding-left: 12px; border-left: 2px solid var(--line); }

.login-discord { margin: 8px 0 4px; }
.discord-login { display: inline-block; text-decoration: none; padding: 10px 18px; }
.login-discord .small { font-size: 0.85em; margin-top: 8px; }
