:root {
  --bar: 52px;
  --bg: #101218;
  --panel: #161a22;
  --line: #2a3140;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #c4a35a;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body { display: flex; flex-direction: column; }

a { color: var(--accent); }

.topbar {
  height: var(--bar);
  flex: 0 0 var(--bar);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-right: 12px;
  white-space: nowrap;
}

.brand strong {
  font-size: 14px;
  letter-spacing: 0.04em;
  font-weight: 650;
}

.brand span { font-size: 11px; color: var(--muted); }

.server-pick,
.server-select {
  flex: 0 0 auto;
  max-width: 260px;
  height: 32px;
  background: #4b5563;
  color: #f5d76e;
  border: 1px solid #6b7280;
  border-radius: 4px;
  padding: 0 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.server-pick option,
.server-select option {
  background: #4b5563;
  color: #f5d76e;
}

.nav {
  display: flex;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 0 12px;
  display: flex;
  align-items: center;
}

.nav a:hover { color: var(--text); background: #1e2430; }

.nav a.on { color: var(--text); }

.spacer { flex: 1; }

.who {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.who b { color: var(--text); font-weight: 600; }

.note { font-size: 12px; color: var(--muted); margin-top: 14px; }

.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  height: 32px;
  padding: 0 10px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.ghost:hover { color: var(--text); }

.nick-save {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: var(--accent);
  color: #1a1408;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.field-row .note { margin-top: 4px; }

#open-panel {
  background: var(--accent);
  color: #1a1408;
  border: 0;
  height: 40px;
  padding: 0 16px;
  font-weight: 650;
}

body.wrap {
  overflow: hidden;
}

#cad-crcon {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  min-height: 0;
  background: #0b0d12;
}

.sheet {
  position: relative;
  flex: 1;
  overflow: auto;
  padding: 28px 32px 48px;
}

.sheet h1 { font-size: 22px; font-weight: 600; margin: 0 0 8px; }

.sheet p.lead {
  color: var(--muted);
  margin: 0 0 24px;
  max-width: 62ch;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px;
}

.card h2 {
  font-size: 13px;
  font-weight: 650;
  margin: 0 0 8px;
  color: var(--accent);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.card dl {
  margin: 0;
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 10px;
  font-size: 13px;
}

.card dt { color: var(--muted); }

.card ul { margin: 0; padding-left: 18px; font-size: 13px; }

.card li { margin: 4px 0; }

.roster {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.roster th,
.roster td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.roster th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tag.ok {
  color: #8fbf8a;
  border-color: #2f4a32;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
  max-width: 68ch;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-row label {
  font-size: 12px;
  color: var(--muted);
}

.form-row input,
.form-row textarea,
.form-row select {
  background: #0f1218;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px;
  font: inherit;
  border-radius: 4px;
}

.form-row textarea { min-height: 90px; resize: vertical; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
#staff-actions { margin: 0 0 14px; }

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px 24px;
}

.login-card h1 { margin: 0 0 6px; font-size: 20px; }

.login-card p { color: var(--muted); font-size: 13px; margin: 0 0 20px; }

.login-card label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.login-card select,
.login-card input {
  width: 100%;
  margin-bottom: 14px;
  background: #0f1218;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px;
  font: inherit;
  border-radius: 4px;
}

.login-card button[type="submit"] {
  width: 100%;
  height: 40px;
  border: 0;
  background: var(--accent);
  color: #1a1408;
  font-weight: 650;
  cursor: pointer;
  border-radius: 4px;
  font: inherit;
}

.login-card button[type="submit"]:disabled { opacity: 0.6; cursor: wait; }

.login-error {
  color: #e07070;
  font-size: 13px;
  margin: 0 0 12px !important;
}

.nick-card { grid-column: 1 / -1; }

.nick-table input {
  width: 100%;
  min-width: 160px;
  background: #0f1218;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px;
  font: inherit;
  border-radius: 4px;
}

.nick-table button {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: var(--accent);
  color: #1a1408;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.nick-status {
  margin-left: 8px;
  font-size: 12px;
  color: var(--muted);
}

.nick-msg {
  font-size: 13px;
  color: #e0b0b0;
  margin: 0 0 12px;
}

.patreon-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  flex-wrap: wrap;
}

.patreon-toolbar input[type="search"] {
  background: #0f1218;
  border: 1px solid var(--line);
  color: var(--text);
  height: 36px;
  min-width: 240px;
  padding: 0 12px;
  font: inherit;
  border-radius: 4px;
}

.patreon-toolbar .hint {
  margin: 0;
}

.note { font-size: 12px; color: var(--muted); margin-top: 14px; }
code { color: var(--text); }

.cad-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 40;
}
.cad-modal[hidden] { display: none; }
.cad-modal-card {
  width: min(420px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 18px;
}
.cad-modal-card h2 { margin: 0 0 14px; font-size: 18px; }
.field-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-row label { font-size: 12px; color: var(--muted); }
.field-row input,
.field-row select {
  background: #0f1218;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px;
  font: inherit;
  border-radius: 4px;
}
.cad-modal-card .actions { display: flex; gap: 8px; margin-top: 8px; }

.field-row textarea {
  background: #0f1218;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px;
  font: inherit;
  border-radius: 4px;
  min-height: 90px;
  resize: vertical;
}

.server-head,
.server-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.server-head-actions,
.server-head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.status-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
  color: var(--muted);
}
.status-pill.on,
.status-pill.on {
  color: #b6e0b0;
  border-color: #3d6a3d;
  background: #1a2a1a;
}
.status-pill.off,
.status-pill.off {
  color: #e0b0b0;
  border-color: #6a3d3d;
  background: #2a1a1a;
}
.server-public {
  margin: 4px 0 16px;
  font-size: 20px;
  font-weight: 600;
}
.gauges {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}
@media (max-width: 980px) {
  .gauges { grid-template-columns: 1fr 1fr; }
}
.gauge {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
}
.gauge h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.gauge-val {
  margin: 8px 0 10px;
  font-size: 18px;
  font-weight: 650;
}
.gauge-bar {
  height: 8px;
  background: #1e2430;
  border-radius: 99px;
  overflow: hidden;
}
.gauge-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.gauge-bar.good > span { background: #6fbf72; }
.gauge-bar.low > span { background: #c45c5c; }
.gauge-bar.hot > span { background: #c45c5c; }
.gauge-sub {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.tag {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.ok {
  color: #8fbf8a;
  border-color: #2f4a32;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
@media (max-width: 800px) {
  .form-grid { grid-template-columns: 1fr; }
}
.card dl {
  margin: 0;
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 10px;
  font-size: 13px;
}
.card dt { color: var(--muted); }
.card dd { margin: 0; overflow-wrap: anywhere; }

.conn-card {
  max-width: 520px;
}
.conn-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.conn-head h2 {
  margin: 0;
}
.conn-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.conn-row label {
  font-size: 13px;
  color: var(--muted);
}
.conn-row input {
  width: 100%;
  background: #2a303c;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  border-radius: 8px;
}
@media (max-width: 560px) {
  .conn-row { grid-template-columns: 1fr; }
}
