/* Slate & Teal component kit. Needs tokens.css and base.css before it (same folder).
 * Extracted from the Dashboard and the PNN cabinet, where every rule here runs in production.
 * Rules: spacing only from the --space-* scale, figures in the mono face with tabular numerals, colour only where it carries
 * meaning, no gradients, no blur, no decoration. App-specific layouts (filters, bulk bar, product cell, form preview...) stay in
 * the app's own CSS; see design-system/README.md. */

/* ---------- Icons: local SVG sprite (assets/ui/icons.svg), see templates/ui.php ---------- */
.icon { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon-lg { width: 20px; height: 20px; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Shell ---------- */
.app-shell { display: block; min-height: 100vh; }
.app-header { position: sticky; top: 0; z-index: var(--z-sticky); background: var(--color-surface); border-bottom: var(--rule-hair) solid var(--color-rule); }
.app-header-bar { display: flex; align-items: center; gap: var(--space-lg); max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); min-height: var(--header-h); }
.app-brand { display: inline-flex; align-items: center; gap: var(--space-sm); flex: 0 0 auto; font-weight: 600; font-size: var(--text-lg); letter-spacing: var(--tracking-display); }
.app-logo { width: 28px; height: 28px; flex: 0 0 auto; }
.app-logo rect { fill: var(--color-accent); }
.app-logo g { fill: none; stroke: var(--color-accent-ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.app-menu { flex: 1 1 auto; min-width: 0; }
.app-menu > summary { display: none; list-style: none; }
.app-menu > summary::-webkit-details-marker { display: none; }
.app-nav { display: flex; align-items: center; gap: var(--space-3xs); }
.app-nav a { display: inline-flex; align-items: center; gap: var(--space-xs); min-height: 36px; padding: 0 var(--space-sm); border-radius: var(--radius-input); color: var(--color-ink-2); font-size: var(--text-md); font-weight: 500; white-space: nowrap; transition: color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out); }
.app-nav a:hover { color: var(--color-ink); background: var(--color-paper-2); }
.app-nav a[aria-current="page"] { color: var(--color-accent-2); background: var(--color-accent-wash); }
.app-nav-gap { flex: 1 1 auto; }
.app-nav a.app-nav-exit, .app-nav a.app-nav-util, .app-nav a.app-nav-util { color: var(--color-muted); }
.app-shop { display: inline-flex; align-items: center; gap: var(--space-xs); max-width: 22ch; min-height: 28px; padding: 0 var(--space-sm); border: var(--rule-hair) solid var(--color-rule-2); border-radius: var(--radius-pill); color: var(--color-ink-2); font-size: var(--text-sm); }
.app-shop span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 75rem) {
  .app-nav a.app-nav-util span, .app-nav a.app-nav-exit span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .app-nav a.app-nav-util, .app-nav a.app-nav-util, .app-nav a.app-nav-exit { padding: 0; width: 36px; justify-content: center; }
}
@media (max-width: 60rem) { .app-shop { display: none; } }
@media (max-width: 48rem) {
  .app-header-bar { position: relative; flex-wrap: wrap; gap: var(--space-xs); padding-block: var(--space-xs); }
  .app-brand { flex: 1 1 auto; }
  .app-menu { flex: 1 0 100%; order: 3; }
  .app-menu > summary { display: inline-flex; align-items: center; gap: var(--space-xs); position: absolute; top: calc((var(--header-h) - 40px) / 2); right: var(--gutter); min-height: 40px; padding: 0 var(--space-md); border: var(--rule-hair) solid var(--color-rule-2); border-radius: var(--radius-input); background: var(--color-surface); color: var(--color-ink); font-weight: 500; cursor: pointer; }
  .app-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xs); padding-bottom: var(--space-xs); }
  .app-nav a, .app-nav a.app-nav-util, .app-nav a.app-nav-util, .app-nav a.app-nav-exit { width: auto; min-height: 48px; justify-content: flex-start; padding: 0 var(--space-md); border: var(--rule-hair) solid var(--color-rule); background: var(--color-paper); }
  .app-nav a span, .app-nav a.app-nav-util span, .app-nav a.app-nav-exit span { position: static; width: auto; height: auto; clip-path: none; }
  .app-nav-gap { display: none; }
}

.app-main { display: block; width: 100%; max-width: var(--container); margin: 0 auto; padding: var(--space-lg) var(--gutter) var(--space-2xl); min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-xs) var(--space-md); margin: 0 0 var(--space-lg); min-height: 36px; }
.page-head h1 { display: flex; align-items: center; gap: var(--space-sm); }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-xs) var(--space-sm); }
.page-stack { display: grid; gap: var(--space-md); }
.page-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-md); align-items: start; }
@media (max-width: 75rem) { .page-cols { grid-template-columns: minmax(0, 1fr); } }


/* ---------- Panels ---------- */
.panel { background: var(--color-surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: var(--space-md) var(--space-lg) var(--space-lg); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-xs) var(--space-md); margin-bottom: var(--space-md); min-height: 32px; }
.panel-head h2 { display: flex; align-items: center; gap: var(--space-xs); max-width: none; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 var(--space-xs); border-radius: var(--radius-pill); background: var(--color-paper-3); color: var(--color-ink-2); font: 500 var(--text-xs)/1 var(--font-outlier); font-variant-numeric: tabular-nums; }
.note { color: var(--color-muted); font-size: var(--text-sm); max-width: 75ch; }

/* ---------- Metrics strip: one card, five cells, hairlines between ---------- */
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--rule-hair); background: var(--color-rule); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden; }
.metric { display: grid; align-content: start; gap: var(--space-2xs); min-width: 0; padding: var(--space-md) var(--space-lg); background: var(--color-surface); border: 0; color: inherit; font: inherit; text-align: left; }
button.metric { cursor: pointer; transition: background-color var(--dur-micro) var(--ease-out); }
button.metric:hover { background: var(--color-paper-2); }
button.metric[aria-pressed="true"] { background: color-mix(in oklab, var(--color-accent) 9%, var(--color-surface)); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--color-accent) 30%, transparent); }
button.metric:focus-visible { outline-offset: -2px; }
.metric-label { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); color: var(--color-muted); font-size: var(--text-sm); }
.metric-value { font-family: var(--font-outlier); font-size: var(--text-2xl); font-weight: 500; line-height: 1.15; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.metric-value small { margin-left: var(--space-2xs); font: 400 var(--text-sm)/1 var(--font-body); letter-spacing: 0; color: var(--color-muted); }
.metric-note { min-height: 20px; color: var(--color-muted); font-size: var(--text-sm); }
.metric-warn .metric-value { color: var(--color-warn); }
.delta { font-size: var(--text-sm); font-weight: 500; font-variant-numeric: tabular-nums; color: var(--color-muted); }
.delta[data-tone="up"] { color: var(--color-ok); }
.delta[data-tone="down"] { color: var(--color-error); }
.spark { display: block; width: 100%; height: 32px; margin-top: var(--space-xs); overflow: visible; }
.spark .spark-area { fill: var(--bar, var(--color-accent)); opacity: 0.1; stroke: none; }
.spark .spark-line { fill: none; stroke: var(--bar, var(--color-accent)); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark.is-quiet { --bar: var(--color-muted); }
@media (max-width: 75rem) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } .metric:last-child:nth-child(odd) { grid-column: 1 / -1; } }
@media (max-width: 40rem) { .metric { padding: var(--space-sm) var(--space-md); } .metric-value { font-size: var(--text-xl); } .spark { height: 24px; } }

/* ---------- Chart ---------- */
.chart-tools { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-xs) var(--space-md); }
.chart-legend { display: flex; margin-bottom: var(--space-xs); flex-wrap: wrap; gap: var(--space-xs) var(--space-md); color: var(--color-muted); font-size: var(--text-sm); }
.legend-item { display: inline-flex; align-items: center; gap: var(--space-xs); }
.legend-item::before { content: ""; width: 12px; height: 2px; border-radius: 2px; background: var(--legend, var(--color-accent)); }
.legend-item[data-kind="previous"]::before { height: 0; background: none; border-top: 2px dashed var(--color-muted); border-radius: 0; }
.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart-grid { stroke: var(--color-rule); stroke-width: 1; }
.chart-tick { fill: var(--color-muted); font: 11px var(--font-outlier); }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; stroke: var(--color-accent); }
.chart-area { fill: var(--color-accent); opacity: 0.09; stroke: none; }
.chart-prev { fill: none; stroke: var(--color-muted); stroke-width: 1.5; stroke-dasharray: 4 4; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: 0.8; }
.chart-cursor { stroke: var(--color-rule-2); stroke-width: 1; }
.chart-dot { fill: var(--color-accent); stroke: var(--color-surface); stroke-width: 2; }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-tip { position: absolute; z-index: var(--z-raised); min-width: 140px; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-input); background: var(--color-raised); box-shadow: var(--shadow-pop); font-size: var(--text-sm); pointer-events: none; }
.chart-tip dl { display: grid; grid-template-columns: 1fr auto; gap: var(--space-3xs) var(--space-md); }
.chart-tip dt { color: var(--color-muted); }
.chart-tip dd { font-family: var(--font-outlier); font-variant-numeric: tabular-nums; text-align: right; }
.chart-tip strong { display: block; margin-bottom: var(--space-2xs); font-weight: 500; }

/* ---------- Status, badge ---------- */
.status { display: inline-flex; align-items: center; gap: var(--space-xs); font-size: var(--text-md); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--color-neutral-mark); flex: 0 0 auto; }
.status-awaiting::before { background: var(--color-info-mark); }
.status-queued::before { background: var(--color-warn-mark); }
.status-done::before { background: var(--color-ok-mark); }
.status-muted { color: var(--color-muted); }
.status-ok::before { background: var(--color-ok-mark); }
.status-warn::before { background: var(--color-warn-mark); }
.status-error::before { background: var(--color-error-mark); }
.status-info::before { background: var(--color-info-mark); }
.status-error { color: var(--color-error); }
.badge { display: inline-flex; align-items: center; gap: var(--space-2xs); padding: 1px var(--space-xs); border-radius: var(--radius-pill); background: var(--color-paper-2); color: var(--color-ink-2); font-size: var(--text-sm); font-weight: 500; line-height: 1.5; white-space: nowrap; }
.badge-ok { background: var(--color-ok-wash); color: var(--color-ok); }
.badge-warn { background: var(--color-warn-wash); color: var(--color-warn); }
.pill { display: inline-flex; align-items: center; gap: var(--space-xs); min-height: 28px; padding: 0 var(--space-sm); border: var(--rule-hair) solid var(--color-rule-2); border-radius: var(--radius-pill); color: var(--color-ink-2); font-size: var(--text-sm); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--color-ok-mark); }
.pill[data-state="late"] { border-color: var(--color-warn-mark); background: var(--color-warn-wash); color: var(--color-warn); }
.pill[data-state="late"]::before { background: var(--color-warn-mark); }
.pill .icon-btn { margin-right: calc(var(--space-xs) * -1); }

/* ---------- Feed and ranking ---------- */
.feed { display: grid; }
.feed-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-md); padding: var(--space-sm) 0; border-top: var(--rule-hair) solid var(--color-rule); }
.feed-row:first-child { border-top: 0; padding-top: 0; }
.feed-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.feed-title a:hover { color: var(--color-accent-2); }
.feed-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-muted); font-size: var(--text-sm); }
.feed-meta { display: grid; justify-items: end; gap: var(--space-3xs); }
.feed-time { color: var(--color-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.rank { display: grid; }
.rank-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-md); padding: var(--space-sm) 0; border-top: var(--rule-hair) solid var(--color-rule); }
.rank-row:first-child { border-top: 0; padding-top: 0; }
.rank-row::after { content: ""; position: absolute; left: 0; bottom: -1px; height: 3px; width: var(--share, 0%); max-width: 100%; border-radius: 3px; background: var(--color-accent); opacity: 0.6; }
.rank-name { min-width: 0; }
.rank-name a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.rank-name a:hover { color: var(--color-accent-2); }
.rank-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-muted); font: 400 var(--text-sm)/1.4 var(--font-outlier); }
.rank-fig { font-family: var(--font-outlier); font-size: var(--text-md); font-variant-numeric: tabular-nums; text-align: right; min-width: 3ch; }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.chip { display: inline-flex; align-items: center; gap: var(--space-xs); min-height: 28px; max-width: 100%; padding: 0 var(--space-sm); border-radius: var(--radius-pill); background: var(--color-paper-2); color: var(--color-ink-2); font-size: var(--text-sm); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs); min-height: 36px; padding: 0 var(--space-md); border: var(--rule-hair) solid var(--color-accent); border-radius: var(--radius-input); background: var(--color-accent); color: var(--color-accent-ink); font-size: var(--text-md); font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
.btn:hover { background: var(--color-accent-2); border-color: var(--color-accent-2); color: var(--color-accent-ink); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; pointer-events: none; }
.btn-secondary { background: var(--color-surface); color: var(--color-ink); border-color: var(--color-rule-2); }
.btn-secondary:hover { background: var(--color-paper-2); border-color: var(--color-muted); color: var(--color-ink); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--color-ink-2); padding-inline: var(--space-sm); }
.btn-quiet:hover { background: var(--color-paper-2); border-color: transparent; color: var(--color-ink); }
.btn-danger { background: var(--color-surface); border-color: var(--color-rule-2); color: var(--color-error); }
.btn-danger:hover { background: var(--color-error-wash); border-color: var(--color-error-mark); color: var(--color-error); }
.btn-sm { min-height: 28px; padding: 0 var(--space-sm); font-size: var(--text-sm); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--color-muted); cursor: pointer; transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out); }
.icon-btn:hover { background: var(--color-paper-3); color: var(--color-ink); }
.icon-btn[disabled] { opacity: 0.5; cursor: wait; }
.link { color: var(--color-accent-2); border-bottom: var(--rule-hair) solid transparent; transition: border-color var(--dur-micro) var(--ease-out); }
.link:hover { border-bottom-color: currentColor; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-2xs); min-width: 0; }
.field > label { font-size: var(--text-sm); color: var(--color-muted); font-weight: 500; }
input[type="text"], input[type="search"], input[type="number"], input[type="email"], input[type="password"], input[type="date"], input[type="url"], select, textarea { min-height: 36px; width: 100%; padding: 0 var(--space-sm); background: var(--color-surface); border: var(--rule-hair) solid var(--color-rule-2); border-radius: var(--radius-input); color: var(--color-ink); font-size: var(--text-md); transition: border-color var(--dur-micro) var(--ease-out); }
textarea { padding: var(--space-xs) var(--space-sm); line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--color-faint); }
input:hover, select:hover, textarea:hover { border-color: var(--color-muted); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: var(--icon-select); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; cursor: pointer; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--color-accent); cursor: pointer; }
@media (max-width: 48rem) { input[type="text"], input[type="search"], input[type="number"], input[type="email"], input[type="password"], input[type="date"], input[type="url"], select, textarea { font-size: 16px; min-height: 44px; } .btn { min-height: 44px; } .btn-sm { min-height: 36px; } }

.segmented { display: inline-flex; flex-wrap: wrap; gap: var(--space-3xs); padding: var(--space-3xs); background: var(--color-paper-3); border-radius: var(--radius-input); max-width: 100%; }
.segmented > button, .segmented > a { display: inline-flex; align-items: center; gap: var(--space-xs); min-height: 30px; padding: 0 var(--space-sm); border: 0; border-radius: calc(var(--radius-input) - 2px); background: transparent; color: var(--color-ink-2); font-size: var(--text-md); font-weight: 500; transition: color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out); }
.segmented > :hover { color: var(--color-ink); }
.segmented > [aria-pressed="true"], .segmented > [aria-current="page"] { background: var(--color-raised); color: var(--color-ink); box-shadow: var(--shadow-card); }

.switch { display: inline-flex; align-items: center; gap: var(--space-xs); cursor: pointer; font-size: var(--text-md); }
.switch input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; min-height: 0; padding: 0; border: 0; border-radius: var(--radius-pill); background: var(--color-rule-2); position: relative; cursor: pointer; flex: 0 0 auto; transition: background-color var(--dur-micro) var(--ease-out); }
.switch input[type="checkbox"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--color-raised); transition: transform var(--dur-short) var(--ease-out); }
.switch input[type="checkbox"]:checked { background: var(--color-accent); }
.switch input[type="checkbox"]:checked::after { transform: translateX(14px); }

details.disclosure > summary { display: inline-flex; align-items: center; gap: var(--space-xs); list-style: none; cursor: pointer; min-height: 32px; color: var(--color-ink-2); font-size: var(--text-md); font-weight: 500; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: ""; width: 14px; height: 14px; background: currentColor; -webkit-mask: var(--mask-chevron) center / contain no-repeat; mask: var(--mask-chevron) center / contain no-repeat; transition: transform var(--dur-short) var(--ease-out); }
details.disclosure[open] > summary::after { transform: rotate(180deg); }
details.disclosure > summary:hover { color: var(--color-ink); }
details.disclosure > :not(summary) { margin-top: var(--space-sm); }

/* ---------- Tables ---------- */
.table-scroll { position: relative; overflow-x: auto; max-width: 100%; }
.table { width: 100%; font-size: var(--text-md); }
.table th { text-align: left; font-weight: 500; font-size: var(--text-sm); color: var(--color-muted); padding: var(--space-xs) var(--space-md); border-bottom: var(--rule-hair) solid var(--color-rule-2); white-space: nowrap; }
.table td { padding: var(--space-sm) var(--space-md); border-bottom: var(--rule-hair) solid var(--color-rule); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--color-paper-2); }
.table tbody tr.is-selected td { background: var(--color-accent-wash); }
.table th:first-child, .table td:first-child { padding-left: 0; width: 24px; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table td.when { color: var(--color-ink-2); font-size: var(--text-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-title { overflow-wrap: anywhere; }
.cell-title a:hover { color: var(--color-accent-2); }
.cell-sub { display: block; color: var(--color-muted); font-size: var(--text-sm); }
.table-sort { display: inline-flex; align-items: center; gap: var(--space-2xs); color: inherit; }
.table-sort:hover, .table-sort.is-active { color: var(--color-ink); }
.table-sort .icon { width: 14px; height: 14px; }
@media (max-width: 48rem) { .table .col-secondary { display: none; } }

/* ---------- Pager: numbered pages plus a jump field (markup in templates/pager.php) ---------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-sm) var(--space-md); margin: var(--space-md) 0; }
.pager-pages { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs); }
.pager-link, .pager-current, .pager-gap { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; padding: 0 var(--space-sm); border-radius: var(--radius-input); color: var(--color-ink-2); font-size: var(--text-md); font-variant-numeric: tabular-nums; }
.pager-link:hover { background: var(--color-paper-2); color: var(--color-ink); }
.pager-current { background: var(--color-accent-wash); color: var(--color-accent-2); font-weight: 500; }
.pager-gap { color: var(--color-faint); min-width: 16px; padding: 0; }
.pager-link.is-disabled { color: var(--color-faint); pointer-events: none; }
.pager-jump { display: flex; align-items: center; gap: var(--space-xs); color: var(--color-muted); font-size: var(--text-sm); }
.pager-jump input { width: 72px; min-height: 32px; }
.pager-jump .btn { min-height: 32px; }
@media (max-width: 40rem) { .pager-link:not(.pager-step), .pager-gap, .pager-jump { display: none; } .pager { justify-content: center; } }

/* ---------- Settings rows: label and hint on the left, the control on the right ---------- */
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-md); align-items: start; }
.settings-stack { display: grid; gap: var(--space-md); }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-xs) var(--space-lg); padding: var(--space-md) 0; border-top: var(--rule-hair) solid var(--color-rule); }
.panel-head + .setting { border-top: 0; padding-top: 0; }
.setting:last-child { padding-bottom: 0; }
.setting.is-stacked { grid-template-columns: minmax(0, 1fr); }
.setting-label { font-weight: 500; }
.setting-help { margin-top: var(--space-3xs); color: var(--color-muted); font-size: var(--text-sm); max-width: 60ch; }
.setting-control { min-width: 0; }
.color-row { display: flex; align-items: center; gap: var(--space-xs); }
.color-row input[type="text"] { width: 120px; font-family: var(--font-outlier); text-transform: lowercase; }
.color-swatch { appearance: none; -webkit-appearance: none; width: 36px; height: 36px; min-height: 0; padding: 0; border: var(--rule-hair) solid var(--color-rule-2); border-radius: var(--radius-input); background: none; cursor: pointer; }
.color-swatch::-webkit-color-swatch-wrapper { padding: 4px; }
.color-swatch::-webkit-color-swatch { border: 0; border-radius: 5px; }
.color-swatch::-moz-color-swatch { border: 0; border-radius: 5px; }
.panel-warn { background: var(--color-warn-wash); box-shadow: 0 0 0 1px color-mix(in oklab, var(--color-warn-mark) 45%, transparent); }
.save-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-sm) var(--space-md); }
.flash-inline { display: none; align-items: center; gap: var(--space-xs); font-size: var(--text-md); }
.flash-inline.is-error { color: var(--color-error); }
.flash-inline.is-success { color: var(--color-ok); }
.settings-aside { position: sticky; top: calc(var(--header-h) + var(--space-md)); }
@media (max-width: 75rem) { .settings-layout { grid-template-columns: minmax(0, 1fr); } .settings-aside { position: static; order: -1; } }
@media (max-width: 40rem) { .setting:has(> .setting-control) { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Alerts: calm plates with the action next to the message ---------- */
.alert { display: grid; gap: var(--space-xs); margin-bottom: var(--space-md); padding: var(--space-md) var(--space-lg); border-radius: var(--radius-card); background: var(--color-paper-2); font-size: var(--text-md); }
.alert > strong, .alert h2 { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--text-lg); font-weight: 600; }
.alert p { color: var(--color-ink-2); max-width: 75ch; }
.alert-danger { background: var(--color-error-wash); }
.alert-danger > strong, .alert-danger h2 { color: var(--color-error); }
.alert-warning { background: var(--color-warn-wash); }
.alert-warning > strong, .alert-warning h2 { color: var(--color-warn); }
.alert .btn { justify-self: start; }
.alert-actions { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-sm); margin-top: var(--space-2xs); }

/* ---------- States ---------- */
.state { display: flex; flex-direction: column; gap: var(--space-xs); align-items: flex-start; padding: var(--space-md) 0; color: var(--color-muted); }
.state strong { color: var(--color-ink); font-weight: 500; }
.state-center { align-items: center; text-align: center; padding: var(--space-xl) var(--space-md); }
.state .icon { width: 24px; height: 24px; color: var(--color-faint); }

.skeleton { display: block; height: 14px; border-radius: var(--radius-input); background: var(--color-paper-3); animation: skeleton-pulse 1.4s var(--ease-out) infinite; }
.skeleton + .skeleton { margin-top: var(--space-xs); }
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .skeleton, .spin { animation: none; } }

/* ---------- Lightbox (native <dialog>) (native <dialog>) ---------- */
.lightbox { max-width: min(92vw, 960px); max-height: 92vh; padding: 0; border: 0; border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-pop); overflow: hidden; }
.lightbox::backdrop { background: oklch(15% 0.02 245 / 0.6); }
.lightbox img { display: block; max-width: 100%; max-height: 92vh; margin: 0 auto; }
.lightbox .icon-btn { position: absolute; top: var(--space-xs); right: var(--space-xs); background: var(--color-raised); box-shadow: var(--shadow-card); }

/* ---------- Tooltips (tippy theme "app") ---------- */
.tippy-box[data-theme~='app'] { background: var(--color-ink); color: var(--color-paper); border-radius: var(--radius-input); font-size: var(--text-sm); font-family: var(--font-body); box-shadow: var(--shadow-pop); }
.tippy-box[data-theme~='app'] .tippy-arrow { color: var(--color-ink); }
.tippy-box[data-theme~='app'] .tippy-content { padding: var(--space-xs) var(--space-sm); }
/* ---------- Access gate: a centred card for sign-in and error pages ---------- */
.gate { display: grid; place-items: center; min-height: 100vh; padding: var(--space-md); }
.gate-card { display: grid; justify-items: start; gap: var(--space-sm); width: 100%; max-width: 440px; padding: var(--space-lg); }
.gate-card .app-logo { width: 40px; height: 40px; margin-bottom: var(--space-xs); }
.gate-card p { color: var(--color-ink-2); }
.gate-card .btn { margin-top: var(--space-xs); }

/* ---------- Shared by Search and Frontpad: shop pill, support banner, overview rows ---------- */
.app-shop { display: inline-flex; align-items: center; gap: var(--space-xs); max-width: 24ch; min-height: 28px; padding: 0 var(--space-sm); border: var(--rule-hair) solid var(--color-rule-2); border-radius: var(--radius-pill); color: var(--color-ink-2); font-size: var(--text-sm); }
.app-shop span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 60rem) { .app-shop { max-width: 18ch; } }
@media (max-width: 48rem) { .app-shop { display: none; } }
.support-banner { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-md); padding: var(--space-sm) var(--space-md); border-radius: var(--radius-input); background: var(--color-info-wash); color: var(--color-info); font-size: var(--text-md); }
.support-banner > div { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.support-banner span { color: var(--color-ink-2); font-size: var(--text-sm); }
.metrics--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 75rem) { .metrics--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.metric-value--date { font-size: var(--text-xl); letter-spacing: 0; }
.metric-state { font-family: var(--font-body); font-size: var(--text-xl); letter-spacing: 0; }
.metric-state .status { font-size: var(--text-xl); font-weight: 500; }
.metric-state .status::before { width: 10px; height: 10px; }
.glance { display: grid; }
.glance-row { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) auto; align-items: center; gap: var(--space-md); padding: var(--space-sm) 0; border-top: var(--rule-hair) solid var(--color-rule); color: inherit; transition: background-color var(--dur-micro) var(--ease-out); }
.glance-row:first-child { border-top: 0; padding-top: 0; }
.glance-row:hover .glance-name { color: var(--color-accent-2); }
.glance-name { font-weight: 500; }
.glance-value { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); color: var(--color-ink-2); }
.glance-of { color: var(--color-muted); margin-left: var(--space-2xs); }
.glance-arrow { color: var(--color-faint); }
.glance-row:hover .glance-arrow { color: var(--color-accent-2); }
.chip-off { color: var(--color-muted); }
.chip .status { gap: var(--space-xs); font-size: var(--text-sm); }
@media (max-width: 48rem) { .glance-row { grid-template-columns: minmax(0, 1fr) auto; } .glance-value { grid-column: 1; grid-row: 2; } .glance-arrow { grid-column: 2; grid-row: 1 / 3; } }
.status-neutral::before { background: var(--color-neutral-mark); }

/* ---------- Code samples (help) ---------- */
.code-wrap { position: relative; margin-top: var(--space-sm); }
.code { margin: 0; padding: var(--space-md) var(--space-lg); padding-right: calc(var(--space-3xl) * 2 + var(--space-sm)); overflow-x: auto; border-radius: var(--radius-card); background: var(--color-paper-3); color: var(--color-ink); font: 400 var(--text-md)/1.6 var(--font-outlier); tab-size: 2; }
.code code { font: inherit; }
.code-wrap .btn { position: absolute; top: var(--space-sm); right: var(--space-sm); }
.note code { padding: 0 var(--space-2xs); border-radius: var(--radius-input); background: var(--color-paper-3); font-family: var(--font-outlier); font-size: var(--text-sm); }
@media (max-width: 40rem) { .code { padding-right: var(--space-lg); padding-bottom: calc(var(--space-2xl) + var(--space-xs)); } .code-wrap .btn { top: auto; bottom: var(--space-sm); } }

/* ---------- Shared by Frontpad and MyOrders: settings form helpers, journal rows, setup guide ---------- */
.form-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.form-fieldset:disabled { opacity: 0.6; }
.field-note { margin-top: var(--space-sm); color: var(--color-muted); font-size: var(--text-sm); }
.field-note[role="alert"] { color: var(--color-error); }
.field-note[hidden] { display: none; }
.save-bar--sticky { position: sticky; bottom: var(--space-md); z-index: var(--z-raised); padding: var(--space-sm) var(--space-md); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-card); }
.save-dirty { color: var(--color-warn); font-size: var(--text-sm); }
.save-dirty[hidden] { display: none; }
.save-bar--sticky .flash-inline { margin-left: auto; }
/* ---------- Journal ---------- */
.log { display: grid; }
.log[hidden] { display: none; }
.log-day { margin: var(--space-lg) 0 var(--space-xs); font-size: var(--text-sm); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-muted); }
.log-day:first-child { margin-top: 0; }
.log-day[hidden], .log-row[hidden] { display: none; }
.log-row { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--space-md); padding: var(--space-sm) 0; border-top: var(--rule-hair) solid var(--color-rule); }
.log-row.is-first { border-top: 0; padding-top: 0; }
.log-time { color: var(--color-muted); font-size: var(--text-sm); line-height: 1.7; }
.log-main { display: grid; gap: var(--space-2xs); min-width: 0; }
.log-title .status { align-items: flex-start; font-weight: 500; white-space: normal; }
.log-title .status::before { margin-top: 0.6em; }
.log-reason { color: var(--color-ink-2); font-size: var(--text-md); max-width: 75ch; }
.log-hint { display: block; margin-top: var(--space-3xs); color: var(--color-muted); font-size: var(--text-sm); }
.log-facts { display: flex; flex-wrap: wrap; gap: 0 var(--space-md); color: var(--color-muted); font-size: var(--text-sm); }
.log-facts .mono { color: var(--color-ink-2); }
.log-foot { margin-top: var(--space-lg); color: var(--color-faint); font-size: var(--text-sm); }

@media (max-width: 40rem) { .log-row { grid-template-columns: 44px minmax(0, 1fr); gap: var(--space-sm); } .save-bar--sticky .flash-inline { margin-left: 0; } }
/* ---------- Guide ---------- */
.guide { display: grid; grid-template-columns: minmax(0, 16rem) minmax(0, 1fr); gap: var(--space-2xl); align-items: start; }
.guide-lead { position: sticky; top: calc(var(--header-h) + var(--space-md)); display: grid; gap: var(--space-sm); }
.guide-lead p { color: var(--color-ink-2); }
.guide-toc { display: grid; gap: var(--space-2xs); margin: var(--space-xs) 0; padding: 0 0 0 var(--space-md); color: var(--color-muted); }
.guide-toc a { color: var(--color-ink-2); }
.guide-toc a:hover { color: var(--color-accent-2); }
.guide-steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-xl); min-width: 0; max-width: 52rem; }
.guide-step { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: var(--space-sm); padding-top: var(--space-lg); border-top: var(--rule-hair) solid var(--color-rule-2); scroll-margin-top: calc(var(--header-h) + var(--space-md)); }
.guide-step:first-child { padding-top: 0; border-top: 0; }
.guide-step h3 { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-xs) var(--space-sm); font-size: var(--text-xl); }
.guide-step p { color: var(--color-ink-2); max-width: 65ch; }
.guide-n { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--color-accent-wash); color: var(--color-accent-2); font: 500 var(--text-md)/1 var(--font-outlier); }
.guide-opt { padding: 0 var(--space-xs); border-radius: var(--radius-pill); background: var(--color-paper-3); color: var(--color-muted); font: 400 var(--text-sm)/22px var(--font-body); }
.guide-fig { display: grid; gap: var(--space-2xs); margin: var(--space-2xs) 0 var(--space-xs); }
.guide-fig figcaption { color: var(--color-muted); font-size: var(--text-sm); }
.guide-zoom { position: relative; display: block; width: fit-content; max-width: 100%; padding: 0; border: var(--rule-hair) solid var(--color-rule-2); border-radius: var(--radius-card); background: var(--color-paper-2); overflow: hidden; cursor: zoom-in; }
.guide-zoom img { display: block; width: auto; max-width: 100%; max-height: 24rem; }
.guide-lead .link { display: inline-flex; align-items: center; gap: var(--space-xs); justify-self: start; }
.guide-zoom-icon { position: absolute; right: var(--space-xs); bottom: var(--space-xs); padding: var(--space-2xs); border-radius: var(--radius-input); background: var(--color-raised); box-shadow: var(--shadow-card); color: var(--color-muted); width: 24px; height: 24px; }
.guide-checks { display: grid; gap: var(--space-xs); margin: 0; padding: 0 0 0 var(--space-md); color: var(--color-ink-2); max-width: 65ch; }
@media (max-width: 75rem) { .guide { grid-template-columns: minmax(0, 1fr); gap: var(--space-lg); } .guide-lead { position: static; } }
button.chip { border: 0; cursor: pointer; font: inherit; transition: background-color var(--dur-micro) var(--ease-out); }
button.chip:hover { background: var(--color-accent-wash); color: var(--color-accent-2); }

/* ---------- Day bars (charts/stackbars.js): rounded tops, a hairline between stacked segments, a hover band, a grow-in ---------- */
.chart-bars .chart-grid { stroke-dasharray: 2 4; }
.chart-bars .chart-grid-base { stroke: var(--color-rule-2); stroke-dasharray: none; }
.chart-seg-1 { fill: var(--color-accent); }
.chart-seg-2 { fill: var(--color-info-mark); }
.chart-seg-err { fill: var(--color-error-mark); }
.chart-zero { fill: var(--color-rule-2); }
.chart-band { fill: var(--color-accent-wash); opacity: 0.75; pointer-events: none; }
.chart-peak { fill: var(--color-ink-2); font: 500 11px var(--font-outlier); pointer-events: none; }
.chart-col { transition: opacity var(--dur-short) var(--ease-out); }
.chart-bars.has-focus .chart-col:not(.is-active) { opacity: 0.45; }
@keyframes chart-grow { from { transform: scaleY(0.04); opacity: 0; } }
@media (prefers-reduced-motion: no-preference) { .chart-col { transform-box: fill-box; transform-origin: 50% 100%; animation: chart-grow 380ms var(--ease-out) both; animation-delay: calc(var(--i) * 9ms); } }

