:root, [data-theme="dark"] {
  --bg: #121316;
  --bg-2: #17191d;
  --surface: #1b1e23;
  --surface-2: #22262d;
  --surface-3: #282d35;
  --hover: #2a3038;
  --border: #30353f;
  --border-soft: #272c34;
  --border-strong: #3c4350;
  --text: #eceae5;
  --text-2: #c9c4bb;
  --muted: #9a968f;
  --faint: #716d66;
  --accent: #d4a437;
  --accent-hover: #dfb24d;
  --accent-soft: rgba(212, 164, 55, 0.12);
  --accent-soft-2: rgba(212, 164, 55, 0.06);
  --accent-text: #151311;
  --ok-bg: rgba(74, 222, 128, 0.1);
  --ok-text: #86dba0;
  --ok-border: rgba(74, 222, 128, 0.2);
  --bad-bg: rgba(248, 113, 113, 0.1);
  --bad-text: #f29b9b;
  --bad-border: rgba(248, 113, 113, 0.2);
  --warn-bg: rgba(251, 191, 36, 0.1);
  --warn-text: #e7c96d;
  --warn-border: rgba(251, 191, 36, 0.22);
  --info-bg: rgba(96, 165, 250, 0.1);
  --info-text: #93baf5;
  --info-border: rgba(96, 165, 250, 0.22);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --sidebar-w: 236px;
  --display: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --transition: 160ms ease;
}

[data-theme="light"] {
  --bg: #f4f2ee;
  --bg-2: #eceae5;
  --surface: #fbfaf7;
  --surface-2: #f1efea;
  --surface-3: #e8e5de;
  --hover: #ece9e2;
  --border: #d9d4ca;
  --border-soft: #e2ddd3;
  --border-strong: #c8c1b4;
  --text: #1f1d19;
  --text-2: #3f3b35;
  --muted: #68645d;
  --faint: #8a857d;
  --accent: #b8891d;
  --accent-hover: #a77b16;
  --accent-soft: rgba(184, 137, 29, 0.1);
  --accent-soft-2: rgba(184, 137, 29, 0.05);
  --accent-text: #fffaf0;
  --ok-bg: rgba(22, 163, 74, 0.08);
  --ok-text: #237a49;
  --ok-border: rgba(22, 163, 74, 0.2);
  --bad-bg: rgba(220, 38, 38, 0.08);
  --bad-text: #b54242;
  --bad-border: rgba(220, 38, 38, 0.18);
  --warn-bg: rgba(217, 119, 6, 0.08);
  --warn-text: #9a6700;
  --warn-border: rgba(217, 119, 6, 0.2);
  --info-bg: rgba(37, 99, 235, 0.08);
  --info-text: #3464b8;
  --info-border: rgba(37, 99, 235, 0.18);
  --shadow: 0 18px 40px rgba(28, 24, 18, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(212, 164, 55, 0.08), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,0.015), transparent 30%);
}
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
.mono { color: var(--text-2); }
.strong { font-weight: 600; color: var(--text); }
.muted { color: var(--muted); }
.hidden, [hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection { background: var(--accent-soft); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); border: 2px solid transparent; background-clip: padding-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}
.btn:hover:not(:disabled) { background: var(--hover); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.38rem 0.65rem; font-size: 0.8rem; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); border-color: transparent; }
.btn-danger {
  background: transparent;
  border-color: var(--bad-border);
  color: var(--bad-text);
}
.btn-danger:hover:not(:disabled) { background: var(--bad-bg); border-color: rgba(248,113,113,0.35); }
.btn-block { width: 100%; }
.icon-btn {
  width: 36px; height: 36px; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label, .field-label { font-size: 0.78rem; font-weight: 600; color: var(--text-2); letter-spacing: 0.01em; }
.field-hint { font-size: 0.75rem; color: var(--muted); margin: 0; }
input[type="text"], input[type="search"], input[type="password"], input[type="number"],
input[type="url"], input[type="email"], select, textarea {
  width: 100%;
  padding: 0.58rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.4;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(212,164,55,0.55);
  box-shadow: 0 0 0 3px rgba(212,164,55,0.12);
}
select { cursor: pointer; padding-right: 2rem; }
textarea { resize: vertical; min-height: 72px; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 2.5rem; }
.input-wrap .input-action {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted);
  border-radius: 4px; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.input-wrap .input-action:hover { color: var(--text); background: var(--hover); }

/* Login */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-view::before {
  content: '';
  position: absolute;
  width: min(820px, 90vw);
  height: min(820px, 90vw);
  background: url('/logo.webp') center / contain no-repeat;
  filter: blur(10px);
  opacity: 0.22;
  pointer-events: none;
}
.login-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.login-panel h2 {
  margin: 0 0 24px;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 620;
  letter-spacing: -0.02em;
}
.login-form { display: grid; gap: 18px; }
.login-error {
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--bad-bg);
  border: 1px solid var(--bad-border);
  color: var(--bad-text);
  font-size: 0.84rem;
}
.login-error[hidden] { display: none !important; }

/* App shell */
.console-view { min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform 0.2s ease;
}
.sidebar-head {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent-soft);
  border: 1px solid rgba(212,164,55,0.18);
  display: grid; place-items: center; flex: 0 0 auto;
}
.sidebar-mark img { width: 20px; height: 20px; }
.sidebar-brand { min-width: 0; }
.sidebar-brand-name {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.2;
}
.sidebar-brand-sub { font-size: 0.72rem; color: var(--muted); }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  padding: 14px 10px 6px;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 0.58rem 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: rgba(212,164,55,0.12);
}
.nav-item.active::before {
  content: "";
  position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: 0.85; }
.nav-item.active svg { opacity: 1; color: var(--accent); }
.nav-count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  line-height: 1.4;
}
.nav-item.active .nav-count { background: rgba(212,164,55,0.15); color: var(--accent); }
.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.sidebar-user { min-width: 0; }
.sidebar-user-label { font-size: 0.72rem; color: var(--faint); }
.sidebar-user-name { font-size: 0.82rem; font-weight: 550; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main-wrap { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 28px;
  background: rgba(18,19,22,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .topbar { background: rgba(244,242,238,0.88); }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
#menuBtn, #navToggle { display: none; }
.page-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.topbar-search {
  position: relative; width: min(320px, 100%);
}
.topbar-search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint); pointer-events: none;
}
.topbar-search input { padding-left: 34px; height: 36px; background: var(--surface); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  width: 36px; height: 36px; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.topbar-btn:hover { background: var(--hover); color: var(--text); border-color: var(--border-strong); }
.topbar-btn svg { width: 17px; height: 17px; }
#signOutBtn { width: auto; padding: 0 12px; font-size: 0.82rem; font-weight: 550; }

.content { padding: 28px; flex: 1; width: 100%; max-width: 1680px; }
.page[hidden] { display: none !important; }
.page:not([hidden]) { display: block; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.025em;
}
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 0.88rem; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-ic {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 10px;
}
.stat-ic svg { width: 18px; height: 18px; }
.stat-value {
  font-family: var(--display);
  font-size: clamp(1.7rem, 2.2vw, 2.1rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}
.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
  margin-top: 4px;
}
.stat-sub { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* Cards / panels */
.panel-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}
.card-head, .panel-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h2, .card-head h3, .panel-head h2, .panel-head h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.01em;
}
.card-head p, .panel-head p { margin: 2px 0 0; font-size: 0.76rem; color: var(--muted); }
.card-body, .panel-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* Chart */
.chart-wrap { padding: 16px 18px 18px; }
.chart-total { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.chart-container { position: relative; width: 100%; }
.chart-svg { width: 100%; height: 240px; display: block; overflow: visible; }
.chart-svg[hidden], .chart-container[hidden] { display: none !important; }
.chart-grid-line { stroke: var(--border-soft); stroke-width: 1; }
.chart-grid-line.zero { stroke: var(--border); }
.chart-axis-label { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.chart-area { fill: url(#chartAreaGrad); }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: var(--bg-2); stroke: var(--accent); stroke-width: 2; opacity: 0; transition: opacity 0.12s ease; }
.chart-dot.active { opacity: 1; }
.chart-cursor { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0; transition: opacity 0.12s ease; }
.chart-cursor.active { opacity: 1; }
.chart-hover-zone { fill: transparent; cursor: crosshair; }
.chart-tooltip {
  position: absolute; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 8px 12px;
  box-shadow: var(--shadow); font-size: 0.78rem; z-index: 5;
  transform: translate(-50%, calc(-100% - 14px));
  white-space: nowrap;
}
.chart-tooltip[hidden] { display: none !important; }
.chart-tooltip-date { color: var(--muted); font-size: 0.72rem; margin-bottom: 2px; }
.chart-tooltip-val { color: var(--text); font-weight: 650; font-family: var(--display); font-size: 0.95rem; }
.chart-tooltip-val span { color: var(--muted); font-weight: 500; font-size: 0.78rem; font-family: var(--font); margin-left: 4px; }
.chart-empty {
  height: 240px;
  display: grid; place-items: center;
  color: var(--muted); font-size: 0.84rem;
}
.chart-empty[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) {
  .chart-line { stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: chartDraw 0.8s ease forwards; }
  .chart-area { opacity: 0; animation: chartFade 0.5s ease 0.3s forwards; }
}
@keyframes chartDraw { to { stroke-dashoffset: 0; } }
@keyframes chartFade { to { opacity: 1; } }

/* Activity feed */
.activity-feed { list-style: none; margin: 0; padding: 0; }
.activity-feed li {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: flex-start; gap: 12px;
  font-size: 0.84rem;
}
.activity-feed li:last-child { border-bottom: 0; }
ul.audit { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); overflow: hidden; }
ul.audit li { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); font-size: 0.82rem; color: var(--text-2); display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
ul.audit li:last-child { border-bottom: 0; }
.activity-feed .dot, .audit .dot, .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex: 0 0 auto; margin-top: 6px;
}
.dot.ok, .dot.green { background: var(--ok-text); }
.dot.bad, .dot.red { background: var(--bad-text); }
.dot.warn { background: var(--warn-text); }
.activity-main { flex: 1; min-width: 0; }
.activity-title { color: var(--text); font-weight: 500; line-height: 1.4; }
.activity-meta { color: var(--muted); font-size: 0.76rem; margin-top: 2px; }
.when { color: var(--muted); font-size: 0.76rem; white-space: nowrap; margin-left: auto; padding-left: 12px; }
.act { font-weight: 550; color: var(--text); }

/* Toolbar */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.toolbar-search { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.toolbar-search svg, .toolbar-search .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint); pointer-events: none;
}
.toolbar-search input { padding-left: 34px; }
.toolbar select { width: auto; min-width: 140px; flex: 0 0 auto; }
.toolbar .btn { margin-left: auto; }
.toolbar-spacer { flex: 1; }

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.84rem; }
thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text-2);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,0.015); }
[data-theme="light"] tbody tr:hover td { background: rgba(0,0,0,0.015); }
tbody tr.selected td { background: var(--accent-soft-2); }
td .strong, td strong { color: var(--text); }
.th-sort, .sort {
  background: none; border: 0; padding: 0; color: inherit; font: inherit;
  font-weight: inherit; letter-spacing: inherit; text-transform: inherit;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.th-sort:hover, .sort:hover { color: var(--text); }
.sort[data-dir="asc"]::after { content: "↑"; font-size: 0.7rem; }
.sort[data-dir="desc"]::after { content: "↓"; font-size: 0.7rem; }

.key-cell { display: flex; align-items: center; gap: 8px; }
.key-cell .mono, .key-cell code { font-size: 0.8rem; color: var(--text); }
.copy-btn, .reveal-btn, .key-action {
  padding: 0.2rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1.3;
}
.copy-btn:hover, .reveal-btn:hover, .key-action:hover { color: var(--text); border-color: var(--border-strong); background: var(--hover); }

.seats { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.seats-text { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 550; font-size: 0.82rem; }
.meter {
  width: 52px; height: 5px; background: var(--surface-3);
  border-radius: 999px; overflow: hidden; flex: 0 0 auto;
}
.meter-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.meter-fill.full { background: var(--warn-text); }
.meter-fill.over { background: var(--bad-text); }

/* Pills / badges */
.pill, .badge, .status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before, .status-pill::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.9;
}
.pill-ok, .pill-active { color: var(--ok-text); background: var(--ok-bg); border-color: var(--ok-border); }
.pill-bad, .pill-revoked, .pill-expired { color: var(--bad-text); background: var(--bad-bg); border-color: var(--bad-border); }
.pill-warn, .pill-warning { color: var(--warn-text); background: var(--warn-bg); border-color: var(--warn-border); }
.pill-muted, .pill-neutral { color: var(--muted); background: rgba(138,133,123,0.1); border-color: rgba(138,133,123,0.18); }
.pill-info { color: var(--info-text); background: var(--info-bg); border-color: var(--info-border); }

.type-chip, .ver-chip {
  display: inline-flex; align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}
.type-chip.plugin { color: #93baf5; background: rgba(96,165,250,0.08); border-color: rgba(96,165,250,0.15); }
.type-chip.webapp { color: #c4b5fd; background: rgba(167,139,250,0.08); border-color: rgba(167,139,250,0.15); }
.type-chip.discordbot { color: #86dba0; background: rgba(74,222,128,0.08); border-color: rgba(74,222,128,0.15); }

/* Row actions */
.row-actions { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; }
.row-actions .btn { padding: 0.3rem 0.55rem; font-size: 0.74rem; }
.row-actions .btn-ghost { color: var(--muted); }
.row-actions .btn-ghost:hover { color: var(--text); }
.row-actions .btn-danger { padding: 0.3rem 0.55rem; font-size: 0.74rem; }

/* Pagination */
.pagination, .pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 0.8rem; color: var(--muted);
}
.pagination[hidden], .pager[hidden] { display: none !important; }
.pagination-info { font-size: 0.8rem; color: var(--muted); }
.pagination-btns, .pager-btns { display: flex; gap: 6px; }

/* Empty / skeleton / error */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state[hidden] { display: none !important; }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--faint); opacity: 0.6; }
.empty-state p { margin: 0; font-size: 0.88rem; }
.empty-state .empty-title { font-weight: 600; color: var(--text-2); font-size: 0.92rem; margin-bottom: 4px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skeleton-row td { padding: 14px; }
.skeleton-line { height: 12px; width: 100%; }
.skeleton-line.sm { width: 60%; }
.skeleton-wrap[hidden], .skeleton[hidden] { display: none !important; }

.error-banner {
  display: flex;
  padding: 0.75rem 1rem;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: var(--bad-bg);
  border: 1px solid var(--bad-border);
  color: var(--bad-text);
  font-size: 0.84rem;
  align-items: center;
  gap: 10px;
}
.error-banner[hidden] { display: none !important; }
.error-banner p { margin: 0; flex: 1; }
.error-banner button { background: none; border: 0; color: inherit; cursor: pointer; font-size: 1.1rem; padding: 0 2px; line-height: 1; }

/* Dialogs */
dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  box-shadow: var(--shadow);
  max-height: calc(100vh - 48px);
}
dialog::backdrop { background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
dialog[open] { display: flex; flex-direction: column; }
.dialog-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.dialog-head h2 {
  margin: 0; font-family: var(--display); font-size: 1.1rem; font-weight: 650; letter-spacing: -0.01em;
}
.dialog-close {
  width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: var(--muted);
  border-radius: 6px; display: grid; place-items: center; cursor: pointer; font-size: 1.2rem; line-height: 1;
}
.dialog-close:hover { background: var(--hover); color: var(--text); }
.dialog-body { padding: 20px; overflow-y: auto; }
.dialog-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error {
  padding: 0.6rem 0.75rem; border-radius: var(--radius-sm);
  background: var(--bad-bg); border: 1px solid var(--bad-border);
  color: var(--bad-text); font-size: 0.82rem; margin-top: 12px; display: none;
}
.form-error.visible { display: block; }
.form-result {
  margin-top: 12px; padding: 12px; border-radius: var(--radius-sm);
  background: var(--ok-bg); border: 1px solid var(--ok-border);
  color: var(--ok-text); font-size: 0.84rem; display: none;
}
.form-result.visible { display: block; }
.form-result code { display: block; margin-top: 6px; color: var(--text); word-break: break-all; }

/* Detail dialog */
#detailDialog { width: min(760px, calc(100vw - 32px)); }
.detail-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--border-soft); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 20px;
}
.detail-field { background: var(--surface); padding: 12px 14px; }
.detail-h { font-size: 0.7rem; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; }
.detail-v { font-size: 0.88rem; color: var(--text); word-break: break-word; }
.detail-v.mono { font-family: var(--mono); font-size: 0.82rem; }
.detail-grid dt { font-size: 0.7rem; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--faint); margin: 0 0 4px; }
.detail-grid dd { margin: 0; font-size: 0.88rem; color: var(--text); word-break: break-word; }
.detail-grid > div { background: var(--surface); padding: 12px 14px; }
.detail-section { margin-top: 20px; }
.detail-section h3, h3.detail-h { margin: 20px 0 10px; font-size: 0.78rem; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
ul.detail-acts { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); overflow: hidden; }
ul.detail-acts li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); font-size: 0.83rem; }
ul.detail-acts li:last-child { border-bottom: 0; }
.detail-table { width: 100%; font-size: 0.82rem; }
.detail-table th { font-size: 0.7rem; padding: 8px 10px; }
.detail-table td { padding: 8px 10px; }

/* Bulk bar */
.bulk-bar {
  display: flex;
  align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(212,164,55,0.2);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}
.bulk-bar[hidden] { display: none !important; }
.bulk-bar span { color: var(--text-2); }
.bulk-bar strong { color: var(--text); }
.bulk-bar .btn { padding: 0.35rem 0.65rem; font-size: 0.78rem; }
.bulk-bar .bulk-spacer { flex: 1; }

/* Toast */
.toast-wrap, #toasts {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  max-width: 360px;
}
.toast.ok { border-color: var(--ok-border); }
.toast.bad, .toast.error { border-color: var(--bad-border); color: var(--bad-text); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Misc */
.section-gap { margin-bottom: 24px; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 35; }
.backdrop[hidden] { display: none !important; }
kbd { font-family: var(--mono); font-size: 0.75em; padding: 0.1em 0.35em; border: 1px solid var(--border); border-radius: 3px; background: var(--surface-2); color: var(--muted); }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.setting-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--border-soft);
}
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-info h4 { margin: 0; font-size: 0.88rem; font-weight: 600; color: var(--text); }
.setting-info p { margin: 3px 0 0; font-size: 0.78rem; color: var(--muted); line-height: 1.5; }
.token-display {
  font-family: var(--mono); font-size: 0.8rem; padding: 0.6rem 0.75rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-2); word-break: break-all; user-select: all;
}
.danger-zone { border-color: var(--bad-border); }
.danger-zone .card-head h2, .danger-zone .panel-head h2 { color: var(--bad-text); }

/* Responsive */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main-wrap { margin-left: 0; }
  #menuBtn, #navToggle { display: inline-grid; }
  .topbar { padding: 12px 16px; }
  .content { padding: 20px 16px; }
  .login-panel { padding: 24px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-direction: column; align-items: stretch; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-search { max-width: none; }
  .toolbar select { width: 100%; }
  .toolbar .btn { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .hide-mobile { display: none !important; }
}

/* Metrics drill-down */
.row-clickable { cursor: pointer; }
.row-clickable:hover td { background: var(--hover); }
.row-chevron { display: inline-flex; align-items: center; justify-content: center; color: var(--faint); }
.row-chevron svg { width: 16px; height: 16px; }
.row-clickable:hover .row-chevron { color: var(--accent); }
.metrics-crumb { display: flex; align-items: center; gap: 12px; }
.metrics-back {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted); display: inline-grid; place-items: center;
  cursor: pointer; flex: 0 0 auto;
}
.metrics-back:hover { color: var(--text); border-color: var(--border-strong); background: var(--hover); }
.metrics-back svg { width: 16px; height: 16px; }
.crumb-link {
  background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; font-size: inherit;
}
.crumb-link:hover { text-decoration: underline; }
.crumb-sep { color: var(--faint); margin: 0 2px; }
.metrics-detail { padding: 18px; }
.metrics-detail[hidden] { display: none !important; }
.metrics-detail-grid { margin-bottom: 0; }
#metricsWrap .card-head h2 { margin: 0; font-size: 0.88rem; font-weight: 650; color: var(--text); letter-spacing: -0.01em; }
#metricsWrap .card-head p { margin: 2px 0 0; font-size: 0.76rem; color: var(--muted); }
