/* Design system: cards, panels, tables, tabs, pagination and the policy
 * banner (#3441, epic #3432). Tokens only; light and dark come from
 * tokens.css. Helpers live in ds/surfaces.ts. Pages adopt these in their
 * Phase 2 issues; nothing here restyles an existing class.
 *
 * Text Figma draws in #adb5bd / #9ca3af / #10b981 at 9-10px fails WCAG AA,
 * so it uses --fg-muted (and --live-text for "running"), as #3520 did. */

:root {
  --table-head-tracking: 1px;            /* 1:6848: Figma's header tracking */
  --scroll-fade-height: 210px;           /* about three 70px activity rows (1:7161-1:7177) */
}

/* ---- Card (1:6690, 1:6726, 1:14717) ---- */
.ui-card {
  box-sizing: border-box; padding: var(--space-6);
  background: var(--surface); border: 1px solid var(--border-card);
  border-radius: var(--radius-2xl); box-shadow: var(--shadow-card);
}
.ui-card-tight { padding: var(--space-5); }   /* 1:14717 Pay as you go */
.ui-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.ui-card-eyebrow { margin: 0; font: var(--type-eyebrow); letter-spacing: var(--type-eyebrow-tracking); text-transform: uppercase; color: var(--fg-muted); }
.ui-card-icon {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px;
  border-radius: var(--radius); background: var(--surface-sunken); color: var(--fg-muted);
}
.ui-card-icon svg { width: 12px; height: 12px; }

/* ---- Panel (the Activity Log, 1:7107 / dark 52:26256) ---- */
.ui-panel {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-card); border-radius: var(--radius-2xl);
}
.ui-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-4) var(--space-5); background: var(--surface-header);
  border-bottom: 1px solid var(--border-strong);
}
.ui-panel-title { display: flex; align-items: center; gap: 6px; margin: 0; font: var(--type-title-sm); letter-spacing: var(--type-title-sm-tracking); color: var(--fg); }
.ui-panel-actions { display: flex; align-items: center; gap: var(--space-1); }
.ui-panel-link { font: var(--type-label); color: var(--fg-muted); text-decoration: none; }
.ui-panel-link:hover { color: var(--fg); }
/* CollapseBtn: a bare 20px icon button (chevron-right, x). */
.ui-panel-action {
  display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--fg-muted); cursor: pointer;
}
.ui-panel-action:hover { background: var(--surface-sunken); color: var(--fg); }
.ui-panel-action svg { width: 16px; height: 16px; }
.ui-panel-list { list-style: none; margin: 0; padding: 0; }
.ui-panel-row { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--divider); }
.ui-panel-row:last-child { border-bottom: 0; }

/* Scroll fade + hint (1:7161-1:7191): while more is below, the last rows fade
 * (1 -> .6 -> .3 -> .15) and "Scroll for more" shows; at the end both go.
 * uiScrollFadeMount() sets data-more from scrollHeight/clientHeight/scrollTop. */
.ui-scroll { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.ui-scroll[data-more] {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - var(--scroll-fade-height)), rgba(0, 0, 0, 0.6) calc(100% - var(--scroll-fade-height) * 2 / 3), rgba(0, 0, 0, 0.3) calc(100% - var(--scroll-fade-height) / 3), rgba(0, 0, 0, 0.15) 100%);
  mask-image: linear-gradient(to bottom, #000 calc(100% - var(--scroll-fade-height)), rgba(0, 0, 0, 0.6) calc(100% - var(--scroll-fade-height) * 2 / 3), rgba(0, 0, 0, 0.3) calc(100% - var(--scroll-fade-height) / 3), rgba(0, 0, 0, 0.15) 100%);
}
.ui-scroll-hint {
  display: none; flex-direction: column; align-items: center; justify-content: center; box-sizing: border-box;
  height: 63px; padding: var(--space-4) 0; color: var(--fg-muted);
  font: var(--type-eyebrow); letter-spacing: var(--type-eyebrow-tracking); text-transform: uppercase;
}
.ui-scroll-hint svg { width: 24px; height: 24px; }
.ui-scroll[data-more] + .ui-scroll-hint { display: flex; }

/* ---- Data table (1:6844, header 1:6791, row 1:6866, Repositories 42:8351) ---- */
.ui-table-card { overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-2xl); box-shadow: var(--shadow-toolbar); }
.ui-table-scroll { position: relative; overflow-x: auto; max-width: 100%; }
/* separate, not collapse: a row's hover shadow only paints on a separate table. */
.ui-table { width: 100%; border-collapse: separate; border-spacing: 0; font: var(--type-body-sm); color: var(--fg); }
.ui-table th {
  box-sizing: border-box; height: 56px; padding: 0 var(--space-3); text-align: left; white-space: nowrap; vertical-align: middle;
  background: var(--surface-header); border-bottom: 1px solid var(--divider);
  font: var(--type-eyebrow); letter-spacing: var(--table-head-tracking); text-transform: uppercase; color: var(--fg-muted);
}
.ui-table th svg { width: 12px; height: 12px; margin-left: 6px; vertical-align: -2px; }
.ui-table td { padding: var(--space-5) var(--space-3); vertical-align: middle; border-top: 1px solid var(--divider); }
.ui-table tbody tr:first-child td { border-top: 0; }
.ui-table tbody tr { background: var(--surface); }
/* Row hover: the "intable hover effect" shadow lifting the row on --surface.
 * Proposed, not in Figma: shadow only, no tint (open designer question). */
.ui-table tbody tr:hover, .ui-table tbody tr[data-force-hover] { position: relative; z-index: 1; box-shadow: var(--shadow-row-hover); }
.ui-table tbody tr[aria-expanded], .ui-table tbody tr.ui-row-expandable { cursor: pointer; }
.ui-table .ui-num { text-align: right; font-variant-numeric: tabular-nums; }
.ui-table .ui-col-expander { width: 48px; padding-left: 0; padding-right: 0; text-align: center; }
.ui-expander { display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; background: none; color: var(--fg-muted); cursor: pointer; }
.ui-expander svg { width: 12px; height: 12px; transition: transform var(--motion-fast, 120ms) ease; }
[aria-expanded="true"] > .ui-col-expander .ui-expander svg, .ui-expander[aria-expanded="true"] svg { transform: rotate(90deg); }
.ui-table tr.ui-row-detail td { padding-top: 0; border-top: 0; }

/* Cells */
.ui-cell-title { display: block; font: 700 12px/20px var(--font-sans); color: var(--fg-strong); }
.ui-cell-sub { display: block; font: 700 12px/16px var(--font-sans); color: var(--fg-muted); }
.ui-cell-strong { font: 700 12px/18px var(--font-sans); color: var(--fg); }          /* cost, 1:6903 */
.ui-cell-when { display: block; font: var(--type-label); color: var(--fg); }
.ui-cell-status { display: block; font: var(--type-micro); text-transform: uppercase; color: var(--fg-muted); }
.ui-cell-status-running { color: var(--live-text); }
/* Rounds (1:6900): 24 square, the P3 chip's tint, Plex Mono Bold 10. */
.ui-rounds {
  display: inline-grid; place-items: center; box-sizing: border-box; min-width: 24px; height: 24px; padding: 0 4px;
  background: var(--risk-p3-bg); border: 1px solid var(--risk-p3-border); border-radius: var(--radius-xs);
  font: var(--type-badge-mono); color: var(--fg); font-variant-numeric: tabular-nums;
}

/* Empty and loading */
.ui-table td.ui-table-empty { padding: var(--space-7) var(--space-5); text-align: center; color: var(--fg-muted); font: var(--type-body); }
.ui-table tr.ui-table-loading:hover { box-shadow: none; }

/* ---- Pagination (23:37144) in the table footer (1:7096) ----
 * The buttons are #3438's Secondary icon-only L (.btn.btn-secondary.btn-icon.btn-l);
 * a disabled one is that family's disabled fill. */
.ui-table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); box-sizing: border-box;
  min-height: 56px; padding: 10px var(--space-7) 10px var(--space-7);
  background: var(--surface-header); border-top: 1px solid var(--divider);
}
.ui-pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); width: 100%; }
.ui-pagination-status { margin: 0; font: 500 10px/15px var(--font-sans); color: var(--fg-muted); }
.ui-pagination-buttons { display: flex; gap: var(--space-2); }

/* ---- Tabs (Nav - Tabs 1:14703, Tab 23:36957) ---- */
.ui-tabs { display: flex; align-items: stretch; gap: var(--space-7); margin: 0; padding: 0; list-style: none; }
.ui-tab {
  display: inline-flex; align-items: center; box-sizing: border-box; height: 48px; padding: 11px var(--space-1) 14.5px;
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; text-decoration: none; white-space: nowrap;
  font: 500 13px/19.5px var(--font-sans); color: var(--fg-muted);
  transition: color var(--motion-fast, 120ms) ease, border-color var(--motion-fast, 120ms) ease;
}
.ui-tab:hover { color: var(--fg); }
.ui-tab[aria-selected="true"], .ui-tab[aria-current="page"] { font-weight: 600; color: var(--live-text); border-bottom-color: var(--live-text); }

/* ---- Policy banner (42:8493) ---- */
.ui-banner {
  box-sizing: border-box; padding: var(--space-7); background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent); border-radius: var(--radius-2xl); box-shadow: var(--shadow-card);
}
.ui-banner-title { display: flex; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-6); font: 700 20px/28px var(--font-sans); letter-spacing: -0.5px; color: var(--fg-strong); }
.ui-banner-title::before { content: ""; flex: none; width: 8px; height: 24px; border-radius: var(--radius-pill); background: var(--brand); }
.ui-banner-body {
  margin: 0 0 var(--space-2); padding: var(--space-3) 7px;
  background: color-mix(in srgb, var(--brand) 5%, transparent); border: 1px solid color-mix(in srgb, var(--brand) 10%, transparent);
  border-radius: var(--radius-sm); font: 400 15px/24.38px var(--font-sans); color: var(--fg-muted);
}
.ui-banner-body strong { font-weight: 700; }
.ui-banner-note { margin: 0; font: 400 13px/20px var(--font-sans); color: var(--fg-muted); }
.ui-banner-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }

@media (prefers-reduced-motion: reduce) {
  .ui-expander svg, .ui-tab { transition: none; }
}
