:root {
  --ink: #101820;
  --ink-2: #263443;
  --muted: #667587;
  --line: #d8e0e8;
  --soft-line: #e9eef3;
  --canvas: #f4f7fa;
  --panel: #ffffff;
  --rail: #07111c;
  --rail-2: #111c29;
  --accent: #1d6b99;
  --accent-2: #2f8bc3;
  --green: #177245;
  --amber: #946200;
  --red: #b3261e;
  --violet: #6941c6;
  --focus: rgba(29,107,153,.22);
  --shadow: 0 1px 2px rgba(16,24,32,.06);
  --shadow-lg: 0 18px 46px rgba(16,24,32,.11);
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .48; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}
h1, h2, h3, p { margin-top: 0; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 282px minmax(0,1fr);
}
.side-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  padding: 18px 14px;
  color: #eef5fa;
  background: linear-gradient(180deg, var(--rail), var(--rail-2));
}
.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #f2f7fb;
  color: #102436;
  font-weight: 900;
}
.brand-block strong, .tenant-card strong { display: block; font-size: 14px; }
.brand-block small, .tenant-card small { color: #aebbc8; font-size: 11px; }
nav { display: grid; gap: 4px; align-content: start; }
.nav-item {
  min-height: 42px;
  display: grid;
  grid-template-columns: 30px minmax(0,1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #d9e4ed;
  background: transparent;
  text-align: left;
}
.nav-item span:first-child {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255,255,255,.08);
  font-size: 10px;
  font-weight: 900;
}
.nav-item:hover { background: rgba(255,255,255,.07); }
.nav-item.active {
  color: #0f2538;
  background: #f4f8fb;
}
.nav-item.active span:first-child {
  color: var(--accent);
  background: #dcebf5;
}
.tenant-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  background: rgba(255,255,255,.06);
}
.tenant-card > span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #28b878;
  box-shadow: 0 0 0 4px rgba(40,184,120,.15);
}
.workspace { min-width: 0; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}
h1 { margin-bottom: 0; font-size: 24px; line-height: 1.15; }
h2 { margin-bottom: 10px; font-size: 16px; }
h3 { margin-bottom: 7px; font-size: 13px; }
.topbar-actions, .toolbar, .filter-group, .selection-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}
.primary, .secondary, .ghost {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 800;
}
.primary { color: white; background: var(--accent); box-shadow: var(--shadow); }
.primary:hover { background: #155477; }
.secondary { color: var(--ink-2); background: white; border-color: var(--line); box-shadow: var(--shadow); }
.secondary:hover { background: #f8fafc; }
.secondary.compact { min-height: 30px; padding: 0 10px; font-size: 12px; }
.secondary.danger { color: var(--red); }
.ghost { color: var(--accent); background: transparent; padding: 0 4px; }
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.content { min-width: 0; padding: 22px 28px 36px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.cols-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.cols-4 { grid-template-columns: repeat(4,minmax(0,1fr)); }
.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel + .panel, .section-gap { margin-top: 14px; }
.command-strip {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  border-top: 3px solid var(--accent);
}
.command-strip h2 { margin-bottom: 6px; font-size: 20px; }
.command-strip small { display: block; max-width: 820px; color: var(--muted); line-height: 1.45; }
.command-actions { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 7px; }
.customer-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  margin-bottom: 14px;
  padding: 20px;
  border: 1px solid #cbdde9;
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(231,241,248,.92), rgba(255,255,255,.96) 58%),
    #ffffff;
  box-shadow: var(--shadow);
}
.customer-hero h2 {
  margin-bottom: 6px;
  font-size: 22px;
}
.customer-hero small {
  display: block;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.45;
}
.customer-hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}
.billing-hero { border-left-color: var(--green); }
.support-hero { border-left-color: var(--violet); }
.setup-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 10px;
}
.setup-grid .workbench-item {
  min-height: 128px;
  grid-template-columns: 32px minmax(0,1fr);
  align-content: start;
}
.setup-grid .workbench-item .badge {
  grid-column: 2;
  justify-self: start;
}
.toolbar-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.download-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 9px;
}
.download-card {
  min-height: 86px;
  display: grid;
  gap: 5px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--ink);
  text-decoration: none;
}
.download-card:hover {
  border-color: #b8cfdf;
  background: #f1f7fb;
}
.download-card strong { font-size: 13px; }
.download-card small {
  color: var(--muted);
  line-height: 1.35;
}
.package-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 12px;
}
.package-card {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 224px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}
.package-card strong { font-size: 16px; }
.package-card span {
  color: var(--accent);
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}
.package-card small,
.package-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}
.package-card button { margin-top: auto; }
.referral-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: #fbfcfd;
}
.referral-box strong,
.referral-box small { display: block; }
.referral-box small {
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.payment-qr-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.payment-qr {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: #fbfcfd;
}
.payment-qr img {
  width: min(220px, 100%);
  height: auto;
}
.metric {
  display: grid;
  gap: 7px;
  border-top: 3px solid #d7e8f4;
}
.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.metric strong { font-size: 30px; line-height: 1; }
.metric small { color: var(--muted); line-height: 1.35; }
.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--soft-line);
}
.status-row:last-child { border-bottom: 0; }
.status-row strong, .status-row small { display: block; }
.status-row small { margin-top: 3px; color: var(--muted); line-height: 1.35; }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge.healthy, .badge.active, .badge.paid, .badge.allowed, .badge.business { color: var(--green); background: #e8f5ee; border-color: #bfdecf; }
.badge.warning, .badge.trial, .badge.degraded, .badge.review { color: var(--amber); background: #fff5dc; border-color: #ead49a; }
.badge.blocked, .badge.revoked, .badge.failed, .badge.overdue { color: var(--red); background: #fdeceb; border-color: #f2c3bf; }
.badge.enterprise, .badge.policy, .badge.gateway, .badge.mfa { color: var(--accent); background: #e7f1f8; border-color: #c5dceb; }
.badge.neutral { color: #536273; background: #f0f3f6; border-color: #d9e0e7; }
.table {
  width: 100%;
  table-layout: fixed;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
.table th {
  text-align: left;
  color: #536273;
  background: #f7f9fb;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.table th, .table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--soft-line);
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.table th:first-child:has(input),
.table td:first-child:has(input) {
  width: 42px;
  text-align: center;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table td { color: var(--ink-2); font-size: 13px; }
.table tbody tr:hover td { background: #fafcff; }
.table tbody tr.selected-row td { background: #eef7fc; }
.table strong, .table small { display: block; }
.table small { margin-top: 3px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}
.toolbar h2 { margin-bottom: 0; }
.input, select, textarea {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: white;
}
textarea { width: 100%; min-height: 86px; resize: vertical; }
.workbench { display: grid; gap: 10px; }
.workbench-item {
  display: grid;
  grid-template-columns: 32px minmax(0,1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: #fbfcfd;
}
.workbench-item > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--accent);
  background: #e7f1f8;
  font-weight: 900;
}
.workbench-item strong, .workbench-item small { display: block; }
.workbench-item small { margin-top: 2px; color: var(--muted); line-height: 1.35; }
.map {
  min-height: 420px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(#edf2f6 1px, transparent 1px),
    linear-gradient(90deg, #edf2f6 1px, transparent 1px),
    #f8fafc;
  background-size: 28px 28px;
  overflow: hidden;
}
.region {
  position: absolute;
  min-width: 148px;
  padding: 11px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow-lg);
}
.region strong, .region small { display: block; }
.region small { margin-top: 4px; color: var(--muted); }
.policy-builder {
  display: grid;
  grid-template-columns: 260px minmax(0,1fr);
  gap: 14px;
}
.policy-list {
  display: grid;
  gap: 8px;
  align-content: start;
}
.policy-pill {
  width: 100%;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  text-align: left;
}
.policy-pill.active { border-color: #b8cfdf; background: #eef7fc; }
.policy-pill strong, .policy-pill small { display: block; }
.policy-pill small { margin-top: 3px; color: var(--muted); }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
}
.form-grid label, .field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.auth-panel {
  max-width: 980px;
}
.inline-actions {
  padding: 0;
  border: 0;
  background: transparent;
}
.plan-option {
  display: grid;
  gap: 7px;
  min-height: 136px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--ink);
  cursor: pointer;
}
.plan-option.active,
.plan-option:has(input:checked) {
  border-color: #8ebcd7;
  background: #eef7fc;
}
.plan-option input { width: auto; }
.plan-option strong { font-size: 16px; }
.plan-option span { color: var(--accent); font-weight: 900; }
.plan-option small { color: var(--muted); line-height: 1.4; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8,18,28,.46);
  z-index: 40;
}
.modal {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: 0 24px 70px rgba(8,24,38,.24);
}
.modal-header, .modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: #fbfcfd;
}
.modal-header { border-bottom: 1px solid var(--line); align-items: flex-start; }
.modal-actions { justify-content: flex-end; border-top: 1px solid var(--line); }
.modal-header h2 { margin: 0 0 4px; }
.modal-header p { margin: 0; color: var(--muted); line-height: 1.35; }
.modal-body { padding: 18px 20px; }
.qr-modal { width: min(520px, 100%); }
.qr-body {
  display: grid;
  place-items: center;
}
.qr-body img {
  width: min(360px, 78vw);
  height: auto;
  image-rendering: pixelated;
}
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: white;
  background: #132536;
  box-shadow: 0 14px 34px rgba(8,24,38,.2);
  z-index: 60;
}
.timeline { display: grid; gap: 0; }
.event {
  display: grid;
  grid-template-columns: 92px minmax(0,1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--soft-line);
}
.event:last-child { border-bottom: 0; }
.event time { color: var(--muted); font-size: 12px; font-weight: 900; }
.event strong, .event small { display: block; }
.event small { margin-top: 3px; color: var(--muted); line-height: 1.35; }
.empty-state {
  padding: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .cols-4, .cols-3, .cols-2, .policy-builder, .setup-grid, .package-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .side-rail { position: static; height: auto; }
  .topbar, .toolbar, .topbar-actions, .filter-group, .command-strip, .customer-hero, .customer-hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .form-grid { grid-template-columns: 1fr; }
  .download-grid { grid-template-columns: 1fr; }
  .payment-qr-grid { grid-template-columns: 1fr; }
  .referral-box {
    align-items: stretch;
    flex-direction: column;
  }
  .workbench-item { grid-template-columns: 32px minmax(0,1fr); }
  .workbench-item .badge { grid-column: 2; justify-self: start; }
}
