:root {
  --bg: #ffffff;
  --panel: #f6f6f8;
  --panel-2: #eeeef1;
  --track: #ececef;
  --line: #e6e6ea;
  --line-strong: #d7d7dd;
  --text: #15171c;
  --muted: #696f7a;
  --muted-dim: #9b9fa9;
  --accent: #111827;

  --good: #157f4a;
  --danger: #c8362c;

  --c-socket: #2f6df6;
  --c-data: #7c3aed;
  --c-switch: #0f9d6b;
  --c-frame: #e0820b;
  --c-clem: #db4453;
  --c-tv: #0891b2;
  --c-cover: #7c8698;

  --r: 14px;
  --r-sm: 10px;
  --maxw: 640px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --shadow: 0 1px 2px rgba(16, 18, 24, .06), 0 1px 3px rgba(16, 18, 24, .04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding-left: 16px; padding-right: 16px; }
button { font-family: inherit; margin: 0; }
input, textarea { font-family: inherit; font-size: 16px; }
h1, h2, h3, h4 { margin: 0; }

/* ---------------- single sticky app bar ---------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: max(8px, env(safe-area-inset-top));
}
.appbar > .wrap { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; padding-bottom: 10px; }

.bar-row { display: flex; align-items: center; gap: 10px; }
.bolt { width: 22px; height: 22px; flex: none; fill: var(--accent); }
#jobTitle {
  flex: 1; min-width: 0; height: 40px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0 12px; background: var(--panel); color: var(--text);
}
#jobDate {
  flex: none; height: 40px; max-width: 9.5rem;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0 8px; background: var(--panel); color: var(--muted);
  font-family: var(--mono); font-size: 13px;
}
#jobTitle:focus, #jobDate:focus { outline: none; border-color: var(--accent); background: #fff; }
.lang-switch { flex: none; display: flex; gap: 2px; background: var(--track); border-radius: 8px; padding: 2px; }
.lang-switch button { border: none; background: transparent; color: var(--muted); border-radius: 6px; padding: 6px 8px; font-size: 11.5px; font-weight: 700; cursor: pointer; }
.lang-switch button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* room dropdown */
.roombar { position: relative; }
.room-trigger {
  width: 100%; display: flex; align-items: center; gap: 10px; cursor: pointer;
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  border-radius: var(--r-sm); padding: 9px 12px; text-align: left;
}
.room-trigger .rt-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.room-trigger .rt-name { font-size: 15px; font-weight: 650; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-trigger .rt-floor { font-size: 11.5px; color: var(--muted); }
.room-trigger .rt-total { font-family: var(--mono); font-size: 12px; color: var(--muted-dim); font-variant-numeric: tabular-nums; }
.room-trigger .rt-caret { color: var(--muted); font-size: 12px; transition: transform .16s; }
.room-trigger.open .rt-caret { transform: rotate(180deg); }

.room-dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60;
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--r);
  box-shadow: 0 12px 32px rgba(16,18,24,.16); overflow: hidden;
  display: flex; flex-direction: column; max-height: min(60vh, 440px);
}
.rd-list { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px; }
.rd-empty { padding: 16px; text-align: center; color: var(--muted-dim); font-size: 13.5px; }
.rd-floor { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-dim); font-weight: 700; padding: 10px 10px 5px; }
.rd-item { width: 100%; display: flex; align-items: center; gap: 10px; border: none; background: transparent; border-radius: 8px; padding: 10px 10px; cursor: pointer; color: var(--text); }
.rd-item:active { background: var(--panel); }
.rd-item.active { background: var(--accent-soft); }
.rd-item .rd-name { flex: 1; min-width: 0; text-align: left; font-size: 14.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-item.active .rd-name { font-weight: 700; }
.rd-item .rd-tot { font-family: var(--mono); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rd-foot { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); background: var(--panel); }
.rd-foot-btn { flex: 1; border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; padding: 10px; font-size: 13.5px; font-weight: 600; color: var(--text); cursor: pointer; }
.rd-foot-btn:active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* manage rooms page */
.mg-sort { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 20px; }
.mg-sort-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-right: 2px; }
.mg-sort-btn { border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.mg-sort-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.mg-hint { font-size: 12.5px; color: var(--muted); margin: -10px 0 16px; }
.mg-drag { flex: none; width: 28px; height: 34px; border: none; background: transparent; color: var(--muted-dim); font-size: 17px; line-height: 1; cursor: grab; touch-action: none; padding: 0; }
.mg-drag:active { cursor: grabbing; color: var(--text); }
.mg-room.dragging { opacity: .9; background: var(--accent-soft); border-radius: 10px; border-bottom-color: transparent; box-shadow: 0 8px 22px rgba(16,18,24,.18); }
.mg-floor { margin-bottom: 22px; }
.mg-data { margin-top: 28px; padding-top: 6px; border-top: 1px solid var(--line); }
.mg-data-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 4px; }
.mg-data-actions .btn { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.mg-floor-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 10px; }
.mg-floor-head span:first-child { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.mg-count { font-family: var(--mono); font-size: 11px; color: var(--muted-dim); }
.mg-room { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--panel-2); }
.mg-names { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.mg-nl { display: flex; align-items: center; gap: 6px; }
.mg-lang { flex: none; width: 30px; font-size: 10px; font-weight: 700; color: var(--muted-dim); text-transform: uppercase; text-align: right; }
.mg-name { flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 8px; padding: 8px 8px; font-size: 15px; font-weight: 550; background: var(--panel); color: var(--text); }
.mg-name:focus { outline: none; border-color: var(--accent); background: #fff; }
.mg-floor-sel { flex: none; border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 6px; font-size: 12.5px; background: #fff; color: var(--text); }
.mg-tot { flex: none; font-family: var(--mono); font-size: 11px; color: var(--muted-dim); min-width: 44px; text-align: right; }
.mg-dup { flex: none; width: 32px; height: 32px; border: none; background: var(--panel); border-radius: 8px; color: var(--muted); font-size: 15px; cursor: pointer; }
.mg-dup:active { background: var(--accent); color: #fff; }
.mg-del { flex: none; width: 32px; height: 32px; border: none; background: var(--panel); border-radius: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.mg-del:active { background: var(--danger); color: #fff; }
.mg-addbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.mg-addbar-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.mg-addbtn { border: 1px dashed var(--line-strong); background: #fff; border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.mg-addbtn:active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* report floor heading */
.rep-floor { font-size: 15px; font-weight: 700; color: var(--accent); margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 2px solid var(--line-strong); }

/* report switch wiring legend */
.sw-legend { margin: 8px 0 4px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); }
.sw-legend-title { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--c-switch); font-weight: 700; margin-bottom: 6px; }
.sw-item { font-size: 13px; margin-bottom: 6px; }
.sw-item .sw-block { font-weight: 650; }
.sw-buttons { list-style: none; margin: 4px 0 0; padding: 0 0 0 4px; }
.sw-buttons li { font-size: 13px; padding: 2px 0; }
.sw-buttons .sw-btn-n { display: inline-block; min-width: 62px; color: var(--muted); font-size: 11.5px; font-weight: 600; }

/* segmented tab control (iOS-style, robust, no offsets) */
.seg { display: flex; gap: 3px; background: var(--track); border-radius: 11px; padding: 3px; }
.seg-btn {
  flex: 1; border: none; background: transparent; color: var(--muted);
  border-radius: 8px; padding: 8px 6px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg-btn.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

main { padding-top: 16px; display: flex; flex-direction: column; gap: 14px; }

/* ---------------- count cards ---------------- */
.card { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 9px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.card-title { font-size: 14px; font-weight: 650; }
.card-sub { margin-left: auto; font-family: var(--mono); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-sub b { color: var(--text); }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--panel-2); }
.row:first-child { border-top: none; }
.row-label { flex: 1; min-width: 0; font-size: 14.5px; }
.row-label small { display: block; color: var(--muted-dim); font-size: 11.5px; margin-top: 1px; }
.sw { display: inline-block; width: 13px; height: 13px; border-radius: 4px; margin-right: 7px; vertical-align: -2px; border: 1px solid rgba(0,0,0,.18); }
.sw.white { background: #f3f2ee; } .sw.gray { background: #99a1a8; }
.row.has .row-label { font-weight: 600; }

/* ---------------- build tab: blocks ---------------- */
.blocks { display: flex; flex-direction: column; gap: 14px; }
.blk-drag { flex: none; width: 26px; height: 34px; border: none; background: transparent; color: var(--muted-dim); font-size: 16px; line-height: 1; cursor: grab; touch-action: none; padding: 0; }
.blk-drag:active { cursor: grabbing; color: var(--text); }
.block-card.dragging { opacity: .92; box-shadow: 0 10px 26px rgba(16,18,24,.20); border-color: var(--accent); }
.block-card { border: 1px solid var(--line); border-radius: var(--r); background: #fff; box-shadow: var(--shadow); padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.block-head { display: flex; align-items: center; gap: 10px; }
.blk-color { flex: none; width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.blk-label { flex: 1; min-width: 0; border: none; border-bottom: 1px dashed transparent; background: transparent; font-size: 15px; font-weight: 600; padding: 4px 2px; color: var(--text); }
.blk-label:focus { outline: none; border-bottom-color: var(--accent); }
.blk-label::placeholder { color: var(--muted-dim); font-weight: 500; }
.blk-del { flex: none; width: 32px; height: 32px; border: none; background: var(--panel); border-radius: var(--r-sm); color: var(--muted); font-size: 14px; cursor: pointer; }
.blk-del:active { background: var(--danger); color: #fff; }
.block-ctl { display: flex; align-items: center; gap: 16px; }
.blk-pcs { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mini { display: inline-flex; align-items: center; gap: 8px; }
.mini-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.mini-btn { width: 30px; height: 30px; border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; font-size: 18px; line-height: 1; color: var(--text); cursor: pointer; }
.mini-btn:active { background: var(--accent); border-color: var(--accent); color: #fff; }
.mini-num { min-width: 18px; text-align: center; font-family: var(--mono); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slot { flex: 0 0 auto; width: 66px; height: 56px; border: 1.5px solid var(--line-strong); border-radius: 10px; background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; padding: 2px; }
.slot.filled { background: #fff; }
.slot .slot-dev { font-size: 11.5px; font-weight: 700; line-height: 1.1; text-align: center; }
.slot .slot-var { font-size: 10px; color: var(--muted); }
.slot .slot-plus { font-size: 22px; color: var(--muted-dim); line-height: 1; }
.slot .slot-note { position: absolute; top: 3px; right: 5px; font-size: 10px; color: var(--c-switch); }
.slot { position: relative; }
.slot:active { transform: scale(.96); }
/* pan-y keeps vertical page scrolling while sideways drags rearrange the slot */
.slot { touch-action: pan-y; cursor: grab; }
.slot.dragging { cursor: grabbing; opacity: .95; transform: scale(1.04); border-style: dashed; box-shadow: 0 8px 20px rgba(16,18,24,.22); z-index: 2; }
.blk-sort { margin-bottom: 12px; }

/* switch per-button note editor (in the slot picker) */
.switch-notes { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; display: flex; flex-direction: column; gap: 10px; }
.sn-title { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.sn-row { display: flex; align-items: center; gap: 10px; }
.sn-num { flex: none; width: 66px; font-size: 12.5px; font-weight: 600; color: var(--c-switch); }
.sn-row input { flex: 1; min-width: 0; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 9px 11px; background: #fff; color: var(--text); }
.sn-row input:focus { outline: none; border-color: var(--accent); }

.add-block { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 4px 2px 2px; }
.add-block-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.size-btn { width: 38px; height: 38px; border: 1px dashed var(--line-strong); background: #fff; border-radius: var(--r-sm); font-size: 15px; font-weight: 700; color: var(--text); cursor: pointer; font-variant-numeric: tabular-nums; }
.size-btn:active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* slot device picker */
.slot-options { display: flex; flex-direction: column; gap: 12px; }
.dev-group { display: flex; flex-direction: column; gap: 7px; }
.dev-name { display: flex; align-items: center; gap: 7px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.dev-variants { display: flex; flex-wrap: wrap; gap: 7px; }
.dev-opt { border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 9px 14px; font-size: 14px; font-weight: 550; color: var(--text); cursor: pointer; }
.dev-opt.sel { background: var(--accent); border-color: var(--accent); color: #fff; }

/* room default colour bar */
.color-bar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; box-shadow: var(--shadow); }
.cb-label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.color-pick { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 6px 12px 6px 8px; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; }
.color-pick .caret { color: var(--muted-dim); font-size: 11px; }

/* colour swatch */
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.22); box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
.swatch.sm { width: 13px; height: 13px; vertical-align: -2px; margin-right: 6px; }
.swatch.lg { width: 30px; height: 30px; }

/* per-element colour button (next to the counter) */
.row-color { flex: none; width: 38px; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.row-color:active { background: var(--panel); }

/* colour picker grid */
.color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.color-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; padding: 12px 6px; cursor: pointer; }
.color-opt .cname { font-size: 12px; color: var(--muted); }
.color-opt.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.color-opt.sel .cname { color: var(--text); font-weight: 600; }

/* stepper */
.stepper { display: flex; align-items: center; flex: none; }
.stepper button {
  width: 40px; height: 40px; flex: none; border: 1px solid var(--line-strong); background: #fff;
  color: var(--text); font-size: 21px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}
.stepper button:active { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper .minus { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.stepper .plus { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.stepper input {
  width: 48px; height: 40px; text-align: center; border: 1px solid var(--line-strong); border-left: none; border-right: none;
  background: #fff; color: var(--text); font-family: var(--mono); font-size: 16px; font-weight: 600;
  font-variant-numeric: tabular-nums; padding: 0; -moz-appearance: textfield;
}
.stepper input:focus { outline: none; background: var(--panel); }

/* ---------------- plan tab ---------------- */
.plan-empty { text-align: center; padding: 40px 18px; border: 1px dashed var(--line-strong); border-radius: var(--r); color: var(--muted); }
.plan-empty p { margin: 0 0 16px; }
.plan-palette { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.ptype { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 550; cursor: pointer; color: var(--text); }
.ptype .pdot { width: 10px; height: 10px; border-radius: 50%; }
.ptype.active { color: #fff; border-color: transparent; }
.plan-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
.plan-stage { position: relative; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--panel); line-height: 0; touch-action: manipulation; }
.plan-stage img { width: 100%; height: auto; display: block; }
.plan-stage.placing { cursor: crosshair; }
.pin { position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: pointer; }
.pin::after { content: ""; position: absolute; inset: 6px; background: #fff; border-radius: 50%; opacity: .85; }
.plan-toolbar { display: flex; gap: 16px; margin-top: 12px; }
.plan-toolbar button, .plan-toolbar .filebtn { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.plan-toolbar button:hover { color: var(--text); }
.tally { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.tally .t { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-family: var(--mono); }
.tally .t .pdot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------------- notes & photos ---------------- */
.block-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 2px 0 10px; font-weight: 600; }
.note-add { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.note-add textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; font-size: 15px; resize: vertical; min-height: 66px; background: var(--panel); color: var(--text); }
.note-add textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
.note { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 13px; margin-bottom: 8px; background: #fff; }
.note p { margin: 0; white-space: pre-wrap; font-size: 14.5px; }
.note .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; }
.note .meta time { font-family: var(--mono); font-size: 11px; color: var(--muted-dim); }
.note .meta button { background: none; border: none; color: var(--danger); font-size: 12px; cursor: pointer; padding: 0; }
.empty-line { color: var(--muted-dim); font-size: 13.5px; padding: 4px 2px 14px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.photo-grid figure { position: relative; margin: 0; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.photo-grid .del { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; }
.photo-grid figcaption { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.62)); color: #fff; font-size: 10.5px; padding: 14px 6px 4px; }

/* file button */
.filebtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.filebtn input { display: none; }

/* ---------------- buttons ---------------- */
.btn { border: 1px solid var(--line-strong); background: #fff; color: var(--text); border-radius: var(--r-sm); padding: 12px 16px; font-size: 14.5px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: var(--panel); }
.btn.danger { color: var(--danger); }
.btn.full { width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: var(--r-sm); border: 1px solid var(--line); background: #fff; color: var(--text); font-size: 22px; line-height: 1; cursor: pointer; }

/* ---------------- bottom bar ---------------- */
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--bg); border-top: 1px solid var(--line); }
.bottombar-in { display: flex; align-items: center; gap: 14px; padding-top: 11px; padding-bottom: calc(11px + env(safe-area-inset-bottom)); }
.grand { display: flex; flex-direction: column; }
.grand-label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-dim); }
.grand-num { font-family: var(--mono); font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.bar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bar-actions .btn { padding: 12px 18px; }

/* ---------------- report sheet ---------------- */
.sheet { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-head { position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 14px 16px; max-width: var(--maxw); margin: 0 auto; }
.sheet-head h2 { font-size: 18px; }
.sheet-head .icon-btn { margin-left: auto; }
.sheet-body { padding-top: 18px; padding-bottom: 48px; }
.rep-topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.rep-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.lang-toggle { display: flex; gap: 3px; background: var(--track); border-radius: 9px; padding: 3px; flex: none; }
.lang-toggle button { border: none; background: transparent; color: var(--muted); border-radius: 6px; padding: 6px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.lang-toggle button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.rep-title { font-size: 22px; font-weight: 700; }
.rep-date { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.rep-hero { display: flex; align-items: center; gap: 16px; border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 14px 0 22px; background: var(--panel); }
.rep-hero .big { font-family: var(--mono); font-size: 40px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.rep-hero .meta { font-size: 13px; color: var(--muted); }
.rep-hero .meta b { color: var(--text); }
.rep-sec { margin-top: 24px; }
.rep-sec h3 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--panel-2); }
th { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-dim); font-weight: 600; }
td.q, th.q { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.q { font-weight: 600; }
.rep-total > h3 { color: var(--accent); border-bottom-width: 2px; border-bottom-color: var(--line-strong); }
tr.grand-row td { border-top: 2px solid var(--accent); font-weight: 800; font-size: 14px; padding-top: 10px; }
tr.grand-row td.q { font-size: 15px; }
tr.cat-head td { background: var(--panel); font-weight: 700; font-size: 13px; padding-top: 10px; padding-bottom: 10px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
tr.cat-head td.q { color: var(--text); }
tr.v-row td:first-child { padding-left: 18px; color: var(--text); }
.room-block { margin-bottom: 16px; }
.room-block h4 { margin-bottom: 2px; font-size: 15px; }
.room-block .rt { font-family: var(--mono); font-size: 11px; color: var(--muted-dim); font-weight: 400; }
.rep-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.rep-actions .btn { display: flex; align-items: center; justify-content: center; }
.rep-actions .span2 { grid-column: 1 / -1; }
.empty { text-align: center; color: var(--muted-dim); padding: 48px 16px; }

/* ---------------- modals ---------------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.modal-card { background: #fff; width: 100%; max-width: var(--maxw); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.modal-card h3 { margin-bottom: 4px; font-size: 16px; }
.pin-types { display: flex; flex-wrap: wrap; gap: 7px; }
#markerLabel { width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 12px; background: var(--panel); color: var(--text); }
#markerLabel:focus { outline: none; border-color: var(--accent); background: #fff; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; }
.viewer-close { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px; background: rgba(255,255,255,.16); border: none; color: #fff; }

.toast { position: fixed; left: 50%; bottom: 104px; transform: translateX(-50%) translateY(16px); background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; padding: 10px 18px; border-radius: 999px; z-index: 70; opacity: 0; transition: .22s; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

[hidden] { display: none !important; }

@media (min-width: 560px) { .photo-grid { grid-template-columns: repeat(4, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media print {
  .appbar, main, .bottombar, .sheet-head, .rep-actions, .lang-toggle, .modal, .viewer, .toast { display: none !important; }
  body { padding: 0; }
  .sheet { position: static; overflow: visible; }
  .sheet-body { padding: 0; max-width: none; }
  .rep-hero { background: #f4f4f4; }
  td, th, .rep-title, .rep-sec h3 { color: #000 !important; }
}
