/* ============================================================
   SD RMM stylesheet — matches Tower / LLM Chat product chrome
   (deep slate, restrained accents, trust-led typography).
   ============================================================ */

:root {
  --bg:        #0f1115;
  --surface:   #161a22;
  --surface-2: #1c2230;
  --surface-3: #242c3d;
  --line:      #2a3142;
  --line-soft: #1f2532;
  --ink:       #ececec;
  --ink-2:     #d0d4dc;
  --muted:     #9aa0aa;
  --muted-2:   #6b7280;
  --accent:    #e63946;
  --accent-soft: rgba(230, 57, 70, .14);
  --accent-ring: rgba(230, 57, 70, .35);
  --accent-ink: #fff;
  --ok:   #4ade80;
  --warn: #fbbf24;
  --bad:  #f97373;
  --info: #60a5fa;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.32);
  --shadow-2: 0 8px 24px rgba(0,0,0,.28);
  --header-h: 56px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font: 14.5px/1.55 var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .copy-code {
  font-family: var(--font-mono);
  font-size: .89em;
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  word-break: break-all;
}
.copy-code { user-select: all; cursor: text; }

/* ---------- App bar ---------- */
.appbar {
  display: flex; align-items: center; gap: 18px;
  height: var(--header-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink); font-weight: 700; font-size: 16px;
  text-decoration: none;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ok);
  font-family: var(--font-mono); font-weight: 700; font-size: 14px;
}
.brand-name { letter-spacing: .2px; }
.appnav { display: flex; gap: 4px; }
.appnav a {
  padding: 6px 12px; border-radius: 8px;
  color: var(--muted); font-weight: 500;
}
.appnav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.appnav a.is-active { color: var(--ink); background: var(--surface-2); }
.appbar-spacer { flex: 1; }
.appbar-user {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
}
.user-email { color: var(--muted); }

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 18px 80px;
}
.page-title { font-size: 22px; font-weight: 600; margin: 0 0 18px; letter-spacing: -.2px; }
.section-title { font-size: 15px; font-weight: 600; margin: 28px 0 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .6px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 24px; }
.page-header .crumb { color: var(--muted); margin: 0 0 4px; font-size: 12px; }
.page-header h1 { margin: 0; }

/* ---------- Buttons + inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font: 600 13.5px/1 var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.btn-primary:hover { background: #d22936; border-color: #d22936; text-decoration: none; }
.btn-ghost {
  background: transparent; color: var(--ink-2); border-color: var(--line);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.btn-danger {
  background: transparent; color: var(--bad); border-color: rgba(249,115,115,.4);
}
.btn-danger:hover { background: rgba(249,115,115,.12); text-decoration: none; }
.link { background: none; border: 0; color: var(--info); cursor: pointer; padding: 0; font: inherit; }
.link:hover { text-decoration: underline; }
.inline { display: inline; }

.form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.form input[type="text"], .form input[type="email"], .form input[type="password"],
.form select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: 14.5px var(--font-sans);
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.form input:focus, .form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.form-inline {
  flex-direction: row; flex-wrap: wrap; align-items: center;
  gap: 8px; margin-top: 14px;
}
.form-inline input, .form-inline select { flex: 1 1 180px; }
.inline-check {
  display: inline-flex; gap: 6px; align-items: center;
  font-size: 13px; color: var(--muted);
}

/* ---------- Auth pages ---------- */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 24px;
  background: radial-gradient(circle at top, #181c25, var(--bg));
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--shadow-2);
}
.auth-card--wide { max-width: 460px; }
.auth-head { text-align: center; margin-bottom: 14px; }
.auth-head .brand-mark { margin: 0 auto 10px; width: 40px; height: 40px; font-size: 18px; }
.auth-head h1 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.auth-head .sub { margin: 0; color: var(--muted); font-size: 13.5px; }
.auth-foot { text-align: center; margin: 18px 0 0; color: var(--muted); font-size: 12.5px; }
.qr-wrap {
  display: flex; justify-content: center;
  margin: 14px 0;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
}
.qr-wrap svg { width: 220px; height: 220px; display: block; }
details.muted { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
details.muted summary { cursor: pointer; }
details.muted .copy-code { display: inline-block; margin-top: 8px; font-size: 13px; }

/* ---------- Alerts ---------- */
.alert {
  padding: 10px 12px; border-radius: 8px; margin-bottom: 14px;
  font-size: 13.5px;
}
.alert-error { background: rgba(249,115,115,.1); border: 1px solid rgba(249,115,115,.4); color: var(--bad); }
.alert-info  { background: rgba(96,165,250,.1); border: 1px solid rgba(96,165,250,.4); color: var(--info); }
.alert-ok    { background: rgba(74,222,128,.1); border: 1px solid rgba(74,222,128,.4); color: var(--ok); }

/* ---------- Pills + dots ---------- */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font: 600 11px/1.4 var(--font-sans); letter-spacing: .3px; text-transform: uppercase;
}
.pill-ok    { background: rgba(74,222,128,.16);  color: var(--ok); }
.pill-warn  { background: rgba(251,191,36,.16);  color: var(--warn); }
.pill-bad   { background: rgba(249,115,115,.16); color: var(--bad); }
.pill-super { background: var(--accent-soft);    color: var(--accent); }
.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.dot-ok  { background: var(--ok); }
.dot-off { background: var(--muted-2); }

/* ---------- Tables ---------- */
.datatable {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.datatable th, .datatable td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px; vertical-align: middle;
}
.datatable th {
  background: var(--surface-2);
  color: var(--muted); text-transform: uppercase;
  font: 600 11px/1.5 var(--font-sans); letter-spacing: .5px;
}
.datatable tbody tr:last-child td { border-bottom: 0; }
.datatable tbody tr:hover { background: rgba(255,255,255,.02); }

/* ---------- Card sections (admin pages) ---------- */
.card-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 22px;
}
.card-section > header h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }

/* ---------- Empty state ---------- */
.empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Stat cards (agent detail) ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0 4px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font: 600 11px/1.4 var(--font-sans); color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat-val   { font: 700 26px/1 var(--font-sans); }
.stat-val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat-sub   { font-size: 12px; color: var(--muted); }
@media (max-width: 640px) { .stat-row { grid-template-columns: 1fr; } }

/* ---------- Chart ---------- */
.chart-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px;
}
.chart-card canvas { width: 100%; display: block; }
.legend { display: flex; gap: 16px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.legend .dot { display: inline-block; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--line-soft);
  padding: 14px 18px;
  font-size: 12.5px; color: var(--muted-2);
  text-align: center;
}
.footer code { background: transparent; }
.muted { color: var(--muted); }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .appbar { padding: 0 12px; gap: 10px; }
  .brand-name { display: none; }
  .appbar-user .user-email { display: none; }
  .container { padding: 18px 12px 60px; }
  .page-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .form-inline input, .form-inline select { flex: 1 1 auto; }
  .datatable th, .datatable td { padding: 8px 10px; font-size: 12.5px; }
}
