:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --panel-2: #182338;
  --text: #e7eef8;
  --muted: #93a4bd;
  --line: #243044;
  --accent: #0284c7;
  --danger: #f87171;
  --ok: #34d399;
  --shadow: 0 16px 40px rgba(0, 0, 0, .28);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --danger: #b91c1c;
  --ok: #047857;
  --shadow: 0 12px 32px rgba(15, 23, 42, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.skip {
  position: absolute; left: 8px; top: -40px; background: var(--accent); color: #fff; padding: 6px 10px; border-radius: 8px;
}
.skip:focus { top: 8px; }
.ca-header {
  display: flex; align-items: center; gap: 8px;
  height: 60px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.mark, .login-mark { color: var(--accent); }
.mark { width: 32px; height: 32px; flex: 0 0 auto; }
.wordmark { font-weight: 700; letter-spacing: -0.03em; font-size: 18px; white-space: nowrap; }
.brand-cor { color: var(--text); }
.brand-suffix { color: var(--accent); }
.ca-header-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.header-icon-btn, .theme-toggle {
  width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer;
}
.header-icon-btn:hover, .theme-toggle:hover, .help-btn:hover { background: var(--panel-2); }
.header-icon-svg { width: 20px; height: 20px; }
.theme-toggle::before { content: "☀"; font-size: 16px; }
[data-theme="dark"] .theme-toggle::before { content: "☾"; }
.help-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; border-radius: 10px;
  text-decoration: none; color: var(--text); font-weight: 600;
}
.help-btn-icon {
  width: 22px; height: 22px; border-radius: 999px; border: 1.5px solid currentColor;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
}
.ca-nav-toggle { display: none; }
.ca-nav-icon-close { display: none; }
.ca-nav-toggle[aria-expanded="true"] .ca-nav-icon-open { display: none; }
.ca-nav-toggle[aria-expanded="true"] .ca-nav-icon-close { display: block; }
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 60px); }
#primary-nav {
  border-right: 1px solid var(--line); padding: 12px; background: var(--panel); display: flex; flex-direction: column; gap: 4px;
}
#primary-nav a {
  text-decoration: none; color: var(--text); padding: 8px 10px; border-radius: 10px;
}
#primary-nav a[aria-current="page"], #primary-nav a:hover { background: var(--panel-2); }
.nav-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 8px 10px 4px; }
.tenant-select, input, select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
textarea { min-height: 96px; }
main { padding: 24px; max-width: 1100px; }
h1 { font-size: 28px; margin: 0 0 8px; letter-spacing: -0.03em; }
h2 { font-size: 18px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.pad { padding: 16px; }
.card, .panel, .badge, .login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}
.card { padding: 16px; }
.card strong { display: block; font-size: 22px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 180px; }
.btn {
  border: 0; background: var(--accent); color: #fff; border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 650;
}
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.banner { padding: 12px 14px; border-radius: 12px; margin: 0 0 16px; }
.banner.error { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.banner.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); }
.state, .empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge { padding: 12px 14px; min-width: 180px; text-align: left; cursor: pointer; color: inherit; }
.badge small { display: block; color: var(--muted); }
.cat { margin: 18px 0 8px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(440px, 100%); background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: var(--shadow); padding: 20px; overflow: auto; z-index: 30;
}
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); padding: 28px; box-shadow: var(--shadow); position: relative; }
.login-theme { position: absolute; top: 12px; right: 12px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; }
.login-mark { width: 76px; height: 76px; }
.checks { list-style: none; padding: 0; }
.checks li { padding: 4px 0; }
.pass { color: var(--ok); }
.fail { color: var(--danger); }
.token-box { font-family: ui-monospace, monospace; word-break: break-all; background: var(--bg); padding: 10px; border-radius: 10px; }
pre.preview { white-space: pre-wrap; background: var(--bg); padding: 12px; border-radius: 12px; overflow: auto; max-height: 280px; }
.form-field { margin-bottom: 12px; }
label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
@media (max-width: 900px) {
  .ca-nav-toggle { display: inline-flex; }
  .shell { display: block; }
  #primary-nav { display: none; border-right: 0; border-bottom: 1px solid var(--line); }
  #primary-nav.open { display: flex; }
  .help-btn-label { display: none; }
}
