/* ============================================================================
   Hookline / component language
   Shared by the console and the creator app. One radius scale, one accent,
   three shadows, five status hues. Nothing here invents a value.
   ========================================================================= */

/* --- Icons --------------------------------------------------------------- */

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: currentColor;
  pointer-events: none;
}
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 24px; height: 24px; }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--h-control);
  padding: 0 var(--s-4);
  border: 1px solid transparent;
  border-radius: var(--r-control);
  font: var(--t-sm);
  font-weight: 500;
  letter-spacing: -0.003em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

/* Primary is ink, so the accent stays reserved for "interactive or selected". */
.btn-primary {
  background: var(--ink-bg);
  color: var(--fg-on-ink);
}
.btn-primary:hover:not(:disabled) { background: var(--ink-bg-hover); }

.btn-secondary {
  background: var(--bg-panel);
  border-color: var(--bd-control);
  color: var(--fg-primary);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--fg-secondary);
}

.btn-ghost { color: var(--fg-secondary); }
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--fg-primary);
}

.btn-danger {
  background: var(--st-danger-bg);
  border-color: var(--st-danger-bd);
  color: var(--st-danger-fg);
}
.btn-danger:hover:not(:disabled) { background: var(--st-danger-bd); }

.btn-sm { height: var(--h-control-sm); padding: 0 var(--s-3); font: var(--t-xs); font-weight: 500; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-lg { height: var(--h-control-lg); padding: 0 var(--s-5); font: var(--t-body); font-weight: 500; }

.btn-block { width: 100%; }

.btn-icon {
  width: var(--h-control);
  padding: 0;
}
.btn-icon.btn-sm { width: var(--h-control-sm); }
/* A finger needs more than a pointer: on touch screens every control is at
   least 44px tall, whatever its visible size on a desk. */
@media (pointer: coarse) {
  .btn, .input, .segmented > button, [role="tab"], .row-actions > .btn { min-height: 44px; }
  .btn-icon { min-width: 44px; }
}
.btn-icon.btn-lg { width: var(--h-control-lg); }

.btn[data-loading="true"] { color: transparent; position: relative; pointer-events: none; }
.btn[data-loading="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 13px; height: 13px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--r-pill);
  color: var(--fg-on-ink);
  animation: spin 620ms linear infinite;
}
.btn-secondary[data-loading="true"]::after,
.btn-ghost[data-loading="true"]::after { color: var(--fg-secondary); }

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

/* --- Segmented control --------------------------------------------------- */

.segmented {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--bg-inset);
  border-radius: var(--r-control);
}
.segmented > button {
  height: 26px;
  padding: 0 var(--s-3);
  border-radius: 3px;
  font: var(--t-xs);
  font-weight: 500;
  color: var(--fg-secondary);
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segmented > button:hover { color: var(--fg-primary); }
.segmented > button[aria-pressed="true"] {
  background: var(--bg-panel);
  color: var(--fg-primary);
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.06);
}
.segmented .count {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--fg-tertiary);
  margin-left: var(--s-2);
}

/* On a narrow screen the filter scrolls rather than pushing the page wide. */
@media (max-width: 720px) {
  .segmented {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .segmented::-webkit-scrollbar { display: none; }
}

/* --- Form controls ------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.field-row { display: grid; gap: var(--s-4); grid-template-columns: 1fr 1fr; }

.label {
  font: var(--t-xs);
  font-weight: 500;
  color: var(--fg-secondary);
}
.label .req { color: var(--st-danger-fg); margin-left: 2px; }

.hint { font: var(--t-xs); color: var(--fg-tertiary); }

.field-error {
  font: var(--t-xs);
  color: var(--st-danger-fg);
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.input,
.textarea,
.select {
  width: 100%;
  min-width: 0;
  height: var(--h-control);
  padding: 0 var(--s-3);
  background: var(--bg-panel);
  border: 1px solid var(--bd-control);
  border-radius: var(--r-control);
  font: var(--t-sm);
  color: var(--fg-primary);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.input:hover:not(:disabled),
.textarea:hover:not(:disabled),
.select:hover:not(:disabled) { border-color: var(--fg-secondary); }
.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible { border-color: var(--accent-fg); outline-offset: 1px; }
.input:disabled,
.textarea:disabled,
.select:disabled { background: var(--bg-inset); color: var(--fg-disabled); cursor: not-allowed; }
.input[aria-invalid="true"],
.textarea[aria-invalid="true"] { border-color: var(--st-danger-fg); }

.textarea { height: auto; min-height: 72px; padding: var(--s-2) var(--s-3); resize: vertical; line-height: 1.5; }

.select {
  appearance: none;
  padding-right: var(--s-7);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% + 1px), calc(100% - 11px) calc(50% + 1px);
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.input-mono { font-family: var(--font-mono); font-size: 0.8125rem; }

/* Input with a leading icon (search, url, currency) */
.input-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.input-wrap > .icon {
  position: absolute;
  left: var(--s-3);
  color: var(--fg-tertiary);
}
.input-wrap > .input { padding-left: var(--s-8); }
.input-wrap > .input-clear {
  position: absolute;
  right: var(--s-2);
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: var(--r-control);
  color: var(--fg-tertiary);
}
.input-wrap > .input-clear:hover { background: var(--bg-hover); color: var(--fg-primary); }

.input-suffix { position: relative; display: flex; align-items: center; }
.input-suffix > .suffix {
  position: absolute;
  right: var(--s-3);
  font: var(--t-xs);
  color: var(--fg-tertiary);
  pointer-events: none;
}
.input-suffix > .input { padding-right: var(--s-8); }

/* Checkbox and radio */
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  cursor: pointer;
  font: var(--t-sm);
  min-height: 20px;
}
.check input[type="checkbox"],
.check input[type="radio"] {
  appearance: none;
  width: 16px; height: 16px;
  flex: none;
  margin: 0;
  border: 1px solid var(--bd-control);
  border-radius: 3px;
  background: var(--bg-panel);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.check input[type="radio"] { border-radius: var(--r-pill); }
.check input:hover:not(:disabled) { border-color: var(--fg-secondary); }
.check input:checked {
  background: var(--accent-fg);
  border-color: var(--accent-fg);
}
.check input[type="checkbox"]:checked::after {
  content: "";
  width: 9px; height: 5px;
  border: 1.75px solid var(--accent-on);
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) translate(0.5px, -1px);
}
.check input[type="checkbox"]:indeterminate {
  background: var(--accent-fg);
  border-color: var(--accent-fg);
}
.check input[type="checkbox"]:indeterminate::after {
  content: "";
  width: 8px; height: 1.75px;
  background: var(--accent-on);
}
.check input[type="radio"]:checked::after {
  content: "";
  width: 6px; height: 6px;
  border-radius: var(--r-pill);
  background: var(--accent-on);
}
.check input:disabled { opacity: 0.5; cursor: not-allowed; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font: var(--t-sm); }
.switch input {
  appearance: none;
  position: relative;
  width: 32px; height: 18px;
  flex: none;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--bd-control);
  cursor: pointer;
  transition: background-color var(--dur-base) var(--ease);
}
.switch input::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: var(--r-pill);
  background: #fff;
  transition: transform var(--dur-base) var(--ease);
}
.switch input:checked { background: var(--accent-fg); }
.switch input:checked::after { transform: translateX(14px); }

/* Radio card group, used for choices that carry an explanation */
.choice {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-4);
  border: 1px solid var(--bd-default);
  border-radius: var(--r-panel);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.choice:hover { border-color: var(--bd-strong); }
.choice:has(input:checked) {
  border-color: var(--accent-fg);
  background: var(--accent-bg);
}
.choice input { margin-top: 2px; }
.choice .choice-title { display: block; font: var(--t-sm); font-weight: 500; }
.choice .choice-desc { display: block; font: var(--t-xs); color: var(--fg-secondary); margin-top: 2px; }

/* --- Status pill: dot plus word, never colour alone ---------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 20px;
  padding: 0 var(--s-2) 0 var(--s-2);
  border: 1px solid var(--st-neutral-bd);
  border-radius: var(--r-pill);
  background: var(--st-neutral-bg);
  color: var(--st-neutral-fg);
  font: var(--t-micro);
  letter-spacing: var(--tr-micro);
  text-transform: uppercase;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  flex: none;
  border-radius: var(--r-pill);
  background: currentColor;
}
.badge-info    { background: var(--st-info-bg);    border-color: var(--st-info-bd);    color: var(--st-info-fg); }
.badge-warn    { background: var(--st-warn-bg);    border-color: var(--st-warn-bd);    color: var(--st-warn-fg); }
.badge-success { background: var(--st-success-bg); border-color: var(--st-success-bd); color: var(--st-success-fg); }
.badge-danger  { background: var(--st-danger-bg);  border-color: var(--st-danger-bd);  color: var(--st-danger-fg); }
.badge-nodot::before { display: none; }
.badge-nodot { padding: 0 var(--s-2); }

/* Tag: a label with no status meaning (genre, market, format) */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  height: 20px;
  padding: 0 var(--s-2);
  border: 1px solid var(--bd-default);
  border-radius: var(--r-control);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font: var(--t-xs);
  white-space: nowrap;
}
.tag-more { color: var(--fg-tertiary); border-style: dashed; }

/* --- Avatar -------------------------------------------------------------- */

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--bg-inset);
  color: var(--fg-secondary);
  font: var(--t-micro);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow: hidden;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 40px; height: 40px; font-size: 0.8125rem; }
.avatar-xl { width: 56px; height: 56px; font-size: 1rem; }
.avatar-sm { width: 20px; height: 20px; font-size: 0.625rem; }

.avatar-group { display: flex; }
.avatar-group > .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--bg-panel); }
.avatar-group > .avatar:first-child { margin-left: 0; }

/* --- Panel: the only container. Never nested. ---------------------------- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--bd-default);
  border-radius: var(--r-panel);
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 40px;
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--bd-subtle);
}
.panel-title {
  font: var(--t-sm);
  font-weight: 600;
  letter-spacing: -0.008em;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.panel-title .count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--fg-tertiary);
}
.panel-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.panel-body { padding: var(--s-5); }
.panel-body-tight { padding: var(--s-4); }
.panel-foot {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--bd-subtle);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--r-panel) var(--r-panel);
}

/* A panel holding a table bleeds its own border */
.panel > .table-wrap { border-radius: 0 0 var(--r-panel) var(--r-panel); overflow: hidden; }
.panel > .table-wrap:first-child { border-radius: var(--r-panel); }

/* --- Table --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  font: var(--t-sm);
}
.table th,
.table td {
  padding: 0 var(--s-4);
  height: var(--h-row);
  text-align: left;
  vertical-align: middle;
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: 32px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--bd-default);
  font: var(--t-micro);
  letter-spacing: var(--tr-micro);
  text-transform: uppercase;
  color: var(--fg-tertiary);
  white-space: nowrap;
  user-select: none;
}
.table tbody tr { border-bottom: 1px solid var(--bd-subtle); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr[aria-selected="true"] { background: var(--bg-selected); }
.table tbody tr[data-clickable] { cursor: pointer; }
.table tbody tr:focus-visible {
  outline: 2px solid var(--accent-fg);
  outline-offset: -2px;
}
.table td.num,
.table th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table th.num { font-family: var(--font-sans); }
.table .col-check { width: 36px; padding-right: 0; }
.table .col-actions { width: 1%; padding-left: 0; text-align: right; }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  height: 100%;
}
.th-sort:hover { color: var(--fg-primary); }
.th-sort .icon { width: 12px; height: 12px; opacity: 0.45; }
[aria-sort="ascending"] .th-sort .icon,
[aria-sort="descending"] .th-sort .icon { opacity: 1; color: var(--accent-fg); }

/* The labelled action is contextual, so it waits for hover and keeps the table
   calm. The overflow menu never hides: it is the only route to destructive
   actions, and an affordance you cannot see is one nobody finds. */
.row-actions {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  justify-content: flex-end;
}
.row-actions > .btn {
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.row-actions > .btn-icon { opacity: 0.55; }
tr:hover .row-actions > .btn,
tr:focus-within .row-actions > .btn { opacity: 1; }
@media (hover: none) { .row-actions > .btn { opacity: 1; } }

/* The identity cell: avatar, name, handle */
.cell-id { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.cell-id .cell-name { font-weight: 500; }
.cell-id .cell-sub {
  font: var(--t-xs);
  color: var(--fg-tertiary);
  font-family: var(--font-mono);
}

/* --- Narrowing a wide table ----------------------------------------------

   Between the stacked layout and a roomy desktop there is a range where a
   twelve column table simply does not fit. The panel clips rather than
   scrolls, so without this the last columns are unreachable: no scrollbar,
   no hint they exist. The columns marked secondary are the ones worth losing
   first, so they drop out here and the table fits instead of being cut. */

@media (max-width: 1366px) {
  .table th.col-secondary,
  .table td.col-secondary { display: none; }
}

/* --- Stacked table for narrow viewports ---------------------------------- */

@media (max-width: 900px) {
  .table.responsive thead { display: none; }
  .table.responsive,
  .table.responsive tbody,
  .table.responsive tr,
  .table.responsive td { display: block; width: 100%; }
  .table.responsive tr {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--bd-subtle);
  }
  .table.responsive td {
    height: auto;
    padding: var(--s-1) 0;
    display: flex;
    align-items: baseline;
    gap: var(--s-4);
    text-align: left !important;
  }
  .table.responsive td::before {
    content: attr(data-label);
    flex: none;
    width: 104px;
    font: var(--t-micro);
    letter-spacing: var(--tr-micro);
    text-transform: uppercase;
    color: var(--fg-tertiary);
  }
  .table.responsive td[data-label=""]::before { display: none; }
  .table.responsive td.col-secondary { display: none; }
  .table.responsive td.col-actions,
  .table.responsive td.col-check { justify-content: flex-start; }
  /* Stacked records have no hover target, so every action stays out. */
  .table.responsive .row-actions { justify-content: flex-start; }
  .table.responsive .row-actions > .btn { opacity: 1; }
}

/* --- Toolbar above every table ------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--bd-subtle);
  flex-wrap: wrap;
}
.toolbar .input-wrap { width: 240px; flex: 0 1 240px; }
.toolbar .spacer { flex: 1 1 auto; }
.toolbar .result-count {
  font: var(--t-xs);
  color: var(--fg-tertiary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* A second toolbar row, for a filter that narrows what the row above chose.
   Recessed a step so the two read as parent and child rather than as peers. */
.toolbar-sub {
  padding-block: var(--s-2);
  background: var(--bg-subtle);
}
.toolbar-sub .segmented { font: var(--t-xs); }

/* Bulk bar replaces the toolbar in place when a selection exists */
.bulkbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--accent-border);
  background: var(--accent-bg);
  flex-wrap: wrap;
}
.bulkbar .selected-count { font: var(--t-sm); font-weight: 500; }

/* --- Metric strip: one panel, hairline columns, no boxes ----------------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  background: var(--bg-panel);
  border: 1px solid var(--bd-default);
  border-radius: var(--r-panel);
  overflow: hidden;
}
.metric {
  padding: var(--s-4) var(--s-5);
  border-left: 1px solid var(--bd-subtle);
  min-width: 0;
}
.metric:first-child { border-left: 0; }
.metric-label {
  font: var(--t-micro);
  letter-spacing: var(--tr-micro);
  text-transform: uppercase;
  color: var(--fg-tertiary);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.metric-value {
  margin-top: var(--s-2);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
}
.metric-value .unit { font-size: 0.8125rem; color: var(--fg-tertiary); font-weight: 400; }
.metric-note { margin-top: 2px; font: var(--t-xs); color: var(--fg-tertiary); }
.metric-note.up { color: var(--st-success-fg); }
.metric-note.down { color: var(--st-danger-fg); }
.metric-note.attention { color: var(--st-warn-fg); }

@media (max-width: 900px) {
  .metrics { grid-auto-flow: column; grid-auto-columns: minmax(146px, 1fr); grid-template-columns: none; overflow-x: auto; }
}

/* --- The signature: pipeline meter --------------------------------------- */

.meter {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.meter-seg {
  position: relative;
  height: 14px;
  flex: 1 1 0;
  min-width: 6px;
  background: var(--bg-inset);
  border-radius: 1px;
  overflow: hidden;
}
.meter-seg::after {
  content: "";
  position: absolute;
  inset: 0;
  transform-origin: left;
  transform: scaleX(var(--fill, 0));
  background: var(--accent-meter);
  transition: transform var(--dur-slow) var(--ease);
}
.meter-seg[data-stage="paid"]::after { background: var(--st-success-fg); }
.meter-sm .meter-seg { height: 10px; }

.meter-legend {
  display: flex;
  gap: 2px;
  margin-top: var(--s-2);
}
.meter-legend > span {
  flex: 1 1 0;
  min-width: 0;
  font: var(--t-micro);
  letter-spacing: var(--tr-micro);
  text-transform: uppercase;
  color: var(--fg-tertiary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pipeline as a labelled row of counts, used on the campaign header */
.pipeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--bd-default);
  border-radius: var(--r-panel);
  overflow: hidden;
  background: var(--bg-panel);
}
.pipeline-stage {
  padding: var(--s-3) var(--s-4);
  border-left: 1px solid var(--bd-subtle);
  min-width: 0;
}
.pipeline-stage:first-child { border-left: 0; }
.pipeline-stage .stage-label {
  font: var(--t-micro);
  letter-spacing: var(--tr-micro);
  text-transform: uppercase;
  color: var(--fg-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pipeline-stage .stage-count {
  margin-top: var(--s-1);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.pipeline-stage[data-current="true"] { background: var(--accent-bg); }
.pipeline-stage[data-current="true"] .stage-label { color: var(--accent-fg); }

@media (max-width: 900px) {
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pipeline-stage:nth-child(4) { border-left: 0; }
  .pipeline-stage:nth-child(n+4) { border-top: 1px solid var(--bd-subtle); }
}

/* --- Tabs ---------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: var(--s-5);
  border-bottom: 1px solid var(--bd-default);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs > button {
  position: relative;
  padding: var(--s-3) 0;
  font: var(--t-sm);
  font-weight: 500;
  color: var(--fg-secondary);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  transition: color var(--dur-fast) var(--ease);
}
.tabs > button:hover { color: var(--fg-primary); }
.tabs > button[aria-selected="true"] { color: var(--fg-primary); }
.tabs > button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent-fg);
}
.tabs .count {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--fg-tertiary);
  background: var(--bg-inset);
  border-radius: var(--r-pill);
  padding: 1px 6px;
}

/* --- Dropdown menu ------------------------------------------------------- */

.menu-anchor { position: relative; display: inline-flex; }

.menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: calc(var(--z-modal) + 5);   /* above a modal it was opened from, below toasts */
  min-width: 200px;
  padding: var(--s-1);
  background: var(--bg-panel);
  border: 1px solid var(--bd-default);
  border-radius: var(--r-panel);
  box-shadow: var(--sh-menu);
  max-height: 320px;
  overflow-y: auto;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border-radius: 3px;
  font: var(--t-sm);
  color: var(--fg-primary);
  text-align: left;
  cursor: pointer;
}
.menu-item:hover:not(:disabled) { background: var(--bg-hover); }
.menu-item:disabled { color: var(--fg-disabled); cursor: not-allowed; }
.menu-item .icon { color: var(--fg-tertiary); }
.menu-item.danger { color: var(--st-danger-fg); }
.menu-item.danger .icon { color: currentColor; }
.menu-item .shortcut { margin-left: auto; font-family: var(--font-mono); font-size: 0.6875rem; color: var(--fg-tertiary); }
.menu-sep { height: 1px; background: var(--bd-subtle); margin: var(--s-1) 0; }
.menu-label {
  padding: var(--s-2) var(--s-3) var(--s-1);
  font: var(--t-micro);
  letter-spacing: var(--tr-micro);
  text-transform: uppercase;
  color: var(--fg-tertiary);
}

/* --- Scrim, modal, drawer ------------------------------------------------ */

.scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  background: var(--bg-scrim);
  animation: fade var(--dur-base) var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.modal {
  position: fixed;
  z-index: var(--z-modal);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--bd-default);
  border-radius: var(--r-large);
  box-shadow: var(--sh-modal);
  animation: modal-in var(--dur-base) var(--ease);
}
.modal-wide { width: min(760px, calc(100vw - 32px)); }
@keyframes modal-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); }
}

.drawer {
  position: fixed;
  z-index: var(--z-drawer);
  top: 0; right: 0; bottom: 0;
  width: min(var(--w-drawer), 100vw);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--bd-default);
  box-shadow: var(--sh-modal);
  animation: drawer-in var(--dur-slow) var(--ease);
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }

.sheet-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--bd-subtle);
  flex: none;
}
.sheet-title { font: var(--t-heading); letter-spacing: var(--tr-heading); }
.sheet-sub { font: var(--t-xs); color: var(--fg-tertiary); margin-top: 2px; }
.sheet-close { margin-left: auto; }
.sheet-body { padding: var(--s-5); overflow-y: auto; flex: 1 1 auto; }
.sheet-body-flush { padding: 0; overflow-y: auto; flex: 1 1 auto; }
.sheet-foot {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--bd-subtle);
  background: var(--bg-subtle);
  flex: none;
}
.sheet-foot .spacer { flex: 1 1 auto; }

@media (max-width: 900px) {
  .drawer { width: 100vw; border-left: 0; }
}

/* --- Toast --------------------------------------------------------------- */

.toasts {
  position: fixed;
  z-index: var(--z-toast);
  right: var(--s-5);
  bottom: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-panel);
  border: 1px solid var(--bd-default);
  border-radius: var(--r-panel);
  box-shadow: var(--sh-toast);
  font: var(--t-sm);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast .icon { margin-top: 1px; color: var(--fg-tertiary); }
.toast[data-tone="success"] .icon { color: var(--st-success-fg); }
.toast[data-tone="danger"] .icon { color: var(--st-danger-fg); }
.toast[data-tone="warn"] .icon { color: var(--st-warn-fg); }
.toast .toast-body { flex: 1 1 auto; min-width: 0; }
.toast .toast-desc { color: var(--fg-secondary); font: var(--t-xs); margin-top: 2px; }

@media (max-width: 640px) {
  .toasts { left: var(--s-4); right: var(--s-4); bottom: var(--s-4); max-width: none; }
}

/* --- Empty state: an invitation to act, not a shrug ---------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-10) var(--s-5);
  text-align: center;
}
.empty .icon { color: var(--fg-disabled); }
.empty-title { font: var(--t-sm); font-weight: 600; }
.empty-desc { font: var(--t-sm); color: var(--fg-secondary); max-width: 44ch; }

/* --- Callout ------------------------------------------------------------- */

.callout {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--st-info-bd);
  border-radius: var(--r-panel);
  background: var(--st-info-bg);
  color: var(--fg-primary);
  font: var(--t-sm);
}
.callout .icon { color: var(--st-info-fg); flex: none; margin-top: 1px; }
.callout-warn { border-color: var(--st-warn-bd); background: var(--st-warn-bg); }
.callout-warn .icon { color: var(--st-warn-fg); }
.callout-danger { border-color: var(--st-danger-bd); background: var(--st-danger-bg); }
.callout-danger .icon { color: var(--st-danger-fg); }
.callout-neutral { border-color: var(--bd-default); background: var(--bg-subtle); }
.callout-neutral .icon { color: var(--fg-tertiary); }
.callout-success { border-color: var(--st-success-bd); background: var(--st-success-bg); }
.callout-success .icon { color: var(--st-success-fg); }

/* --- Definition list, used in every detail view -------------------------- */

.dl { display: grid; grid-template-columns: 132px 1fr; gap: var(--s-3) var(--s-4); align-items: baseline; }
.dl dt { font: var(--t-xs); color: var(--fg-tertiary); }
.dl dd { font: var(--t-sm); min-width: 0; overflow-wrap: anywhere; }
.dl-rows { display: flex; flex-direction: column; }
.dl-rows > div {
  display: flex;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--bd-subtle);
  font: var(--t-sm);
}
.dl-rows > div:last-child { border-bottom: 0; }
.dl-rows dt { color: var(--fg-secondary); }
.dl-rows dd { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }

@media (max-width: 640px) {
  .dl { grid-template-columns: 1fr; gap: var(--s-1); }
  .dl dd { margin-bottom: var(--s-3); }
}

/* --- Activity timeline --------------------------------------------------- */

.timeline { display: flex; flex-direction: column; }
.timeline-item {
  position: relative;
  display: flex;
  gap: var(--s-4);
  padding-bottom: var(--s-5);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: 9px; top: 20px; bottom: 0;
  width: 1px;
  background: var(--bd-default);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 19px; height: 19px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--bg-inset);
  border: 1px solid var(--bd-default);
  color: var(--fg-tertiary);
}
.timeline-dot .icon { width: 11px; height: 11px; }
.timeline-dot[data-tone="success"] { background: var(--st-success-bg); border-color: var(--st-success-bd); color: var(--st-success-fg); }
.timeline-dot[data-tone="danger"]  { background: var(--st-danger-bg);  border-color: var(--st-danger-bd);  color: var(--st-danger-fg); }
.timeline-dot[data-tone="info"]    { background: var(--st-info-bg);    border-color: var(--st-info-bd);    color: var(--st-info-fg); }
.timeline-dot[data-tone="warn"]    { background: var(--st-warn-bg);    border-color: var(--st-warn-bd);    color: var(--st-warn-fg); }
.timeline-body { min-width: 0; font: var(--t-sm); padding-top: 1px; }
.timeline-meta { font: var(--t-xs); color: var(--fg-tertiary); margin-top: 2px; }

/* --- Keyboard hint ------------------------------------------------------- */

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 1px solid var(--bd-default);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--fg-secondary);
}

/* --- Link with an external target ---------------------------------------- */

.link-out {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  color: var(--accent-fg);
  font: var(--t-sm);
  min-width: 0;
}
.link-out .icon { width: 12px; height: 12px; flex: none; }

/* --- Section heading inside a body, below panel level -------------------- */

.section-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.section-head h3 { font: var(--t-sm); font-weight: 600; }
.section-head .spacer { flex: 1 1 auto; }
