:root {
  --bar: #27989c;
  --bar-2: #1a6b6e;
  --soft-bar: #69b5b8;
  --ink: #1a1a1a;
  --muted: #616161;
  --line: #e0e0e0;
  --field: #bdbdbd;
  --bg: #ffffff;
  --soft: #f4f7f7;
  --red: #c62828;
  --ok: #1b7a46;
  --warn: #8a5a00;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Roboto, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--bar-2); }
img { max-width: 100%; }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 6px; color: var(--bar-2); }
h2, h3 { color: var(--bar-2); }
.lede, .hint, .small, .muted { color: var(--muted); }
.lede { margin: 0 0 16px; font-size: 14px; line-height: 1.45; }
.small { font-size: 14px; }
.hint { margin: 6px 0 0; font-size: 12px; line-height: 1.35; }

.app { min-height: 100vh; }
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 8px 0 4px;
  background: var(--bar);
  color: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.top-back, .top-link {
  color: white;
  text-decoration: none;
  min-width: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.top-link { font-size: 14px; font-weight: 600; min-width: auto; padding: 0 10px; }
.brand strong { font-size: 20px; font-weight: 600; }
.top-nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.top-ico, .top-sort summary {
  width: 40px; height: 40px; color: white;
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; cursor: pointer; list-style: none;
}
.top-sort summary::-webkit-details-marker { display: none; }
.top-sort summary span { font-size: 11px; font-weight: 700; }
.top-sort summary { width: auto; padding: 0 4px; }
.top-ico svg, .top-sort svg { width: 22px; height: 22px; fill: currentColor; }
.top-sort { position: relative; }
.top-sort[open] > div {
  position: absolute; right: 0; top: 44px; z-index: 30;
  background: white; color: var(--ink); min-width: 230px;
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden;
}
.top-sort a { display: block; padding: 12px 14px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); font-size: 14px; }
.app-row { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.app-row .label { flex: 1.2; margin: 0; font-size: 13px; font-weight: 500; color: var(--ink); }
.app-row select, .app-row .measure { flex: 1.4; min-width: 0; }
.app-row select { min-height: 44px; margin: 0; font-size: 16px; }
.app-row .measure input { width: 84px; font-size: 16px; }
.mat select { border: 0; min-height: 32px; padding: 2px 0; background: transparent; }
body.in { background: linear-gradient(180deg, #e7f4f4 0%, #ffffff 220px); }
main { padding: 16px 16px 32px; max-width: 720px; margin: 0 auto; }
main.wide { max-width: 980px; }

body.guest {
  background: linear-gradient(180deg, #27989c 0%, #69b5b8 42%, #ffffff 100%);
  min-height: 100vh;
}
body.guest .app { background: transparent; }
body.guest main { max-width: 480px; margin: 0 auto; }

.auth-card {
  background: white;
  border-radius: 20px;
  padding: 24px 20px 20px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.15);
}
.auth-mark {
  width: 96px;
  height: 96px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: white;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}
.auth-card h1, .auth-card .lede { text-align: center; }

.card {
  background: #fafafa;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.btn, button.btn, a.btn, label.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin: 0 0 10px;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1.5px solid var(--bar);
  background: white;
  color: var(--bar-2);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(26, 107, 110, 0.08);
}
.btn.primary {
  background: var(--bar);
  color: white;
  border-color: var(--bar);
  box-shadow: 0 4px 10px rgba(39, 152, 156, 0.35);
}
.btn.danger { color: var(--red); border-color: var(--red); background: white; box-shadow: none; }
.btn.slim, .btn.ghost.slim { min-height: 40px; width: auto; margin: 0; padding: 8px 12px; font-size: 14px; box-shadow: none; }
.btn.block { background: white; }
.btn:disabled { opacity: 0.55; }

label.field-label, label.sub, .label, .sub {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  font-size: 13px;
  font-weight: 600;
  color: #424242;
  margin: 0 0 14px;
}
.sub { margin-bottom: 0; }
input:not([type="radio"]):not([type="checkbox"]):not([type="file"]):not([type="hidden"]),
select,
textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--field);
  border-radius: 12px;
  background: white;
  padding: 10px 14px;
  font-size: 16px;
  color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--bar);
  border-width: 2px;
}
.field { margin-bottom: 14px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.measure { display: flex; align-items: center; gap: 8px; }
.measure input { width: 96px; min-width: 96px; flex: none; min-height: 40px; padding: 8px; }
.mat {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  margin: 0 0 16px;
  padding: 8px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  background: white;
}
.mat:focus-within { border-color: var(--bar); border-width: 2px; }
.mat-icon { width: 24px; height: 24px; flex: none; color: var(--bar); }
.mat-body { flex: 1; min-width: 0; }
.mat-label { display: block; font-size: 12px; font-weight: 600; color: #616161; }
.mat input {
  border: 0;
  min-height: 28px;
  padding: 2px 0 0;
  border-radius: 0;
  background: transparent;
}
.mat input:focus { border: 0; outline: none; }
.gps {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f3f3f3;
  border: 1px solid #e0e0e0;
  color: #424242;
  font-size: 13px;
}
.gps.ok { background: #e5f6ec; border-color: #b7e4c7; color: var(--ok); }
.gps.off { background: #fdecee; border-color: #f5c2c7; color: var(--red); }
.measure span { color: var(--muted); font-size: 14px; flex: none; }

.choices { display: flex; flex-direction: column; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: white; }
.choice { position: relative; display: block; }
.choice input { position: absolute; opacity: 0; }
.choice span {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px 10px 48px;
  border-bottom: 1px solid var(--line);
  background: white;
  line-height: 1.3;
}
.choice:last-child span { border-bottom: 0; }
.choice span::before {
  content: "";
  position: absolute;
  left: 14px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #757575;
  background: white;
}
.choice input:checked + span { background: #e7f5f5; color: var(--bar-2); font-weight: 700; }
.choice input:checked + span::before { border: 6px solid var(--bar); }
.choice input:disabled + span { opacity: 0.4; }
.choice input:focus-visible + span { outline: 2px solid var(--bar); }

.flash { display: grid; gap: 8px; margin-bottom: 12px; }
.flash p { margin: 0; padding: 10px 12px; border-radius: 12px; background: white; font-size: 14px; }
.flash .ok { background: #e5f6ec; color: var(--ok); }
.flash .error { background: #fdecee; color: var(--red); }
.flash .warn { background: #fff4d6; color: var(--warn); }
.banner, .lock-banner {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff4d6;
  color: var(--warn);
  font-size: 14px;
  line-height: 1.4;
  margin: 0 0 12px;
}
.lock-banner { background: #e5f6ec; color: var(--ok); font-weight: 700; }

.rows { list-style: none; margin: 8px 0 0; padding: 0; }
.rows li { margin-bottom: 10px; }
.rows a, .account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}
.rows strong { display: block; font-size: 16px; font-weight: 600; }
.rows small { display: block; color: var(--muted); font-size: 13px; }
.badge { flex: none; font-style: normal; font-size: 12px; font-weight: 700; color: var(--bar-2); }
.badge.lock { color: var(--ok); }
.badge.wait { color: var(--warn); }
.empty { color: var(--muted); padding: 24px 0; }

.type-picker h2 { margin: 0 0 10px; font-size: 16px; }
.add-type .mat { margin-bottom: 10px; }
.type-cards { display: grid; gap: 10px; margin: 0 0 16px; }
.type-card, .expand-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 76px;
  margin-bottom: 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: white;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  border: 1px solid transparent;
}
.type-card strong, .expand-card strong { font-size: 16px; font-weight: 700; color: var(--bar-2); }
.type-card span, .expand-card span { color: var(--muted); font-size: 13px; }
.type-card small, .expand-card small { color: var(--muted); font-size: 12px; }
.type-card:active, .expand-card:active { border-color: var(--bar); transform: scale(0.99); }
.stack { display: grid; gap: 0; }
.actions, .form-block { margin-bottom: 8px; }
.photo-actions { display: grid; gap: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions .btn, .row-actions form { flex: 1; margin: 0; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; font-size: 40px; cursor: pointer; }

.photo-grid, .preview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
.photo-grid figure, .preview-grid figure { margin: 0; position: relative; aspect-ratio: 1; overflow: hidden; background: var(--soft); border-radius: 12px; }
.photo-grid img, .preview-grid img { width: 100%; height: 100%; object-fit: cover; }
.icon-x {
  position: absolute; top: 4px; right: 4px;
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.72); color: white; cursor: pointer;
}
.chips-selected { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.sel-chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%; padding: 6px 8px; border-radius: 12px;
  background: #e7f5f5; color: var(--bar-2); font-size: 12px;
  border: 1px solid #b7e0e1; cursor: pointer; text-align: left; font: inherit;
}
.sel-chip-open:hover, .sel-chip-open:focus-visible {
  outline: 2px solid var(--bar);
  outline-offset: 1px;
}
.sel-chip button,
.sel-chip-x {
  border: 0; background: transparent; color: var(--bar-2); font-weight: 700;
  cursor: pointer; min-height: 28px; min-width: 28px; display: inline-grid; place-items: center;
}

.sheet, .came-fig { border: 1.5px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 8px; background: white; }
.shaft { width: 100%; height: auto; display: block; }
.cote-boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.cote { background: var(--cote); color: white; border-radius: 8px; padding: 6px 4px 8px; text-align: center; }
.cote-n { display: block; font-size: 12px; font-weight: 700; }
.cote input { min-height: 36px; border: 0; border-radius: 8px; text-align: center; font-weight: 700; padding: 4px; color: var(--ink); }
.cote small { display: block; margin-top: 4px; font-size: 10px; }
.cote:nth-child(3) { color: #1a1a1a; }
.legend { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.came-fig svg { width: 100%; height: auto; }
.came-fig figcaption { font-weight: 700; margin-bottom: 4px; }
.summary dt { margin-top: 8px; font-size: 12px; color: var(--muted); }
.summary dd { margin: 0; }
.item-block { padding: 4px 2px 8px; }
.item-block h3 { margin: 0; font-size: 16px; }
.dock { margin-top: 8px; }

.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: white; display: flex; flex-direction: column;
}
.overlay header {
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 8px; background: var(--bar); color: white;
}
.overlay header button { background: transparent; color: white; border: 0; min-height: 48px; font-weight: 700; cursor: pointer; }
.overlay .body { padding: 8px 16px 16px; overflow: auto; flex: 1; }
.cat-list, .open-pick { display: grid; }
.cat-list button, .open-pick button {
  width: 100%; text-align: left; background: white; border: 0;
  border-bottom: 1px solid var(--line); min-height: 56px; padding: 12px 4px; cursor: pointer;
  border-radius: 0;
}
.viewer { display: grid; grid-template-rows: auto 1fr auto; min-height: 70vh; }
.viewer .frame {
  border: 0; border-radius: 0; min-height: 0; overflow: hidden;
  display: block; padding: 0;
}
.viewer .frame iframe { width: 100%; height: 100%; border: 0; background: white; }
.schema-img, .came-fig img, .schema-fig img { width: 100%; height: auto; display: block; }
.opening-fig { margin: 8px 0 0; text-align: center; }
.opening-fig.door-logo {
  max-width: 180px;
}
.opening-fig.door-logo img {
  display: block;
  width: auto;
  max-width: 140px;
  max-height: 96px;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}
.opening-fig figcaption { color: var(--bar); font-weight: 700; font-size: 12px; margin-top: 4px; }
.field > .label + select[data-opening-image-select],
.field > select[data-opening-image-select] {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
  margin-top: 6px;
}
.page-card { text-align: center; padding: 20px 8px; }
.page-card b { display: block; font-size: 40px; color: var(--bar); }
.viewer .bar { display: flex; gap: 8px; padding-top: 10px; }
.viewer .bar .btn { margin: 0; }

@media (max-width: 520px) {
  .split { grid-template-columns: 1fr; }
}

.home-tools {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 12px;
  padding-bottom: 2px;
}
.tool, .tool-menu summary {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  background: white;
  color: var(--bar-2);
  border: 1px solid #d7e4e4;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
}
.tool-menu { position: relative; }
.tool-menu summary::-webkit-details-marker { display: none; }
.tool-menu[open] { z-index: 5; }
.tool-menu a {
  display: block;
  min-width: 220px;
  padding: 10px 12px;
  background: white;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.tool-menu a.on { color: var(--bar); font-weight: 700; }
.tool-menu[open] a:first-of-type { border-radius: 12px 12px 0 0; }
.tool-menu { display: inline-flex; }
.tool-menu[open] {
  display: inline-flex;
  flex-direction: column;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
}
.search input { margin: 0 0 8px; }
.survey-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding-bottom: 84px; }
.survey-list { display: grid; gap: 8px; padding-bottom: 84px; }
.survey-card, .survey-row {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,.08);
  padding: 12px;
}
.survey-card { min-height: 168px; display: flex; flex-direction: column; }
.survey-card-top, .survey-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.survey-card a, .survey-row a { text-decoration: none; color: inherit; display: grid; gap: 2px; min-width: 0; }
.survey-card strong, .survey-row strong { font-size: 14px; }
.survey-card span, .survey-row span, .survey-row small, .survey-date { color: var(--muted); font-size: 12px; }
.survey-date { margin: auto 0 0; padding-top: 8px; border-top: 1px solid var(--line); }
.survey-ico {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  background: #e7f5f5; color: var(--bar); font-weight: 700;
}
.more { position: relative; }
.more summary { cursor: pointer; list-style: none; min-width: 32px; min-height: 32px; text-align: center; font-weight: 700; color: #616161; }
.more summary::-webkit-details-marker { display: none; }
.more[open] { position: relative; z-index: 4; }
.more a, .more button {
  display: block; width: 100%; text-align: left;
  background: white; border: 0; border-bottom: 1px solid var(--line);
  padding: 8px 10px; color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 600;
}
.more form { margin: 0; }
.more[open] {
  position: absolute; right: 8px; top: 40px;
  background: white; border-radius: 12px; overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,.15); min-width: 140px;
}
.survey-row .more[open] { top: 8px; }
.empty-state { text-align: center; color: var(--muted); padding: 48px 12px 80px; }
.empty-state strong { display: block; font-size: 20px; font-weight: 500; margin-bottom: 6px; }
.fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 15;
  display: inline-flex; align-items: center; min-height: 52px;
  padding: 0 18px; border-radius: 16px;
  background: var(--bar); color: white; text-decoration: none; font-weight: 700;
  box-shadow: 0 6px 16px rgba(39, 152, 156, .4);
}
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: white; border-radius: 16px; box-shadow: 0 4px 10px rgba(0,0,0,.08); padding: 14px 8px; text-align: center; }
.stat strong { display: block; color: var(--bar); font-size: 26px; }
.stat span { color: var(--muted); font-size: 12px; }
.bars { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.bars li { display: grid; grid-template-columns: 130px 1fr 28px; gap: 8px; align-items: center; font-size: 13px; }
.bars i { display: block; height: 10px; border-radius: 8px; background: var(--bar); min-width: 4px; }
.map-frame { width: 100%; height: 280px; border: 0; border-radius: 16px; margin-bottom: 12px; }
html.theme-dark, html.theme-dark body, html.theme-dark body.in {
  background: var(--bg) !important;
  color: var(--ink);
}
html.theme-dark .app, html.theme-dark main { background: transparent; color: var(--ink); }
html.theme-dark h1, html.theme-dark h2, html.theme-dark h3, html.theme-dark .label, html.theme-dark .mat-label { color: #d7efef; }
html.theme-dark .survey-card, html.theme-dark .survey-row, html.theme-dark .stat, html.theme-dark .card,
html.theme-dark .rows a, html.theme-dark .account, html.theme-dark .mat, html.theme-dark .auth-card,
html.theme-dark .sheet, html.theme-dark .choices, html.theme-dark .choice span,
html.theme-dark .more a, html.theme-dark .more button, html.theme-dark .more[open],
html.theme-dark .top-sort[open] > div, html.theme-dark .overlay, html.theme-dark .overlay .body,
html.theme-dark input, html.theme-dark select, html.theme-dark textarea {
  background: var(--surface); color: var(--ink); border-color: var(--field);
}
html.theme-dark .survey-card span, html.theme-dark .hint, html.theme-dark .lede, html.theme-dark .muted,
html.theme-dark .survey-date, html.theme-dark .small { color: var(--muted); }
html.theme-dark .choice input:checked + span { background: var(--soft); color: #9ad4d6; }
html.theme-dark .cat-list button, html.theme-dark .open-pick button { background: var(--surface); color: var(--ink); border-color: var(--line); }
@media (max-width: 640px) {
  .survey-grid, .stat-grid { grid-template-columns: 1fr 1fr; }
  .bars li { grid-template-columns: 92px 1fr 24px; }
}

body.splash-body {
  min-height: 100vh;
  background: #134d4f;
  color: white;
}
.splash {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 24px;
  background: linear-gradient(165deg, #27989c 0%, #1a6b6e 58%, #134d4f 100%);
}
.splash-center { width: min(420px, 100%); text-align: center; }
.splash-mark {
  margin: 0 0 18px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}
.splash h1 {
  margin: 0;
  color: white;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.35;
}
.splash-track {
  position: relative;
  height: 3px;
  margin: 36px auto 14px;
  width: min(220px, 70%);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}
.splash-track span {
  position: absolute;
  inset: 0;
  background: white;
  transform: scaleX(0);
  transform-origin: left center;
}
.splash-status {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.78);
}

/* Flutter Material identity parity */
:root {
  color-scheme: light;
  --bar: #27989c;
  --bar-2: #1a6b6e;
  --soft-bar: #69b5b8;
  --ink: #1a1a1a;
  --muted: #616161;
  --line: #e0e0e0;
  --field: #d5d5d5;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --soft: #e7f5f5;
  --shadow: rgba(0, 0, 0, 0.10);
  --scrim: rgba(0, 0, 0, 0.18);
}

html.theme-dark {
  color-scheme: dark;
  --ink: #ffffff;
  --muted: #bdbdbd;
  --line: #424242;
  --field: #616161;
  --bg: #121212;
  --surface: #2d2d2d;
  --surface-2: #1e1e1e;
  --soft: #17393a;
  --shadow: rgba(0, 0, 0, 0.34);
  --scrim: rgba(0, 0, 0, 0.46);
}

html.theme-light { color-scheme: light; }
html, body { background-color: var(--bg); }
body {
  color: var(--ink);
  accent-color: var(--bar);
  transition: background-color 180ms ease, color 180ms ease;
}
body.in {
  background: linear-gradient(180deg, rgba(39, 152, 156, 0.10) 0, var(--bg) 220px);
}
html.theme-dark body.guest {
  background: linear-gradient(180deg, #174f51 0%, #1f6f72 40%, var(--bg) 100%);
}

h1, h2, h3 { color: var(--bar-2); }
html.theme-dark h1,
html.theme-dark h2,
html.theme-dark h3 { color: #8bcdd0; }
.lede, .hint, .small, .muted,
.measure span, .empty, .summary dt, .legend { color: var(--muted); }

.top {
  min-height: 56px;
  height: auto;
  padding-top: env(safe-area-inset-top);
  background: var(--bar);
  box-shadow: 0 2px 6px var(--scrim);
}
.top-back, .top-link, .top-ico, .top-sort summary {
  border-radius: 999px;
  transition: background-color 120ms ease;
}
.top-back:hover, .top-link:hover, .top-ico:hover, .top-sort summary:hover {
  background: rgba(255, 255, 255, 0.14);
}
main { width: 100%; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

.card, .survey-card, .survey-row, .type-card, .rows a, .account,
.stat, .auth-card, .sheet, .came-fig {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 12px var(--shadow);
}
.card, .survey-card, .type-card, .rows a, .account, .stat { border-radius: 16px; }
.survey-row { border-radius: 12px; }
.survey-card, .survey-row {
  border: 1px solid transparent;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}
.survey-card:hover, .survey-row:hover {
  border-color: rgba(39, 152, 156, 0.35);
  box-shadow: 0 6px 16px var(--shadow);
}
.survey-card:focus-within, .survey-row:focus-within { border-color: var(--bar); }
.survey-card span, .survey-row span, .survey-row small, .survey-date,
.rows small, .type-card span, .stat span { color: var(--muted); }
.survey-ico { background: var(--soft); color: var(--soft-bar); }
html.theme-light .survey-ico { color: var(--bar); }

input:not([type="radio"]):not([type="checkbox"]):not([type="file"]):not([type="hidden"]),
select, textarea, .mat, .choices, .choice span {
  color: var(--ink);
  background-color: var(--surface);
  border-color: var(--field);
  color-scheme: inherit;
}
input[type="number"] {
  color: var(--ink) !important;
  background-color: var(--surface) !important;
  border-color: var(--field) !important;
  color-scheme: inherit;
  -webkit-text-fill-color: var(--ink);
  opacity: 1;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { opacity: 0.72; }
input::-webkit-calendar-picker-indicator { filter: none; opacity: 0.72; }
select option { color: var(--ink); background: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--ink);
}
label.field-label, label.sub, .label, .sub,
.app-row .label, .mat-label { color: var(--ink); }
input:focus, select:focus, textarea:focus, .mat:focus-within {
  border-color: var(--soft-bar);
  box-shadow: 0 0 0 1px var(--soft-bar);
}
.mat input:focus { box-shadow: none; }

.btn, button.btn, a.btn, label.btn {
  background: var(--surface);
  color: var(--bar);
  border-color: var(--bar);
  box-shadow: 0 2px 5px var(--shadow);
  transition: transform 100ms ease, box-shadow 100ms ease, background-color 100ms ease;
}
.btn:hover { background: var(--soft); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary, .fab {
  background: var(--bar);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(39, 152, 156, 0.36);
}
.btn.primary:hover, .fab:hover { background: #238b8f; }
.btn.block, .tool, .tool-menu summary, .tool-menu a,
.more a, .more button, .more[open], .top-sort[open] > div {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.fab {
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
}

.gps { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.choice input:checked + span { background: var(--soft); color: var(--soft-bar); }
.choice span::before { background: var(--surface); }
.overlay, .overlay .body, .cat-list button, .open-pick button {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
}
.flash p { background: var(--surface); }
.viewer .frame { border-color: var(--line); }

/* Flutter splash: centered mark with a bottom version/credit block. */
body.splash-body { overflow: hidden; background: #134d4f; }
.splash {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: linear-gradient(135deg, #27989c 0%, #1a6b6e 56%, #134d4f 100%);
}
.splash-center {
  align-self: center;
  width: min(440px, 100%);
  animation: splash-enter 900ms cubic-bezier(.2,.8,.2,1) both;
}
.splash-icon {
  width: 140px;
  height: 140px;
  margin: 0 auto 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.30);
}
.splash-icon img { width: 80px; height: 80px; }
.splash h1 {
  font-size: clamp(30px, 8vw, 36px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.20);
}
.splash-subtitle {
  display: inline-block;
  margin: 12px 0 0;
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 16px;
  font-weight: 300;
}
.splash-track,
.splash-status { display: none !important; }
.splash-start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(280px, 100%);
  min-height: 54px;
  margin: 36px auto 0;
  padding: 0 28px;
  border-radius: 16px;
  background: #ffffff;
  color: #134d4f;
  border: 0;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  text-decoration: none;
}
.splash-start-btn:hover,
.splash-start-btn:focus-visible {
  filter: brightness(1.04);
}
.splash-footer {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: #ffffff;
  animation: splash-fade 900ms 350ms ease both;
}
.splash-footer strong { font-size: 14px; font-weight: 500; }
.splash-footer small { color: rgba(255, 255, 255, 0.72); font-size: 12px; font-style: italic; }
.splash-rule {
  width: 60px;
  height: 2px;
  margin-bottom: 10px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.30);
}
@keyframes splash-enter {
  from { opacity: 0; transform: translateY(50px) scale(.72); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes splash-fade { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 700px) {
  main { padding: 20px 24px 40px; }
  .survey-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
  .survey-card { min-height: 190px; padding: 18px; }
  .survey-card strong, .survey-row strong { font-size: 17px; }
  .survey-card span, .survey-row span, .survey-row small, .survey-date { font-size: 13px; }
  .survey-row { padding: 16px; }
  .btn { min-height: 54px; }
}
@media (max-width: 420px) {
  main { padding-left: 12px; padding-right: 12px; }
  .top-nav { gap: 0; }
  .top-ico { width: 36px; }
  .brand strong { font-size: 18px; }
  .survey-grid { gap: 10px; }
  .survey-card { padding: 10px; min-height: 158px; }
  .splash-icon { width: 112px; height: 112px; margin-bottom: 28px; }
  .splash-icon img { width: 64px; height: 64px; }
  .splash-track { margin-top: 42px; }
}
@media (max-width: 340px) {
  .survey-grid, .stat-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* CSS fallback when scripting or storage is unavailable. */
@media (prefers-color-scheme: dark) {
  html.theme-system {
    color-scheme: dark;
    --ink: #ffffff;
    --muted: #bdbdbd;
    --line: #424242;
    --field: #616161;
    --bg: #121212;
    --surface: #2d2d2d;
    --surface-2: #1e1e1e;
    --soft: #17393a;
    --shadow: rgba(0, 0, 0, 0.34);
  }
}

.survey-stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 20px;
}
.survey-stepper a, .survey-stepper span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}
.survey-stepper b {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink);
}
.survey-stepper .active { border-color: var(--bar); color: var(--bar); font-weight: 700; }
.survey-stepper .active b { background: var(--bar); color: #fff; }

.viewer .frame iframe { min-height: 0; }
.identify-preview {
  display: block;
  width: 100%;
  max-height: 55vh;
  margin-top: 14px;
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
}
.sketch-tools, .sketch-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}
.sketch-tools .btn, .sketch-actions .btn { width: auto; margin: 0; }
.sketch-tools label:not(.btn) { display: flex; align-items: center; gap: 6px; }
.sketch-tools input[type="color"] { width: 46px; height: 38px; padding: 2px; }
.sketch-board {
  width: 100%;
  overflow: auto;
  border: 2px solid var(--bar);
  border-radius: 12px;
  background: #fff;
  touch-action: none;
}
#sketch-canvas { display: block; width: 100%; height: auto; min-width: 640px; }

@media (max-width: 520px) {
  .survey-stepper a, .survey-stepper span { flex-direction: column; gap: 3px; font-size: 10px; }
}

/* ===== Mobile / tablet parity with Android app ===== */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html.catalog-open,
html.catalog-open body {
  overflow: hidden;
  touch-action: none;
}
.overlay {
  background: #121212;
  padding-bottom: env(safe-area-inset-bottom);
}
.overlay header {
  flex: none;
  min-height: 56px;
  height: auto;
  padding: max(8px, env(safe-area-inset-top)) 10px 8px;
}
.overlay header strong {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overlay header .cat-close {
  flex: none;
  margin-left: auto;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 14px;
}
.overlay .body {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: #121212;
  color: #f2f2f2;
}
.overlay .open-pick,
.overlay .cat-list {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
}
.overlay .open-pick button,
.overlay .cat-list button {
  min-height: 56px;
  padding: 14px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid #333;
  background: #1e1e1e;
  color: #f2f2f2;
  font-size: 15px;
  font-weight: 600;
}
.viewer {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
}
.viewer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
  padding: 8px 12px;
  background: #1a1a1a;
  border-bottom: 1px solid #2c2c2c;
}
.viewer-meta strong {
  flex: 1 1 auto;
  min-width: 0;
  color: #8bcdd0;
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
}
.viewer-meta span {
  flex: none;
  color: #bdbdbd;
  font-size: 12px;
}
.viewer .frame {
  margin: 0;
  min-height: 0;
  height: auto;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: #0d0d0d;
  overflow: hidden;
  padding: 0;
  display: block;
  position: relative;
}
.viewer .frame iframe,
.viewer .frame .pdf-frame {
  width: 100%;
  height: 100%;
  min-height: 100%;
  border: 0;
  background: #fff;
}
.zoom-pane {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  display: block;
  background: #fff;
  padding: 0;
  box-sizing: border-box;
}
.viewer .frame .zoom-pane img,
.zoom-pane img {
  display: block;
  max-width: none !important;
  max-height: none !important;
  width: 100%;
  height: auto !important;
  object-fit: unset;
  margin: 0;
  padding: 0;
  transform: none;
  user-select: none;
  -webkit-user-drag: none;
  background: #fff;
}
.zoom-tools {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 3;
  display: grid;
  grid-template-columns: 44px auto 44px;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(18, 18, 18, 0.88);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}
.zoom-tools button {
  min-height: 40px;
  min-width: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #2a2a2a;
  color: #8bcdd0;
  font-weight: 700;
  cursor: pointer;
}
.viewer .bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: #1a1a1a;
  border-top: 1px solid #2c2c2c;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
}
.viewer .bar .btn {
  margin: 0;
  min-height: 48px;
  font-size: 13px;
  padding: 10px 6px;
}
.viewer .bar .btn.ghost {
  background: #2a2a2a;
  color: #8bcdd0;
  border-color: #3a3a3a;
}
.viewer .bar .btn.primary {
  background: var(--bar);
  color: #fff;
  border-color: var(--bar);
}
.viewer .bar .btn:disabled {
  opacity: 0.35;
}

/* Form rows: phone stacks like Flutter phone; tablet keeps label | control */
@media (max-width: 699px) {
  main {
    padding: 12px 12px calc(88px + env(safe-area-inset-bottom));
    max-width: 100%;
  }
  .app-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin: 0 0 14px;
  }
  .app-row .label {
    flex: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
  }
  .app-row select,
  .app-row .measure {
    flex: none;
    width: 100%;
  }
  .app-row .measure {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
  }
  .app-row .measure input,
  .measure input {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    font-size: 16px;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .opening-fig.door-logo {
    margin: 10px 0 0;
    padding: 8px;
    border: 1.5px solid var(--bar);
    border-radius: 12px;
    background: #fff;
    max-width: 160px;
  }
  .opening-fig.door-logo img {
    max-width: 120px;
    max-height: 84px;
    margin: 0 auto;
    width: auto;
  }
  .came-fig img,
  .schema-img {
    max-height: 280px;
    margin: 0 auto;
    width: auto;
  }
  .btn, button.btn, a.btn, label.btn {
    min-height: 52px;
    font-size: 15px;
  }
  .photo-grid,
  .preview-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .survey-stepper {
    gap: 6px;
    margin-bottom: 14px;
  }
  .fab {
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    min-height: 56px;
    padding: 0 18px;
    border-radius: 28px;
    box-shadow: 0 8px 20px rgba(39, 152, 156, 0.45);
  }
  .dock {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 12px -12px -12px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, transparent, var(--bg) 28%);
  }
  .dock .btn {
    margin-bottom: 0;
  }
}

@media (min-width: 700px) and (max-width: 1024px) {
  main {
    max-width: 860px;
    padding: 18px 22px 40px;
  }
  .app-row {
    gap: 14px;
  }
  .app-row .label {
    flex: 0 0 38%;
    font-size: 14px;
  }
  .app-row select,
  .app-row .measure {
    flex: 1;
  }
  .app-row .measure input {
    width: 140px;
    min-width: 140px;
    min-height: 48px;
  }
  .survey-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
  .opening-fig.door-logo img {
    max-width: 140px;
    max-height: 96px;
    margin: 0 auto;
    width: auto;
  }
  .viewer .frame {
    min-height: 0;
  }
}

@supports (height: 100dvh) {
  .overlay { height: 100dvh; }
}

/* Secondary screens (list selection, map, dashboard, settings) */
.selection-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface, #fff);
}
.selection-toolbar .btn { width: auto; margin: 0; }
.survey-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.survey-select input {
  width: 18px;
  height: 18px;
  accent-color: var(--bar);
}
.map-count { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.map-empty { margin: 20px 0; }
.leaflet-map, #intervention-map {
  width: 100%;
  height: min(62vh, 520px);
  min-height: 280px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin: 0 0 14px;
  z-index: 1;
}
.client-bars li span {
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-editor {
  margin: 0 0 16px;
}
.profile-editor > summary {
  list-style: none;
  width: auto;
  display: inline-flex;
  cursor: pointer;
}
.profile-editor > summary::-webkit-details-marker { display: none; }
.profile-editor[open] {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface, #fff);
}
.profile-editor form { margin-top: 12px; }
@media (max-width: 699px) {
  .leaflet-map, #intervention-map { height: 48vh; min-height: 240px; }
  .selection-toolbar { position: sticky; top: 56px; z-index: 8; }
}

.confirm-panel {
  max-width: 480px;
  margin: 12px auto 0;
  padding: 22px 18px 18px;
  border-radius: 18px;
  background: #15181e;
  color: #f4f6f8;
  border-top: 6px solid var(--bar);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}
.confirm-panel h1 {
  margin: 0 0 8px;
  color: #7fd0d3;
  font-size: 24px;
}
.confirm-panel .lede,
.confirm-panel .lock-banner { color: #d7dde5; }
.confirm-panel .btn {
  background: #222831;
  color: #7fd0d3;
  border-color: #3a4554;
}
.confirm-panel .btn.primary {
  background: var(--bar);
  color: #fff;
  border-color: var(--bar);
  box-shadow: 0 0 0 1px rgba(39, 152, 156, 0.35), 0 8px 20px rgba(39, 152, 156, 0.28);
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 10, 14, 0.72);
}
.confirm-dialog {
  width: min(420px, 100%);
  padding: 24px 20px 18px;
  border-radius: 22px;
  background: #1a1d23;
  color: #f4f6f8;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.confirm-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(39, 152, 156, 0.18);
  color: #7fd0d3;
}
.confirm-icon svg { width: 28px; height: 28px; fill: currentColor; }
.confirm-dialog h2 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #fff;
}
.confirm-dialog p {
  margin: 0 0 22px;
  color: #a8b0bc;
  font-size: 15px;
  line-height: 1.45;
}
.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.confirm-actions .btn {
  margin: 0;
  min-height: 48px;
  border-radius: 14px;
}
.confirm-actions .btn.ghost {
  background: #252a33;
  color: #c5ccd6;
  border-color: #3a4250;
}
.confirm-actions .btn.primary {
  background: var(--bar);
  border-color: var(--bar);
  color: #fff;
}
html.theme-dark .sel-chip {
  background: rgba(39, 152, 156, 0.18);
  border-color: rgba(39, 152, 156, 0.45);
  color: #8bcdd0;
}
.item-preview-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface, #fff);
}
.item-preview-card .opening-fig {
  max-width: 140px;
}
.item-preview-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.item-preview-actions .btn { margin: 0; }
