:root {
  --bg: #f5f6f8; --surface: #fff; --surface-2: #f0f2f5; --line: #e2e5ea; --text: #161a22; --muted: #667085;
  --brand: #e8590c; --brand-ink: #fff; --brand-soft: #fff1e8; --focus: #2563eb;
  --ok: #067647; --ok-bg: #e7f6ec; --warn: #b54708; --warn-bg: #fef0c7; --bad: #b42318; --bad-bg: #fee4e2; --info: #175cd3; --info-bg: #e5efff;
  --side: #12161d; --side-text: #aab2c0; --side-active: #1f2632; --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1016; --surface: #151a22; --surface-2: #1b212b; --line: #262d39; --text: #e8ebf0; --muted: #8e98a8;
    --brand-soft: #2b1a10; --ok-bg: #0f2a1b; --warn-bg: #2e2208; --bad-bg: #321412; --info-bg: #122240;
    --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --info: #7cb0ff; --side: #0a0d12; --side-active: #181e28;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, "Segoe UI", Inter, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; font-size: 15px; padding: 4px 10px 18px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #ff8a3d, #e8590c); display: grid; place-items: center; color: #fff; font-weight: 800; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 6px; color: #6b7585; }
.nav a, .nav span { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); }
.nav a:hover { background: var(--side-active); color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 2px 0 0 var(--brand); }
.nav span { opacity: .45; cursor: default; }
.nav .soon { margin-left: auto; font-size: 10px; border: 1px solid #3a4352; border-radius: 99px; padding: 0 6px; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #222a36; display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #2a3342; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.side-foot button { background: none; border: 0; color: var(--side-text); cursor: pointer; padding: 0; font: inherit; font-size: 12px; text-decoration: underline; }

.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.menu-btn { display: none; }
.cmd-trigger { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 7px 12px; cursor: pointer; font: inherit; text-align: left; }
kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface); margin-left: auto; }
.content { padding: 24px 28px 60px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a:hover { color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-b { padding: 18px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: 2fr 1fr; align-items: start; }
.stat { padding: 16px 18px; }
.stat .n { font-size: 28px; font-weight: 650; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 12.5px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 14px; font: inherit; font-weight: 550; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 10px; font-size: 12.5px; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 550; background: var(--surface-2); color: var(--muted); }
.badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.lead { background: var(--info-bg); color: var(--info); }
.badge.paused { background: var(--warn-bg); color: var(--warn); }
.badge.former { background: var(--bad-bg); color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 18px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .04em; }
td { padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--surface-2); }
.name-cell { display: flex; align-items: center; gap: 12px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a, .tabs span { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-color: var(--brand); font-weight: 600; }
.tabs span { opacity: .55; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.pill { padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; }
.pill.on { background: var(--text); color: var(--bg); border-color: var(--text); }

form .row { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); margin-bottom: 14px; }
form .row.three { grid-template-columns: 2fr 1fr 1fr; }
label { display: block; font-weight: 550; font-size: 13px; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 11px; font: inherit; }
textarea { min-height: 90px; resize: vertical; }
.err { color: var(--bad); font-size: 12.5px; margin-top: 4px; }
.flash { background: var(--ok-bg); color: var(--ok); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-top: 7px; flex: none; }
.dot.note { background: var(--brand); }
.note-body { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin-top: 6px; white-space: pre-wrap; }
.empty { text-align: center; padding: 36px 18px; color: var(--muted); }
.pager { padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); }
.pager nav svg { width: 16px; height: 16px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 380px; padding: 28px; }

.cmd { position: fixed; inset: 0; background: rgba(8,10,14,.55); display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 50; }
.cmd.open { display: flex; }
.cmd-box { width: min(600px, 92vw); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.cmd-box input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 15px 18px; font-size: 16px; background: transparent; }
.cmd-box input:focus { outline: none; }
.cmd-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmd-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 12px 4px; }
.cmd-item { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.cmd-item.sel { background: var(--surface-2); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .top { padding: 10px 16px; }
  .content { padding: 18px 16px 50px; }
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g2 { grid-template-columns: 1fr; }
  form .row, form .row.three { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}

/* Server and messaging pages */
.badge.good { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: var(--surface-2); color: var(--muted); }
.mono { font: 12.5px/1.4 ui-monospace, "SFMono-Regular", Consolas, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; word-break: break-all; }
.mono-plain { font: 12.5px/1.4 ui-monospace, "SFMono-Regular", Consolas, monospace; color: var(--muted); word-break: break-all; }
.switch { display: flex; gap: 8px; margin-bottom: 16px; }
.btn.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.stat .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat .n.sm { font-size: 22px; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.section { margin: 30px 0 12px; font-size: 15px; font-weight: 650; }
.issue-list { margin: 10px 0 0; padding-left: 18px; }
.inline-form { display: inline; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
details.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; box-shadow: var(--shadow); }
details.panel > summary { cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: "▸ "; color: var(--brand); }
details.panel[open] > summary::before { content: "▾ "; }
details.panel > .inner { padding: 0 18px 18px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.form-grid label { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.mini { padding: 4px 10px; font-size: 12.5px; }
.cols2 { display: grid; gap: 24px; grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .cols2, .g3 { grid-template-columns: 1fr; } }
.pre { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font: 12.5px/1.5 ui-monospace, Consolas, monospace; }
.token-box { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; word-break: break-all; }
