/* ============================================================
   Fit Notebook — components.css
   Shared component classes. Modules use these classes and the
   semantic tokens only — never raw colors (DESIGN_SYSTEM §8).
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-target);
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 600; font-size: var(--fs-sm);
  cursor: pointer; text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); color: var(--on-brand); }
.btn-secondary {
  background: var(--bg-surface); color: var(--brand-strong);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--brand-soft); color: var(--brand-strong); }
.btn-subtle { background: transparent; color: var(--text-secondary); }
.btn-subtle:hover { background: var(--bg-inset); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger:hover { filter: brightness(0.92); color: var(--on-danger); }

.btn-sm { min-height: 36px; padding: 0 var(--space-4); font-size: var(--fs-xs); }
.btn-lg { min-height: 52px; padding: 0 var(--space-7); font-size: var(--fs-base); }
.btn-icon { width: var(--touch-target); padding: 0; }
.btn-block { width: 100%; }

.btn .spinner { display: none; }
.btn[aria-busy="true"] .spinner { display: inline-block; }
.btn[aria-busy="true"] { pointer-events: none; opacity: 0.8; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: fn-spin 700ms linear infinite;
}
@keyframes fn-spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { margin-bottom: var(--space-5); }
.field-label {
  display: block;
  font-weight: 600; font-size: var(--fs-sm);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.field-label .req { color: var(--danger); margin-left: 2px; }
.field-help {
  font-size: var(--fs-xs); color: var(--text-muted);
  margin-top: var(--space-2);
}
.field-error {
  display: flex; align-items: center; gap: var(--space-1);
  font-size: var(--fs-xs); color: var(--danger);
  margin-top: var(--space-2); font-weight: 600;
}

.input, .select, .textarea {
  width: 100%;
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid var(--focus-ring); outline-offset: 0;
  border-color: var(--focus-ring);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--danger);
}
.textarea { min-height: 96px; resize: vertical; }

/* Number input with unit suffix */
.input-unit { display: flex; align-items: stretch; }
.input-unit .input {
  border-top-right-radius: 0; border-bottom-right-radius: 0;
  border-right: 0; text-align: right;
  font-family: var(--font-display); font-variant-numeric: tabular-nums;
  font-size: var(--fs-lg);
}
.input-unit .unit {
  display: flex; align-items: center;
  padding: 0 var(--space-3);
  background: var(--bg-inset); color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--fs-sm); font-weight: 600;
}

/* Search input */
.input-search { position: relative; }
.input-search .icon {
  position: absolute; left: var(--space-3); top: 50%;
  transform: translateY(-50%); color: var(--text-muted);
  pointer-events: none;
}
.input-search .input { padding-left: var(--space-8); }

/* Checkbox / radio / toggle */
.check {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--touch-target); cursor: pointer;
}
.check input[type="checkbox"], .check input[type="radio"] {
  width: 20px; height: 20px; accent-color: var(--brand); cursor: pointer;
}

.toggle { position: relative; display: inline-flex; align-items: center; gap: var(--space-3); min-height: var(--touch-target); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 44px; height: 24px; cursor: pointer; }
.toggle .track {
  width: 44px; height: 24px; border-radius: var(--radius-full);
  background: var(--border-strong); position: relative; flex: none;
  transition: background-color var(--dur-fast) var(--ease);
}
.toggle .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: var(--radius-full);
  background: var(--bg-surface);
  transition: transform var(--dur-fast) var(--ease);
}
.toggle input:checked + .track { background: var(--brand); }
.toggle input:checked + .track::after { transform: translateX(20px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Segmented control */
.segmented {
  display: inline-flex; padding: var(--space-1);
  background: var(--bg-inset); border-radius: var(--radius-md);
  gap: var(--space-1);
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented .seg {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary);
  cursor: pointer;
}
.segmented input:checked + .seg {
  background: var(--bg-surface); color: var(--brand-strong);
  box-shadow: var(--shadow-1);
}
.segmented input:focus-visible + .seg { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

/* Radio cards (theme selector, options) */
.radio-cards { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.radio-card { position: relative; }
/* The invisible full-card input applies only to a radio card's OWN control.
   Child controls inside a .check label (Admin → Themes) must stay visible and
   individually clickable — the descendant selector used to swallow them. */
.radio-card > input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.radio-card .rc-body {
  display: block; padding: var(--space-4);
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease);
}
.radio-card > input:checked + .rc-body { border-color: var(--brand); background: var(--brand-soft); }
.radio-card > input:focus-visible + .rc-body { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
/* A link inside a radio card paints above the invisible input, or it could
   never be clicked. */
.radio-card .rc-body a { position: relative; z-index: 1; }
.rc-title { font-weight: 700; font-family: var(--font-display); }
.rc-desc { font-size: var(--fs-xs); color: var(--text-muted); }

/* Theme swatch strip inside theme radio cards */
.swatches { display: flex; gap: var(--space-1); margin: var(--space-2) 0; }
.swatch { width: 22px; height: 22px; border-radius: var(--radius-full); border: 1px solid var(--border); }

/* Field grid (two-column ≥ md) */
.field-grid { display: grid; gap: 0 var(--space-5); }
@media (min-width: 768px) { .field-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: var(--density-pad);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-4);
}
.card-title { margin: 0; font-size: var(--fs-lg); }

.stat-card { display: flex; flex-direction: column; gap: var(--space-1); }
.stat-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value {
  font-family: var(--font-display); font-variant-numeric: tabular-nums;
  font-size: var(--fs-2xl); font-weight: 800; color: var(--text-primary);
  line-height: 1.1;
}
.stat-value .stat-unit { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.stat-delta {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: var(--fs-xs); font-weight: 700;
  padding: 2px var(--space-2); border-radius: var(--radius-full);
  align-self: flex-start;
}
.stat-delta.down, .stat-delta.good { background: var(--success-soft); color: var(--success); }
.stat-delta.up, .stat-delta.bad { background: var(--danger-soft); color: var(--danger); }
.stat-delta.flat { background: var(--bg-inset); color: var(--text-secondary); }
.sparkline-slot { height: 36px; margin-top: var(--space-2); }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: 700;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-neutral { background: var(--bg-inset);     color: var(--text-secondary); }
.badge-brand   { background: var(--brand-soft);   color: var(--brand-strong); }
/* Provenance chips are a visible design element (PRODUCT_SPEC §6.1) */
.chip-provenance { border: 1px dashed currentColor; background: transparent; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; }
.table thead th {
  position: sticky; top: 0;
  background: var(--bg-inset); color: var(--text-secondary);
  font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-inset); }
.th-sort { display: inline-flex; align-items: center; gap: var(--space-1); background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; }

/* Stacked table on small screens */
@media (max-width: 767px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: var(--space-3) 0; }
  .table-stack td { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-1) var(--space-4); }
  .table-stack td::before { content: attr(data-label); font-weight: 600; color: var(--text-muted); font-size: var(--fs-xs); }
}

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  margin-bottom: var(--space-4);
}
.alert .icon { flex: none; margin-top: 1px; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-danger  { background: var(--danger-soft);  color: var(--danger); }
.alert-info    { background: var(--info-soft);    color: var(--info); }
.alert-title { font-weight: 700; display: block; }

/* ---------- Toasts ---------- */
.toast-region {
  position: fixed; bottom: calc(var(--bottomnav-h) + var(--space-4));
  left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--space-2);
  z-index: var(--z-toast); width: min(92vw, 380px);
}
@media (min-width: 1024px) { .toast-region { bottom: var(--space-6); left: auto; right: var(--space-6); transform: none; } }
.toast {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--bg-surface-raised); color: var(--text-primary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  animation: fn-toast-in var(--dur-base) var(--ease);
}
.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-danger  { border-left-color: var(--danger); }
@keyframes fn-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Dialogs ---------- */
.overlay {
  position: fixed; inset: 0; background: var(--overlay);
  z-index: var(--z-overlay);
  display: none;
}
.overlay.open { display: block; }
.dialog {
  position: fixed; z-index: var(--z-dialog);
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 460px);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  padding: var(--space-6);
  display: none;
}
.dialog.open { display: block; }
.dialog-title { margin-bottom: var(--space-2); }
.dialog-body { color: var(--text-secondary); font-size: var(--fs-sm); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-6); }
.dialog-danger .dialog-title { color: var(--danger); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--space-1); border-bottom: 2px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.tab {
  padding: var(--space-3) var(--space-4);
  min-height: var(--touch-target);
  background: none; border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-secondary); font-weight: 600; font-size: var(--fs-sm);
  cursor: pointer; white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--brand-strong); border-bottom-color: var(--brand); }
.tab:hover { color: var(--text-primary); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: var(--space-1); align-items: center; flex-wrap: wrap; }
.page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--touch-target); min-height: var(--touch-target);
  border-radius: var(--radius-md);
  color: var(--text-secondary); text-decoration: none; font-weight: 600; font-size: var(--fs-sm);
  border: 1px solid transparent;
}
.page-link:hover { background: var(--bg-inset); color: var(--text-primary); }
.page-link[aria-current="page"] { background: var(--brand); color: var(--on-brand); }

/* ---------- Date-range preset chips ---------- */
.range-chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.range-chip {
  min-height: 36px; padding: 0 var(--space-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius-full);
  background: var(--bg-surface); color: var(--text-secondary);
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.range-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* ---------- Progress ---------- */
.progress-bar {
  height: 10px; border-radius: var(--radius-full);
  background: var(--bg-inset); overflow: hidden;
}
.progress-bar .fill { height: 100%; background: var(--brand); border-radius: var(--radius-full); transition: width var(--dur-slow) var(--ease); }

.progress-ring { position: relative; width: 108px; height: 108px; }
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-ring .ring-track { stroke: var(--bg-inset); }
.progress-ring .ring-fill { stroke: var(--brand); transition: stroke-dashoffset var(--dur-slow) var(--ease); }
.progress-ring .ring-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
}

/* ---------- Stepper ---------- */
.stepper { display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-6); }
.step { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); }
.step-dot {
  width: 28px; height: 28px; border-radius: var(--radius-full);
  display: grid; place-items: center;
  background: var(--bg-inset); color: var(--text-secondary);
  font-family: var(--font-display);
}
.step[aria-current="step"] { color: var(--brand-strong); }
.step[aria-current="step"] .step-dot { background: var(--brand); color: var(--on-brand); }
.step.done .step-dot { background: var(--success-soft); color: var(--success); }
.step-line { flex: 1; height: 2px; background: var(--border); min-width: var(--space-4); }

/* ---------- Empty / loading / error states ---------- */
.empty-state {
  text-align: center; padding: var(--space-9) var(--space-5);
  color: var(--text-secondary);
}
.empty-state .icon { width: 44px; height: 44px; color: var(--text-muted); margin-bottom: var(--space-3); }
.empty-state h3 { color: var(--text-primary); }
.empty-state p { max-width: 40ch; margin: 0 auto var(--space-5); font-size: var(--fs-sm); }

.skeleton {
  background: linear-gradient(90deg, var(--bg-inset) 25%, var(--bg-surface) 50%, var(--bg-inset) 75%);
  background-size: 200% 100%;
  animation: fn-shimmer 1.4s linear infinite;
  border-radius: var(--radius-md);
  min-height: 16px;
}
@keyframes fn-shimmer { to { background-position: -200% 0; } }

.error-card { border-left: 4px solid var(--danger); }

/* ---------- Expander (progressive disclosure) ---------- */
.expander { border: 1px solid var(--border); border-radius: var(--radius-md); }
.expander > summary {
  display: flex; align-items: center; justify-content: space-between;
  min-height: var(--touch-target); padding: 0 var(--space-4);
  cursor: pointer; font-weight: 600; font-size: var(--fs-sm);
  color: var(--text-secondary); list-style: none;
}
.expander > summary::-webkit-details-marker { display: none; }
.expander[open] > summary { border-bottom: 1px solid var(--border); color: var(--text-primary); }
.expander .expander-body { padding: var(--space-4); }

/* ---------- Utility ---------- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-center { text-align: center; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; } .flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--space-2); } .mb-4 { margin-bottom: var(--space-4); } .mb-6 { margin-bottom: var(--space-6); }

/* ---------- Chart card (Checkpoint 2C) ----------
   Every value here is a token. The chart's own colours are not set in CSS at
   all: charts.js reads --chart-* at render time so a new theme needs no edit
   here and no edit in any module (DESIGN_SYSTEM §8.2, §8.6). */
.chart-card { display: flex; flex-direction: column; gap: var(--space-3); }
.chart-head { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; justify-content: space-between; }
.chart-summary { font-size: var(--fs-sm); color: var(--text-secondary); margin: 0; }
.chart-canvas { position: relative; height: 220px; }
@media (min-width: 640px) { .chart-canvas { height: 320px; } }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: var(--fs-xs); color: var(--text-secondary); }
.chart-legend .key { display: inline-flex; align-items: center; gap: var(--space-2); }
.chart-legend .key i { width: 18px; height: 0; border-top-width: 3px; border-top-style: solid; display: inline-block; }
.chart-legend .key-raw i { border-top-color: var(--chart-1); }
.chart-legend .key-calculated i { border-top-color: var(--chart-4); border-top-style: dashed; }
.chart-legend .key-smoothed i { border-top-color: var(--chart-trend); border-top-style: dashed; }
.chart-legend .key-goal i { border-top-color: var(--chart-goal-line); border-top-style: dashed; }
/* Checkpoint 6C: legend keys for additional series, so a chart with more than
   one plain dataset names a TOKEN rather than carrying an inline colour. */
.chart-legend .key-series-2 i { border-top-color: var(--chart-2); }
.chart-legend .key-series-3 i { border-top-color: var(--chart-3); }
.chart-legend .key-series-4 i { border-top-color: var(--chart-4); }
.chart-note { font-size: var(--fs-xs); color: var(--text-muted); margin: 0; }
.chart-stats { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.chart-stat { background: var(--bg-inset); border-radius: var(--radius-md); padding: var(--space-3); }
.chart-stat .stat-label { margin-bottom: var(--space-1); }
.chart-stat .stat-value { font-size: var(--fs-lg); }
.metric-picker { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.metric-picker .range-chip { max-width: 100%; }
.dash-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ---------- Checkpoint 5B: camera barcode scanner dialog ---------- */
.scanner-dialog {
  position: fixed; inset: 0; margin: 0; padding: 0;
  width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh;
  background: var(--bg-surface-raised); color: var(--text-primary);
  border: none; z-index: var(--z-dialog);
}
.scanner-dialog::backdrop { background: var(--overlay); }
.scanner-dialog[open] { display: flex; flex-direction: column; }
@media (min-width: 640px) {
  .scanner-dialog {
    inset: auto; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: min(92vw, 480px); height: min(88vh, 640px);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
  }
}
.scanner-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border);
  flex: none;
}
.scanner-head h2 { margin: 0; font-size: var(--fs-lg); }
.scanner-body { flex: 1; overflow-y: auto; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.scanner-status {
  font-size: var(--fs-sm); color: var(--text-secondary); min-height: 1.4em;
}
.scanner-video-wrap {
  position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 60vh;
  /* black, not a theme color: this is the camera letterbox behind a live
     video element, not part of any theme's palette, so a hex/token color
     would be the wrong signal here either way */
  background: black; border-radius: var(--radius-md); overflow: hidden; flex: none;
}
.scanner-video-wrap video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.scanner-reticle {
  position: absolute; inset: 18% 10%; border: 3px solid var(--brand);
  border-radius: var(--radius-md); opacity: 0.85; pointer-events: none;
}
.scanner-controls {
  display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: center; flex: none;
}
.scanner-controls .btn { flex: 1 1 auto; min-width: 96px; }
.scanner-fallback { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Quick actions (Checkpoint 11) ----------
   Dashboard welcome band and the mobile quick-add sheet share this tile.
   Tokens only, so it repaints under every theme with no module edit. */
.quick-actions {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  margin-top: var(--space-5);
}
.quick-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-2); text-align: center; text-decoration: none;
  min-height: 88px; padding: var(--space-3);
  background: var(--bg-inset); color: var(--text-primary);
  border-radius: var(--radius-lg);
  font-size: var(--fs-xs); font-weight: 700;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.quick-action:hover { background: var(--brand-soft); color: var(--brand-strong); }
.quick-action .icon { color: var(--brand); width: 24px; height: 24px; }
.quick-action-primary { background: var(--brand); color: var(--on-brand); }
.quick-action-primary .icon { color: var(--on-brand); }
.quick-action-primary:hover { background: var(--brand-strong); color: var(--on-brand); }

/* Quick-add sheet (Checkpoint 11): a dialog listing the same destinations as
   the mobile "+" FAB, reusing the existing .dialog/.overlay engine — no new
   dialog mechanism, just new content inside it. */
.quickadd-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-4); }
.quickadd-list .btn { justify-content: flex-start; }

/* ---------- Strength training (Checkpoint 6B) ----------
   Every value below is a token. No colour is named here, so all five themes
   apply to these screens automatically and a future theme needs no edit
   (DESIGN_SYSTEM §8.2, "no hard-coded colours in modules — ever"). */

/* Visually hidden, still announced by screen readers. This class was already
   in use by markup written at 2A/6A but had no rule anywhere in the
   stylesheet, so those labels rendered as stray visible text. Defined here as
   the shared primitive it was always meant to be — see CHECKPOINT_6B_TESTS.md
   §A.3, finding F-1. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Rapid set entry: reps, weight, type and the add button on one line on a
   phone, so a set can be logged between efforts without scrolling. Inputs
   keep the 44px target height every other control uses. */
.set-entry { margin-top: var(--space-4); }
.set-entry-grid {
  display: grid; gap: var(--space-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}
.set-entry-grid .field-label { margin-bottom: var(--space-1); }
@media (min-width: 640px) {
  .set-entry-grid { grid-template-columns: 1fr 1fr 1.4fr auto; }
}

/* ===========================================================================
   Checkpoint 11B — professional dashboard components
   Every colour here is a semantic token, so an administrator theme change
   restyles all of it with no dashboard edit. Soft/strong token pairs are used
   deliberately: in the four light themes --*-soft is a pale tint and
   --*-strong a darker ink; in Midnight the pair inverts (dark tint, light
   ink), so one rule reads correctly in both directions.
   ======================================================================== */

/* Icon container — one consistent shape for every metric/section icon. */
.icon-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: var(--radius-md);
  background: var(--brand-soft); color: var(--brand-strong);
}
.icon-chip .icon { width: 20px; height: 20px; }
.icon-chip-accent  { background: var(--accent-soft);  color: var(--accent); }
.icon-chip-success { background: var(--success-soft); color: var(--success); }
.icon-chip-warning { background: var(--warning-soft); color: var(--warning); }
.icon-chip-danger  { background: var(--danger-soft);  color: var(--danger); }
.icon-chip-info    { background: var(--info-soft);    color: var(--info); }
.icon-chip-sm { width: 30px; height: 30px; flex-basis: 30px; }
.icon-chip-sm .icon { width: 16px; height: 16px; }

/* Section heading used above a group of cards or a list card. */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin: var(--space-8) 0 var(--space-4);
}
.section-head h2 { margin: 0; font-size: var(--fs-lg); }
.section-head-titles { display: flex; align-items: center; gap: var(--space-3); }
.section-head p { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); }

/* A metric card: icon + title + action, one dominant figure, then meta. */
.metric-card { display: flex; flex-direction: column; gap: var(--space-3); }
.metric-card-head {
  display: flex; align-items: center; gap: var(--space-3);
}
.metric-card-head h3 {
  margin: 0; font-size: var(--fs-sm); font-weight: 700;
  color: var(--text-secondary); letter-spacing: 0.01em;
}
.metric-card-head .metric-card-action { margin-left: auto; }

/* The dominant number. Tabular so digits do not jitter between renders. */
.figure {
  display: flex; align-items: baseline; gap: var(--space-2);
  font-family: var(--font-display); font-weight: 700;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
  color: var(--text-primary); line-height: 1.05;
}
.figure-lg { font-size: var(--fs-xl); }
.figure-xl { font-size: var(--fs-display); }
.figure-unit {
  font-family: var(--font-body); font-size: var(--fs-sm);
  font-weight: 600; color: var(--text-muted);
}
.figure-none { color: var(--text-muted); font-weight: 600; }
.metric-meta { color: var(--text-muted); font-size: var(--fs-xs); margin: 0; }

/* Change chip. Direction is carried by an arrow glyph AND a word, never by
   colour alone (DESIGN_SYSTEM: no colour-only status). */
.change-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: 700;
  padding: 2px var(--space-2); border-radius: var(--radius-full);
  background: var(--bg-inset); color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.change-chip .icon { width: 13px; height: 13px; }

/* Slim progress bar for a goal or target. */
.mini-bar {
  height: 8px; border-radius: var(--radius-full);
  background: var(--bg-inset); overflow: hidden;
}
.mini-bar > span {
  display: block; height: 100%; border-radius: var(--radius-full);
  background: var(--brand); transition: width var(--dur-slow) var(--ease);
}
.mini-bar-accent > span { background: var(--accent); }
.mini-bar-warning > span { background: var(--warning); }
.mini-bar-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-2); font-size: var(--fs-xs); color: var(--text-muted);
  margin-bottom: 4px; font-variant-numeric: tabular-nums;
}

/* ---------- The energy anchor card ---------- */
.energy-card { border-top: 3px solid var(--brand); }
.energy-main {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--space-5) var(--space-6);
}
.energy-readout { min-width: 0; flex: 1 1 190px; }
.energy-readout .figure-xl { line-height: 1; }
.energy-caption {
  font-size: var(--fs-sm); color: var(--text-secondary);
  margin: var(--space-2) 0 0; font-variant-numeric: tabular-nums;
}
.energy-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-5); }

/* A larger, refined progress ring for the anchor card. */
.progress-ring.ring-xl { width: 168px; height: 168px; flex: 0 0 168px; }
.progress-ring.ring-xl .ring-label {
  font-size: var(--fs-lg); font-family: var(--font-display); font-weight: 700;
}
.progress-ring .ring-fill-over { stroke: var(--warning); }

/* Macro trio — three equal figures, deliberately smaller than the anchor. */
.macro-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3); margin-top: var(--space-5);
  padding-top: var(--space-5); border-top: 1px solid var(--border);
}
.macro-cell .macro-label {
  display: block; font-size: var(--fs-xs); font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.macro-cell .figure { margin-top: 2px; font-size: var(--fs-base); }

/* Expenditure sub-panel: inset, so it reads as supporting detail. */
.energy-sub {
  margin-top: var(--space-5); padding: var(--space-4);
  background: var(--bg-inset); border-radius: var(--radius-lg);
}
.energy-sub-grid {
  display: grid; gap: var(--space-3) var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}
.energy-sub dt {
  font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600;
}
.energy-sub dd {
  margin: 2px 0 0; font-size: var(--fs-base); font-weight: 700;
  color: var(--text-primary); font-variant-numeric: tabular-nums;
}

/* ---------- List rows (goals, meal groups) ---------- */
.data-list { display: flex; flex-direction: column; }
.data-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) 0; border-top: 1px solid var(--border);
}
.data-list > .data-row:first-child { border-top: 0; padding-top: 0; }
.data-row-body { flex: 1 1 auto; min-width: 0; }
.data-row-title {
  margin: 0; font-size: var(--fs-sm); font-weight: 700; color: var(--text-primary);
}
.data-row-sub { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.data-row-value {
  text-align: right; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text-primary); white-space: nowrap;
}
.data-row-value small { display: block; font-weight: 600; color: var(--text-muted); }
.data-row .btn-icon { flex: 0 0 auto; }
.goal-progress { margin-top: var(--space-2); }

/* Provenance/detail disclosure — keeps technical text off the main card. */
.detail-toggle {
  margin-top: var(--space-3); font-size: var(--fs-xs);
  border-top: 1px solid var(--border); padding-top: var(--space-3);
}
.detail-toggle > summary {
  cursor: pointer; color: var(--text-secondary); font-weight: 600;
  min-height: 28px; display: flex; align-items: center; gap: var(--space-2);
}
.detail-toggle > summary::marker { color: var(--text-muted); }
.detail-toggle p { margin: var(--space-2) 0 0; color: var(--text-muted); }
