/* Dashboard v5 — local, framework-free presentation layer */
:root {
  --v5-bg: #f3f1ec;
  --v5-surface: #fffefa;
  --v5-surface-muted: #e9e7e1;
  --v5-ink: #25292b;
  --v5-muted: #62696c;
  --v5-border: #d3d0c8;
  --v5-accent: #315b70;
  --v5-accent-soft: #dce8ed;
  --v5-attention: #826a3d;
  --v5-info: #66567a;
  --v5-shadow: 0 8px 24px rgba(29, 37, 40, .07);
  --v5-radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; background: var(--v5-bg); overflow-x: hidden; }
body { margin: 0; min-width: 0; color: var(--v5-ink); background: var(--v5-bg); overflow-x: hidden; }
[hidden] { display: none !important; }

[data-dashboard-v5] {
  width: 100%;
  max-width: 1600px;
  min-width: 0;
  margin-inline: auto;
  padding: clamp(16px, 2.2vw, 34px);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
}

[data-dashboard-v5] h1,
[data-dashboard-v5] h2,
[data-dashboard-v5] h3 { margin-block: 0 .55em; line-height: 1.18; text-wrap: balance; }
.skip-link { position: fixed; top: 8px; left: -10000px; z-index: 100; min-width: 44px; min-height: 44px; padding: 10px 14px; white-space: nowrap; background: var(--v5-surface); border: 2px solid var(--v5-accent); }
.skip-link:focus { left: 8px; }
.app-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: end; }
.header-actions, .global-controls, .dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.global-controls { margin-block: 12px 10px; }
.app-view { min-width: 0; padding: 26px 0 36px; }
.view-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 10px 28px; margin-bottom: 18px; }
.view-heading .context-note { margin: 0 0 .55em; }
.today-grid, .metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.today-grid > article, .hero-card, .chart-panel, .event-track, dialog { min-width: 0; border: 1px solid var(--v5-border); border-radius: var(--v5-radius); padding: 18px; background: var(--v5-surface); box-shadow: var(--v5-shadow); }
.today-grid > article { min-height: 220px; overflow-wrap: anywhere; }
.today-grid > article p { overflow-wrap: anywhere; }
.today-snapshot-card { grid-column: span 1; }
.today-vitals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--v5-border); }
.today-vital { display: grid; gap: 3px; min-width: 0; }
.today-vital strong { font-size: 1.05rem; overflow-wrap: anywhere; }
.metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card { display: grid; grid-template-rows: auto auto auto auto minmax(54px, auto); gap: 7px; min-height: 230px; }
.metric-card .v5-kpi { margin-top: 2px; }
.metric-card-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 10px; align-items: center; }
.metric-sparkline { width: 100%; height: 58px; color: var(--v5-accent); overflow: hidden; }
.metric-card[role='button'] { cursor: pointer; }
.metric-card[role='button']:focus-visible { outline: 3px solid var(--v5-blue); outline-offset: 3px; }
.chart-panel { height: min(440px, 54vh); margin-block: 18px; }
.cockpit-chart-panel { min-height: 360px; }
.chart-panel canvas, .chart-panel .v5-echart { width: 100% !important; height: calc(100% - 116px) !important; min-height: 260px; }
.v5-echart { width: 100%; min-height: 320px; }
.event-track { min-height: 112px; }
.event-axis { position: relative; width: calc(100% - 44px); min-height: 46px; margin: 12px 22px 0; border-top: 2px solid var(--v5-border); }
.event-marker { position: absolute; left: var(--event-position); top: -2px; width: 2px; height: 14px; background: var(--v5-accent); transform: translateX(-1px); }
.event-marker-control { position: absolute; top: -14px; left: 50%; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; color: var(--v5-accent); background: transparent; transform: translateX(-50%); }
.event-marker[data-edge="start"] .event-marker-control { left: 0; transform: translateX(-22px); }
.event-marker[data-edge="end"] .event-marker-control { left: auto; right: 0; transform: translateX(22px); }
.event-details { display: grid; gap: 6px; margin: 0; padding-left: 22px; }
.event-detail { color: var(--v5-muted); font-size: .86rem; line-height: 1.4; overflow-wrap: anywhere; }
.event-detail:focus { outline: 3px solid var(--v5-focus); outline-offset: 3px; border-radius: 4px; }
.bottom-nav { position: sticky; z-index: 20; top: 8px; bottom: auto; display: flex; align-items: center; gap: 4px; margin: 0; padding: 5px; border: 1px solid var(--v5-border); border-radius: 14px; background: color-mix(in srgb, var(--v5-surface) 96%, transparent); box-shadow: var(--v5-shadow); backdrop-filter: blur(12px); }
.bottom-nav [data-dashboard-view] { flex: 1 1 0; text-align: center; }
.nav-label-short { display: none; }
.mobile-capture-action { display: inline-flex; align-items: center; gap: 6px; }
.score-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.score-grid label { display: grid; gap: 4px; }
.capture-status { max-width: 70ch; margin-top: 16px; padding: 12px 14px; border: 1px solid var(--v5-border); border-radius: 10px; background: var(--v5-surface-muted); }
select, textarea { min-height: 44px; max-width: 100%; font: inherit; }
dialog { max-width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; }
dialog::backdrop { background: rgba(20, 28, 32, .45); }
.context-note { max-width: 75ch; color: var(--v5-muted); }
[data-dashboard-v5] .primary-action { min-height: 48px; margin-top: 16px; padding-inline: 18px; border: 0; border-radius: 10px; color: white; background: var(--v5-accent); font: inherit; font-weight: 700; }
[data-dashboard-v5] .primary-action:hover { color: white; background: #26495a; }
.sr-summary { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[data-dashboard-v5] p { margin-block: .4em 1em; }
[data-dashboard-v5] a { color: var(--v5-accent); text-underline-offset: .18em; }

.v5-shell { display: grid; grid-template-columns: minmax(190px, 230px) minmax(0, 1fr); gap: clamp(16px, 2.4vw, 32px); }
.v5-main, [data-dashboard-panel] { min-width: 0; }
.v5-header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.v5-eyebrow { color: var(--v5-muted); font-size: .82rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }

[data-dashboard-nav] { display: flex; flex-direction: row; gap: 5px; }
[data-dashboard-view],
[data-dashboard-period],
.v5-button,
[data-dashboard-v5] button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--v5-ink);
  background: transparent;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}
[data-dashboard-view] { width: 100%; text-align: left; }
[data-dashboard-view]:hover, [data-dashboard-period]:hover, .v5-button:hover { background: var(--v5-surface-muted); }
[data-dashboard-view].is-active, [data-dashboard-view][aria-selected="true"],
[data-dashboard-period].is-active, [data-dashboard-period][aria-pressed="true"] {
  color: var(--v5-accent);
  border-color: #b9ccd4;
  background: var(--v5-accent-soft);
}

[data-dashboard-v5] :focus-visible { outline: 3px solid var(--v5-info); outline-offset: 3px; }

.v5-periods { display: inline-flex; max-width: 100%; gap: 3px; padding: 3px; border: 1px solid var(--v5-border); border-radius: 12px; background: var(--v5-surface); overflow-x: auto; }
[data-dashboard-period] { flex: 0 0 auto; min-width: 44px; padding-inline: 11px; }

.v5-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(12px, 1.6vw, 20px); }
.v5-span-12 { grid-column: span 12; }
.v5-span-8 { grid-column: span 8; }
.v5-span-6 { grid-column: span 6; }
.v5-span-4 { grid-column: span 4; }
.v5-span-3 { grid-column: span 3; }

.v5-card, [data-chart-frame] {
  min-width: 0;
  border: 1px solid var(--v5-border);
  border-radius: var(--v5-radius);
  padding: clamp(14px, 2vw, 22px);
  background: var(--v5-surface);
  box-shadow: var(--v5-shadow);
  overflow-wrap: anywhere;
}
.v5-card--quiet { background: transparent; box-shadow: none; }
.v5-kpi { font-size: clamp(1.5rem, 3vw, 2.4rem); font-weight: 750; letter-spacing: -.025em; }
.v5-label, .v5-meta { color: var(--v5-muted); font-size: .9rem; }
.v5-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 9px; border: 1px solid var(--v5-border); border-radius: 999px; color: var(--v5-muted); background: var(--v5-surface-muted); font-size: .82rem; font-weight: 700; }
.v5-badge--attention { color: #59471f; border-color: #cbbd9d; background: #f0e9d8; }
.v5-badge--info { color: #4b4060; border-color: #c4bbd0; background: #e9e4ef; }

.v5-chart { position: relative; width: 100%; height: clamp(220px, 32vw, 360px); }
.v5-chart canvas { width: 100% !important; height: 100% !important; }
.v5-empty { padding: 22px; border: 1px dashed var(--v5-border); border-radius: 10px; color: var(--v5-muted); text-align: center; background: var(--v5-bg); }
.v5-table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.v5-table { width: 100%; min-width: 520px; border-collapse: collapse; }
.v5-table th, .v5-table td { padding: 11px 10px; border-bottom: 1px solid var(--v5-border); text-align: left; vertical-align: top; }
.v5-table th { color: var(--v5-muted); font-size: .82rem; letter-spacing: .03em; }

.v5-list { margin: 0; padding: 0; list-style: none; }
.v5-list > li { padding-block: 12px; border-bottom: 1px solid var(--v5-border); }
.v5-list > li:last-child { border-bottom: 0; }
.v5-stack { display: grid; gap: 12px; }
.v5-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.v5-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; }

/* Advanced Explorer: presentation-only controls over the allowlisted v2 bundle. */
.explorer-heading, .panel-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: start; gap: 10px 24px; }
.explorer-heading .context-note, .panel-heading > p { max-width: 62ch; }
.explorer-controls { display: grid; gap: 18px; margin-block: 16px; }
.mode-selector { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 4px; border: 1px solid var(--v5-border); border-radius: 12px; }
.mode-selector legend { padding-inline: 7px; color: var(--v5-muted); font-weight: 700; }
.mode-selector [aria-pressed="true"] { color: var(--v5-accent); border-color: #b9ccd4; background: var(--v5-accent-soft); }
.preset-controls, .metric-picker { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.metric-picker .v5-button { display: inline-flex; align-items: center; gap: 7px; border-color: var(--v5-border); background: var(--v5-surface); }
.metric-picker input { width: 44px; height: 44px; margin: 0; accent-color: var(--v5-accent); }
.explorer-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.explorer-panel { min-height: 260px; margin: 0; height: auto; }
.explorer-panel[data-explorer-panel="trend"] { display: grid; grid-template-rows: auto auto; grid-column: 1 / -1; height: auto; overflow: hidden; }
.explorer-chart-frame { position: relative; width: 100%; height: 340px; min-height: 280px; overflow: hidden; }
.explorer-chart-frame canvas { position: absolute; inset: 0; display: block; width: 100% !important; height: 100% !important; min-height: 0; }
.explorer-panel .panel-heading { margin-bottom: 12px; }
.explorer-panel .panel-heading h3 { margin-top: 8px; }
.explorer-result-cell { min-height: 44px; padding: 10px; border-bottom: 1px solid var(--v5-border); overflow-wrap: anywhere; }
.preset-list { display: contents; }
.preset-list button, .preset-controls > button { border-color: var(--v5-border); background: var(--v5-surface); }
.preset-list button:hover, .preset-controls > button:hover { background: var(--v5-surface-muted); }
.explorer-event-track { grid-column: 1 / -1; }
.explorer-lag-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.explorer-lag-grid .explorer-result-cell { border: 1px solid var(--v5-border); border-radius: 9px; }
.explorer-result-cell[data-rho-direction="positive"] { background: color-mix(in srgb, #d8e8ee calc(var(--rho-strength) * 70%), var(--v5-surface)); }
.explorer-result-cell[data-rho-direction="negative"] { background: color-mix(in srgb, #eee4cf calc(var(--rho-strength) * 70%), var(--v5-surface)); }
.explorer-result-cell[data-rho-direction="zero"] { background: var(--v5-surface-muted); }
.explorer-phase-group { min-width: 0; margin-block: 12px; padding: 10px; border: 1px solid var(--v5-border); border-radius: 10px; }
.explorer-phase-group h4 { margin: 0 0 8px; overflow-wrap: anywhere; }
.explorer-phase-group .explorer-result-cell:last-child { border-bottom: 0; }
.explorer-results { margin-top: 16px; }
.explorer-results summary { min-height: 44px; padding-block: 10px; cursor: pointer; font-weight: 700; }

@media (max-width: 900px) {
  .v5-shell { grid-template-columns: 1fr; }
  .today-grid, .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-nav { position: fixed; inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px; top: auto; display: flex; gap: 4px; margin: 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; }
  .bottom-nav [data-dashboard-view] { flex: 1 0 max-content; width: auto; min-width: 64px; padding-inline: 7px; text-align: center; white-space: nowrap; }
  .app-view { padding-bottom: calc(112px + env(safe-area-inset-bottom)); scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
  .v5-span-8, .v5-span-6, .v5-span-4, .v5-span-3 { grid-column: span 6; }
}

@media (max-width: 560px) {
  [data-dashboard-v5] { padding: 10px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .today-grid, .metric-grid { grid-template-columns: minmax(0, 1fr); }
  .today-grid > article { min-height: 0; }
  .today-vitals { grid-template-columns: minmax(0, 1fr); }
  .score-grid { grid-template-columns: minmax(0, 1fr); }
  .bottom-nav [data-dashboard-view] { flex: 1 1 0; min-height: 48px; min-width: 52px; padding-inline: 2px; font-size: .65rem; letter-spacing: -.01em; }
  .nav-label-full { display: none; }
  .nav-label-short { display: inline; }
  .cockpit-chart-panel { height: 520px; overflow: hidden; }
  .cockpit-chart-panel canvas { height: 365px !important; }
  .mobile-capture-action { width: 100%; justify-content: center; }
  .v5-header { align-items: stretch; }
  .v5-header > * { max-width: 100%; }
  .v5-periods { width: 100%; }
  [data-dashboard-period] { flex: 1 0 44px; }
  .v5-grid { grid-template-columns: minmax(0, 1fr); }
  .v5-span-12, .v5-span-8, .v5-span-6, .v5-span-4, .v5-span-3 { grid-column: 1; }
  .v5-card, [data-chart-frame] { padding: 14px; border-radius: 12px; }
  .v5-chart { height: 240px; }
  .explorer-panels { grid-template-columns: 1fr; }
  .explorer-lag-grid { grid-template-columns: 1fr; }
  .explorer-panel[data-explorer-panel="trend"] { grid-column: 1; height: auto; grid-template-rows: auto auto; }
  .mode-selector button, .preset-controls button { flex: 1 1 145px; }
}

.echarts-prototype { margin-top: 18px; overflow: hidden; }
.prototype-toolbar, .prototype-series-controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.prototype-toolbar button { flex: 0 1 auto; }
.prototype-series-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.prototype-series-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
.prototype-series-control button { min-width: 0; }
.prototype-series-control [data-prototype-series-solo] { padding-inline: 10px; }
.prototype-series-control [aria-pressed="false"] { opacity: .55; text-decoration: line-through; }
.prototype-legend-note { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--v5-muted); }
.reference-swatch { width: 34px; height: 18px; border: 1px dashed #1e3a5f; background: repeating-linear-gradient(135deg, rgba(37,99,235,.18) 0 4px, rgba(255,255,255,.9) 4px 8px); }
.event-swatch { display: inline-grid; place-items: center; width: 24px; height: 24px; color: #111827; background: #facc15; border: 2px solid #111827; transform: rotate(45deg); }
.event-swatch::first-letter { transform: rotate(-45deg); }
.prototype-chart { width: 100%; height: 520px; min-height: 360px; border: 1px solid var(--v5-border); border-radius: 12px; background: #fff; }
.prototype-table-wrap { margin-top: 12px; }
.prototype-table-wrap summary { min-height: 44px; display: flex; align-items: center; }
.prototype-table-wrap .table-scroll { max-width: 100%; overflow: auto; max-height: 520px; border: 1px solid var(--v5-border); border-radius: 10px; }
.prototype-table-wrap table { border-collapse: collapse; min-width: 980px; width: 100%; }
.prototype-table-wrap caption { text-align: left; padding: 10px; color: var(--v5-muted); }
.prototype-table-wrap th, .prototype-table-wrap td { padding: 6px 9px; border-bottom: 1px solid var(--v5-border); text-align: right; white-space: nowrap; }
.prototype-table-wrap th:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; }
.prototype-table-wrap thead th { position: sticky; top: 0; background: #edf4f8; z-index: 2; }
.prototype-table-wrap tbody button { width: 100%; justify-content: flex-start; border-color: transparent; background: transparent; color: var(--v5-blue); }

@media (max-width: 700px) {
  .prototype-series-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prototype-toolbar button { flex: 1 1 145px; }
  .prototype-chart { height: 430px; min-height: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Add .privacy-mode to the v5 root while screen sharing. */
[data-dashboard-v5].privacy-mode [data-private],
[data-dashboard-v5][data-privacy="true"] [data-private] { color: transparent !important; text-shadow: 0 0 9px var(--v5-ink); user-select: none; }
[data-dashboard-v5].print-mode [data-private],
[data-dashboard-v5].print-mode [data-private] * { color: #172027 !important; -webkit-text-fill-color: #172027 !important; text-shadow: none !important; user-select: auto; }
[data-dashboard-v5].print-mode .app-view > :not(h2):not(.context-note) { filter: none !important; pointer-events: auto; }
[data-dashboard-v5].privacy-mode .app-view > :not(h2):not(.context-note) {
  filter: blur(10px);
  pointer-events: none;
  user-select: none;
}

@media print {
  @page { margin: 14mm; }
  html, body, [data-dashboard-v5] { color: #000; background: #fff; }
  [data-dashboard-v5] { max-width: none; padding: 0; font-size: 10pt; }
  [data-dashboard-nav], .v5-periods, .v5-no-print, button, .explorer-controls,
  .app-header, .global-controls, .record-tabs, .record-filter-form,
  .record-view > .view-heading, [data-record-status] { display: none !important; }
  [data-dashboard-panel][hidden] { display: none !important; }
  .v5-shell { display: block; }
  .v5-card, [data-chart-frame] { break-inside: avoid; border-color: #aaa; box-shadow: none; background: #fff; }
  [data-private],
  [data-private] *,
  [data-dashboard-v5].privacy-mode [data-private],
  [data-dashboard-v5].privacy-mode [data-private] *,
  [data-dashboard-v5][data-privacy="true"] [data-private],
  [data-dashboard-v5][data-privacy="true"] [data-private] * { color: #172027 !important; -webkit-text-fill-color: #172027 !important; text-shadow: none !important; border-color: #aaa; }
  [data-dashboard-v5].privacy-mode .app-view > :not(h2):not(.context-note) { filter: none !important; pointer-events: auto; }
  a { color: #000 !important; text-decoration: none; }
  .explorer-panels { display: block; }
  .explorer-panel { min-height: 0; height: auto !important; margin-bottom: 8mm; break-inside: avoid; }
  .prototype-table-wrap tbody button { display: inline-flex !important; min-height: 0; padding: 0; color: #000; border: 0; }
}

/* Sprint 6C: visible desktop ECharts surface; narrow view intentionally uses the table fallback. */
[data-api-explorer-chart] { min-height: 320px; width: 100%; }
@media (max-width: 390px) { [data-api-explorer-chart] { min-height: 0; } }

/* Sprint 6D: server-anchored calendar and central day view. */
.day-header-picker { display: inline-flex; align-items: center; gap: 6px; }
.calendar-toolbar, .day-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar-weekday { text-align: center; font-weight: 700; color: var(--v5-muted); }
.calendar-day { min-width: 0; min-height: 72px; padding: 8px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; background: #fff; }
.calendar-day[aria-selected='true'] { outline: 3px solid var(--v5-blue); outline-offset: 1px; }
.calendar-day-number { font-weight: 800; }
.calendar-day-codes { font-size: .72rem; line-height: 1.2; overflow-wrap: anywhere; color: var(--v5-muted); }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 10px 0; }
.calendar-agenda { margin-top: 16px; }
.day-summary, .day-notices { margin-bottom: 12px; }
.day-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.day-sections > section { min-width: 0; }
.day-view pre { white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .day-header-picker { width: 100%; }
  .calendar-grid { gap: 3px; }
  .calendar-day { min-height: 56px; padding: 5px 3px; }
  .calendar-day-codes { font-size: .62rem; }
  .day-sections { grid-template-columns: 1fr; }
}
@media (max-width: 390px) {
  .calendar-view, .day-view { max-width: 100%; overflow-x: clip; }
  .calendar-toolbar > *, .day-toolbar > * { min-height: 44px; }
  .calendar-toolbar button, .day-toolbar button { min-width: 44px; }
  .calendar-toolbar input { min-height: 44px; }
  .day-view summary { min-height: 44px; display: flex; align-items: center; }
  .calendar-day { min-height: 48px; min-width: 0; }
  .calendar-day-codes { font-size: 0; }
  .calendar-day-codes::before { content: '•'; font-size: .8rem; }
}

/* Sprint 6E: compact, horizontally operable record tabs. */
.record-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.record-tabs button { min-height: 44px; white-space: nowrap; }
.record-view ul { padding-left: 1.25rem; }
@media (max-width: 390px) { .record-view { max-width: 100%; overflow-x: clip; } .record-tabs { margin-inline: -4px; padding-inline: 4px; } }

/* Sprint 6E.4A: unified range, ECharts explorer and global search. */
.range-toolbar { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; padding: 4px; border: 1px solid var(--v5-border); border-radius: 12px; background: var(--v5-surface); }
.range-toolbar > button, .range-toolbar > details { flex: 0 0 auto; }
.range-toolbar summary { display: flex; align-items: center; min-height: 44px; padding: 8px 12px; cursor: pointer; font-weight: 650; }
.range-custom { position: absolute; z-index: 40; display: grid; gap: 9px; min-width: 290px; margin-top: 4px; padding: 14px; border: 1px solid var(--v5-border); border-radius: 12px; background: var(--v5-surface); box-shadow: var(--v5-shadow); }
.range-custom label { display: grid; gap: 4px; }
.range-custom input, .metric-add input, .global-search-input-row input { min-height: 44px; min-width: 0; font: inherit; }
.explorer-toolbar, .explorer-shortcuts, .metric-add-row, .explorer-status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.explorer-toolbar { margin-block: 14px; }
.explorer-shortcuts { margin-block: 10px; }
.metric-add { margin-block: 12px; }
.metric-add-row { margin-top: 6px; }
.metric-add-row input { flex: 1 1 260px; }
.api-explorer-result-list { display: grid; gap: 10px; margin-top: 12px; }
.metric-search-group h4 { margin: 0 0 6px; }
.metric-search-results, .metric-chip-list { display: flex; flex-wrap: wrap; gap: 7px; }
.metric-search-results button { border-color: var(--v5-border); background: var(--v5-surface); }
.metric-chip { display: inline-flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--v5-border); border-radius: 999px; background: var(--v5-surface); }
.metric-chip button { min-width: 44px; min-height: 44px; padding-inline: 10px; border-radius: 999px; }
.metric-chip button[aria-pressed='false'] { opacity: .62; text-decoration: line-through; }
.explorer-status-row { justify-content: space-between; }
.api-explorer-chart { width: 100%; min-height: 420px; margin-block: 12px; border: 1px solid var(--v5-border); border-radius: 12px; background: #fff; }
.api-explorer-events ul { display: flex; flex-wrap: wrap; gap: 7px; padding: 0; list-style: none; }
.api-explorer-table-wrap { margin-top: 12px; }
.api-explorer-table-wrap summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
.api-explorer-table-wrap table { width: 100%; min-width: 560px; border-collapse: collapse; }
.api-explorer-table-wrap th, .api-explorer-table-wrap td { padding: 8px; border-bottom: 1px solid var(--v5-border); text-align: left; }
.global-search-open { border-color: var(--v5-border) !important; background: var(--v5-surface) !important; }
.global-search-dialog { width: min(920px, calc(100vw - 24px)); }
.global-search-header, .global-search-input-row { display: flex; align-items: center; gap: 8px; }
.global-search-header { justify-content: space-between; }
.global-search-input-row input { flex: 1; }
.global-search-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.global-search-group { min-width: 0; padding: 12px; border: 1px solid var(--v5-border); border-radius: 10px; }
.global-search-group ul { margin: 0; padding: 0; list-style: none; }
.global-search-group li + li { margin-top: 5px; }
.global-search-group button { width: 100%; text-align: left; border-color: var(--v5-border); }

@media (max-width: 560px) {
  .range-toolbar { margin-inline: -2px; }
  .range-custom { position: fixed; inset: auto 8px calc(84px + env(safe-area-inset-bottom)) 8px; min-width: 0; max-height: 62vh; overflow: auto; }
  .global-search-open span { display: none; }
  .global-search-dialog { inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .global-search-results { grid-template-columns: 1fr; }
  .api-explorer-chart { min-height: 320px; }
  .explorer-toolbar > *, .explorer-shortcuts button { flex: 1 1 140px; }
}

/* Sprint 6E.4B: reusable V5 foundations, record, calendar and day views. */
:root {
  --v5-space-1: 4px; --v5-space-2: 8px; --v5-space-3: 12px; --v5-space-4: 16px;
  --v5-space-5: 24px; --v5-space-6: 32px; --v5-radius-sm: 9px; --v5-radius-lg: 20px;
  --v5-shadow-soft: 0 2px 8px rgba(29,37,40,.06); --v5-focus: #66567a;
  --v5-positive-neutral: #e5f0eb; --v5-warning-neutral: #f3ead8;
}
.v5-surface, .v5-empty-state { min-width: 0; padding: var(--v5-space-4); border-radius: var(--v5-radius); background: var(--v5-surface); box-shadow: var(--v5-shadow-soft); }
.section-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--v5-space-3); }
.v5-compact-list { display: grid; gap: 8px; margin: 0; padding-left: 1.1rem; }
.button-primary, .record-actions a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 12px; border-radius: 10px; color: #fff !important; background: var(--v5-accent); font-weight: 700; text-decoration: none; }
.status-chip { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 9px; border-radius: 999px; color: var(--v5-muted); background: var(--v5-surface-muted); font-size: .78rem; font-weight: 750; }
.status-available, .status-geprueft, .status-known { color: #285649; background: var(--v5-positive-neutral); }
.status-blocked, .status-unsupported, .status-missing { color: #6e5427; background: var(--v5-warning-neutral); }
.record-hero, .day-hero { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--v5-space-4); margin-bottom: var(--v5-space-4); }
.record-tabs { position: sticky; z-index: 12; top: 74px; padding: 6px; border: 1px solid var(--v5-border); border-radius: 12px; background: color-mix(in srgb,var(--v5-surface) 96%,transparent); backdrop-filter: blur(10px); }
.record-tabs button.is-active { color: var(--v5-accent); background: var(--v5-accent-soft); }
.record-breadcrumb { margin: 12px 0; color: var(--v5-muted); font-size: .88rem; }
.record-kpi-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: var(--v5-space-3); }
.record-kpi { display: grid; gap: 5px; min-height: 120px; padding: var(--v5-space-4); border-radius: var(--v5-radius); background: var(--v5-accent-soft); }
.record-kpi span, .record-kpi small { color: var(--v5-muted); }
.record-kpi strong { font-size: clamp(1.05rem,2vw,1.35rem); overflow-wrap: anywhere; }
.record-overview-groups { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--v5-space-4); margin-top: var(--v5-space-5); }
.record-filter-compact { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: var(--v5-space-3); padding: var(--v5-space-4); border-radius: var(--v5-radius); background: var(--v5-surface-muted); }
.record-filter-compact label { display: grid; gap: 4px; min-width: 0; }
.record-filter-compact input, .record-filter-compact select, .record-viewer-tools input { width: 100%; min-width: 0; min-height: 44px; font: inherit; }
.active-filter-chips, .document-statuses { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.filter-chip { min-height: 44px !important; border-color: var(--v5-border) !important; border-radius: 999px !important; background: var(--v5-surface) !important; }
.document-timeline { display: grid; gap: var(--v5-space-3); margin-top: var(--v5-space-4); }
.document-entry { display: grid; grid-template-columns: 125px minmax(0,1fr) minmax(160px,auto); gap: var(--v5-space-4); align-items: start; padding: var(--v5-space-4); border-left: 4px solid var(--v5-accent); border-radius: 0 var(--v5-radius) var(--v5-radius) 0; background: var(--v5-surface); box-shadow: var(--v5-shadow-soft); }
.document-date-block { font-size: 1rem; font-weight: 800; overflow-wrap: anywhere; }
.document-entry h4 { margin: 0; }.document-neutral-note { color: var(--v5-muted); }.document-actions { justify-content: flex-end; }
.record-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.document-coverage { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 10px; margin: 14px 0; }
.document-coverage-item { display: grid; gap: 4px; min-width: 0; padding: 12px; border-radius: 10px; background: var(--v5-surface-muted); }
.document-coverage-item strong { font-size: 1.2rem; }
.document-statuses { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.document-status-item { display: grid; gap: 3px; min-width: 0; }
.lab-parameter-list, .lab-observation-list { display: grid; gap: 14px; min-width: 0; }
.lab-parameter-card { display: grid; gap: 14px; min-width: 0; }
.lab-parameter-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.lab-parameter-heading h4 { margin: 0; }
.lab-parameter-facts { display: grid; grid-template-columns: minmax(150px,.45fr) minmax(0,1fr); gap: 6px 12px; margin: 0; }
.lab-parameter-facts dt { color: var(--v5-muted); font-weight: 700; }
.lab-parameter-facts dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.lab-observation-history summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 700; }
.lab-observation-card { display: grid; gap: 8px; min-width: 0; padding: 12px; border: 1px solid var(--v5-border); border-radius: 10px; }
.record-viewer { padding: clamp(16px,3vw,32px); }.record-viewer-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--v5-border); }
.record-viewer-tools { position: sticky; z-index: 10; top: 134px; display: grid; grid-template-columns: minmax(180px,1fr) auto auto auto; gap: 8px; align-items: center; margin: 14px 0; padding: 10px; border-radius: 12px; background: var(--v5-surface); box-shadow: var(--v5-shadow); }
.record-viewer-toc { margin: 12px 0; }.record-viewer-toc summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 700; }
.record-document-sections { display: grid; gap: var(--v5-space-5); max-width: 82ch; }.record-document-sections article { scroll-margin-top: 190px; }.record-document-sections p { white-space: pre-wrap; overflow-wrap: anywhere; }
.calendar-grid { display: block; min-width: 0; padding: 10px; border-radius: var(--v5-radius-lg); background: var(--v5-surface); box-shadow: var(--v5-shadow); }
.calendar-toolbar { justify-content: space-between; align-items: center; }.calendar-toolbar strong { min-width: 170px; text-align: center; font-size: 1.2rem; }.calendar-month-picker { display: flex; align-items: center; gap: 6px; }
.calendar-legend { color: var(--v5-muted); font-size: .82rem; }.calendar-range-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }.calendar-range-panel > div { display: flex; flex-wrap: wrap; gap: 8px; }.calendar-range-panel label { display: grid; gap: 3px; }.calendar-range-panel input { min-height: 44px; font: inherit; }
.fc { --fc-border-color: #8b949e; --fc-page-bg-color: var(--v5-surface); --fc-neutral-bg-color: #f2f5f7; --fc-today-bg-color: #d9eef2; font-size: .92rem; }
.fc .fc-col-header-cell-cushion, .fc .fc-daygrid-day-number { color: #111827; text-decoration: none; }.fc .fc-daygrid-day { min-height: 94px; }.fc .fc-day-other { background: #eef1f4; }.fc .fc-day-today .fc-daygrid-day-number { display: inline-grid; place-items: center; min-width: 32px; min-height: 32px; border-radius: 50%; color: #fff; background: #235b68; }.fc .fc-highlight { background: #c8e5eb; }.fc .fc-daygrid-event { min-height: 24px; padding: 2px 5px; border: 1px solid #637381; border-radius: 6px; color: #111827; background: #ffffff; font-size: .72rem; }.fc a:focus-visible,.fc button:focus-visible,.fc .fc-daygrid-day-frame:focus-visible { outline: 3px solid #0f5b7a; outline-offset: 2px; }.fc .health-calendar-event::before { content: '•'; margin-right: 3px; font-weight: 900; color: #235b68; }.fc .is-lab::before { content: '+'; }.fc .is-document::before { content: '□'; }.fc .is-medication::before { content: 'Rx'; font-size: .62rem; }
.day-weekday { color: var(--v5-muted); font-size: 1.1rem; text-transform: capitalize; }.day-toolbar { justify-content: flex-end; }.day-kpi-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: var(--v5-space-3); margin: var(--v5-space-4) 0; }.day-kpi-card { display: grid; gap: 6px; min-height: 100px; padding: var(--v5-space-4); border-radius: var(--v5-radius); background: var(--v5-accent-soft); }.day-kpi-card span { color: var(--v5-muted); }.day-kpi-card strong { font-size: 1.2rem; }.day-context-section { margin: var(--v5-space-5) 0; }.day-context-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--v5-space-4); }.day-metric-card { display: grid; grid-template-columns: minmax(150px,.7fr) minmax(220px,1.3fr); gap: 12px; }.day-metric-heading { display: grid; align-content: start; gap: 6px; }.day-metric-heading h4 { margin: 0; }.day-mini-chart { min-width: 0; height: 150px; }.day-sections { grid-template-columns: repeat(2,minmax(0,1fr)); }.day-missing { margin-top: var(--v5-space-4); }.day-provenance { margin-top: var(--v5-space-3); }.day-provenance summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
@media (max-width: 900px) { .record-kpi-grid,.day-kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }.record-filter-compact { grid-template-columns: repeat(2,minmax(0,1fr)); }.document-entry { grid-template-columns: 100px minmax(0,1fr); }.document-actions { grid-column: 2; justify-content: flex-start; }.day-context-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .record-kpi-grid,.record-overview-groups,.day-kpi-grid { grid-template-columns: 1fr; }.record-filter-compact { grid-template-columns: 1fr; }.record-tabs { top: 60px; margin-inline: -8px; overflow: visible; flex-wrap: wrap; border-radius: 0; }.record-tabs button { flex: 1 1 30%; }.document-entry { grid-template-columns: 1fr; }.document-actions { grid-column: 1; }.document-coverage,.document-statuses { grid-template-columns: 1fr; }.lab-parameter-facts { grid-template-columns: 1fr; }.lab-parameter-card,.lab-observation-card { max-width: 100%; overflow: hidden; }.lab-parameter-card :is(button,a,summary),.lab-observation-card :is(button,a) { min-height: 44px; }.record-viewer-tools { position: static; grid-template-columns: 1fr 1fr; }.record-viewer-tools input,.record-viewer-tools span { grid-column: 1/-1; }.calendar-toolbar { justify-content: center; }.calendar-toolbar strong { order: -1; width: 100%; }.calendar-month-picker { width: 100%; justify-content: center; }.calendar-grid { padding: 3px; }.fc { font-size: .82rem; }.fc .fc-daygrid-day { min-height: 72px; }.fc .fc-daygrid-event { width: auto; max-width: 100%; min-height: 18px; overflow: hidden; color: #111827; border-radius: 4px; padding: 1px 3px; white-space: nowrap; text-overflow: ellipsis; }.fc .fc-daygrid-event::before { color: #235b68; font-size: .8rem; }.day-metric-card { grid-template-columns: 1fr; }.day-mini-chart { height: 130px; }.day-toolbar > * { flex: 1 1 140px; } }
.fc .health-calendar-event::before { content: none; }
.fc .health-event-title { display: block; min-width: 0; max-width: 100%; overflow: hidden; color: #111827; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.fc .health-event-title-compact { display: none; }
.fc .fc-daygrid-more-link { display: inline-flex; align-items: center; min-height: 24px; color: #173f54; font-weight: 750; }
.today-task-button { display: block; width: 100%; min-height: 44px; margin-block: 6px; border-color: var(--v5-border) !important; background: var(--v5-surface) !important; text-align: left; }
.record-filter-form { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: var(--v5-space-3); margin-bottom: var(--v5-space-4); }
.record-filter-form label { display: grid; gap: 4px; min-width: 0; }
.record-filter-form input, .record-filter-form select { width: 100%; min-width: 0; min-height: 44px; font: inherit; }
@media (max-width: 560px) {
  .record-filter-form { grid-template-columns: 1fr; }
  .fc .health-event-title-full { display: none; }
  .fc .health-event-title-compact { display: inline; }
}
#view-nutrition .chart-panel { height: auto; min-height: 0; overflow: visible; }
#view-nutrition .chart-panel #nutrition-chart { height: 340px !important; min-height: 300px; }
#view-nutrition .api-explorer-table-wrap { max-width: 100%; overflow: hidden; }
#view-nutrition .api-explorer-table-wrap .table-scroll { max-width: 100%; overflow-x: auto; }
#view-nutrition :is(button, input, select, textarea, summary) { min-height: 44px; }
#mapping-review { display: grid; gap: 10px; max-width: 100%; min-width: 0; }
.mapping-review-card { max-width: 100%; min-width: 0; overflow: hidden; }
.mapping-product-summary { display: flex; align-items: center; min-height: 52px; cursor: pointer; }
.mapping-product-info { display: grid; gap: 3px; min-width: 0; }
.mapping-product-info > * { overflow-wrap: anywhere; }
.mapping-action-form { display: grid; gap: 14px; min-width: 0; padding-top: 14px; border-top: 1px solid var(--v5-border); }
.mapping-field-group { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--v5-border); border-radius: 10px; }
.mapping-field-group legend { padding-inline: 6px; font-weight: 750; }
.mapping-field { display: grid; align-content: start; gap: 5px; min-width: 0; color: var(--v5-muted); font-size: .9rem; }
.mapping-field :is(input,select,textarea) { width: 100%; min-width: 0; }
.mapping-tolerance-group { grid-template-columns: repeat(2,minmax(0,1fr)); }
.mapping-technical-details { min-width: 0; padding: 0 12px; border: 1px solid var(--v5-border); border-radius: 10px; }
.mapping-technical-details summary { display: flex; align-items: center; cursor: pointer; font-weight: 700; }
.mapping-action-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.mapping-action-row .primary-action { margin-top: 0; }
@media (max-width: 560px) {
  .range-toolbar { flex-wrap: wrap; overflow-x: visible; }
  #view-nutrition .chart-panel { padding: 14px; }
  #view-nutrition .chart-panel #nutrition-chart { height: 300px !important; min-height: 280px; }
  .mapping-field-group, .mapping-tolerance-group { grid-template-columns: 1fr; padding: 10px; }
  .mapping-action-row, .mapping-action-row .primary-action { width: 100%; }
}
.v5-grid-12 { display: grid; grid-template-columns: repeat(12,minmax(0,1fr)); gap: var(--v5-space-4); }
.button-primary, .button-secondary, .button-tertiary { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 12px; border-radius: 10px; font-weight: 700; text-decoration: none; }
.button-secondary { color: var(--v5-accent); border: 1px solid var(--v5-accent); background: var(--v5-surface); }.button-tertiary { color: var(--v5-ink); border: 0; background: transparent; }
.v5-skeleton { min-height: 72px; border-radius: var(--v5-radius); background: linear-gradient(90deg,var(--v5-surface-muted),var(--v5-surface),var(--v5-surface-muted)); background-size: 200% 100%; }
@media (max-width: 560px) { .v5-grid-12 { grid-template-columns: 1fr; } }
