/* Gate design system. One stylesheet, no build step.
   Tokens first, then base, shells, components, pages, responsive. */

:root {
  color-scheme: light;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Neutrals */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #5b6578;

  /* The one accent */
  --accent: #2366d1;
  --accent-hover: #1d56b3;
  --accent-ink: #1a4fa3;
  --accent-soft: #e8f0fc;
  --accent-softer: #f3f7fe;
  --focus: #2366d1;

  /* Status (reserved; always paired with a label) */
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --ok-border: #abefc6;
  --bad: #b42318;
  --bad-bg: #fef3f2;
  --bad-border: #fecdca;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --warn-border: #fedf89;
  --neutral-bg: #f2f4f7;

  /* Chart */
  --chart-bar: #2a78d6;
  --chart-bar-current: #b9d3f3;
  --chart-grid: #eaecf0;

  /* Console chrome */
  --console-side: #0f1729;
  --console-side-2: #1a2438;
  --console-ink: #c7d0df;
  --console-ink-strong: #ffffff;
  --console-muted: #8b97ab;
  --console-focus: #8fb3f2;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 20px 40px -8px rgba(16, 24, 40, 0.18), 0 6px 12px -4px rgba(16, 24, 40, 0.06);

  --topbar-h: 60px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { color: var(--text); line-height: 1.25; margin: 0; }
h1 { font-size: 1.625rem; font-weight: 650; letter-spacing: -0.02em; }
h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--neutral-bg);
  border-radius: 4px;
  padding: 0.05em 0.35em;
  color: var(--text-2);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -100px;
  z-index: 100;
  background: var(--surface);
  color: var(--accent);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-weight: 600;
}
.skip-link:focus { top: 0.75rem; }

.muted { color: var(--muted); }
.eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.lede { color: var(--muted); margin-top: 0.35rem; max-width: 62ch; }
.footnote {
  display: flex; gap: 0.5rem; align-items: flex-start;
  margin-top: 1rem; color: var(--muted); font-size: 0.875rem;
}
.footnote .icon { margin-top: 0.1em; }
.link-sm { font-size: 0.875rem; font-weight: 550; }
.truncate { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.js .js-hide { display: none; }
[hidden] { display: none !important; }

/* ---------- Logo and brand ---------- */
.logo { width: 28px; height: 28px; flex: none; }
.logo-bg { fill: var(--accent); }
.logo-fg { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; }

.brand, .auth-brand, .console-brand {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em;
  color: var(--text);
}
.brand:hover, .auth-brand:hover, .console-brand:hover { text-decoration: none; color: inherit; }

/* ---------- Top bars ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  height: var(--topbar-h);
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }

/* ---------- Tenant mark and avatars ---------- */
.tenant-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 700; font-size: 0.8rem; letter-spacing: 0.02em;
}
.tenant-mark-sm { width: 28px; height: 28px; border-radius: 7px; font-size: 0.7rem; }
.tenant-mark-lg { width: 44px; height: 44px; border-radius: 11px; font-size: 0.95rem; }
.tenant-mark-xl { width: 56px; height: 56px; border-radius: 14px; font-size: 1.15rem; }
.is-disabled .tenant-mark { background: #98a2b3; }

.avatar {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 650; font-size: 0.75rem;
}
.avatar-lg { width: 40px; height: 40px; font-size: 0.85rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 38px;
  padding: 0.5rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit; font-weight: 600; font-size: 0.9rem; line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--neutral-bg); color: var(--text); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #912018; color: #fff; }
.btn-danger-outline { background: var(--surface); color: var(--bad); border-color: var(--bad-border); box-shadow: var(--shadow-xs); }
.btn-danger-outline:hover { background: var(--bad-bg); color: #912018; }
.btn-ghost-danger { background: transparent; color: var(--bad); }
.btn-ghost-danger:hover { background: var(--bad-bg); color: #912018; }
.btn-sm { min-height: 30px; padding: 0.3rem 0.65rem; font-size: 0.82rem; border-radius: 7px; }
.btn-lg { min-height: 44px; font-size: 0.95rem; }
.btn-block { width: 100%; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.75rem; font-weight: 600; line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-on { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.badge-off { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-muted { background: var(--neutral-bg); color: var(--text-2); }
.badge-role { background: var(--neutral-bg); color: var(--text-2); border-color: var(--border); }
.badge-role-owner { background: var(--accent-soft); color: var(--accent-ink); border-color: #c7d9f6; }
.badge-role-admin { background: var(--accent-softer); color: var(--accent-ink); border-color: var(--accent-soft); }
h1 .badge { margin-left: 0.4rem; font-size: 0.75rem; letter-spacing: 0; vertical-align: 0.25em; }

.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip { font-size: 0.75rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 1.25rem;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 1rem;
}
.card-head-pad { padding: 1.1rem 1.25rem 0; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.card-foot { margin-top: 1rem; }

/* ---------- Page header ---------- */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-actions { display: flex; gap: 0.5rem; align-items: center; }
.entity-head { display: flex; align-items: center; gap: 1rem; }
.entity-meta {
  display: flex; flex-wrap: wrap; gap: 0.35rem 1rem;
  margin-top: 0.4rem; color: var(--muted); font-size: 0.875rem;
}

.breadcrumbs {
  display: flex; align-items: center; gap: 0.35rem;
  margin-bottom: 0.75rem;
  color: var(--muted); font-size: 0.85rem;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .icon { width: 0.9em; height: 0.9em; }
.breadcrumbs [aria-current] { color: var(--text-2); font-weight: 550; }

/* ---------- Alerts and toasts ---------- */
.alert {
  display: flex; gap: 0.65rem; align-items: flex-start;
  padding: 0.8rem 1rem;
  border: 1px solid;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}
.alert .icon { margin-top: 0.15em; }
.alert-error { background: var(--bad-bg); border-color: var(--bad-border); color: #7a271a; }
.alert-warning { background: var(--warn-bg); border-color: var(--warn-border); color: #7a2e0e; }
.alert-info { background: var(--accent-softer); border-color: var(--accent-soft); color: var(--accent-ink); }

.toasts {
  position: fixed; top: calc(var(--topbar-h) + 12px); right: 16px; z-index: 50;
  display: flex; flex-direction: column; gap: 0.5rem;
  width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.shell-auth .toasts { top: 16px; }
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 0.65rem;
  padding: 0.85rem 0.9rem 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--ok);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  animation: toast-in 0.22s ease-out;
}
.toast > .icon { margin-top: 0.15em; color: var(--ok); }
.toast p { flex: 1; color: var(--text-2); }
.toast-error { border-left-color: var(--bad); }
.toast-error > .icon { color: var(--bad); }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s; }
.toast-close {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; margin: -0.2rem -0.2rem 0 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  cursor: pointer;
}
.toast-close:hover { background: var(--neutral-bg); color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-inline { flex-direction: row; align-items: flex-start; flex-wrap: wrap; }
.form-inline .alert { flex-basis: 100%; margin: 0; }
.form-inline .form-actions { padding-top: 1.6rem; }
.form-actions { display: flex; gap: 0.5rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field-grow { flex: 1 1 280px; }
.field-check { justify-content: flex-end; padding-bottom: 0.4rem; }
.field label, .fieldset legend { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], select {
  width: 100%;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 0.925rem;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input::placeholder { color: #98a2b3; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(35, 102, 209, 0.18); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
input[aria-invalid="true"]:focus, select[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.15); }
select {
  appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6578' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 16px;
}
.select-sm { min-height: 32px; padding: 0.25rem 2rem 0.25rem 0.6rem; font-size: 0.85rem; width: auto; }

.hint { color: var(--muted); font-size: 0.82rem; font-weight: 400; }
.field-error { display: flex; gap: 0.35rem; align-items: flex-start; color: var(--bad); font-size: 0.82rem; font-weight: 550; }
.field-error .icon { margin-top: 0.1em; width: 1em; height: 1em; }

.check { display: flex; align-items: flex-start; gap: 0.55rem; font-size: 0.9rem; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0.18rem 0 0; accent-color: var(--accent); flex: none; }
.check .hint { display: block; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem 1rem; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.fieldset legend { padding: 0 0.35rem; }
.fieldset legend .hint { display: block; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 4.2rem; }
.reveal {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--accent);
  font: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 0.3rem 0.5rem; border-radius: 6px; cursor: pointer;
}
.reveal:hover { background: var(--accent-softer); }

.switch {
  appearance: none;
  position: relative;
  width: 40px; height: 22px; flex: none;
  margin: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color 0.15s;
}
.switch::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.25);
  transition: transform 0.15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.inline-form { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0; }

.search { position: relative; flex: 1; max-width: 360px; }
.search > .icon { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 2.2rem; min-height: 36px; }

/* ---------- Disclosure (inline create forms) ---------- */
.disclosure { margin-bottom: 1.25rem; padding: 0; }
.disclosure-summary {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.9rem 1.25rem;
  font-weight: 600; color: var(--accent);
  cursor: pointer; list-style: none;
  border-radius: var(--radius-lg);
}
.disclosure-summary::-webkit-details-marker { display: none; }
.disclosure-summary:hover { background: var(--accent-softer); }
.disclosure[open] > .disclosure-summary { border-bottom: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.disclosure > form { padding: 1.25rem; }
.disclosure-flush { margin: 0; border-top: 1px solid var(--border); }
.disclosure-flush > .disclosure-summary { border-radius: 0; }

/* ---------- Tables ---------- */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.table-scroll { overflow-x: auto; }
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.table-count { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th {
  padding: 0.6rem 1.25rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  text-align: left; white-space: nowrap;
}
.table td {
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--accent-softer); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-compact th, .table-compact td { padding-left: 0.9rem; padding-right: 0.9rem; }
.table-compact th:first-child, .table-compact td:first-child { padding-left: 1.25rem; }
.nowrap { white-space: nowrap; }
.cell-sub { display: block; margin-top: 0.25rem; color: var(--muted); font-size: 0.78rem; }
.table tr.is-disabled .person-name, .table tr.is-disabled .tenant-cell-name { color: var(--muted); }
.card-head-pad + .table-scroll, .card-head-pad + .empty-state { margin-top: 1rem; border-top: 1px solid var(--border); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline; }
.row-chevron { width: 1%; color: var(--muted); }
.row-chevron a { color: inherit; }
.row-link:hover .row-chevron { color: var(--accent); }

.person { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.person-text { display: flex; flex-direction: column; min-width: 0; }
.person-name { font-weight: 600; color: var(--text); }
.person-sub { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; }

.tenant-cell { display: flex; align-items: center; gap: 0.7rem; color: inherit; min-width: 220px; }
.person { min-width: 200px; }
.tenant-cell:hover { text-decoration: none; }
.tenant-cell:hover .tenant-cell-name { color: var(--accent); }
.tenant-cell > span:last-child { display: flex; flex-direction: column; }
.tenant-cell-name { font-weight: 600; color: var(--text); }
.tenant-cell-slug { color: var(--muted); font-size: 0.8rem; font-family: var(--mono); }

/* ---------- Empty states ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 2.5rem 1.5rem;
}
.empty-state .lede { margin-left: auto; margin-right: auto; }
.empty-state h1, .empty-state h2, .empty-state h3 { margin-top: 0.25rem; }
.empty-icon {
  display: grid; place-items: center;
  width: 48px; height: 48px; margin-bottom: 0.9rem;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.empty-icon .icon { width: 24px; height: 24px; }
.empty-icon-warn { background: var(--warn-bg); color: var(--warn); }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 1.5rem; }
.empty-actions form { margin: 0; }
.empty-inline { padding: 1rem 1.25rem; color: var(--muted); font-size: 0.9rem; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpis-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 1rem 1.15rem;
}
.kpi-label { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.85rem; font-weight: 550; }
.kpi-label .icon { color: var(--accent); }
.kpi-value { margin-top: 0.4rem; font-size: 1.85rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.15; }
.kpi-value-sm { font-size: 1.25rem; padding: 0.3rem 0; }
.kpi-of { font-size: 1rem; font-weight: 500; color: var(--muted); }
.kpi-sub { margin-top: 0.35rem; color: var(--muted); font-size: 0.82rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }

.grid-main-side { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 1.25rem; align-items: start; margin-bottom: 1.5rem; }
.grid-main-side > .table-card { margin-bottom: 0; }

/* ---------- Chart ---------- */
.chart { margin: 0; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart-value { fill: var(--text); font-size: 12px; font-weight: 650; font-family: var(--font); }
.chart-bar { fill: var(--chart-bar); transition: fill 0.12s; }
.chart-bar-current { fill: var(--chart-bar-current); stroke: var(--chart-bar); stroke-width: 1; stroke-dasharray: 3 2; }
.chart-hit { fill: transparent; }
.chart-col { cursor: default; outline: none; }
.chart-col:hover .chart-hit, .chart-col:focus .chart-hit { fill: rgba(35, 102, 209, 0.06); }
.chart-col:hover .chart-bar:not(.chart-bar-current), .chart-col:focus .chart-bar:not(.chart-bar-current) { fill: var(--accent-ink); }
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem; margin-top: 0.5rem; color: var(--muted); font-size: 0.8rem; }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--chart-bar); }
.legend-swatch-current { margin-left: 0.75rem; background: var(--chart-bar-current); border: 1px dashed var(--chart-bar); }
.chart-tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  padding: 0.4rem 0.6rem;
  background: var(--text); color: #fff;
  border-radius: 6px; box-shadow: var(--shadow-md);
  font-size: 0.8rem; font-weight: 550; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}

/* ---------- Feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid var(--border); }
.feed-item:first-child { border-top: 0; padding-top: 0; }
.feed-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.feed-title { font-weight: 600; font-size: 0.9rem; }
.feed-sub { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

/* ---------- Menus ---------- */
.menu { position: relative; }
.menu-trigger {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border-radius: 999px;
  cursor: pointer; list-style: none;
  color: var(--text-2); font-weight: 550; font-size: 0.9rem;
}
.menu-trigger::-webkit-details-marker { display: none; }
.menu-trigger:hover { background: var(--neutral-bg); }
.menu-trigger > .icon { color: var(--muted); width: 1em; height: 1em; }
.menu[open] > .menu-trigger { background: var(--neutral-bg); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  width: 290px;
  padding: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.menu-head { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.7rem 0.6rem 0.8rem; }
.menu-head > div { min-width: 0; }
.menu-name { font-weight: 650; color: var(--text); }
.menu-email { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.35rem; }
.menu-label { padding: 0.5rem 0.6rem 0.25rem; color: var(--muted); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; border-top: 1px solid var(--border); }
.menu-sep { height: 1px; background: var(--border); margin: 0.3rem 0; }
.menu-item {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  padding: 0.5rem 0.6rem;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--text-2); font: inherit; font-size: 0.9rem; text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--neutral-bg); color: var(--text); text-decoration: none; }
.menu-item > .icon { color: var(--muted); }
.menu-item-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu form { margin: 0; }

/* ---------- Dialog ---------- */
.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 1.5rem;
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.dialog::backdrop { background: rgba(16, 24, 40, 0.5); }
.dialog[open] { animation: toast-in 0.18s ease-out; }
.dialog-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--bad-bg); color: var(--bad); margin-bottom: 1rem; }
.dialog-icon .icon { width: 22px; height: 22px; }
.dialog h2 { font-size: 1.1rem; }
.dialog p { margin-top: 0.5rem; color: var(--muted); font-size: 0.925rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }

/* ---------- Side navigation (shared) ---------- */
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 1rem 0.75rem 0.35rem; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.9rem; font-weight: 550;
  white-space: nowrap;
}
.nav-item:hover { background: var(--neutral-bg); color: var(--text); text-decoration: none; }
.nav-item > .icon { color: var(--muted); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item[aria-current="page"] > .icon { color: var(--accent); }

/* ---------- Auth shell ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); min-height: 100vh; }
.auth-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, #0f1f3d 0%, #13306a 55%, #1b4fa8 100%);
  color: #e7eefb;
}
.auth-contours { position: absolute; inset: 0; width: 100%; height: 100%; color: rgba(255, 255, 255, 0.09); }
.auth-hero-inner { position: relative; display: flex; flex-direction: column; height: 100%; padding: 2.5rem 3rem; }
.auth-hero .auth-brand { color: #fff; }
.auth-hero .logo-bg { fill: #fff; }
.auth-hero .logo-fg { stroke: var(--accent); }
.auth-pitch { margin: auto 0; max-width: 30rem; }
.auth-pitch h2 { color: #fff; font-size: 2rem; font-weight: 650; letter-spacing: -0.025em; line-height: 1.2; }
.auth-points { list-style: none; padding: 0; margin: 2rem 0 0; display: flex; flex-direction: column; gap: 1rem; }
.auth-points li { display: flex; gap: 0.75rem; align-items: flex-start; color: #c9d7f2; }
.auth-points .icon { width: 20px; height: 20px; margin-top: 0.1rem; color: #8fb3f2; }
.auth-foot { color: #8ea3c8; font-size: 0.85rem; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: var(--surface); }
.auth-card { width: min(400px, 100%); }
.auth-card h1 { font-size: 1.75rem; }
.auth-card .lede { margin-bottom: 1.75rem; }
.auth-brand-compact { display: none; margin-bottom: 2rem; }
.auth-switch { margin-top: 1.5rem; color: var(--muted); font-size: 0.9rem; text-align: center; }
.auth-switch a { font-weight: 600; }

/* ---------- Plain shell ---------- */
.plain-main { width: min(720px, calc(100% - 2rem)); margin: 0 auto; padding: 3rem 0 4rem; }
.empty-state-page { padding-top: 3rem; }
.empty-state-page h1 { font-size: 1.75rem; }

.picker h1 { text-align: center; }
.picker > .lede { text-align: center; margin: 0.5rem auto 2rem; }
.picker-list { list-style: none; margin: 0 auto; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; max-width: 520px; }
.picker-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.picker-item:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow-md); color: var(--text); }
.picker-item > .icon { color: var(--muted); }
.picker-text { flex: 1; display: flex; flex-direction: column; }
.picker-name { font-weight: 650; }
.picker-sub { color: var(--muted); font-size: 0.85rem; }
.picker-foot { text-align: center; margin-top: 1.5rem; font-size: 0.9rem; }

/* ---------- Workspace shell ---------- */
.topbar-workspace { box-shadow: var(--shadow-xs); }
.ws-brand { display: flex; align-items: center; gap: 0.7rem; color: var(--text); min-width: 0; }
.ws-brand:hover { text-decoration: none; color: var(--text); }
.ws-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.ws-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-product { font-size: 0.75rem; color: var(--muted); }
.ws-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.ws-nav {
  position: sticky; top: var(--topbar-h); align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 1rem 0.75rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.ws-main { padding: 2rem 2.25rem 4rem; max-width: 1200px; width: 100%; }

.app-grid { list-style: none; margin: 0 0 1.75rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.app-tile {
  display: flex; flex-direction: column; height: 100%;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.app-tile:hover { text-decoration: none; color: var(--text); border-color: #b5cdf2; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.app-tile-name { margin-top: 1rem; font-weight: 650; font-size: 1.02rem; }
.app-tile-desc { margin-top: 0.3rem; color: var(--muted); font-size: 0.88rem; flex: 1; }
.app-tile-open { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 1rem; color: var(--accent); font-weight: 600; font-size: 0.875rem; }
.app-tile-open .icon { transition: transform 0.15s; }
.app-tile:hover .app-tile-open .icon { transform: translateX(3px); }

.app-icon {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
}
.app-icon .icon { width: 24px; height: 24px; }
.app-icon-sm { width: 34px; height: 34px; border-radius: 9px; }
.app-icon-sm .icon { width: 19px; height: 19px; }
.app-icon-lg { width: 56px; height: 56px; border-radius: 14px; }
.app-icon-lg .icon { width: 30px; height: 30px; }

.summary-strip {
  display: flex; flex-wrap: wrap; gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.summary-item { flex: 1 1 160px; display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; padding: 1rem 1.25rem; border-left: 1px solid var(--border); }
.summary-item:first-child { border-left: 0; }
.summary-label { color: var(--muted); font-size: 0.8rem; font-weight: 550; }
.summary-value { font-weight: 650; font-size: 1.05rem; color: var(--text); }

.app-header { align-items: center; justify-content: flex-start; flex-wrap: nowrap; }
.app-preview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 1.25rem; }
.check-list { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.check-list li { display: flex; gap: 0.65rem; align-items: flex-start; color: var(--text-2); }
.check-list .icon { color: var(--ok); margin-top: 0.15em; }

.mock { padding: 0; overflow: hidden; }
.mock span { display: block; background: var(--neutral-bg); border-radius: 5px; }
.mock-toolbar { display: flex; gap: 0.5rem; padding: 0.75rem; border-bottom: 1px solid var(--border); }
.mock-toolbar span { width: 56px; height: 22px; }
.mock-toolbar .mock-grow { flex: 1; background: transparent; }
.mock-body { display: grid; grid-template-columns: 110px 1fr; min-height: 220px; }
.mock-side { display: flex; flex-direction: column; gap: 0.55rem; padding: 0.85rem; border-right: 1px solid var(--border); }
.mock-side span { height: 12px; }
.mock-side span:nth-child(2n) { width: 70%; }
.mock-canvas { padding: 1rem; display: flex; }
.mock-canvas svg { width: 100%; height: 100%; min-height: 180px; }
.mock-area { fill: var(--accent-softer); }
.mock-line { fill: none; stroke: #b5cdf2; stroke-width: 2; vector-effect: non-scaling-stroke; }

/* ---------- Console shell ---------- */
.console {
  display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh;
  /* Paint the sidebar color down the full page height, past the sticky column. */
  background: linear-gradient(90deg, var(--console-side) 252px, transparent 252px);
}
.console-side {
  position: sticky; top: 0; align-self: start;
  display: flex; flex-direction: column;
  height: 100vh;
  padding: 1rem 0.85rem;
  background: var(--console-side);
  color: var(--console-ink);
}
.console-brand { color: var(--console-ink-strong); padding: 0.3rem 0.5rem 1.25rem; }
.console-brand:hover { color: var(--console-ink-strong); }
.console-tag {
  margin-left: 0.15rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(143, 179, 242, 0.16);
  color: #b7cdf7;
  font-size: 0.68rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
}
.console-nav .nav-item { color: var(--console-ink); }
.console-nav .nav-item > .icon { color: var(--console-muted); }
.console-nav .nav-item:hover { background: var(--console-side-2); color: var(--console-ink-strong); }
.console-nav .nav-item[aria-current="page"] { background: var(--console-side-2); color: var(--console-ink-strong); }
.console-nav .nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -0.85rem; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--console-focus);
}
.console-nav .nav-item[aria-current="page"] > .icon { color: var(--console-focus); }
.console-side :focus-visible { outline-color: var(--console-focus); }
.console-side-foot { margin-top: auto; padding: 0.75rem 0.5rem 0; border-top: 1px solid var(--console-side-2); color: var(--console-muted); font-size: 0.78rem; }
.console-body { min-width: 0; display: flex; flex-direction: column; }
.console-context { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.875rem; font-weight: 550; }
.console-context .icon { color: var(--accent); }
.console-main { padding: 2rem 2.25rem 4rem; max-width: 1320px; width: 100%; }

/* ---------- Console pages ---------- */
.toggle-list { list-style: none; margin: 0; padding: 0; }
.toggle-list li + li { border-top: 1px solid var(--border); }
.toggle-row { display: flex; align-items: center; gap: 0.85rem; padding: 0.8rem 0; cursor: pointer; }
.toggle-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.toggle-name { font-weight: 600; color: var(--text); font-size: 0.925rem; }
.toggle-sub { color: var(--muted); font-size: 0.8rem; }

.role-defaults { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); }
.role-defaults strong { color: var(--text-2); font-weight: 600; margin-right: 0.35rem; }

.catalog { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.catalog-item { display: flex; flex-direction: column; }
.catalog-head { display: flex; gap: 0.9rem; align-items: center; }
.catalog-desc { margin: 1rem 0; color: var(--text-2); font-size: 0.9rem; flex: 1; }
.catalog-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.usage { flex: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.usage-label { font-size: 0.82rem; color: var(--muted); font-weight: 550; }
.meter {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 6px; border: 0; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  overflow: hidden;
}
.meter::-webkit-progress-bar { background: var(--accent-soft); border-radius: 999px; }
.meter::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.meter::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* ---------- Sign-up confirmation, capacity, outbox ---------- */
.auth-card > .empty-icon { margin-bottom: 1.25rem; }
.steps { list-style: none; margin: 0 0 1.75rem; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.steps li { display: flex; align-items: center; gap: 0.75rem; color: var(--text-2); font-size: 0.925rem; }
.step-num {
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 0.8rem; font-weight: 700;
}
.empty-hint { margin-top: 1rem; }
.copy-field { display: flex; gap: 0.4rem; align-items: center; min-width: 320px; }
.copy-field input { min-height: 32px; font-family: var(--mono); font-size: 0.78rem; padding: 0.3rem 0.5rem; }
.mail-body { margin-top: 0.3rem; }
.mail-body summary { cursor: pointer; color: var(--accent); font-size: 0.82rem; }
.mail-body pre {
  margin: 0.5rem 0 0; padding: 0.75rem; max-width: 46ch;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 0.78rem; white-space: pre-wrap; word-break: break-all;
}

.badge-pending { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.capacity-card { margin-bottom: 1.5rem; padding: 0; }
.capacity-main { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; padding: 1.25rem; flex-wrap: wrap; }
.capacity-text { flex: 1 1 320px; display: flex; flex-direction: column; gap: 0.5rem; }
.capacity-figure { font-size: 1.85rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.capacity-pending { font-size: 1rem; font-weight: 500; color: var(--muted); }
.capacity-text .meter { height: 8px; max-width: 420px; }
.cap-form { display: flex; flex-direction: column; gap: 0.35rem; }
.cap-form label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.cap-fields { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.cap-fields input { width: 8rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.6rem 1.25rem; margin: 1rem 0 0; font-size: 0.9rem; }
.facts dt { color: var(--muted); font-weight: 550; }
.facts dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

.card .form { margin-top: 1rem; }
/* Tenant page: members get the full width so every column fits; the
   application toggles sit below in two columns. */
.tenant-sections { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 1.5rem; }
.tenant-sections > .table-card { margin-bottom: 0; }
@media (min-width: 900px) {
  .tenant-sections .toggle-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 2rem; }
  .tenant-sections .toggle-list li + li { border-top: 0; }
  .tenant-sections .toggle-list li { border-bottom: 1px solid var(--border); }
  .tenant-sections .card-foot .btn-block { width: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main-side, .app-preview { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-brand-compact { display: inline-flex; }

  .ws-layout { grid-template-columns: 1fr; }
  .ws-nav {
    position: sticky; top: var(--topbar-h); z-index: 10;
    height: auto; flex-direction: row; align-items: center; overflow-x: auto;
    padding: 0.5rem 0.75rem;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .ws-nav .nav-label { display: none; }
  .ws-main, .console-main { padding: 1.5rem 1rem 3rem; }

  .console { grid-template-columns: 1fr; background: none; }
  .console-side { position: static; height: auto; flex-direction: row; align-items: center; gap: 0.5rem; padding: 0.6rem 0.75rem; overflow-x: auto; }
  .console-brand { padding: 0 0.5rem 0 0; }
  .console-nav { flex-direction: row; }
  .console-nav .nav-item[aria-current="page"]::before { display: none; }
  .console-side-foot { display: none; }

  .form-grid { grid-template-columns: 1fr; }
  .kpis-compact { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}

@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
  .entity-head { align-items: flex-start; }
  .tenant-mark-xl { width: 44px; height: 44px; font-size: 0.95rem; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
  .summary-item { border-left: 0; border-top: 1px solid var(--border); }
  .summary-item:first-child { border-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (forced-colors: active) {
  .badge, .btn, .switch { border: 1px solid CanvasText; }
  .chart-bar { fill: Highlight; }
}
