:root {
  color-scheme: light;
  --bg: #f4f6f8; --surface: #fff; --text: #17212c; --muted: #4e6072;
  --border: #c8d1dc; --primary: #145d91; --on-primary: #fff;
  --danger: #a32732; --focus: #0077b6; --shadow: 0 3px 16px #17212c12;
  --waiting-bg: #e9edf2; --waiting-text: #35455a;
  --active-bg: #dceeff; --active-text: #154f7e;
  --done-bg: #d9f2e3; --done-text: #185637;
  --problem-bg: #ffe2e2; --problem-text: #84212c;
  --radius: .65rem; --gap: 1.25rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55; font-size: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark; --bg: #111923; --surface: #1b2633; --text: #edf3f9; --muted: #b9c9da;
    --border: #4a5d70; --primary: #86c9fc; --on-primary: #092236; --danger: #ffb4bc; --focus: #86c9fc;
    --waiting-bg: #334356; --waiting-text: #e1eaf5; --active-bg: #193f61; --active-text: #b7dfff;
    --done-bg: #1c4935; --done-text: #b9f2cd; --problem-bg: #5a2630; --problem-text: #ffd6da;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark; --bg: #111923; --surface: #1b2633; --text: #edf3f9; --muted: #b9c9da;
  --border: #4a5d70; --primary: #86c9fc; --on-primary: #092236; --danger: #ffb4bc; --focus: #86c9fc;
  --waiting-bg: #334356; --waiting-text: #e1eaf5; --active-bg: #193f61; --active-text: #b7dfff;
  --done-bg: #1c4935; --done-text: #b9f2cd; --problem-bg: #5a2630; --problem-text: #ffd6da;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-underline-offset: .2em; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; }
h1 { font-size: clamp(1.65rem, 4vw, 2.2rem); }
h2 { font-size: 1.2rem; }
p { margin: .5rem 0 1rem; }
.topbar { height: 4.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { color: var(--text); font-size: 1.3rem; font-weight: 750; text-decoration: none; }
.layout { display: grid; grid-template-columns: 13rem minmax(0, 1fr); min-height: calc(100dvh - 4.5rem); }
.sidebar { padding: 1rem; border-right: 1px solid var(--border); background: var(--surface); }
.sidebar a, .mobile-nav a { display: block; padding: .65rem .8rem; border-radius: .4rem; text-decoration: none; color: var(--text); }
nav a[aria-current="page"] { background: var(--active-bg); color: var(--active-text); font-weight: 700; }
main { width: 100%; max-width: 90rem; min-width: 0; padding: clamp(1rem, 3vw, 2rem); }
.mobile-nav { display: none; }
.grid, .kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: var(--gap); }
.card { padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.empty { text-align: center; padding: 3rem 1.25rem; margin-top: 1.5rem; }
.muted, .timeline-meta { color: var(--muted); }
.toolbar { display: flex; align-items: end; gap: .75rem; flex-wrap: wrap; }
.topbar .toolbar { align-items: center; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; padding: .55rem 1rem; border: 1px solid transparent; border-radius: .4rem; cursor: pointer; text-decoration: none; font-weight: 650; }
.primary { background: var(--primary); color: var(--on-primary); }
.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.danger { background: var(--problem-bg); color: var(--danger); border-color: var(--danger); }
.button:hover { filter: brightness(.94); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button-big, .station .button { min-height: 48px; min-width: 48px; padding: .85rem 1.25rem; }
label { display: grid; gap: .3rem; font-weight: 600; }
input, select, textarea { width: 100%; min-height: 44px; padding: .6rem .75rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: .35rem; }
input[type="checkbox"], input[type="radio"] { width: 1.4rem; min-height: 1.4rem; }
form { display: grid; gap: 1rem; margin: 1rem 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { padding: .75rem 1rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; border-radius: 99rem; padding: .2rem .65rem; font-size: .85rem; font-weight: 650; white-space: nowrap; }
.badge-waiting { color: var(--waiting-text); background: var(--waiting-bg); }
.badge-active { color: var(--active-text); background: var(--active-bg); }
.badge-done { color: var(--done-text); background: var(--done-bg); }
.badge-problem { color: var(--problem-text); background: var(--problem-bg); }
.kpi h2 { color: var(--muted); font-size: .95rem; }
.kpi-value { font-size: 2rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; padding-left: 1rem; border-left: 2px solid var(--border); }
.timeline li { padding: .5rem 0 .5rem 1rem; position: relative; overflow-wrap: anywhere; }
.timeline li::before { content: ""; position: absolute; width: .65rem; height: .65rem; top: .9rem; left: -1.4rem; border-radius: 50%; background: var(--primary); }
.timeline-meta { display: flex; gap: .75rem; flex-wrap: wrap; font-size: .85rem; }
.pagination { margin-top: 1.5rem; }
.flash, .toast { padding: .85rem 1rem; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); }
.flash { margin-bottom: 1rem; }
.toasts { position: fixed; z-index: 100; bottom: 1rem; right: 1rem; max-width: min(26rem, calc(100vw - 2rem)); display: grid; gap: .5rem; }
.toast { box-shadow: var(--shadow); display: flex; gap: 1rem; align-items: center; overflow-wrap: anywhere; }
.toast-error { border-color: var(--danger); }
.toast button { margin-left: auto; }
.skip-link { position: absolute; top: -5rem; left: 1rem; background: var(--surface); padding: 1rem; z-index: 200; }
.skip-link:focus { top: .5rem; }
.stl-viewer { margin: 1rem 0; padding: .75rem; }
.stl-canvas { height: clamp(240px, 45vw, 440px); width: 100%; overflow: hidden; }
.stl-canvas canvas { display: block; max-width: 100%; touch-action: none; }
.stl-viewer figcaption { display: flex; align-items: center; justify-content: space-between; gap: .75rem; color: var(--muted); padding-top: .75rem; }
.field-log { max-width: 60rem; }
.field-log section { margin-bottom: 1.5rem; }
.field-log .button, .field-log summary { min-height: 48px; }
.field-log input, .field-log select, .field-log textarea { min-height: 48px; min-width: 0; max-width: 100%; }
.field-log fieldset { min-width: 0; border: 1px solid var(--border); border-radius: .4rem; }
.field-log details summary { cursor: pointer; padding: .65rem 0; }
.field-category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .6rem; }
.field-category { position: relative; cursor: pointer; }
.field-category input { position: absolute; opacity: 0; width: 1px; min-height: 1px; }
.field-category span { display: flex; align-items: center; justify-content: center; min-height: 52px; padding: .6rem; border: 2px solid var(--border); border-radius: .4rem; }
.field-category input:checked + span { background: var(--active-bg); border-color: var(--primary); color: var(--active-text); }
.field-category input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 3px; }
.field-check { display: flex; align-items: center; min-height: 48px; gap: .6rem; }
.field-check input { min-height: 1.4rem; }
.field-entries { display: grid; gap: 1rem; }
.field-entry { min-width: 0; overflow-wrap: anywhere; }
.field-entry h2 { margin-top: .75rem; }
.field-note { white-space: pre-wrap; overflow-wrap: anywhere; margin: .75rem 0 1rem; }
.field-thumbnails { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: .5rem; margin: 1rem 0; }
.field-thumbnails img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: .35rem; }
.field-full-photos { display: grid; gap: 1rem; margin: 1rem 0; }
.field-full-photos img { display: block; max-width: 100%; height: auto; border-radius: .35rem; }
.field-resolution { margin-top: 1rem; }
@media (max-width: 760px) {
  .topbar { padding: .65rem 1rem; }
  .layout { display: block; }
  .sidebar { display: none; }
  .mobile-nav { display: block; border-bottom: 1px solid var(--border); background: var(--surface); padding: .6rem 1rem; }
  .mobile-nav summary { min-height: 44px; padding: .6rem 0; cursor: pointer; }
  .mobile-nav nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .responsive-table thead { display: none; }
  .responsive-table tr { display: block; padding: .5rem; border-bottom: 1px solid var(--border); }
  .responsive-table td { display: flex; gap: 1rem; justify-content: space-between; border: 0; overflow-wrap: anywhere; }
  .responsive-table td::before { content: attr(data-label); font-weight: 650; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
@media print {
  :root { --bg: white; --surface: white; --text: black; --muted: #333; color-scheme: light; }
  .topbar, .sidebar, .mobile-nav, .toasts, .button, .pagination, .stl-viewer, .skip-link { display: none !important; }
  .layout { display: block; } main { max-width: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; } a { color: black; }
  th, td { padding: .3rem; } .table-wrap { overflow: visible; }
}
