:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f1f5f9;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  width: 240px;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 58px;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
}

.brand strong { display: block; font-size: 0.92rem; }
.brand span { display: block; color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }

.mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-size: 0.84rem;
  font-weight: 850;
}

nav { display: grid; gap: 0.2rem; padding: 0.6rem; }
nav a {
  padding: 0.58rem 0.7rem;
  border-radius: 6px;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}
nav a:hover { background: var(--soft); color: var(--ink); }

.boundary-note {
  margin: auto 0.75rem 0.75rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.76rem;
}

.shell { margin-left: 240px; min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 58px;
  padding: 0.7rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

h1, h2, h3 { margin: 0; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1rem; }
h3 { font-size: 0.86rem; }

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.grid { display: grid; gap: 1rem; padding: 1rem 1.5rem 0; }
.grid.two { grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr); }
.wide { margin: 1rem 1.5rem 0; }

.panel {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-panel { border-color: rgba(37, 99, 235, 0.28); }
.panel-heading, .button-row { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; margin-bottom: 0.85rem; }
.button-row.compact { margin-bottom: 0; justify-content: flex-end; flex-wrap: wrap; }

.form-grid { display: grid; gap: 0.75rem; }
.form-grid.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

label { display: grid; gap: 0.35rem; margin-bottom: 0.75rem; color: var(--muted); font-size: 0.78rem; font-weight: 800; }
input, select, textarea {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.78rem; }

button {
  min-height: 2.25rem;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  cursor: pointer;
}
button:hover { background: var(--accent-strong); }
button:disabled { opacity: 0.58; cursor: wait; }
button.secondary { border: 1px solid var(--line); background: white; color: var(--ink); }
button.secondary:hover { background: var(--soft); }

.checkbox { display: flex; align-items: center; gap: 0.5rem; color: var(--ink); }
.checkbox input { width: auto; min-height: auto; }
.hint { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.78rem; }
.subtle-status { color: var(--muted); font-size: 0.76rem; font-weight: 800; white-space: nowrap; }

.status-strip { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 11rem; padding: 0.45rem 0.65rem; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--muted); font-size: 0.8rem; font-weight: 800; }
.dot { width: 0.62rem; height: 0.62rem; border-radius: 50%; background: #94a3b8; }
.dot.ok { background: var(--ok); }
.dot.error { background: var(--danger); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; margin-top: 0.8rem; }
.metric-grid div { padding: 0.75rem; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); }
.metric-grid strong, .metric-grid span { display: block; }
.metric-grid span { margin-top: 0.25rem; color: var(--muted); font-size: 0.78rem; }

.list, .cards { display: grid; gap: 0.55rem; margin-top: 0.85rem; }
.item { display: grid; gap: 0.28rem; padding: 0.7rem; border: 1px solid var(--line); border-radius: 6px; background: #fbfdff; }
.item-title { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; font-weight: 850; }
.item-meta { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.72rem; overflow-wrap: anywhere; }

code {
  padding: 0.08rem 0.28rem;
  border-radius: 4px;
  background: var(--soft);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.activation-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.25rem;
}
.activation-intro h2, .issuance-panel h2 { margin: 0; }
.tenant-picker { display: flex; align-items: end; gap: 0.6rem; min-width: min(100%, 34rem); }
.tenant-picker label { flex: 1; margin: 0; }
.activation-grid { align-items: start; }
.issuance-panel { min-width: 0; }
.activation-key-panel, .bundle-inspector-panel { margin: 1rem 1.5rem 0; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 1.5rem 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.information-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem; }
.information-card { padding: 0.75rem; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); }
.information-card p { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.78rem; }
.prerequisite-note { margin: 0.85rem 0 0; padding: 0.7rem; border-left: 3px solid var(--accent); background: #eff6ff; color: #1e3a8a; font-size: 0.78rem; }
.entitlement-intro { display: flex; align-items: end; justify-content: space-between; gap: 1.25rem; }
.entitlement-policy-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.entitlement-policy-card { padding: 0.8rem; border: 1px solid var(--line); border-radius: 7px; background: #fbfdff; }
.entitlement-policy-card.missing { border-style: dashed; background: var(--soft); }
.entitlement-policy-card .panel-heading { margin-bottom: 0.55rem; }
.entitlement-policy-card dl { margin-bottom: 0.65rem; }
.profile-selector { max-width: 22rem; }
.field-group-title { margin-top: 1rem; }
.field-group-hint { margin: 0.3rem 0 0.75rem; }
.entitlement-limit-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.entitlement-limit-grid label > span { color: var(--muted); font-size: 0.7rem; font-weight: 500; }
.entitlement-editor > button { margin-top: 0.9rem; }
.issuance-panel > button { margin-top: 0.9rem; }
.issuance-result {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.issuance-result.empty-state {
  min-height: 7rem;
  place-items: center;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  text-align: center;
}
.issuance-result.issuance-error { padding: 0.8rem; border: 1px solid #fecaca; border-radius: 7px; background: #fef2f2; color: #991b1b; }
.issuance-result.issuance-error p { margin: 0.35rem 0 0; font-size: 0.78rem; }
.result-status-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.48rem;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
}
.status-badge.good { background: #dcfce7; color: #166534; }
.status-badge.bad { background: #fee2e2; color: #991b1b; }
.metadata-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
}
.metadata-grid > div { min-width: 0; padding: 0.58rem; border: 1px solid var(--line); border-radius: 6px; background: #fbfdff; }
.metadata-grid dt { color: var(--muted); font-size: 0.68rem; font-weight: 850; text-transform: uppercase; letter-spacing: 0.04em; }
.metadata-grid dd { margin: 0.2rem 0 0; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.72rem; }
.secret-label { margin: 0; color: var(--danger); }
.token-value { min-height: 7rem; word-break: break-all; }
.result-actions { justify-content: flex-start; margin: 0; flex-wrap: wrap; }
.security-note { margin: 0; padding: 0.65rem; border-left: 3px solid var(--warn); background: #fffbeb; color: #92400e; font-size: 0.75rem; }
.bundle-profiles { display: grid; gap: 0.65rem; }
.bundle-profile { display: grid; gap: 0.55rem; padding: 0.7rem; border: 1px solid var(--line); border-radius: 7px; background: #fbfdff; }
.bundle-license { display: grid; gap: 0.32rem; padding-top: 0.55rem; border-top: 1px solid var(--line); }
.bundle-license > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.bundle-profile details, .artifact-details { font-size: 0.78rem; }
.bundle-profile summary, .artifact-details summary { cursor: pointer; color: var(--accent-strong); font-weight: 800; }
.artifact-details[open] { display: grid; gap: 0.65rem; }
.inline-json { max-height: 12rem; overflow: auto; margin: 0.5rem 0 0; padding: 0.65rem; border-radius: 6px; background: #0f172a; color: #e2e8f0; font-size: 0.72rem; }
.receipt-item .status-badge { flex: 0 0 auto; }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip { padding: 0.18rem 0.45rem; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-size: 0.72rem; font-weight: 850; }
.chip.no { background: #fee2e2; color: var(--danger); }
.chip.muted { background: var(--soft); color: var(--muted); }

.product-grid, .validity-grid, .catalog-grid { display: grid; gap: 0.55rem; margin-top: 0.6rem; }
.product-grid { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.validity-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.catalog-grid { grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.product-card, .validity-card, .catalog-card { padding: 0.7rem; border: 1px solid var(--line); border-radius: 6px; background: white; }
.product-card-title { font-size: 0.8rem; font-weight: 850; text-transform: capitalize; }
.validity-card.valid { border-color: rgba(22, 163, 74, 0.35); background: #f0fdf4; }
.validity-card.invalid { border-color: rgba(220, 38, 38, 0.35); background: #fef2f2; }

table { width: 100%; border-collapse: collapse; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; font-size: 0.84rem; }
th, td { padding: 0.62rem 0.7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--soft); color: var(--muted); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }

.api-result-panel { margin-bottom: 1.5rem; }
.log { max-height: 18rem; overflow: auto; margin: 0; padding: 0.85rem; border-radius: 6px; background: #0f172a; color: #e2e8f0; font-size: 0.78rem; line-height: 1.45; }

@media (max-width: 980px) {
  .sidebar { position: static; width: auto; }
  .shell { margin-left: 0; }
  nav { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
  .boundary-note { margin-top: 0.5rem; }
  .grid.two, .form-grid.three, .form-grid.two-cols, .metric-grid, .validity-grid, .metadata-grid, .information-grid, .entitlement-limit-grid, .entitlement-policy-list { grid-template-columns: 1fr; }
  .activation-intro, .entitlement-intro, .tenant-picker { align-items: stretch; flex-direction: column; min-width: 0; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .activation-key-panel, .bundle-inspector-panel, .section-heading { margin-inline: 1rem; }
  .wide { margin-inline: 1rem; }
  .grid { padding-inline: 1rem; }
}

/* ── Login gate ─────────────────────────────────────────────────────────── */
/* Access is gated: until authenticated the app chrome is hidden and only the
   login card shows. Toggled by `body.gated`. */
body.gated .sidebar,
body.gated .shell { display: none; }

.login-gate { display: none; }
body.gated .login-gate {
  display: flex;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.login-card h1 { margin: 0.25rem 0 0; font-size: 1.35rem; }
.login-card label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.login-card input {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
}
.login-card button {
  margin-top: 0.35rem;
  padding: 0.6rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { background: var(--accent-strong); }
.gate-error { min-height: 1.1rem; margin: 0; color: var(--danger); font-size: 0.85rem; }

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
button.danger:hover { background: var(--danger); color: #fff; }

/* ── Toasts ─────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
  max-width: min(420px, 90vw);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  line-height: 1.3;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }
.toast.info { background: var(--ink); }
.toast span { flex: 1; word-break: break-word; }
.toast-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  z-index: 900;
  padding: 1.5rem;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0; font-size: 1.15rem; }
.modal-card label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.modal-card input, .modal-card select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
}

/* ── App shell: topbar, profile menu, views, stats ──────────────────────── */
.topbar { display: flex; align-items: center; gap: 0.75rem; }
.topbar h1 { font-size: 1.05rem; margin: 0; }
.spacer { flex: 1; }

.profile { position: relative; }
.profile-trigger {
  display: flex; align-items: center; gap: 0.5rem;
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 0.25rem 0.7rem 0.25rem 0.3rem; cursor: pointer; color: var(--ink); font: inherit;
}
.profile-trigger:hover { background: var(--soft); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 0.8rem; font-weight: 600;
}
.profile-subject { font-size: 0.85rem; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--muted); font-size: 0.7rem; }
.profile-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  width: 300px; max-width: 90vw; padding: 0.85rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.profile-menu[hidden] { display: none; }
.profile-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.profile-name { font-family: ui-monospace, monospace; font-size: 0.85rem; margin: 0.15rem 0 0.4rem; word-break: break-all; }
.profile-meta { font-size: 0.75rem; color: var(--muted); margin: 0.5rem 0; }
.profile-caps { max-height: 9rem; overflow: auto; margin: 0.35rem 0; }
.profile-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.6rem; }
.chip.warn { background: #fef3c7; color: #92400e; }

.views { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.view { display: flex; flex-direction: column; gap: 1rem; }
.view[hidden] { display: none; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; }
.stat {
  display: flex; flex-direction: column; gap: 0.15rem; padding: 1rem 1.25rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.stat-num { font-size: 1.6rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; color: var(--muted); }
