/* Reusable components. */

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--card);
  --btn-fg: var(--text);
  --btn-border: var(--border);
  --btn-hover: var(--hover-strong);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--btn-bg) 100%, transparent);
  background-image: linear-gradient(var(--btn-hover), var(--btn-hover));
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  --btn-bg: var(--primary);
  --btn-fg: var(--on-primary);
  --btn-border: var(--primary);
  --btn-hover: transparent;
}

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

.btn--secondary {
  box-shadow: var(--shadow-sm);
}

.btn--ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
  --btn-fg: var(--text-body);
}

.btn--ghost:hover:not(:disabled) {
  color: var(--text);
}

.btn--danger {
  --btn-bg: var(--err);
  --btn-fg: #ffffff;
  --btn-border: var(--err);
  --btn-hover: #00000014;
}

.btn--danger-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--err-text);
  --btn-border: color-mix(in srgb, var(--err) 35%, transparent);
  --btn-hover: var(--err-bg);
}

.btn--sm {
  height: 30px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  gap: 6px;
}

.btn--xs {
  height: 24px;
  width: 24px;
  padding: 0;
}

.btn--icon {
  width: 36px;
  padding: 0;
}

.btn--icon.btn--sm {
  width: 30px;
}

.btn--block {
  width: 100%;
}

.btn--icon-end {
  flex-direction: row-reverse;
}

.btn.is-busy {
  color: transparent !important;
  pointer-events: none;
}

.btn.is-busy > * {
  visibility: hidden;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: var(--btn-fg);
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

.btn.is-done {
  color: var(--ok-text);
}

.btn.is-failed {
  color: var(--err-text);
}

/* ---------- Status pill ---------- */
.pill {
  --pill-fg: var(--idle-text);
  --pill-bg: var(--idle-bg);
  --pill-dot: var(--idle);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px 0 8px;
  border-radius: var(--radius-full);
  background: var(--pill-bg);
  color: var(--pill-fg);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--pill-dot) 22%, transparent);
}

.pill--sm {
  height: 22px;
  padding: 0 8px 0 7px;
}

.pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pill-dot);
  flex: none;
}

.pill--ok { --pill-fg: var(--ok-text); --pill-bg: var(--ok-bg); --pill-dot: var(--ok); }
.pill--error { --pill-fg: var(--err-text); --pill-bg: var(--err-bg); --pill-dot: var(--err); }
.pill--queued { --pill-fg: var(--warn-text); --pill-bg: var(--warn-bg); --pill-dot: var(--warn); }
.pill--running { --pill-fg: var(--run-text); --pill-bg: var(--run-bg); --pill-dot: var(--run); }
.pill--running .pill__dot { animation: pulse 1.6s infinite; }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface);
  color: var(--text-body);
  border: 1px solid var(--border);
}

.badge--primary { background: var(--primary-bg-soft); color: var(--primary-text); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.badge--ok { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.badge--error { background: var(--err-bg); color: var(--err-text); border-color: transparent; }
.badge--warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.badge--mono { font-family: var(--font-mono); font-weight: 500; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 4px 0 8px;
  border-radius: var(--radius-sm);
  background: var(--primary-bg-soft);
  color: var(--primary-text);
  font-size: var(--text-sm);
  font-weight: 500;
  max-width: 100%;
}

.chip__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip__remove {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font-size: 15px;
  line-height: 1;
}

.chip__remove:hover {
  background: var(--hover-strong);
}

/* ---------- Avatar ---------- */
.avatar {
  --avatar-hue: 220;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: hsl(var(--avatar-hue) 70% 92%);
  color: hsl(var(--avatar-hue) 55% 32%);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  object-fit: cover;
}

:root[data-theme="dark"] .avatar {
  background: hsl(var(--avatar-hue) 45% 24%);
  color: hsl(var(--avatar-hue) 80% 85%);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .avatar {
    background: hsl(var(--avatar-hue) 45% 24%);
    color: hsl(var(--avatar-hue) 80% 85%);
  }
}

.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--lg { width: 40px; height: 40px; font-size: var(--text-sm); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

.card__header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 2px;
}

.card__header--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.card__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
}

.card__title .icon {
  color: var(--muted);
}

.card__subtitle {
  color: var(--muted);
  font-size: var(--text-sm);
}

.card__footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-2);
}

/* ---------- Forms ---------- */
.form {
  display: grid;
  gap: var(--space-4);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.field__hint {
  font-size: var(--text-xs);
  color: var(--muted);
}

.form-error {
  color: var(--err-text);
  font-size: var(--text-sm);
  white-space: pre-line;
}

.input {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  font-size: var(--text-md);
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.input::placeholder {
  color: var(--muted-2);
}

.input:hover {
  border-color: var(--muted-2);
}

.input:focus,
.input:focus-visible {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: var(--focus-ring);
  border-radius: var(--radius);
}

.input:disabled {
  opacity: 0.6;
}

.input--mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.textarea {
  height: auto;
  padding: var(--space-2) var(--space-3);
  resize: vertical;
  line-height: 1.5;
}

.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.select--sm {
  height: 30px;
  width: auto;
  font-size: var(--text-sm);
}

input[type="date"].input {
  padding-right: var(--space-2);
}

.search-box {
  position: relative;
  min-width: 220px;
}

.search-box__icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  pointer-events: none;
}

.search-box__input {
  padding-left: 34px;
}

.search-box__input::-webkit-search-cancel-button {
  cursor: pointer;
}

/* Switch */
.switch {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  transition: background var(--duration) var(--ease);
}

.switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px #0f172a40;
  transition: transform var(--duration) var(--ease);
}

.switch[aria-checked="true"] {
  background: var(--primary);
}

.switch[aria-checked="true"] .switch__thumb {
  transform: translateX(16px);
}

.switch:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch:focus-visible {
  border-radius: var(--radius-full);
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-body);
  cursor: pointer;
  white-space: nowrap;
}

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.segmented__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 30px;
  height: 28px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}

.segmented__item:hover {
  color: var(--text);
}

.segmented__item[aria-checked="true"] {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

.segmented--sm .segmented__item {
  height: 24px;
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
}

/* Checkbox */
.checkbox {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
  flex: none;
}

.checkbox:disabled {
  cursor: not-allowed;
}

.check-list {
  display: grid;
  gap: 2px;
}

.check-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
}

.check-row:hover {
  background: var(--hover);
}

.check-row .checkbox {
  margin-top: 2px;
}

.check-row__text {
  display: grid;
  gap: 2px;
}

.check-row__label {
  color: var(--text);
  font-weight: 600;
}

.check-row__description {
  color: var(--muted);
  font-size: var(--text-sm);
}

/* Notices */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--primary-bg-soft);
  color: var(--primary-text);
  font-size: var(--text-sm);
}

.notice .icon {
  flex: none;
  margin-top: 2px;
}

.notice--subtle {
  background: var(--surface);
  color: var(--text-body);
}

/* ---------- Dialog ---------- */
.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--text-body);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: rise-in var(--duration) var(--ease);
}

.dialog:not([open]) {
  display: none;
}

.dialog::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(2px);
  animation: fade-in var(--duration) var(--ease);
}

.dialog.is-closing {
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 120ms var(--ease), transform 120ms var(--ease);
}

.dialog--sm { width: min(440px, calc(100vw - 32px)); }
.dialog--lg { width: min(760px, calc(100vw - 32px)); }

.dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-3);
}

.dialog__titles {
  display: grid;
  gap: var(--space-1);
}

.dialog__title {
  font-size: var(--text-lg);
}

.dialog__description {
  color: var(--muted);
  font-size: var(--text-sm);
}

.dialog__close {
  margin: -6px -8px 0 0;
}

.dialog__body {
  padding: var(--space-2) var(--space-5) var(--space-5);
  overflow: auto;
}

.dialog__lead {
  color: var(--text-body);
}

.dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--card-alt);
}

.confirm {
  display: grid;
  gap: var(--space-4);
}

.confirm__message {
  color: var(--text-body);
}

/* ---------- Drawer ---------- */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(920px, calc(100vw - 48px));
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--card);
  color: var(--text-body);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide-in var(--duration) var(--ease);
}

.drawer:not([open]) {
  display: none;
}

.drawer::backdrop {
  background: var(--overlay);
  animation: fade-in var(--duration) var(--ease);
}

.drawer.is-closing {
  transform: translateX(24px);
  opacity: 0;
  transition: transform 160ms var(--ease), opacity 160ms var(--ease);
}

.drawer--md { width: min(560px, calc(100vw - 48px)); }

.drawer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.drawer__titles {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.drawer__title {
  font-size: var(--text-lg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer__actions {
  display: flex;
  gap: var(--space-2);
  margin: -4px -8px 0 0;
}

.drawer__body {
  flex: 1;
  min-height: 0;
  padding: var(--space-4) var(--space-6) var(--space-6);
  display: flex;
  flex-direction: column;
}

.drawer__body > .log {
  flex: 1;
  min-height: 0;
}

.drawer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  color: var(--muted);
  font-size: var(--text-sm);
}

.drawer-meta__id {
  color: var(--muted-2);
  font-size: var(--text-xs);
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 100;
  display: grid;
  gap: var(--space-2);
  width: min(380px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  animation: rise-in var(--duration) var(--ease);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}

.toast--success { border-left-color: var(--ok); }
.toast--error { border-left-color: var(--err); }

.toast__icon {
  margin-top: 2px;
  color: var(--primary-text);
}

.toast--success .toast__icon { color: var(--ok-text); }
.toast--error .toast__icon { color: var(--err-text); }

.toast__content {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.toast__title {
  color: var(--text);
  font-weight: 600;
}

.toast__message {
  color: var(--text-body);
  font-size: var(--text-sm);
  white-space: pre-line;
}

.toast__close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
}

.toast__close:hover {
  background: var(--hover-strong);
  color: var(--text);
}

/* ---------- Table ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-md);
}

.table th {
  position: sticky;
  top: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--card-alt);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr {
  transition: background var(--duration-fast) var(--ease);
}

.table tbody tr:hover {
  background: var(--hover);
}

.table tr.is-clickable {
  cursor: pointer;
}

.table tr.is-running {
  background: color-mix(in srgb, var(--run-bg) 45%, transparent);
}

.table tr.is-error td:first-child {
  box-shadow: inset 3px 0 0 var(--err);
}

.table .align-end {
  text-align: right;
}

.table th:first-child,
.table td:first-child {
  padding-left: var(--space-5);
}

.table th:last-child,
.table td:last-child {
  padding-right: var(--space-5);
}

.table-empty {
  padding: var(--space-8) var(--space-4);
}

.cell-grow {
  width: 40%;
}

.cell-stack {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.cell-strong {
  color: var(--text);
  font-weight: 600;
}

.cell-sub {
  color: var(--muted);
  font-size: var(--text-sm);
}

code.cell-sub {
  font-size: var(--text-xs);
}

.cell-sub--accent {
  color: var(--ok-text);
  font-weight: 600;
}

.cell-email {
  color: var(--text-body);
  font-size: var(--text-sm);
}

.cell-detail {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-body);
  font-size: var(--text-sm);
}

.row-actions {
  display: inline-flex;
  justify-content: flex-end;
  gap: var(--space-1);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--card-alt);
  color: var(--muted);
  font-size: var(--text-sm);
}

.pagination__buttons {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pagination__page {
  font-variant-numeric: tabular-nums;
}

/* ---------- Empty state ---------- */
.empty {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-10) var(--space-6);
  text-align: center;
}

.empty--compact {
  padding: var(--space-6) var(--space-4);
}

.empty__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--primary-bg-soft);
  color: var(--primary-text);
}

.empty--compact .empty__icon {
  width: 40px;
  height: 40px;
}

.empty--error .empty__icon {
  background: var(--err-bg);
  color: var(--err-text);
}

.empty__title {
  color: var(--text);
  font-weight: 600;
}

.empty__message {
  max-width: 420px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.empty__action {
  margin-top: var(--space-3);
}

/* ---------- Skeletons ---------- */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface) 25%, var(--hover-strong) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton--line {
  height: 12px;
}

.skeleton--title {
  display: inline-block;
  width: 220px;
  height: 24px;
  vertical-align: middle;
}

.skeleton-stack {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-5);
}

.skeleton-card {
  display: grid;
  gap: var(--space-3);
  min-height: 112px;
}

.skeleton-table {
  display: grid;
}

.skeleton-table__row {
  display: grid;
  grid-template-columns: 2fr 1.4fr 1fr 0.8fr;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 42px;
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.tabs__tab:hover {
  color: var(--text);
}

.tabs__tab[aria-selected="true"] {
  color: var(--primary-text);
}

.tabs__tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: var(--space-2);
  right: var(--space-2);
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--primary);
}

.tabs__panel {
  padding-top: var(--space-5);
}

.tabs__panel:focus-visible {
  box-shadow: none;
}

/* ---------- Menu ---------- */
.menu-anchor {
  position: relative;
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  z-index: 50;
  min-width: 200px;
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  animation: rise-in var(--duration-fast) var(--ease);
}

.menu--end { right: 0; }
.menu--start { left: 0; }

.menu__header {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-1);
}

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: 34px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--text-md);
  text-align: left;
}

.menu__item:hover,
.menu__item:focus-visible {
  background: var(--hover-strong);
  box-shadow: none;
}

.menu__item--danger {
  color: var(--err-text);
}

.menu__label {
  flex: 1;
}

.menu__hint {
  color: var(--muted-2);
  font-size: var(--text-xs);
  font-weight: 600;
}

.menu__check {
  color: var(--primary-text);
}

.menu__separator {
  height: 1px;
  margin: var(--space-1) 0;
  background: var(--border);
}

.user-card {
  display: flex;
  gap: var(--space-3);
  min-width: 240px;
}

.user-card__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-card__name {
  color: var(--text);
  font-weight: 600;
}

.user-card__email {
  color: var(--muted);
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card__roles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

/* ---------- Picker ---------- */
.picker {
  position: relative;
  min-width: 0;
}

.picker__control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 5px var(--space-2) 5px 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--input-bg);
  cursor: text;
  position: relative;
}

.picker.is-open .picker__control,
.picker__control:focus-within {
  border-color: var(--primary-light);
  box-shadow: var(--focus-ring);
}

.picker__icon {
  position: absolute;
  left: 11px;
  top: 10px;
  color: var(--muted-2);
}

.picker__chips {
  display: contents;
}

.picker__input {
  flex: 1;
  width: 0;
  min-width: 80px;
  height: 24px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
}

.picker__input:focus-visible {
  box-shadow: none;
}

.picker__input::placeholder {
  color: var(--muted-2);
}

.picker--single.has-value .picker__input::placeholder {
  color: var(--text);
  font-weight: 500;
}

.picker__clear {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
}

.picker__clear:hover {
  background: var(--hover-strong);
}

.picker__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 260px;
  overflow: auto;
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-lg);
}

/* Inside a dialog the body clips overflowing content, so a floating list
   would be cut off: there the list takes its place in the flow and the
   dialog grows to show it. */
.dialog .picker__list {
  position: static;
  margin-top: 4px;
  max-height: min(260px, 40vh);
  box-shadow: none;
  scrollbar-gutter: stable;
}

.picker__option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.picker__option.is-active,
.picker__option:hover {
  background: var(--hover-strong);
}

.picker__check {
  display: grid;
  place-items: center;
  flex: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: #ffffff;
}

.picker--single .picker__check {
  border-radius: 50%;
}

.picker__check.is-on {
  background: var(--primary);
  border-color: var(--primary);
}

.picker__option-text {
  display: grid;
  min-width: 0;
}

.picker__option-label {
  color: var(--text);
  font-weight: 500;
}

.picker__option-hint {
  color: var(--muted);
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker__status {
  padding: var(--space-3);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ---------- Domains ---------- */
.domains {
  display: grid;
  gap: var(--space-2);
}

.domains--compact {
  gap: 6px;
}

.domains--compact .domains__item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  column-gap: var(--space-2);
  row-gap: 0;
}

.domains--compact .domains__meta {
  grid-column: 2;
  margin-top: -2px;
}

.domains__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  position: relative;
  z-index: 1;
}

.domains__lock {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
}

.domains__lock.is-secure {
  color: var(--ok-text);
  background: var(--ok-bg);
}

.domains__lock.is-insecure {
  color: var(--warn-text);
  background: var(--warn-bg);
}

.domains__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  color: var(--text);
  font-weight: 500;
}

.domains__host {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.domains__ext {
  flex: none;
  color: var(--muted-2);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease);
}

.domains__link:hover {
  color: var(--primary-text);
}

.domains__link:hover .domains__ext,
.domains__link:focus-visible .domains__ext {
  opacity: 1;
}

.domains__meta {
  flex: none;
  color: var(--muted);
  font-size: var(--text-xs);
}

.domains--compact .domains__link {
  font-size: var(--text-sm);
}

.domains__more,
.domains__none {
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ---------- Log viewer ---------- */
.log {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card);
}

.log__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--card-alt);
}

.log__toolbar-start,
.log__toolbar-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.log__label {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.log__search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
}

.log__search-icon {
  position: absolute;
  left: 9px;
  color: var(--muted-2);
  pointer-events: none;
}

.log__search-input {
  width: 200px;
  height: 30px;
  padding-left: 28px;
  font-size: var(--text-sm);
}

.log__counter {
  min-width: 40px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.log__tool[aria-pressed="true"] {
  background: var(--primary-bg-soft);
  color: var(--primary-text);
}

.log__scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--log-bg);
  color: var(--log-text);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.log__scroll:focus-visible {
  box-shadow: inset var(--focus-ring);
  border-radius: 0;
}

.log__content {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 100%;
  width: max-content;
  padding-bottom: var(--space-2);
}

.log.is-wrapped .log__content {
  position: static;
  width: auto;
}

.log__spacer {
  width: 1px;
}

.log__line {
  display: flex;
  height: 20px;
  line-height: 20px;
}

.log.is-wrapped .log__line {
  height: auto;
  min-height: 20px;
}

.log__line:hover {
  background: #ffffff08;
}

.log__line.is-current {
  background: var(--log-current);
}

.log__num {
  position: sticky;
  left: 0;
  flex: none;
  width: 56px;
  padding-right: var(--space-3);
  background: var(--log-gutter);
  color: var(--log-muted);
  text-align: right;
  user-select: none;
}

.log__text {
  padding: 0 var(--space-4) 0 var(--space-3);
  white-space: pre;
}

.log.is-wrapped .log__text {
  white-space: pre-wrap;
  word-break: break-word;
}

.log__line--err .log__text { color: var(--log-err); }
.log__line--warn .log__text { color: var(--log-warn); }
.log__line--ok .log__text { color: var(--log-ok); }

.log__text mark {
  background: var(--log-mark);
  color: inherit;
  border-radius: 2px;
}

.log__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  color: var(--log-muted);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  text-align: center;
}

.log__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  border-top: 1px solid var(--border);
  background: var(--card-alt);
  color: var(--muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

/* ---------- Env editor ---------- */
.env {
  display: grid;
  gap: var(--space-3);
}

.env__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.env__toolbar .search-box {
  width: 260px;
}

.env__count {
  color: var(--muted);
  font-size: var(--text-sm);
}

.env__toolbar-actions {
  margin-left: auto;
  display: flex;
  gap: var(--space-2);
}

.env__notices {
  display: grid;
  gap: var(--space-2);
}

.env__notices:empty {
  display: none;
}

.env__head,
.env__row {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(220px, 3fr) 104px;
  gap: var(--space-2);
  align-items: center;
}

.env__head {
  padding: 0 var(--space-2);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.env__rows {
  display: grid;
  gap: 6px;
}

.env__row {
  padding: 6px var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background var(--duration-fast) var(--ease);
}

.env__row:hover {
  background: var(--hover);
}

.env__row.is-new {
  background: color-mix(in srgb, var(--ok-bg) 55%, transparent);
  border-color: color-mix(in srgb, var(--ok) 25%, transparent);
}

.env__row.is-changed {
  background: color-mix(in srgb, var(--warn-bg) 55%, transparent);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
}

.env__key-input,
.env__value-input {
  border-color: transparent;
  background: transparent;
}

.env__row:hover .env__key-input,
.env__row:hover .env__value-input {
  border-color: var(--border-strong);
  background: var(--input-bg);
}

.env__value-input {
  border-color: var(--border);
  background: var(--input-bg);
}

.env__row.has-error .env__key-input {
  border-color: var(--err);
}

.env__key-text,
.env__value-text {
  display: block;
  min-width: 0;
  padding: 0 var(--space-1);
  color: var(--text);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.env__key-text {
  font-weight: 600;
}

.env__masked {
  padding: 0 var(--space-1);
  color: var(--muted-2);
  letter-spacing: 0.12em;
  user-select: none;
}

.env__cell--actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

.env__remove:hover {
  color: var(--err-text);
}

.env__error {
  grid-column: 1 / -1;
  padding-left: var(--space-1);
  font-size: var(--text-xs);
}

.env__footer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  margin: var(--space-2) calc(var(--space-5) * -1) calc(var(--space-5) * -1);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--card-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.env__dirty {
  margin-right: auto;
  color: var(--warn-text);
  font-size: var(--text-sm);
  font-weight: 600;
}

/* Diff review */
.diff {
  display: grid;
  gap: var(--space-4);
}

.diff__group {
  display: grid;
  gap: var(--space-2);
}

.diff__title {
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
}

.diff__list {
  display: grid;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.diff__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  font-size: var(--text-sm);
}

.diff__item--add { background: var(--ok-bg); color: var(--ok-text); }
.diff__item--remove { background: var(--err-bg); color: var(--err-text); }
.diff__item--change { background: var(--warn-bg); color: var(--warn-text); }

.diff__sign {
  width: 12px;
  font-family: var(--font-mono);
  font-weight: 700;
}

/* ---------- Permission matrix ---------- */
.matrix-wrap {
  overflow: auto;
  max-height: calc(100vh - 220px);
}

.matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-md);
}

.matrix th,
.matrix td {
  border-bottom: 1px solid var(--border);
}

.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--space-3) var(--space-3);
  background: var(--card-alt);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  vertical-align: bottom;
}

.matrix__perm-head {
  left: 0;
  z-index: 3 !important;
  text-align: left;
  min-width: 280px;
  color: var(--muted) !important;
  font-size: var(--text-xs) !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.matrix__role-head {
  min-width: 120px;
  text-align: center;
  vertical-align: middle !important;
}

.matrix__role-head .badge {
  margin-top: 4px;
  height: 18px;
  font-size: 10px;
}

.matrix__role-name {
  display: block;
}

.matrix__role-head.is-dirty .matrix__role-name::after {
  content: " •";
  color: var(--warn);
}

.matrix__perm {
  position: sticky;
  left: 0;
  z-index: 1;
  padding: var(--space-3) var(--space-5);
  background: var(--card);
  text-align: left;
  font-weight: 400;
}

.matrix__perm-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  column-gap: var(--space-2);
}

.matrix__perm-label {
  color: var(--text);
  font-weight: 600;
}

.matrix__perm-code {
  color: var(--muted-2);
  font-size: var(--text-xs);
  justify-self: start;
}

.matrix__perm-desc {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: var(--text-sm);
}

.matrix__group-row th,
.matrix__group-row td {
  background: var(--surface);
}

.matrix__group {
  position: sticky;
  left: 0;
  z-index: 1;
  padding: var(--space-2) var(--space-5);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

.matrix__projects-row .matrix__perm,
.matrix__projects-row td {
  background: var(--primary-bg-soft);
}

.matrix__cell {
  text-align: center;
  vertical-align: middle;
  padding: var(--space-2);
  transition: background var(--duration-fast) var(--ease);
}

.matrix__cell .checkbox {
  display: inline-block;
  width: 17px;
  height: 17px;
}

.matrix__cell.is-changed {
  background: var(--warn-bg) !important;
}

.matrix__row:hover th,
.matrix__row:hover td {
  background-color: color-mix(in srgb, var(--hover-strong) 100%, var(--card));
}

.matrix__row:hover .matrix__perm {
  background: var(--card-alt);
}

/* ---------- Save bar ---------- */
.savebar {
  position: sticky;
  bottom: var(--space-4);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  animation: rise-in var(--duration) var(--ease);
}

.savebar .icon {
  color: var(--warn);
}

.savebar__text {
  font-weight: 600;
}

.savebar__spacer {
  flex: 1;
}

/* ---------- Key/value lists ---------- */
.kv {
  display: grid;
  gap: 0;
}

.kv__row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: var(--space-3);
  align-items: center;
  min-height: 36px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.kv__row:last-child {
  border-bottom: 0;
}

.kv dt {
  color: var(--muted);
  font-size: var(--text-sm);
}

.kv dd {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.kv dd code {
  font-size: var(--text-sm);
}

.kv--inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
}

.kv--inline > div {
  display: grid;
  gap: 2px;
}

/* ---------- Environment tag ---------- */
.env-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-body);
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.env-tag[data-env="production"],
.env-tag[data-env="prod"] {
  background: var(--primary-bg-soft);
  color: var(--primary-text);
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
}

.env-tag[data-env="qa"],
.env-tag[data-env="staging"] {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: transparent;
}

.badge--super {
  margin-left: var(--space-2);
  height: 20px;
  padding: 0 6px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff;
  border-color: transparent;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

.input.is-invalid,
.input.is-invalid:focus {
  border-color: var(--err);
}

/* Global banner (e.g. platform unavailable) */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: var(--text-sm);
}

.banner .icon {
  flex: none;
  margin-top: 2px;
}

.banner__title {
  font-weight: 700;
}

.banner--error {
  border-color: color-mix(in srgb, var(--err) 40%, transparent);
  background: var(--err-bg);
  color: var(--err-text);
  text-align: left;
}

/* ---------- Inner scroll areas keep their width when a scrollbar appears ---------- */
.log__scroll,
.matrix-wrap,
.picker__list,
.dialog__body,
.drawer__body,
.palette__list,
.bell__list {
  scrollbar-gutter: stable;
}

/* ---------- Toggle buttons (favorite / watch) ---------- */
.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.toggle-btn:hover {
  background: var(--hover-strong);
  color: var(--text);
}

.toggle-btn--star.is-on {
  color: #f59e0b;
}

.toggle-btn--watch {
  border-color: var(--border);
}

.toggle-btn--watch.is-on {
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
  background: var(--primary-bg-soft);
  color: var(--primary-text);
}

.icon--filled {
  fill: currentColor;
}

.title-extra,
.title-toggles {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.kbd {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
}

/* ---------- Notification bell ---------- */
.bell {
  position: relative;
}

.bell__trigger {
  position: relative;
}

.bell__badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border: 2px solid var(--bg);
  border-radius: var(--radius-full);
  background: var(--err);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
}

.bell__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  width: min(400px, calc(100vw - 24px));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  animation: rise-in var(--duration-fast) var(--ease);
  overflow: hidden;
}

.bell__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.bell__title {
  color: var(--text);
  font-weight: 700;
}

.bell__list {
  max-height: 420px;
  overflow-y: auto;
}

.bell__item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
}

.bell__item:last-child { border-bottom: 0; }
.bell__item:hover { background: var(--hover); }
.bell__item.is-unread { background: color-mix(in srgb, var(--primary-bg-soft) 60%, transparent); }

.bell__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.bell__icon--error { background: var(--err-bg); color: var(--err-text); }
.bell__icon--ok { background: var(--ok-bg); color: var(--ok-text); }

.bell__body {
  flex: 1;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.bell__message {
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
}

.bell__meta {
  color: var(--muted);
  font-size: var(--text-xs);
}

.bell__dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--primary);
}

/* ---------- Command palette ---------- */
.palette {
  width: min(640px, calc(100vw - 32px));
  max-width: none;
  max-height: min(560px, calc(100vh - 120px));
  margin: 12vh auto auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--text-body);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: rise-in var(--duration) var(--ease);
}

.palette[open] {
  display: flex;
  flex-direction: column;
}

.palette::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(2px);
}

.palette__field {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.palette__search-icon {
  color: var(--muted);
}

.palette__input {
  flex: 1;
  height: 36px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: var(--text-lg);
}

.palette__input:focus-visible {
  box-shadow: none;
}

.palette__list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}

.palette__group + .palette__group {
  margin-top: var(--space-2);
}

.palette__group-title {
  padding: var(--space-2) var(--space-3) var(--space-1);
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.palette__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
}

.palette__item.is-active {
  background: var(--primary-bg-soft);
}

.palette__icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  flex: none;
}

.palette__item.is-active .palette__icon {
  background: var(--primary);
  color: #ffffff;
}

.palette__text {
  flex: 1;
  display: grid;
  min-width: 0;
}

.palette__title {
  color: var(--text);
  font-weight: 600;
}

.palette__subtitle {
  color: var(--muted);
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette__type {
  color: var(--muted-2);
  font-size: var(--text-xs);
  font-weight: 600;
}

.palette__status {
  padding: 0 var(--space-4) var(--space-3);
  color: var(--muted);
  font-size: var(--text-sm);
}

.palette__status:empty {
  display: none;
}

.palette__footer {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--card-alt);
  color: var(--muted);
  font-size: var(--text-xs);
}

.palette__footer span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.log__sep {
  width: 1px;
  height: 20px;
  margin: 0 var(--space-1);
  background: var(--border);
}

.stat__hint {
  grid-column: 2;
  color: var(--muted-2);
  font-size: var(--text-xs);
}

.stat--link {
  color: inherit;
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--ease);
}

.stat--link:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  text-decoration: none;
}

.stat--ok .stat__icon { background: var(--ok-bg); color: var(--ok-text); }
.stat--warn .stat__icon { background: var(--warn-bg); color: var(--warn-text); }

/* Cards are grid/flex children: never let wide content (tables) widen them. */
.card {
  min-width: 0;
}

.table tr.is-muted td {
  color: var(--muted);
}
