/*
  Control-room design direction (build spec §6.4): this is a diagnostic tool used by
  facility/security staff, often live on the phone. Scanability over visual impact,
  density is a feature, legible at 1280x720. Dark, high-contrast, no thin light-grey
  type. The chain metaphor (person -> group -> zone -> door) is the one place we spend
  a boldness budget.
*/

:root {
  --bg: #0b1220;
  --bg-raised: #101a2e;
  --bg-raised-2: #16223b;
  --border: #263551;
  --border-soft: #1c2941;
  --text: #e7ecf7;
  --text-dim: #9fb0cc;
  --text-faint: #6c7ea3;
  --accent: #47c2ff;
  --accent-dim: #1e5a7a;
  --good: #43d692;
  --good-dim: #123a2c;
  --warn: #f5b942;
  --warn-dim: #4a3712;
  --bad: #ff6b6b;
  --bad-dim: #4a1a1a;
  --focus-ring: #ffd35c;
  --radius: 6px;
  --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", Menlo, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/*
  The HTML `hidden` attribute must always win over any `display:` an author rule sets
  further down this file (e.g. `.matrix-pane { display: flex }`) — without this,
  author-origin rules with equal specificity beat the UA stylesheet's `[hidden]`
  default, and JS toggling `el.hidden = true` silently stops hiding the element.
*/
[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}

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

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

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

/* ── Top bar ─────────────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 18px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.topbar-mark {
  display: block;
  width: 32px;
  height: 22px;
  object-fit: contain;
  /* The source asset already bakes in a light backdrop, but the dark topbar cuts
     right up against the image's square edges without this — a chip with a little
     breathing room reads as a badge instead of a jarring rectangle. */
  background: #ededeb;
  border-radius: 4px;
  padding: 2px;
  box-sizing: border-box;
}

.topbar-title {
  font-size: 15px;
}

/* Lives in the topbar so it stays reachable no matter which pane (search results,
   report, or the full-width matrix) is currently showing — it used to sit inside
   .search-pane and vanished along with it in Matrix mode. */
.search-mode {
  display: flex;
  gap: 4px;
}

.mode-btn {
  padding: 6px 12px;
  font-size: 12px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.mode-btn.is-active {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent);
}

.partition-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.partition-bar select {
  background: var(--bg-raised-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
}

.conn-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.conn-status.is-down {
  color: var(--bad);
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.account-link {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

.account-link:hover {
  text-decoration: underline;
}

/* ── Login / admin pages ─────────────────────────────────────────────────────── */

.login-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  padding: 24px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login-brand {
  margin-bottom: 10px;
}

.login-card label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.login-card input {
  padding: 8px 10px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login-card button[type="submit"] {
  margin-top: 10px;
  padding: 9px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
}

.login-card button[type="submit"]:hover:not(:disabled) {
  filter: brightness(1.1);
}

.login-card button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-error {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--bad);
}

/* ── Admin: manage users ─────────────────────────────────────────────────────── */

.admin-pane {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 22px 60px;
}

.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  margin-top: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
}

.admin-table thead th {
  background: var(--bg-raised);
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table tbody tr:nth-child(even) td {
  background: var(--bg-raised-2);
}

.admin-table tbody tr:nth-child(odd) td {
  background: var(--bg-raised);
}

.admin-table button,
.admin-table select {
  font-size: 12px;
  padding: 3px 7px;
  background: var(--bg-raised-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.admin-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
}

.admin-form input,
.admin-form select {
  padding: 7px 9px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.admin-form button {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  cursor: pointer;
}

/* ── Admin: setup (connection + license) ────────────────────────────────────── */

.admin-section {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

.admin-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
}

.admin-form-stacked {
  flex-direction: column;
  align-items: stretch;
}

.admin-form-stacked label {
  width: 100%;
}

.admin-form-stacked textarea {
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  resize: vertical;
}

.admin-form-actions {
  display: flex;
  gap: 8px;
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  height: calc(100vh - 45px);
  min-height: 500px;
}

.search-pane {
  border-right: 1px solid var(--border);
  background: var(--bg-raised);
  padding: 14px;
  overflow-y: auto;
}

.search-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#searchInput {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#searchInput::placeholder {
  color: var(--text-faint);
}

.hint {
  color: var(--text-faint);
  font-size: 12px;
  margin: 10px 2px 0;
}

/* Spinner: a plain rotating ring built from a border, not an image or icon font, so
   it works air-gapped and themes with currentColor like everything else here. */
.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -0.15em;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.6s;
  }
}

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-dim);
}

/* Larger variant used where a whole pane/table is waiting on a fetch that can
   genuinely take several seconds (e.g. the access matrix's multi-path filter
   against a large partition) — a lone "Loading…" label there reads as frozen. */
.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 16px;
  color: var(--text-dim);
  font-size: 13px;
}

.loading-block .spinner {
  width: 1.3em;
  height: 1.3em;
  border-width: 3px;
  color: var(--accent);
}

.search-results {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
}

.search-result:hover {
  background: var(--bg-raised-2);
}

.search-result.is-active {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.result-name {
  font-weight: 600;
  font-size: 13.5px;
}

.result-meta {
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--bg-raised-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.pill.status-active { color: var(--good); border-color: var(--good-dim); background: var(--good-dim); }
.pill.status-inactive { color: var(--bad); border-color: var(--bad-dim); background: var(--bad-dim); }

/* ── Welcome / report panes ─────────────────────────────────────────────────── */

.welcome-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-dim);
  padding: 40px;
}

.welcome-pane p {
  max-width: 42ch;
  margin: 4px 0;
}

.welcome-sub {
  font-size: 13px;
  color: var(--text-faint);
}

.report-pane {
  overflow-y: auto;
  padding: 18px 22px 40px;
}

.subject-card {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}

.subject-name {
  font-size: 20px;
  font-weight: 700;
}

.subject-meta {
  font-size: 12.5px;
  color: var(--text-dim);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.subject-meta code {
  font-family: var(--mono);
  color: var(--text-faint);
}

.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.summary-counts {
  display: flex;
  gap: 14px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.summary-counts b {
  color: var(--text);
  font-family: var(--mono);
}

.expired-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.muted-count {
  color: var(--text-faint);
  font-family: var(--mono);
}

.empty-state {
  color: var(--text-dim);
  font-size: 14px;
  padding: 30px 4px;
}

/* ── Lock groups / rows ─────────────────────────────────────────────────────── */

.group-block {
  margin-bottom: 22px;
}

.group-heading {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin: 0 0 6px 2px;
}

.lock-list {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.lock-row {
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-raised);
}

.lock-row:last-child {
  border-bottom: none;
}

.lock-row.is-muted {
  opacity: 0.55;
}

.lock-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
}

.lock-row-head:hover {
  background: var(--bg-raised-2);
}

.lock-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  flex: none;
}

.lock-row.is-muted .lock-status-dot {
  background: var(--text-faint);
}

.lock-name-block {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.lock-name {
  font-weight: 600;
  font-size: 13.5px;
}

.lock-desc {
  color: var(--text-faint);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.path-kind-icons {
  display: flex;
  gap: 4px;
  flex: none;
}

.kind-chip {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-raised-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.count-badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  flex: none;
}

.expand-caret {
  flex: none;
  color: var(--text-faint);
  transition: transform 0.12s ease;
  font-size: 11px;
}

.lock-row.is-expanded .expand-caret {
  transform: rotate(90deg);
}

.lock-row-body {
  padding: 4px 12px 12px 30px;
}

.lock-row-inline {
  padding: 0 12px 10px 30px;
}

/* ── Chain rendering — the signature element ────────────────────────────────── */

.chain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chain {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  font-size: 13px;
}

.chain.is-expired {
  opacity: 0.55;
  border-style: dashed;
}

.chain-node {
  font-weight: 600;
}

.chain-node.node-User { color: var(--accent); }
.chain-node.node-Group { color: #c792ea; }
.chain-node.node-Zone { color: var(--warn); }
.chain-node.node-Lock { color: var(--good); }

.chain-arrow {
  color: var(--text-faint);
  font-size: 12px;
}

.chain-kind {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 4px;
}

.chain-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 2px;
  font-size: 11.5px;
  font-family: var(--mono);
}

.chain-status {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.chain-status.is-active { color: var(--good); }
.chain-status.is-expired-status { color: var(--bad); }

.chain-window {
  color: var(--text-dim);
}

.chain-optional {
  color: var(--text-faint);
  font-style: italic;
}

/* ── Matrix view ─────────────────────────────────────────────────────────────── */

.matrix-pane {
  /* Spans the full width of the layout grid rather than sitting in the narrower
     content column beside the search sidebar — the search-pane is hidden while in
     matrix mode, so there is no reason to leave that width unused. */
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 18px 22px 16px;
}

.matrix-partition-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  flex: none;
}

.matrix-partition-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.matrix-partition-field select {
  background: var(--bg-raised-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
}

.matrix-partition-hint {
  margin: 0;
  flex: 1;
  min-width: 220px;
}

.matrix-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  flex: none;
}

.matrix-subject {
  font-size: 15px;
  font-weight: 600;
}

.matrix-subject .matrix-subject-count {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 12.5px;
  margin-left: 8px;
}

.matrix-legend {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  display: inline-block;
}

.swatch-single { background: var(--good); }
.swatch-multi { background: var(--warn); }

.matrix-pagers {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  flex: none;
}

.matrix-pager {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.pager-label {
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 2px;
}

.pager-btn {
  background: var(--bg-raised-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 24px;
  height: 24px;
  line-height: 1;
  cursor: pointer;
  font-size: 13px;
}

.pager-btn:hover:not(:disabled) {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.pager-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.pager-status {
  font-family: var(--mono);
  color: var(--text-dim);
  min-width: 4ch;
  text-align: center;
}

.pager-search {
  background: var(--bg-raised-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  width: 160px;
  margin-right: 4px;
}

.pager-search::placeholder {
  color: var(--text-faint);
}

.pager-page-input {
  background: var(--bg-raised-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 4.5ch;
  padding: 3px 4px;
  font-size: 12px;
  font-family: var(--mono);
  text-align: center;
  /* Hide the native spinner — Prev/Next already cover single-step navigation, this
     input is for typing/pasting a specific page number. */
  appearance: textfield;
  -moz-appearance: textfield;
}

.pager-page-input::-webkit-outer-spin-button,
.pager-page-input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.matrix-key-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  margin-left: auto;
}

.matrix-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.matrix-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

/* Row header column — frozen on horizontal scroll. */
.matrix-table th.matrix-row-head {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-raised);
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 5px 10px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Column header row — frozen on vertical scroll, text rotated -90deg per spec. */
.matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
  vertical-align: bottom;
  padding: 0;
  height: 150px;
  min-width: 26px;
  max-width: 26px;
}

/* Corner cell — frozen on both axes, must sit above every other sticky cell. */
.matrix-table thead th.matrix-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 3;
  background: var(--bg-raised);
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.matrix-col-label {
  display: block;
  width: 26px;
  height: 148px;
  position: relative;
}

.matrix-col-label span {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform-origin: bottom left;
  transform: rotate(-90deg) translateX(0);
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-dim);
  padding-left: 2px;
}

.matrix-table tbody tr:nth-child(odd) td,
.matrix-table tbody tr:nth-child(odd) th.matrix-row-head {
  background: var(--bg-raised);
}
.matrix-table tbody tr:nth-child(even) td,
.matrix-table tbody tr:nth-child(even) th.matrix-row-head {
  background: var(--bg-raised-2);
}

.matrix-cell {
  width: 26px;
  height: 24px;
  min-width: 26px;
  max-width: 26px;
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 0;
  text-align: center;
}

.matrix-cell-btn {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  cursor: default;
  padding: 0;
  display: block;
}

.matrix-cell-btn.is-single {
  background: var(--good);
  cursor: pointer;
}

.matrix-cell-btn.is-multi {
  background: var(--warn);
  cursor: pointer;
}

.matrix-cell-btn.is-single:hover,
.matrix-cell-btn.is-multi:hover {
  filter: brightness(1.15);
}

.matrix-cell-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

/* ── Modal (matrix cell path detail) ────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}

.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}

.modal-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.modal-close:hover {
  background: var(--bg-raised-2);
  color: var(--text);
}

.modal-body {
  padding: 14px 16px 16px;
  overflow-y: auto;
}
