:root {
  color-scheme: dark;
  --bg: #0a1111;
  --surface: #101a19;
  --surface-2: #142220;
  --surface-3: #192b29;
  --line: #263b38;
  --line-soft: #1d302e;
  --text: #eef6f4;
  --muted: #91aaa6;
  --faint: #627a76;
  --accent: #61d6c3;
  --accent-strong: #2fb7a3;
  --accent-soft: rgba(97, 214, 195, .12);
  --chart-humidity: #6e91bc;
  --warning: #e2a64a;
  --warning-soft: rgba(226, 166, 74, .13);
  --danger: #df7469;
  --danger-soft: rgba(223, 116, 105, .12);
  --topbar-bg: rgba(10, 17, 17, .94);
  --nav-bg: #0c1514;
  --input-bg: #0d1716;
  --text-soft: #c9d9d6;
  --on-accent: #071411;
  --panel-shadow: 0 30px 90px rgba(0,0,0,.55);
  --login-bg: #08100f;
  --login-context-bg: radial-gradient(circle at 20% 30%, rgba(44, 122, 110, .2), transparent 38%), linear-gradient(145deg, #0d1b19, #091110 68%);
  --radius: 14px;
  --nav-width: 218px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f7f6;
  --surface: #ffffff;
  --surface-2: #edf3f1;
  --surface-3: #e1ebe8;
  --line: #c8d8d4;
  --line-soft: #dce6e3;
  --text: #162421;
  --muted: #536a65;
  --faint: #71847f;
  --accent: #167f71;
  --accent-strong: #0e6b5f;
  --accent-soft: rgba(22, 127, 113, .11);
  --chart-humidity: #416b98;
  --warning: #96620f;
  --warning-soft: rgba(150, 98, 15, .11);
  --danger: #b7463b;
  --danger-soft: rgba(183, 70, 59, .1);
  --topbar-bg: rgba(243, 247, 246, .94);
  --nav-bg: #eaf1ef;
  --input-bg: #ffffff;
  --text-soft: #30433f;
  --on-accent: #ffffff;
  --panel-shadow: 0 28px 75px rgba(30, 58, 52, .18);
  --login-bg: #edf4f2;
  --login-context-bg: radial-gradient(circle at 20% 30%, rgba(35, 150, 132, .16), transparent 39%), linear-gradient(145deg, #e5efec, #f7faf9 70%);
}
:root[data-theme="light"] .preflight,
:root[data-theme="light"] .form-message.is-success,
:root[data-theme="light"] .global-message.is-success { color: #245c53; }
:root[data-theme="light"] .form-message,
:root[data-theme="light"] .global-message { color: #8e3028; }
:root[data-theme="light"] .primary-button:hover { background: #116f63; }
:root[data-theme="light"] .secondary-button:hover { border-color: #91aaa4; }

* { box-sizing: border-box; }
html { background: var(--bg); transition: background-color .18s ease, color .18s ease; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-160%); padding: 10px 14px; background: var(--accent); color: #07110f; border-radius: 8px; }
.skip-link:focus { transform: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); grid-template-rows: 74px 1fr; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; border-bottom: 1px solid var(--line-soft); background: var(--topbar-bg); position: sticky; top: 0; z-index: 30; backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(97, 214, 195, .5); border-radius: 50%; }
.brand-mark::before, .brand-mark::after, .brand-mark span { content: ""; position: absolute; width: 2px; border-radius: 2px; background: var(--accent); transform-origin: bottom; }
.brand-mark { position: relative; }
.brand-mark::before { height: 13px; transform: translate(-6px, 2px); }
.brand-mark span { height: 18px; transform: translate(0, 0); }
.brand-mark::after { height: 9px; transform: translate(6px, 4px); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; }
.topbar-status { display: flex; align-items: center; gap: 14px; }
.live-indicator { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.live-indicator i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.user-menu { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; padding: 0; }
.user-menu > span:first-child { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); color: var(--accent); font-weight: 700; font-size: 12px; }
.user-menu > span:last-child { font-size: 13px; }
.quiet-button, .mobile-menu { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 8px; }
.quiet-button:hover, .mobile-menu:hover { color: var(--text); }
.mobile-menu { display: none; }
.theme-switcher { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.theme-switcher button { min-height: 29px; border: 0; border-radius: 6px; padding: 0 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; }
.theme-switcher button.is-active { background: var(--surface-3); color: var(--text); }

.primary-nav { grid-column: 1; grid-row: 2; position: sticky; top: 74px; height: calc(100vh - 74px); padding: 24px 14px; border-right: 1px solid var(--line-soft); background: var(--nav-bg); }
.primary-nav a { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px; margin: 3px 0; color: var(--muted); text-decoration: none; border-radius: 9px; font-size: 13px; transition: color .18s ease, background .18s ease, transform .18s ease; }
.primary-nav a:hover { color: var(--text); background: rgba(255,255,255,.025); }
.primary-nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); }
.primary-nav a[aria-current="page"] svg { stroke: var(--accent); }
.primary-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.primary-nav b { margin-left: auto; min-width: 20px; padding: 2px 6px; text-align: center; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 10px; }
.mobile-dock, .mobile-more, .mobile-more-backdrop { display: none; }

.workspace { grid-column: 2; grid-row: 2; min-width: 0; padding: 42px clamp(24px, 4vw, 64px) 72px; }
.view { max-width: 1500px; margin: 0 auto; animation: view-in .22s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.view-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.view-heading > div { min-width: 0; }
.view-heading h1 { margin: 2px 0 6px; font-size: clamp(28px, 3vw, 42px); line-height: 1.05; letter-spacing: -.035em; overflow-wrap: anywhere; }
.view-heading p:not(.eyebrow) { max-width: 670px; margin: 0; color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .17em; text-transform: uppercase; }
.heading-actions { display: flex; gap: 10px; }
.primary-button, .secondary-button, .danger-button { min-height: 40px; border-radius: 9px; padding: 0 15px; cursor: pointer; font-weight: 650; font-size: 12px; transition: transform .15s ease, background .15s ease, opacity .15s ease; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); }
.primary-button:hover { background: #7be0d0; transform: translateY(-1px); }
.secondary-button { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.secondary-button:hover { border-color: #3b5652; background: var(--surface-2); }
.danger-button { border: 1px solid rgba(223,116,105,.45); background: var(--danger-soft); color: #f2a39a; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

.filter-bar { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; padding: 15px 0 18px; margin-bottom: 18px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--input-bg); color: var(--text); outline: none; padding: 10px 11px; }
input, select { min-height: 40px; }
textarea { min-height: 100px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-bar select { min-width: 190px; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; margin-left: auto; }
.segmented button { min-height: 32px; min-width: 48px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.segmented button.is-active { background: var(--surface-3); color: var(--text); }

.metric-line { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line-soft); margin-bottom: 28px; }
.metric { min-width: 0; padding: 15px 22px 22px 0; }
.metric + .metric { padding-left: 22px; border-left: 1px solid var(--line-soft); }
.metric span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.metric strong { display: block; font-size: clamp(22px, 2.4vw, 34px); letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric small { display: block; margin-top: 6px; color: var(--faint); font-size: 10px; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(270px, .65fr); gap: 20px; margin-bottom: 34px; }
.chart-stage, .device-focus, .editor-panel, .export-guidance { border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--surface); }
.chart-stage { min-width: 0; padding: 21px; position: relative; }
.chart-stage canvas { width: 100%; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 14px; }
.chart-series-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; font-size: 12px; font-weight: 650; }
.chart-series-toggle small { color: var(--muted); font-size: 11px; font-weight: 500; }
.chart-series-toggle[aria-pressed="false"] { opacity: .55; background: transparent; }
.chart-series-toggle:focus-visible, .chart-latest-button:focus-visible, #overview-chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart-key { width: 24px; height: 0; flex: 0 0 auto; border-top: 3px solid; }
.chart-key-temperature { border-color: var(--accent); }
.chart-key-humidity { border-color: var(--chart-humidity); border-top-style: dashed; }
.chart-readout { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 16px; min-height: 46px; padding: 9px 0; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; }
.chart-readout strong { color: var(--text); font-size: 12px; font-weight: 650; }
#chart-readout-temperature { color: var(--accent); }
#chart-readout-humidity { color: var(--chart-humidity); }
.chart-latest-button { min-height: 32px; margin-left: auto; padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; font: inherit; font-size: 11px; }
#overview-chart { cursor: crosshair; touch-action: pan-y; }
.chart-interaction-hint { margin: 8px 0 0; color: var(--faint); font-size: 10px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2, .editor-panel h2, .export-guidance h2 { margin: 0; font-size: 16px; letter-spacing: -.015em; }
.section-heading > span, .section-heading > strong { color: var(--muted); font-size: 11px; font-weight: 600; }
.chart-empty { position: absolute; inset: 45% 20px auto; text-align: center; color: var(--muted); pointer-events: none; }
.device-focus { padding: 24px; }
.focus-photo { width: 100%; position: relative; display: block; margin: 0 0 22px; padding: 0; overflow: hidden; border: 0; border-radius: 10px; background: var(--surface-2); cursor: zoom-in; aspect-ratio: 4 / 3; }
.focus-photo img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .28s ease; }
.focus-photo:hover img { transform: scale(1.02); }
.focus-photo span { position: absolute; inset: auto 10px 10px; width: max-content; max-width: calc(100% - 20px); padding: 6px 8px; border-radius: 6px; background: rgba(5, 12, 11, .76); color: #f4fbf9; font-size: 10px; backdrop-filter: blur(7px); }
.focus-photo-empty { display: grid; place-items: center; align-content: center; min-height: 190px; margin: 0 0 22px; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface-2); color: var(--muted); text-align: center; }
.photo-upload-target { position: relative; cursor: pointer; overflow: hidden; }
.focus-photo-empty > span { font-size: 28px; color: var(--accent); }.focus-photo-empty strong { margin-top: 6px; color: var(--text); font-size: 13px; }.focus-photo-empty small { margin-top: 3px; color: var(--muted); }
.device-focus h2 { margin: 4px 0 3px; font-size: 22px; }
.device-focus > p { margin: 0 0 24px; color: var(--muted); }
.focus-reading { margin: 28px 0; }
.focus-reading strong { display: block; font-size: 46px; line-height: 1; letter-spacing: -.06em; }
.focus-reading span { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }
.focus-reading small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.focus-status { display: grid; gap: 10px; margin-bottom: 24px; }
.focus-status > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; }
.focus-status strong { min-width: 0; color: var(--text); font-size: 12px; text-align: right; overflow-wrap: anywhere; }
.focus-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.file-button { position: relative; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.file-button input, .photo-upload-target input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-button:focus-within, .photo-upload-target:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.device-cell { display: flex; align-items: center; gap: 11px; min-width: 190px; }
.device-cell img, .device-thumb-empty { width: 54px; height: 40px; flex: 0 0 auto; border-radius: 7px; object-fit: cover; background: var(--surface-3); }
.device-thumb-empty { border: 1px dashed var(--line); }
#device-table tr[data-uid] { cursor: pointer; }
#device-table tr.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.device-select-button { width: 100%; border: 0; padding: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.device-select-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.device-select-hint { display: block; margin-top: 5px; color: var(--accent); font-size: 10px; font-weight: 650; }
#selected-device-heading { scroll-margin-top: 88px; }
#selected-device-heading:focus { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 3px; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); font-size: 11px; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status-pill.normal::before, .status-pill.complete::before, .status-pill.full::before { background: var(--accent); }
.status-pill.warning::before, .status-pill.medium::before, .status-pill.queued::before, .status-pill.running::before { background: var(--warning); }
.status-pill.critical::before, .status-pill.low::before, .status-pill.failed::before { background: var(--danger); }
.battery-icon { display: inline-grid; grid-template-columns: repeat(3, 5px); gap: 2px; padding: 3px; border: 1px solid currentColor; border-radius: 3px; color: var(--muted); }
.battery-icon i { width: 5px; height: 9px; background: currentColor; opacity: .18; }
.battery-icon.full i, .battery-icon.medium i:nth-child(-n+2), .battery-icon.low i:first-child { opacity: 1; }
.signal-icon { display: inline-flex; align-items: end; gap: 2px; height: 13px; }
.signal-icon i { width: 3px; background: currentColor; opacity: .18; }
.signal-icon i:nth-child(1) { height: 4px; }.signal-icon i:nth-child(2) { height: 7px; }.signal-icon i:nth-child(3) { height: 10px; }.signal-icon i:nth-child(4) { height: 13px; }
.signal-icon.bars-1 i:nth-child(1), .signal-icon.bars-2 i:nth-child(-n+2), .signal-icon.bars-3 i:nth-child(-n+3), .signal-icon.bars-4 i { opacity: 1; }

.data-section { margin-top: 30px; }
#recent-heading { scroll-margin-top: 94px; }
.recent-pagination { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.recent-pagination > span { color: var(--muted); font-size: 12px; text-align: center; }
.recent-pagination button { min-width: 88px; }
.table-wrap { width: 100%; overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 12px; color: var(--faint); font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 14px 12px; border-top: 1px solid var(--line-soft); color: var(--text-soft); font-size: 12px; vertical-align: middle; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: rgba(255,255,255,.018); }
tbody tr[data-action] { cursor: pointer; }
td strong { color: var(--text); font-weight: 650; }
td small { display: block; margin-top: 3px; color: var(--faint); }
.table-action { border: 0; background: transparent; color: var(--accent); cursor: pointer; padding: 5px; font-size: 11px; }
.table-action + .table-action { margin-left: 8px; }
.empty-row td { padding: 28px 12px; color: var(--muted); text-align: center; }

.analysis-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.analysis-grid .wide { grid-column: 1 / -1; }
.analysis-scope { margin: -8px 0 20px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.analysis-panel .section-heading { align-items: flex-start; margin-bottom: 4px; }
.analysis-panel .support-copy { margin: 0 0 14px; }
.analysis-panel .chart-legend { min-height: 44px; margin-bottom: 8px; align-items: center; }
.analysis-chart-focus { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.analysis-chart-device { display: grid; gap: 4px; min-width: 190px; max-width: 250px; color: var(--muted); font-size: 11px; font-weight: 600; }
.analysis-chart-device select { min-width: 0; min-height: 38px; }
.analysis-legend-item { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; color: var(--text-soft); font-size: 12px; }
.analysis-key { display: inline-block; width: 22px; height: 0; flex: 0 0 auto; border-top: 3px solid var(--accent); }
.analysis-key-warning { border-color: var(--warning); }
.analysis-key-critical, .analysis-key-threshold { border-color: var(--danger); }
.analysis-key-battery { border-color: var(--warning); }
.analysis-key-threshold { border-top-style: dashed; }
.analysis-readout { margin-bottom: 5px; }
.analysis-readout > span { color: var(--text-soft); }
.analysis-event-breakdown { min-height: 32px; margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.analysis-empty { margin: 12px 0; padding: 20px 16px; border: 1px dashed var(--line); border-radius: 9px; color: var(--muted); background: var(--surface-2); font-size: 12px; line-height: 1.5; text-align: center; }
.analysis-panel canvas { cursor: crosshair; touch-action: pan-y; }
.analysis-panel canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.support-copy { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 10px 0 0; }
.export-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, .6fr); gap: 20px; }
.editor-panel, .export-guidance { padding: 24px; }
.editor-panel h2, .export-guidance h2 { margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
fieldset { margin: 20px 0; padding: 15px; border: 1px solid var(--line); border-radius: 9px; }
legend { color: var(--muted); font-size: 11px; padding: 0 6px; }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.check-grid label { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
.check-grid input { width: auto; min-height: 0; accent-color: var(--accent); }
.selection-list { min-width: 0; max-height: 190px; margin: 0; overflow-y: auto; }
.selection-list > div { display: grid; gap: 3px; }.selection-list label { min-height: 38px; display: flex; grid-template-columns: none; align-items: center; gap: 9px; padding: 6px 7px; border-radius: 6px; color: var(--text); font-weight: 500; cursor: pointer; }.selection-list label:hover { background: var(--surface-2); }.selection-list input { width: auto; min-height: 0; accent-color: var(--accent); }
.form-note { color: var(--muted); font-size: 11px; line-height: 1.55; }
.preflight { margin: 0 0 18px; padding: 11px 13px; border-left: 3px solid var(--accent); background: var(--accent-soft); color: #cde3df; font-size: 11px; line-height: 1.45; }
.preflight.is-draft { border-color: var(--warning); background: var(--warning-soft); }
.export-guidance p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.export-guidance dl { margin: 28px 0 0; }
.export-guidance dl div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.export-guidance dt { color: var(--muted); font-size: 11px; }.export-guidance dd { margin: 0; font-weight: 700; font-size: 12px; }
.establishment-form { margin-bottom: 36px; }

.app-dialog { width: min(650px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--panel-shadow); }
.app-dialog::backdrop { background: rgba(2, 7, 7, .74); backdrop-filter: blur(5px); }
.dialog-frame { min-width: 0; }
.dialog-frame > header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line-soft); background: var(--surface); }
.dialog-frame h2 { margin: 0; font-size: 20px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; font-size: 20px; }
#dialog-content { padding: 22px; max-height: calc(100vh - 130px); overflow-y: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.form-message, .global-message { padding: 11px 13px; border: 1px solid rgba(223,116,105,.35); border-radius: 8px; background: var(--danger-soft); color: #f4b3ac; font-size: 11px; line-height: 1.4; }
.form-message.is-success, .global-message.is-success { border-color: rgba(97,214,195,.35); background: var(--accent-soft); color: #bdebe3; }
.global-message { position: fixed; top: 86px; right: 20px; z-index: 60; width: min(440px, calc(100vw - 40px)); }
.detail-list { display: grid; gap: 0; margin: 0 0 22px; }
.detail-list div { display: grid; grid-template-columns: minmax(130px, .5fr) 1fr; gap: 15px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.detail-list dt { color: var(--muted); font-size: 11px; }.detail-list dd { margin: 0; font-size: 12px; }
.photo-viewer-main { width: 100%; max-height: 58vh; display: block; border-radius: 10px; object-fit: contain; background: var(--surface-2); }
.photo-viewer-meta { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; color: var(--muted); font-size: 10px; }
.photo-history-strip { display: flex; gap: 8px; padding: 10px 0; overflow-x: auto; border-top: 1px solid var(--line-soft); }
.photo-history-strip button { flex: 0 0 84px; padding: 3px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.photo-history-strip button.is-active { border-color: var(--accent); color: var(--text); }.photo-history-strip img { width: 76px; height: 51px; display: block; border-radius: 5px; object-fit: cover; }.photo-history-strip span { display: block; margin-top: 4px; font-size: 9px; }
.photo-delete-zone { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line-soft); }

.login-page { min-height: 100vh; background: var(--login-bg); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(380px, .65fr); }
.login-context { display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: clamp(30px, 5vw, 78px); background: var(--login-context-bg); border-right: 1px solid var(--line-soft); }
.login-context h1 { margin: 9px 0 16px; max-width: 720px; font-size: clamp(44px, 6vw, 78px); line-height: .98; letter-spacing: -.055em; }
.login-context > div > p:not(.eyebrow) { max-width: 550px; color: var(--muted); font-size: 16px; line-height: 1.6; }
.login-footnote { color: var(--faint); font-size: 11px; }
.login-form-panel { position: relative; display: grid; place-items: center; padding: 30px; }
.login-theme { position: absolute; top: 22px; right: 22px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 10px; }
.login-form { width: min(360px, 100%); }
.login-form h2 { margin: 4px 0 7px; font-size: 31px; letter-spacing: -.035em; }
.login-form > p:not(.eyebrow) { margin: 0 0 26px; color: var(--muted); }
.login-form label { margin-bottom: 16px; }
.login-form .form-message { margin: 6px 0 16px; }
.login-form .primary-button { width: 100%; margin-top: 5px; }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }

@media (max-width: 1050px) {
  :root { --nav-width: 76px; }
  .primary-nav a { justify-content: center; padding: 0; }
  .primary-nav a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .primary-nav b { position: absolute; transform: translate(12px,-13px); }
  .overview-grid { grid-template-columns: 1fr; }
  .device-focus { display: grid; grid-template-columns: 1fr 1fr; gap: 0 30px; }
  .focus-actions { grid-column: 1 / -1; }
  .form-grid.three { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .topbar { height: 64px; padding: 0 16px; }
  .topbar-status .live-indicator, .topbar-status .theme-switcher, .topbar-status .user-menu > span:last-child, .quiet-button, .mobile-menu, .primary-nav { display: none; }
  .workspace { padding: 27px 16px calc(104px + env(safe-area-inset-bottom)); }
  .mobile-dock { position: fixed; z-index: 45; inset: auto 0 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 7px 7px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--topbar-bg); backdrop-filter: blur(18px); }
  .mobile-dock a, .mobile-dock button { min-width: 0; min-height: 52px; display: grid; place-items: center; align-content: center; gap: 3px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); text-decoration: none; font-size: 9px; cursor: pointer; }
  .mobile-dock a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
  .mobile-dock svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-more-backdrop { position: fixed; z-index: 47; inset: 0; display: block; background: rgba(2,7,7,.56); backdrop-filter: blur(2px); }
  .mobile-more { position: fixed; z-index: 48; inset: auto 0 0; display: block; max-height: min(82vh, 680px); padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; background: var(--surface); box-shadow: var(--panel-shadow); transform: translateY(102%); transition: transform .18s ease; }
  .mobile-more.is-open { transform: none; }
  .mobile-more > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 15px; border-bottom: 1px solid var(--line-soft); }
  .mobile-more h2 { margin: 0; font-size: 24px; }.mobile-more nav { display: grid; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }.mobile-more nav a { min-height: 48px; display: flex; align-items: center; color: var(--text); text-decoration: none; }
  .mobile-more > section { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }.mobile-label, .mobile-account span { display: block; margin-bottom: 9px; color: var(--muted); font-size: 10px; }.theme-switcher.mobile { display: grid; grid-template-columns: repeat(3, 1fr); }.theme-switcher.mobile button { min-height: 40px; }
  .mobile-account strong { display: block; font-size: 14px; }.mobile-account span { margin: 4px 0 0; }.mobile-more-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding-top: 18px; }
  .view-heading { align-items: flex-start; flex-direction: column; margin-bottom: 23px; }
  .view-heading h1 { font-size: clamp(28px, 9vw, 38px); }
  .heading-actions { width: 100%; }.heading-actions button { flex: 1; }
  .filter-bar { align-items: stretch; }.filter-bar label { flex: 1 1 140px; }.filter-bar select { min-width: 0; }
  .segmented { width: 100%; margin-left: 0; }.segmented button { flex: 1; }
  .metric-line { grid-template-columns: repeat(2, 1fr); }.metric:nth-child(3) { border-left: 0; padding-left: 0; }.metric:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
  .overview-grid, .analysis-grid, .export-layout { grid-template-columns: 1fr; }
  .analysis-grid .wide { grid-column: auto; }
  .device-focus { display: block; }
  .focus-photo, .focus-photo-empty { margin-inline: -16px; width: calc(100% + 32px); border-radius: 10px 10px 0 0; }
  .focus-actions > * { flex: 1 1 calc(50% - 4px); min-height: 44px; }
  .form-grid, .form-grid.three, .check-grid { grid-template-columns: 1fr; }
  .chart-stage { padding: 16px 12px; }
  .analysis-panel .section-heading { flex-wrap: wrap; gap: 10px; }
  .analysis-chart-focus { width: 100%; justify-content: stretch; }
  .analysis-chart-device { width: 100%; max-width: none; }
  .analysis-readout { gap: 4px 12px; }
  .analysis-readout > span { flex: 1 1 100%; }
  .chart-readout { align-items: flex-start; }
  .chart-readout strong { flex: 1 0 100%; }
  .chart-latest-button { margin-left: 0; }
  .data-section .table-wrap { overflow: visible; border: 0; }
  .data-section table, .data-section tbody, .data-section tr, .data-section td { display: block; width: 100%; }
  .data-section thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .data-section tbody { display: grid; gap: 10px; }
  .data-section tbody tr { padding: 8px 12px; border: 1px solid var(--line-soft); border-radius: 11px; background: var(--surface); }
  #device-table tr.is-selected { border-color: var(--accent-strong); background: var(--accent-soft); }
  .data-section tbody td { display: grid; grid-template-columns: minmax(88px, .42fr) minmax(0, .58fr); gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-soft); text-align: right; overflow-wrap: anywhere; }
  .data-section tbody td:first-child { border-top: 0; }.data-section tbody td::before { content: attr(data-label); color: var(--faint); font-size: 9px; font-weight: 700; letter-spacing: .07em; text-align: left; text-transform: uppercase; }
  .data-section tbody td > * { justify-self: end; }.data-section .device-cell { justify-self: stretch; justify-content: flex-end; min-width: 0; }.data-section .empty-row { padding: 0; }.data-section .empty-row td { display: block; padding: 22px 10px; text-align: center; }.data-section .empty-row td::before { content: none; }
  .table-action { min-height: 38px; padding: 8px; }
  #recent-heading { scroll-margin-top: 82px; }
  .recent-pagination { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1fr); gap: 8px; }
  .recent-pagination button { min-width: 0; min-height: 44px; }
  .recent-pagination > span { font-size: 11px; }
  .app-dialog { width: 100%; max-width: none; max-height: calc(100dvh - 18px); margin: 0; inset: auto 0 0; border-radius: 18px 18px 0 0; }
  .dialog-frame > header { padding: 17px 18px; }.dialog-frame h2 { font-size: 18px; }#dialog-content { max-height: calc(100dvh - 94px); padding: 18px; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }.dialog-actions { position: sticky; bottom: 0; padding: 10px 0 0; background: var(--surface); }.dialog-actions button { min-height: 44px; flex: 1; }
  .photo-viewer-main { max-height: 52dvh; }.photo-viewer-meta { align-items: flex-start; flex-direction: column; }
  .global-message { top: 74px; right: 12px; width: calc(100vw - 24px); }
  .login-shell { display: block; }
  .login-context { min-height: 36vh; padding: 25px 22px; }
  .login-context h1 { font-size: clamp(34px, 10vw, 52px); }
  .login-context .login-footnote { display: none; }
  .login-form-panel { display: flex; flex-direction: column; align-items: stretch; gap: 34px; padding: 24px 22px 45px; }
  .login-theme { position: static; align-self: flex-end; }.login-form { margin: 0 auto; }.login-form input, .login-form button { min-height: 46px; }
}

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