:root {
  --bg: #08090c;
  --sidebar: #0b0d11;
  --top: #0e1015;
  --panel: #12151b;
  --panel-2: #181c24;
  --line: #242833;
  --line-2: #2e3340;
  --text: #eceff3;
  --muted: #8b93a1;
  --gold: #c9a15b;
  --gold-dim: rgba(201, 161, 91, 0.12);
  --gold-text: #e6d2a2;
  --ok: #3ba55d;
  --danger: #da373c;
  --blurple: #5865f2;
  --s: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body.desk #login { display: none !important; }
body.gate #app { display: none !important; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 12.5px/1.4 "Segoe UI", Inter, system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
code { color: var(--gold-text); font-size: 0.92em; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.02em; color: #f4f6f8; }
h1 { font-size: 18px; }
h2, h3 { font-size: 12px; color: var(--gold-text); letter-spacing: 0.04em; text-transform: uppercase; }

/* Controls — never full-width gold slabs */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  width: auto;
  max-width: max-content;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { border-color: #444b5a; background: #1e232d; }
button.primary {
  background: #16130e;
  border-color: #6d5728;
  color: var(--gold-text);
}
button.primary:hover { border-color: var(--gold); background: #1c1810; }
button.danger { background: #2a1214; border-color: #7a3034; color: #f0c4c6; }
button.ghost { background: transparent; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

input, select, textarea {
  background: #0c0e13;
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 0 10px;
  width: 100%;
  height: 32px;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 1px solid #6d5728;
  outline-offset: 1px;
}
textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; }
input[type="color"] { padding: 2px; width: 42px; height: 32px; }

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  flex: 0 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: #0c0e13;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
input[type="checkbox"]::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--gold);
  transform: scale(0);
}
input[type="checkbox"]:checked { border-color: var(--gold); }
input[type="checkbox"]:checked::after { transform: scale(1); }
input[type="number"] { font-variant-numeric: tabular-nums; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
label.check, label.row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: max-content;
  color: var(--text);
  font-size: 12.5px;
}

/* Gate */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, #16120c, var(--bg) 55%);
}
.login-card {
  width: min(400px, 100%);
  padding: 24px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.login-card h1 { margin-bottom: 8px; }
.login-card p { text-align: left; color: var(--muted); overflow-wrap: anywhere; }
.logo { width: 72px; display: block; margin: 0 auto 12px; }
.logo.small { width: 28px; margin: 0; }
a.discord-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin: 16px auto 0;
  height: 32px;
  padding: 0 14px;
  width: auto;
  max-width: max-content;
  background: #16130e;
  border: 1px solid #6d5728;
  color: var(--gold-text);
  border-radius: 6px;
  white-space: nowrap;
}
a.discord-login:hover { border-color: var(--gold); background: #1c1810; }

/* App shell */
#app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
aside {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.brand strong { display: block; color: var(--gold-text); font-size: 13px; }
.brand span { color: var(--muted); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
nav { display: flex; flex-direction: column; padding: 8px; flex: 1; }
.nav-label {
  margin: 10px 8px 4px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6d7482;
}
nav button {
  width: 100%;
  max-width: none;
  justify-content: flex-start;
  height: 30px;
  padding: 0 8px;
  background: transparent;
  border-color: transparent;
  color: #c2c8d2;
  border-radius: 6px;
}
nav button:hover { background: var(--panel-2); }
nav button.active {
  background: var(--gold-dim);
  color: var(--gold-text);
  box-shadow: inset 2px 0 0 var(--gold);
}
.aside-foot {
  padding: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.shell-body { display: flex; flex-direction: column; min-width: 0; }
.shell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 48px;
  padding: 0 16px;
  background: var(--top);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.shell-top .crumb { color: var(--muted); font-size: 12px; }
.shell-top-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-search { width: 200px; max-width: 28vw; height: 30px; }
#staff-chip { font-size: 12px; line-height: 1.25; text-align: right; min-width: 0; }
#staff-chip strong { display: block; }
#staff-chip span { color: var(--muted); font-size: 11px; display: block; }

main { padding: 16px; max-width: 1120px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.lede { margin: 4px 0 0; color: var(--muted); max-width: 68ch; }

.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.panel-head, .card > h3:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.stack { display: grid; gap: 8px; }
.grid { display: grid; gap: 8px; }
.grid.two { grid-template-columns: 1fr 1fr; align-items: start; }
.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 8px; align-items: start; }

.metric-strip {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}
.metric {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-right: 1px solid var(--line);
}
.metric:last-child { border-right: 0; }
.metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.metric strong { display: block; font-size: 18px; line-height: 1.2; margin-top: 2px; color: #fff; }
.metric small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

.field-inline {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.field-inline label { flex: 1; min-width: 0; }
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.toolbar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.toolbar label { width: auto; min-width: 140px; }
.toolbar .grow { flex: 1; min-width: 180px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list.rows {
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.list.rows > .card, .list.rows > .live-post, .list.rows > .log-row {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 12px;
  background: transparent;
}
.list.rows > :last-child { border-bottom: 0; }
.live-post { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.live-post p { margin: 2px 0 0; }

.queue { list-style: none; margin: 0; padding: 0; }
.queue li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.queue li:last-child { border-bottom: 0; }
.queue span { color: var(--muted); }
.queue strong { font-variant-numeric: tabular-nums; }

.muted { color: var(--muted); }
.error { color: #f0b4aa; }
.ok { color: #b8e0c0; }
.flash { margin: 0; }
.banner {
  padding: 8px 10px;
  border: 1px solid #3a3324;
  border-radius: 6px;
  background: #16130e;
  color: #e6d7b8;
}
.pill, .chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.pill.on, .chip.gold { color: var(--gold-text); border-color: #4a3d22; }
.chip.warn { color: #e6c98a; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.table-wrap { overflow: auto; }

.chart {
  height: 148px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 37px,
    #0c0e13;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 8px 0;
}
.bars { display: flex; align-items: flex-end; gap: 6px; height: 100%; }
.bar { flex: 1; background: #1b1710; border-radius: 3px 3px 0 0; position: relative; min-height: 3px; }
.bar i { display: block; position: absolute; left: 0; right: 0; bottom: 0; background: var(--gold); border-radius: 3px 3px 0 0; }
.chart-empty {
  height: 148px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 37px,
    #0c0e13;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}
.footnote { margin: 8px 0 0; color: var(--muted); font-size: 11px; }

.rank { display: grid; gap: 4px; }
.rank-title { display: flex; justify-content: space-between; gap: 8px; }
.pipeline { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.step { padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.step.on { border-color: var(--gold); color: var(--gold-text); }
.log-row { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.log-row pre { white-space: pre-wrap; margin: 4px 0 0; font: inherit; color: var(--muted); }
.embed-preview { border: 1px solid var(--line); border-left: 4px solid var(--gold); padding: 10px 12px; background: #0c0e13; border-radius: 6px; margin-top: 8px; }

select.desk-native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.desk-dd { position: relative; width: 100%; }
.desk-dd-btn {
  width: 100%;
  max-width: none;
  justify-content: space-between;
  text-align: left;
  background: #0c0e13;
  border: 1px solid var(--line-2);
  color: var(--text);
  font-weight: 400;
}
.desk-dd-btn:after { content: "▾"; color: var(--gold); margin-left: 8px; font-size: 10px; }
.desk-dd.open .desk-dd-menu { display: block; }
.desk-dd-menu {
  display: none;
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow: auto;
  background: #141821;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.desk-dd-label {
  padding: 6px 10px 2px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}
.desk-dd-opt {
  display: block;
  width: 100%;
  max-width: none;
  height: 28px;
  justify-content: flex-start;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 10px;
}
.desk-dd-opt:hover, .desk-dd-opt.active { background: var(--gold-dim); color: var(--gold-text); }

.embed-editor-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 8px; align-items: start; }
.embed-editor-form { display: grid; gap: 8px; }
.editor-item { border: 1px solid var(--line); border-radius: 6px; padding: 8px; display: grid; gap: 8px; }
.discord-preview { background: #313338; color: #dbdee1; border-radius: 6px; padding: 10px; font: 14px/1.45 "gg sans", Whitney, "Helvetica Neue", Arial, sans-serif; }
.dp-content { margin-bottom: 8px; white-space: pre-wrap; }
.dp-embed { display: flex; gap: 12px; background: #2b2d31; border-left: 4px solid var(--gold); border-radius: 4px; padding: 8px 12px 10px; }
.dp-embed-inner { flex: 1; min-width: 0; }
.dp-author { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.dp-author img, .dp-footer img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.dp-title { font-weight: 700; color: #00a8fc; margin-bottom: 4px; }
.dp-title a { color: inherit; }
.dp-desc { color: #dbdee1; }
.dp-fields { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dp-field { flex: 1 1 100%; }
.dp-field.inline { flex: 1 1 30%; }
.dp-image { width: 100%; max-width: 400px; border-radius: 4px; margin-top: 8px; }
.dp-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; }
.dp-footer { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: #b5bac1; }
.dp-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dp-btn { padding: 6px 10px; border-radius: 4px; background: #4e5058; width: auto; max-width: none; height: auto; }
.dp-btn.primary { background: #5865f2; color: #fff; border-color: #5865f2; }
.dp-btn.success { background: #248046; }
.dp-btn.danger { background: #da373c; }
.dp-btn.link { background: #4e5058; }

@media (max-width: 980px) {
  #app { grid-template-columns: 1fr; }
  aside { position: static; height: auto; }
  .grid.two, .split, .embed-editor-grid { grid-template-columns: 1fr; }
  .metric-strip { flex-wrap: wrap; }
  .metric { flex: 1 1 25%; border-bottom: 1px solid var(--line); }
}
.modal-root { position: fixed; inset: 0; z-index: 80; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 8, 0.72);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: 86vh;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.wide { width: min(960px, calc(100vw - 32px)); }
.modal-head, .modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.modal-foot {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: var(--panel);
  z-index: 2;
}
.modal-head h2 { font-size: 13px; }
.modal-body { padding: 12px; overflow: auto; display: grid; gap: 8px; flex: 1; }
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(320px, calc(100vw - 24px));
}
.toast {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.toast.ok { border-color: #2d5a3a; }
.toast.err { border-color: #7a3034; color: #f0c4c6; }
.empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.empty p { margin: 0 0 8px; }
.search { max-width: 260px; }
.khint { color: #6d7482; font-size: 11px; }

.wizard-progress { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.wiz-step {
  font-size: 11px;
  color: var(--muted);
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.wiz-step.on { color: var(--gold-text); border-color: #6d5728; }
.wiz-step.done { color: var(--ok); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-grid + .choice-grid { margin-top: 8px; }
.choice-card {
  height: auto;
  max-width: none;
  width: 100%;
  padding: 12px;
  text-align: left;
  white-space: normal;
  display: grid;
  gap: 4px;
  justify-items: start;
}
.choice-card span { color: var(--muted); font-size: 11px; }
.choice-card.on { border-color: var(--gold); background: #1c1810; }
.chip.person {
  cursor: pointer;
  height: 22px;
  max-width: none;
  padding: 0 8px;
  background: var(--panel-2);
}
.chip.person:hover { border-color: var(--gold); }
.ctx-menu {
  position: fixed;
  z-index: 100;
  min-width: 180px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.ctx-menu p { margin: 4px 8px; }
.ctx-menu button {
  display: flex;
  width: 100%;
  max-width: none;
  justify-content: flex-start;
  height: 30px;
  background: transparent;
  border: 0;
}
.ctx-menu button:hover { background: #1e232d; }
.reveal {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.unsaved-confirm {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(4, 5, 8, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
}
body > .unsaved-confirm { position: fixed; z-index: 110; }
.unsaved-dialog {
  width: min(420px, calc(100vw - 48px));
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.unsaved-dialog h3 { margin: 0 0 6px; }
.unsaved-dialog p { margin: 0 0 10px; color: var(--muted); }

@media (max-width: 640px) {
  .metric { flex: 1 1 50%; }
  main { padding: 12px; }
  .shell-top { height: auto; padding: 8px 12px; }
  .header-search { width: 140px; max-width: 36vw; }
  .choice-grid { grid-template-columns: 1fr; }
}
