/* ---------- Skeleton Shimmer Loader for Data Tables ---------- */
.skeleton-row {
  display: table-row;
}

.skeleton-cell {
  padding: var(--space-4) var(--space-4);
  vertical-align: middle;
}

.skeleton-bar {
  height: 14px;
  background: linear-gradient(
    90deg,
    var(--neutral-soft) 25%,
    var(--line) 50%,
    var(--neutral-soft) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: shimmerWave 1.4s infinite ease-in-out;
}

@keyframes shimmerWave {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ---------- Card Hover Micro-Elevations & Container Queries ---------- */
.card,
.clickable-card,
.summary-bar {
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.clickable-card:hover,
.summary-bar:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--line-strong);
}

/* Container query container setup */
.grid-container,
.card-wrapper {
  container-type: inline-size;
  container-name: card-grid;
}

/* ---------- Action Buttons & Micro-States ---------- */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition: scale var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}


.btn:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--accent-bg);
  color: var(--accent-ink);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-bg-hover);
}

.btn.secondary {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--line-strong);
}

.btn.danger {
  background: var(--card);
  color: var(--err);
  border: 1px solid var(--err-line);
}

.btn.danger:hover:not(:disabled) {
  background: var(--err-soft);
}

.btn.refresh-btn {
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--line-strong);
  box-shadow: 0 1px 3px rgb(var(--shadow-rgb) / 0.06);
}

.btn.refresh-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgb(var(--accent-rgb) / 0.15);
}

.btn.refresh-btn:disabled {
  background: var(--neutral-soft);
  color: var(--muted);
  border-color: var(--line);
  opacity: 0.85;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.refresh-btn .icon {
  font-size: 0.92rem;
  display: inline-block;
  transition: transform var(--duration-fast) var(--ease-out);
}

.btn.refresh-btn:hover:not(:disabled) .icon {
  transform: rotate(45deg);
}

.btn.refresh-btn.spinning .icon {
  animation: spinIcon 1.2s linear infinite;
}

@keyframes spinIcon {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
}

/* ---------- Table Row Action Buttons (Pull-In Hover Animation) ---------- */
.row-action-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              scale var(--duration-fast) var(--ease-out);
}

.row-action-btn i {
  width: 14px;
  height: 14px;
  transition: transform var(--duration-fast) var(--ease-out);
}

.row-action-btn:hover {
  transform: translateY(-1px);
  scale: 1.04;
}

.row-action-btn:hover i {
  transform: scale(1.15);
}

.row-action-btn:active {
  scale: 0.95 !important;
  transform: translateY(0);
}

/* ---------- Icon-only row actions (table layouts) ----------
   Compact 32px visual so History / Edit / Delete fit on one line. The 44px touch
   target comes from the shared button.icon-only::before rule in base.css (skill 4).
   Tooltip + aria-label name the action. */
.row-action-btn.icon-only {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

.row-action-btn.icon-only i,
.row-action-btn.icon-only svg {
  width: 16px;
  height: 16px;
}

/* Pull-In Color Accents on Hover */
.row-action-btn.action-history:hover,
.row-action-btn.action-edit:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
  box-shadow: var(--shadow-sm);
}

.row-action-btn.action-del:hover {
  background: var(--err-soft);
  color: var(--err);
  border-color: var(--err-line);
  box-shadow: var(--shadow-sm);
}


.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--muted);
}

.summary-bar b {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Pills & Status Badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  line-height: 1.2;
}


.pill.status-active,
.pill.status-closed,
.pill.status-won,
.pill.status-passed {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.status-deactivated,
.pill.status-open,
.pill.status-new {
  background: var(--err-soft);
  color: var(--err);
}

.pill.status-pending,
.pill.status-in_progress {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.status-invoiced,
.pill.status-qualified {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.status-archived,
.pill.status-failed {
  background: var(--neutral-soft);
  color: var(--muted);
}

.pill.role-super_admin {
  background: var(--orange-soft);
  color: var(--orange);
}

.pill.role-dept_admin {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.role-staff {
  background: var(--neutral-soft);
  color: var(--muted);
}

/* ---------- Form Fields & Inputs ---------- */
.field {
  margin-bottom: var(--space-4);
}

.field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--ink);
}

.field label.required::after {
  content: " *";
  color: var(--err);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: var(--space-3) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--card);
  color: var(--ink);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.12);
}

.field textarea {
  min-height: 72px;
  resize: vertical;
}

.field .err {
  color: var(--err);
  font-size: var(--text-xs);
  margin-top: var(--space-1);
}

.form-msg {
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

.form-msg.err {
  background: var(--err-soft);
  color: var(--err);
}

.form-msg.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.form-msg.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

/* ---------- Backdrop Overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.overlay.shown {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Sliding Record Drawer ---------- */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 92vw);
  background: var(--card);
  z-index: 1050;
  box-shadow: -16px 0 40px -12px rgb(var(--shadow-rgb) / 0.25);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--duration-normal) var(--ease-out);
}

.drawer.shown {
  transform: translateX(0);
}

.drawer-head {
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--card);
  border-radius: inherit;
}

.drawer-head h2 {
  font-size: var(--text-lg);
  margin: 0 0 var(--space-half);
}

.drawer-head p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--muted);
  line-height: 1;
  cursor: pointer;
  padding: var(--space-1);
}

.drawer-body {
  padding: var(--space-5) var(--space-5);
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.drawer-foot {
  padding: var(--space-4) var(--space-5);
  padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
  background: var(--card);
  box-shadow: 0 -4px 12px rgb(var(--shadow-rgb) / 0.05);
  z-index: 10;
}

.drawer-foot .btn {
  flex: 1;
}

/* ---------- Modal Overlays & Non-Zero Scale Animations ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-7) var(--space-4);
  overflow-y: auto;
  background: var(--overlay);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.modal.shown {
  display: flex;
  opacity: 1;
}

.modal-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  box-shadow: 0 20px 50px -15px rgb(var(--shadow-rgb) / 0.3);
  transform: scale(0.95) translateY(8px);
  transition: transform var(--duration-normal) var(--ease-out);
}

.modal.shown .modal-card {
  transform: scale(1) translateY(0);
}

/* ---------- Wide dialog (spreadsheet import) ----------
   Room for the row preview on desktop; a full-screen sheet on phones (A11). */
.modal-card.modal-wide {
  max-width: 920px;
}

.modal-card.modal-wide .modal-body {
  max-height: 72vh;
}

@media (max-width: 640px) {
  .modal.modal-host-wide {
    padding: 0;
  }

  .modal-card.modal-wide {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  .modal-card.modal-wide .modal-body {
    flex: 1;
    max-height: none;
  }

  .modal-card.modal-wide .modal-head h2 {
    font-size: var(--text-base);
  }
}

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

.modal-head h2 {
  font-size: var(--text-lg);
  margin: 0;
}

.modal-body {
  padding: var(--space-5) var(--space-5);
  max-height: 70vh;
  overflow-y: auto;
}

.modal-foot {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* One builder row: label, generated key, type, required, remove; the dropdown
   options input wraps onto its own full-width line when the type is "select" */
.col-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.col-row .col-label { flex: 2; min-width: 140px; }
.col-row .col-type { flex: 1; min-width: 90px; }

/* Read-only key preview looks like read-only, not disabled (skill 7) */
.col-row .col-key {
  flex: 1.5;
  min-width: 110px;
  background: var(--neutral-soft);
  color: var(--muted);
}

.col-req-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.75rem;
  user-select: none;
}

.col-row input,
.col-row select {
  padding: var(--space-2) var(--space-2);
  font-size: var(--text-xs);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.col-row .rm {
  border: none;
  background: none;
  color: var(--err);
  font-size: 1.2rem;
  cursor: pointer;
}

.col-row .col-options {
  flex-basis: 100%;
  font-size: 0.8rem;
  margin-top: var(--space-1);
}

/* Link settings: their own full-width line under the row, three labelled pickers that
   wrap on narrow dialogs */
.col-row .col-link {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
}
.col-row .col-link[hidden] { display: none; }
.col-link-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1 1 150px;
  font-size: var(--text-xs);
  color: var(--muted);
}
.col-link-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: var(--text-xs);
  color: var(--muted);
}

.assign-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.assign-tag {
  font-size: var(--text-xs);
  background: var(--neutral-soft);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--ink);
}

/* ---------- Toast Notification Bubbles ---------- */
.toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: 0 10px 30px rgb(var(--shadow-rgb) / 0.35);
  animation: slideUp var(--duration-normal) var(--ease-out);
}

@keyframes slideUp {
  from {
    transform: translateY(12px) scale(0.95);
    opacity: 0;
    filter: blur(4px);
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
    filter: blur(0px);
  }
}

/* ---------- Admin lists, record history and confirm dialogs (A20) ----------
   Classes for markup that used to carry inline styles in the view templates. */

/* Spacing helpers on the --space-* scale */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-5 { margin-top: var(--space-5); }
.mb-5 { margin-bottom: var(--space-5); }

.text-small { font-size: 0.82rem; }

/* Muted values inside record cards (the base value style is ink-coloured) */
.record-field-value.text-muted { color: var(--muted); }

/* Minimum / maximum widths for admin table columns */
.col-min-90 { min-width: 90px; }
.col-min-100 { min-width: 100px; }
.col-min-110 { min-width: 110px; }
.col-min-120 { min-width: 120px; }
.col-min-140 { min-width: 140px; }
.col-min-160 { min-width: 160px; }
.col-min-180 { min-width: 180px; }
.col-min-200 { min-width: 200px; }
.col-min-220 { min-width: 220px; }
.col-min-240 { min-width: 240px; }
.col-max-280 { max-width: 280px; }

/* Avatar sizes for lists (the base .avatar is the sidebar size) */
.avatar.avatar-32 { width: 32px; height: 32px; font-size: 0.75rem; flex-shrink: 0; }
.avatar.avatar-28 { width: 28px; height: 28px; font-size: 0.72rem; flex-shrink: 0; }

/* Avatar + name + email; the text truncates instead of pushing the pill out */
.person {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.person-text {
  min-width: 0;
  overflow: hidden;
}

.person-name,
.person-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-name { font-weight: 600; color: var(--ink); }
.person-email { font-size: 0.75rem; color: var(--muted); }
.record-card .person-name { font-weight: 700; font-size: 0.92rem; }

/* Card title beside the icon on admin cards */
.card-title-text { font-size: 0.95rem; color: var(--ink); }

.record-card-header .pill { flex-shrink: 0; }
.record-field.span-all { grid-column: 1 / -1; }

/* Deactivated users stay readable but recede */
.record-card.is-inactive { opacity: 0.75; background: var(--neutral-soft); }
tr.is-inactive { opacity: 0.65; background: var(--neutral-soft); }

.pill.pill-entra { background: var(--accent-soft); color: var(--accent); margin-left: var(--space-1); }
.pill.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill.is-caps { text-transform: uppercase; letter-spacing: 0.05em; }

/* "None" / "No columns yet" placeholders inside lists */
.empty-inline { font-size: 0.8rem; color: var(--muted); }

/* Row action buttons in admin tables; record actions stay on one line */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.actions-cell { white-space: nowrap; }

.confirm-inline { font-size: 0.78rem; }

/* Dialog bodies that can grow long scroll inside the dialog */
.modal-body.modal-scroll { max-height: 75vh; overflow-y: auto; }
.modal-body.modal-scroll.is-short { max-height: 65vh; }

/* Small bold heading inside a dialog section */
.section-label {
  font-size: 0.82rem;
  font-weight: 600;
}

.section-label.is-spaced { margin: var(--space-4) 0 var(--space-2); }

/* Existing columns list in the Edit Columns dialog */
.col-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}

/* Destructive confirmation dialogs: red title, a note on what is lost */
.modal-head h2.is-danger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--err);
}

.danger-note {
  background: var(--err-soft);
  border-left: 4px solid var(--err);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  font-size: 0.85rem;
  color: var(--ink);
}

.modal-note {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Record history timeline */
.history-entry {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-3);
  margin-bottom: var(--space-3);
}

.history-entry-head { font-size: 0.83rem; font-weight: 600; }
.history-time { font-size: 0.75rem; color: var(--muted); }

.history-payload {
  background: var(--neutral-soft);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  margin-top: var(--space-2);
  overflow-x: auto;
}

/* Home page "Request Dashboard Refresh" button is a size down from .btn */
.btn.refresh-btn.refresh-compact {
  font-size: 0.82rem;
  padding: var(--space-2) var(--space-4);
}

/* Sidebar placeholder when a user has no tables */
.sidebar-empty {
  font-size: 0.78rem;
  color: var(--on-navy-muted);
  padding: var(--space-2);
}

/* The breadcrumb sits in the top bar, which supplies its own spacing */
.top-header-bar .breadcrumb { margin-bottom: 0; }

/* ---------- Naira amount field ----------
   The ₦ sits inside the field's left edge; the input keeps its normal styling. */
.money-input { position: relative; }

.money-symbol {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.money-input input {
  padding-left: calc(var(--space-3) + 1.1em);
  font-variant-numeric: tabular-nums;
}

/* Column actions in Edit Columns stay on one line */
.col-list-item .btn { white-space: nowrap; }

/* ---------- System Logs page (super admins) ---------- */
.log-tabs {
  display: inline-flex;
  margin-bottom: var(--space-4);
}

.log-auto,
.log-date {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Date filters match the other filter controls */
.log-date input {
  height: 38px;
  padding: 0 var(--space-2);
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
}
.log-user { min-width: 170px; }

.log-summary .log-count.is-error b { color: var(--err); }
.log-summary .log-count.is-warning b { color: var(--warn); }

/* Level pills carry their name as text, not colour alone */
.pill.log-level.is-error { background: var(--err-soft); color: var(--err); }
.pill.log-level.is-warning { background: var(--warn-soft); color: var(--warn); }
.pill.log-level.is-info { background: var(--neutral-soft); color: var(--muted); }

.log-source {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Long paths and messages truncate in the row; the full text is in the title and the detail panel */
.log-table .log-where,
.log-table .log-message {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-table td.log-message .text-muted {
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-col-toggle { width: 44px; }

/* Long emails truncate so the reference column stays in view */
.log-table .log-who { max-width: 220px; }
.log-table .log-who .person-text { max-width: 220px; }
.log-row.is-open { background: var(--neutral-soft); }

.log-ref {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
}

.log-detail-row td { background: var(--neutral-soft); }

.log-detail {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  white-space: normal;
}

.log-detail .btn { justify-self: start; }

.log-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-2) var(--space-4);
  margin: 0;
}

.log-facts dt {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.log-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.log-detail-message p { margin: var(--space-1) 0 0; overflow-wrap: anywhere; }

.log-trace {
  margin: var(--space-1) 0 0;
  max-height: 320px;
  overflow: auto;
  padding: var(--space-3);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  white-space: pre;
}

/* ---------- Links between tables ----------
   The record form's picker (a search box with a list under it), link cells in the grid,
   the "only rows linked to …" bar and the Linked records dialog. */
.link-picker-box { position: relative; }

.link-picker-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
  pointer-events: none;
}

.link-picker input { padding-left: calc(var(--space-3) + 22px); }

.link-picker-list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + var(--space-1));
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.link-picker-list [role=option] {
  display: flex;
  flex-direction: column;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.link-picker-list [role=option]:hover,
.link-picker-list [role=option][aria-selected=true] { background: var(--accent-soft); }

.link-picker-label { color: var(--ink); font-weight: 600; }
.link-picker-sub,
.link-picker-empty,
.link-picker-detail { font-size: var(--text-xs); color: var(--muted); }
.link-picker-empty { padding: var(--space-2) var(--space-3); }
.link-picker-detail { min-height: 1.2em; margin-top: var(--space-1); }

.link-cell {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-cell .ic { color: var(--accent); flex: none; }
.link-cell-detail { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.link-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--ink-soft);
  font-size: var(--text-sm);
}
.link-filter-bar .ic { color: var(--accent); }
.link-filter-bar .btn { margin-left: auto; }

.related-list { list-style: none; margin: 0; padding: 0; }

.related-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
}
.related-item:last-child { border-bottom: none; }
.related-count { font-size: var(--text-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.related-skeleton { margin: var(--space-3) 0; }

/* Relationships box in Edit Columns: which table is the parent (one side, holds the key)
   and which is the child (many side, holds the link). Key = accent, link = neutral. */
.rel-list { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: grid; gap: var(--space-2); }
.rel-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--ink);
}
.rel-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--neutral-soft);
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 600;
  vertical-align: middle;
}
.rel-badge-key { background: var(--accent-soft); color: var(--accent); }
.rel-pbi { display: block; margin-top: var(--space-1); font-size: var(--text-xs); color: var(--muted); overflow-wrap: anywhere; }
