/* ==========================================================================
   Flat Handover Pro — styles
   ========================================================================== */
:root {
  --bg: #f4f4f1;
  --bg-soft: #ecebe6;
  --card: #ffffff;
  --card-2: #fafaf8;
  --ink: #1b2320;
  --ink-2: #3d4843;
  --muted: #717b75;
  --line: #dcded8;
  --line-soft: #e9eae5;
  --brand: #0f766e;
  --brand-2: #115e58;
  --brand-soft: #e3f1ee;
  --brand-ink: #0b4f4a;
  --accent: #b45309;
  --accent-soft: #fdf1e0;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warn: #a16207;
  --warn-soft: #fef6e0;
  --ok: #157347;
  --ok-soft: #e6f4ec;
  --info: #1d4ed8;
  --info-soft: #e9eefc;
  --sev-critical: #b42318;
  --sev-major: #b45309;
  --sev-minor: #5b6b62;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(18, 32, 27, .06), 0 6px 18px -8px rgba(18, 32, 27, .12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 30, 25, .35), 0 2px 6px rgba(15, 30, 25, .08);
  --sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sidebar-w: 248px;
  --topbar-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --bg-soft: #181d1a;
    --card: #1b211e;
    --card-2: #202723;
    --ink: #e9eeeb;
    --ink-2: #c3ccc7;
    --muted: #93a09a;
    --line: #303a35;
    --line-soft: #27302b;
    --brand: #4fd1c5;
    --brand-2: #7ee0d5;
    --brand-soft: #14312e;
    --brand-ink: #b4f0e8;
    --accent: #f0a04b;
    --accent-soft: #3a2a18;
    --danger: #ff8b80;
    --danger-soft: #3a1f1d;
    --warn: #e9c46a;
    --warn-soft: #352d18;
    --ok: #7bd6a0;
    --ok-soft: #16301f;
    --info: #9db8ff;
    --info-soft: #1d2742;
    --sev-critical: #ff8b80;
    --sev-major: #f0a04b;
    --sev-minor: #9aa8a1;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .8), 0 2px 8px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ul, ol { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }

/* ---------- App frame ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h); display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #12867c, #0b5c56);
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .04em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 2px 6px rgba(11, 92, 86, .3);
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-txt strong { font-size: 14.5px; letter-spacing: -.01em; white-space: nowrap; }
.brand-txt span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.save-state { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.save-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 16%, transparent); transition: .3s; }
.save-state.dirty .dot { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
.save-state.error .dot { background: var(--danger); }
.menu-btn { display: none; }

.shell { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px 18px;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; color: var(--muted); }
.nav-item:hover { background: color-mix(in srgb, var(--card) 70%, transparent); text-decoration: none; }
.nav-item.active { background: var(--card); color: var(--brand-ink); border-color: var(--line); box-shadow: var(--shadow); font-weight: 600; }
.nav-item.active svg { color: var(--brand); }
.nav-count {
  margin-left: auto; font-style: normal; font-size: 11px; font-weight: 600;
  min-width: 20px; padding: 1px 6px; border-radius: 99px; text-align: center;
  background: var(--accent-soft); color: var(--accent);
}
.nav-count.zero { background: var(--line-soft); color: var(--muted); }

.side-card {
  padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); box-shadow: var(--shadow);
}
.side-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); }
.side-card-head b { font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.progress { height: 7px; border-radius: 99px; background: var(--line-soft); overflow: hidden; margin: 9px 0 8px; }
.progress i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #12867c, #2aa398); transition: width .5s ease; }
.side-meta { font-size: 11px; color: var(--muted); line-height: 1.45; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.mini-field { display: flex; flex-direction: column; gap: 4px; }
.mini-field label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.mini-field select { padding: 6px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); font-size: 12.5px; }
.privacy { display: flex; gap: 7px; font-size: 10.5px; color: var(--muted); line-height: 1.5; align-items: flex-start; }
.privacy svg { width: 14px; height: 14px; margin-top: 1px; }

.main { flex: 1; min-width: 0; padding: 26px 30px 70px; }
.view { max-width: 1180px; margin: 0 auto; animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 23px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.page-sub { margin-top: 5px; color: var(--muted); font-size: 13px; max-width: 70ch; }
.page-sub b { color: var(--ink-2); font-weight: 600; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.eyebrow { font-size: 10.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }

/* ---------- Buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 8px 13px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 13px; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--card-2); border-color: color-mix(in srgb, var(--line) 60%, var(--muted)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(15,118,110,.35); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.btn-sm svg { width: 13px; height: 13px; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border: 1px solid transparent; background: transparent; border-radius: 8px; cursor: pointer;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--line-soft); }
.icon-btn svg { width: 17px; height: 17px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: 11.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.field .hint { font-size: 11px; color: var(--muted); }
.req { color: var(--danger); }
input[type="text"], input[type="date"], input[type="email"], input[type="tel"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
input[type="date"] { font-variant-numeric: tabular-nums; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); width: 15px; height: 15px; cursor: pointer; }
input[type="file"] { font-size: 12px; }

/* ---------- Cards & layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { font-size: 13.5px; font-weight: 650; letter-spacing: -.005em; }
.card-head .sub { font-size: 11.5px; color: var(--muted); }
.card-body { padding: 16px 18px; }
.grid { display: grid; gap: 14px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- KPIs ---------- */
.kpi { padding: 15px 16px 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--k, var(--brand)); opacity: .8; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 550; letter-spacing: .01em; }
.kpi-ico { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--kbg, var(--brand-soft)); color: var(--k, var(--brand)); }
.kpi-ico svg { width: 14px; height: 14px; }
.kpi-val { font-size: 27px; font-weight: 700; letter-spacing: -.03em; margin-top: 7px; font-variant-numeric: tabular-nums; line-height: 1; }
.kpi-val small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.kpi-foot { margin-top: 6px; font-size: 11px; color: var(--muted); }
.kpi-foot b { color: var(--ink-2); font-weight: 600; }

/* ---------- Stats / bars ---------- */
.stat-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 12.5px; }
.stat-row + .stat-row { border-top: 1px dashed var(--line-soft); }
.stat-name { flex: 0 0 138px; color: var(--ink-2); font-size: 12px; line-height: 1.35; }
.stat-track { flex: 1; height: 8px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.stat-track i { display: block; height: 100%; border-radius: 99px; background: var(--bc, var(--brand)); }
.stat-num { width: 30px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }
.stat-num small { color: var(--muted); font-weight: 400; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 650; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 99px; white-space: nowrap;
  background: var(--line-soft); color: var(--ink-2);
  border: 1px solid transparent;
}
.badge.sev-critical { background: var(--danger-soft); color: var(--sev-critical); }
.badge.sev-major { background: var(--warn-soft); color: var(--sev-major); }
.badge.sev-minor { background: var(--line-soft); color: var(--sev-minor); }
.badge.st-open { background: var(--info-soft); color: var(--info); }
.badge.st-notified { background: var(--warn-soft); color: var(--warn); }
.badge.st-inprogress { background: var(--accent-soft); color: var(--accent); }
.badge.st-rectified { background: var(--ok-soft); color: var(--ok); }
.badge.st-reinspected { background: var(--brand-soft); color: var(--brand-ink); }
.badge.st-disputed { background: var(--danger-soft); color: var(--danger); }
.badge.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.dot-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ---------- Register table ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.search-wrap { position: relative; flex: 1 1 220px; min-width: 180px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.search-wrap input { padding-left: 33px; }
.toolbar select { width: auto; min-width: 110px; font-size: 12.5px; padding-top: 7px; padding-bottom: 7px; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--bg-soft); border: 1px solid var(--line); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 10px; font-size: 12px; font-weight: 550; color: var(--muted); border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.07); }

.table-scroll { overflow-x: auto; }
table.reg { width: 100%; border-collapse: collapse; font-size: 12.8px; }
table.reg th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; padding: 9px 12px; white-space: nowrap;
  background: var(--card-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1;
}
table.reg td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.reg tr:last-child td { border-bottom: 0; }
table.reg tbody tr { cursor: pointer; transition: background .12s; }
table.reg tbody tr:hover { background: color-mix(in srgb, var(--brand) 5%, transparent); }
table.reg tbody tr.selected { background: color-mix(in srgb, var(--brand) 9%, transparent); }
table.reg tr.closed td { color: var(--muted); }
table.reg tr.closed .def-title { color: var(--muted); }
.cell-id { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.cell-check { width: 34px; }
.cell-check input { margin-top: 2px; }
.def-title { font-weight: 550; color: var(--ink); line-height: 1.4; }
.def-meta { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.def-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line); }
.thumb-strip { display: flex; gap: 3px; margin-top: 6px; }
.thumb-strip img { width: 34px; height: 28px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.photo-count { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); }
.photo-count svg { width: 12px; height: 12px; }
.bulkbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 14px; background: var(--brand-soft); border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--brand-ink);
}
.bulkbar b { font-variant-numeric: tabular-nums; }
.empty { padding: 52px 24px; text-align: center; }
.empty .emoji { font-size: 30px; }
.empty h3 { margin: 10px 0 4px; font-size: 15px; }
.empty p { color: var(--muted); font-size: 12.5px; max-width: 46ch; margin: 0 auto 14px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }

/* ---------- Quick add ---------- */
.quickadd { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px; }
.quickadd-head { display: flex; align-items: center; gap: 9px; padding: 11px 15px; background: linear-gradient(180deg, var(--card-2), var(--card)); border-bottom: 1px solid var(--line-soft); }
.quickadd-head svg { width: 16px; height: 16px; color: var(--brand); }
.quickadd-head b { font-size: 12.5px; }
.quickadd-head span { font-size: 11.5px; color: var(--muted); }
.quickadd-body { padding: 13px 15px 15px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; align-items: start; }
.qa-room { grid-column: span 3; }
.qa-cat { grid-column: span 3; }
.qa-sev { grid-column: span 2; }
.qa-loc { grid-column: span 4; }
.qa-desc { grid-column: span 12; }
.qa-actions { grid-column: span 12; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.qa-suggest { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.chip {
  font-size: 11.5px; padding: 3px 9px; border-radius: 99px; cursor: pointer;
  border: 1px dashed color-mix(in srgb, var(--brand) 40%, var(--line));
  background: transparent; color: var(--brand-ink);
}
.chip:hover { background: var(--brand-soft); border-style: solid; }

/* ---------- View / detail ---------- */
.breadcrumb { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .sep { opacity: .5; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.detail-h1 { font-size: 19px; font-weight: 650; line-height: 1.35; letter-spacing: -.01em; margin: 4px 0 8px; }
.detail-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.detail-meta b { color: var(--ink-2); font-weight: 600; }
.notes-box { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; line-height: 1.55; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; color: var(--ink-2); }
.history { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0; }
.history li { position: relative; padding: 0 0 13px 19px; font-size: 12px; color: var(--ink-2); }
.history li::before { content: ""; position: absolute; left: 0; top: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.history li:not(:last-child)::after { content: ""; position: absolute; left: 3px; top: 15px; bottom: 1px; width: 1px; background: var(--line); }
.history time { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.status-set { display: flex; flex-wrap: wrap; gap: 5px; }
.status-set button { font-size: 11.5px; padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); cursor: pointer; color: var(--ink-2); }
.status-set button:hover { border-color: var(--brand); }
.status-set button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ---------- Photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.photo-tile { position: relative; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-soft); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo-tile .del { position: absolute; top: 4px; right: 4px; width: 21px; height: 21px; border-radius: 50%; border: 0; background: rgba(0,0,0,.62); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: .15s; }
.photo-tile .del svg { width: 12px; height: 12px; }
.photo-tile:hover .del { opacity: 1; }
.dropzone {
  border: 1.5px dashed var(--line); border-radius: 9px; padding: 15px; text-align: center; cursor: pointer;
  font-size: 12px; color: var(--muted); background: var(--card-2); transition: .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.dropzone b { display: block; color: var(--ink-2); font-size: 12.5px; margin-bottom: 2px; }
.dropzone svg { width: 20px; height: 20px; margin-bottom: 4px; }

/* ---------- Checklist ---------- */
.check-doc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.doc-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card-2); }
.doc-toolbar .grow { flex: 1; }
.doc-paper { padding: 34px 40px; max-width: 900px; margin: 0 auto; }
.doc-title { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.doc-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.doc-props { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 5px 24px; margin: 16px 0 4px; font-size: 12px; }
.doc-props div { display: flex; gap: 8px; border-bottom: 1px dotted var(--line); padding-bottom: 4px; }
.doc-props dt { color: var(--muted); flex: none; min-width: 96px; }
.doc-props dd { margin: 0; color: var(--ink-2); }
.doc-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.check-group { margin-top: 22px; break-inside: avoid; }
.check-group h4 { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.check-group h4 .count { font-weight: 500; color: var(--muted); font-size: 11.5px; margin-left: auto; }
.check-item { display: grid; grid-template-columns: 22px 1fr 96px; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); align-items: start; break-inside: avoid; }
.check-box { width: 15px; height: 15px; padding: 0; border: 1.5px solid var(--ink-2); border-radius: 3px; margin-top: 1px; background: transparent; cursor: pointer; transition: background .15s, border-color .15s; }
.check-box:hover { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.check-box.done { background: var(--ok); border-color: var(--ok); position: relative; }
.check-box.done::after { content: ""; position: absolute; left: 3px; top: 0; width: 3.5px; height: 7px; border: solid #fff; border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); }
.check-text { font-size: 12.5px; line-height: 1.45; }
.check-text .no { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-right: 6px; }
.check-text .loc { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.check-sign { font-size: 10.5px; color: var(--muted); text-align: right; }
.sign-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; margin-top: 30px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.sign-line { height: 30px; border-bottom: 1px solid var(--ink-2); margin-bottom: 5px; }
.doc-note { margin-top: 18px; font-size: 10.5px; color: var(--muted); line-height: 1.55; }

/* ---------- Letter ---------- */
.letter-layout { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.letter-form { display: flex; flex-direction: column; gap: 13px; }
.letter-paper {
  background: #fff; color: #161616; border-radius: 4px; box-shadow: var(--shadow-lg);
  padding: 42px 44px; font-family: "Times New Roman", Times, serif; font-size: 13.2px; line-height: 1.62;
  max-width: 820px; margin: 0 auto; min-height: 780px; overflow-wrap: break-word;
}
.letter-paper h1 { font-size: 15px; font-weight: 700; letter-spacing: .02em; text-transform: none; margin-bottom: 18px; }
.letter-paper .lh { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; font-size: 12px; margin-bottom: 22px; }
.letter-paper .lh .to strong { display: block; }
.letter-paper .to { line-height: 1.5; }
.letter-paper .to strong { display: block; }
.letter-paper p { margin: 0 0 11px; }
.letter-paper ol { margin: 0 0 12px; padding-left: 21px; }
.letter-paper li { margin-bottom: 7px; break-inside: avoid; }
.letter-paper .sig { margin-top: 30px; }
.letter-paper .sig .line { width: 220px; border-bottom: 1px solid #333; height: 34px; }
.letter-paper .foot { margin-top: 26px; padding-top: 8px; border-top: 1px solid #bbb; font-size: 10.5px; color: #555; }
.letter-paper .def-table { width: 100%; border-collapse: collapse; font-size: 11.4px; margin: 0 0 12px; }
.letter-paper .def-table th, .letter-paper .def-table td { border: 1px solid #b9b9b9; padding: 4px 6px; vertical-align: top; text-align: left; }
.letter-paper .def-table th { background: #f1f1ef; font-weight: 700; }
.letter-paper .def-table .c { text-align: center; white-space: nowrap; }
.letter-paper .wm { color: #666; }

/* ---------- Settings ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.help { font-size: 11.5px; color: var(--muted); line-height: 1.55; }
.divider { height: 1px; background: var(--line-soft); margin: 18px 0; }
.danger-zone { border: 1px solid color-mix(in srgb, var(--danger) 26%, var(--line)); border-radius: 10px; padding: 14px 16px; background: color-mix(in srgb, var(--danger-soft) 40%, var(--card)); }
.danger-zone h3 { font-size: 12.5px; color: var(--danger); margin-bottom: 4px; }
.danger-zone p { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }
.cat-editor { display: flex; flex-direction: column; gap: 6px; }
.cat-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.cat-row input { font-size: 12.5px; padding: 6px 9px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(12, 20, 17, .55); backdrop-filter: blur(3px); animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.modal-panel {
  position: relative; width: min(760px, 100%); max-height: min(92vh, 900px);
  display: flex; flex-direction: column;
  background: var(--card); border-radius: 14px; border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.2,.9,.3,1.2);
  overflow: hidden;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { font-size: 16.5px; font-weight: 680; letter-spacing: -.01em; }
.modal-head p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 20px; border-top: 1px solid var(--line-soft); background: var(--card-2); flex-wrap: wrap; }
.modal-actions { display: flex; gap: 8px; margin-left: auto; }
.modal-hint { font-size: 11px; color: var(--muted); }
.modal-body .form-grid { grid-template-columns: repeat(2, 1fr); }
.modal-body .full { grid-column: 1 / -1; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; background: rgba(5, 8, 7, .93); padding: 40px; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 6px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.lightbox-close { position: absolute; top: 16px; right: 16px; color: #fff; background: rgba(255,255,255,.1); }
.lightbox-close:hover { background: rgba(255,255,255,.2); }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 62px; border: 0; background: rgba(255,255,255,.09); color: #fff; font-size: 30px; border-radius: 9px; cursor: pointer; }
.lightbox-nav:hover { background: rgba(255,255,255,.2); }
.lightbox-nav.prev { left: 18px; }
.lightbox-nav.next { right: 18px; }
.lightbox-cap { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: rgba(255,255,255,.8); font-size: 12px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, 90vw); }
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); box-shadow: var(--shadow-lg); font-size: 12.5px;
  animation: slidein .22s ease;
}
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } }
.toast svg { width: 15px; height: 15px; margin-top: 1px; color: var(--brand); }
.toast.ok svg { color: var(--ok); }
.toast.warn svg { color: var(--warn); }
.toast.err svg { color: var(--danger); }
.toast .t-close { margin-left: auto; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }

/* ---------- Dropdown ---------- */
.menu-wrap { position: relative; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 240px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 5px; display: flex; flex-direction: column;
  animation: pop .14s ease;
}
.dropdown[hidden] { display: none; }
.dropdown button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 7px 9px; border: 0; background: transparent; border-radius: 6px;
  font-size: 12.5px; cursor: pointer; color: var(--ink-2);
}
.dropdown button:hover { background: var(--line-soft); color: var(--ink); }
.dropdown button svg { width: 15px; height: 15px; color: var(--muted); }
.dropdown hr { border: 0; border-top: 1px solid var(--line-soft); margin: 4px 2px; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.mt8 { margin-top: 8px; } .mt14 { margin-top: 14px; } .mt20 { margin-top: 20px; }
.flex1 { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.callout { display: flex; gap: 10px; padding: 11px 13px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-ink); font-size: 12px; line-height: 1.5; border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent); }
.callout svg { width: 16px; height: 16px; margin-top: 1px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.callout b { font-weight: 650; }

/* ---------- Responsive ---------- */
@media (max-width: 1120px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .detail-grid { grid-template-columns: 1fr; }
  .letter-layout { grid-template-columns: 1fr; }
  .qa-room, .qa-cat { grid-column: span 6; }
  .qa-sev, .qa-loc { grid-column: span 6; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 232px; }
  .main { padding: 20px 18px 70px; }
  .menu-btn { display: inline-grid; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 50; height: calc(100vh - var(--topbar-h));
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
    background: var(--card);
  }
  .sidebar.open { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(9,15,13,.4); z-index: 45; }
  .brand-txt span { display: none; }
  .save-state { display: none; }
  .g-3 { grid-template-columns: 1fr; }
  .g-2 { grid-template-columns: 1fr; }
  .doc-paper { padding: 22px 18px; }
  .letter-paper { padding: 28px 24px; }
  .form-grid, .modal-body .form-grid { grid-template-columns: 1fr; }
  table.reg th:nth-child(4), table.reg td:nth-child(4) { display: none; }
}
@media (max-width: 560px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .btn span { display: none; }
  .topbar .btn { padding: 8px 10px; }
  .page-title { font-size: 19px; }
  .kpi-val { font-size: 22px; }
  .toolbar select { flex: 1 1 40%; }
  .toolbar .search-wrap { flex: 1 1 100%; }
  .quickadd-head span { display: none; }
  .check-item { grid-template-columns: 20px 1fr; }
  .check-sign { display: none; }
  .doc-props { grid-template-columns: 1fr; }
  .sign-grid { grid-template-columns: 1fr; gap: 30px; }
  table.reg th:nth-child(7), table.reg td:nth-child(7) { display: none; }
  table.reg th, table.reg td { padding-left: 8px; padding-right: 8px; }
  table.reg { font-size: 12px; }
  .cell-id { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================ PRINT ============================ */
.print-root { display: none; }
@media print {
  @page {
    size: A4; margin: 12mm 12mm 14mm;
    @bottom-center { content: "Page " counter(page) " of " counter(pages); font: 7.5pt "Helvetica Neue", Arial, sans-serif; color: #777; }
  }
  html, body { background: #fff !important; color: #111 !important; }
  .no-print, .topbar, .sidebar, .toasts, .lightbox, .modal { display: none !important; }
  .shell, .app > .topbar, .no-print { display: none !important; }
  .main { padding: 0 !important; }
  .view { display: none !important; }
  .print-root { display: block !important; position: absolute; inset: 0 auto auto 0; width: 100%; }
  .print-root:empty { display: none !important; }
  .print-doc { position: static; }
  .print-doc { font-family: "Helvetica Neue", Arial, sans-serif; font-size: 9.6pt; line-height: 1.45; color: #111; }
  .print-doc h1 { font-size: 16pt; margin: 0 0 2mm; letter-spacing: -.01em; }
  .print-doc h2 { font-size: 11pt; margin: 6mm 0 2mm; padding-bottom: 1.2mm; border-bottom: 1.2pt solid #111; }
  .print-doc .p-sub { font-size: 8.6pt; color: #555; margin-bottom: 3mm; }
  .print-doc .p-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6mm 8mm; font-size: 8.6pt; margin: 3mm 0; }
  .print-doc .p-meta div { display: block; border-bottom: .3pt dotted #aaa; padding-bottom: .7mm; }
  .print-doc .p-meta span { display: block; color: #666; font-size: 7pt; text-transform: uppercase; letter-spacing: .04em; }
  .print-doc .p-meta b { font-weight: 600; }
  .print-doc .p-note { font-size: 7.6pt; color: #555; margin-top: 2mm; }
  .print-doc table { width: 100%; border-collapse: collapse; font-size: 8.4pt; }
  .print-doc thead { display: table-header-group; }
  .print-doc tr { break-inside: avoid; }
  .print-doc th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-doc th, .print-doc td { border: .5pt solid #777; padding: 1.1mm 1.6mm; text-align: left; vertical-align: top; }
  .print-doc td.c, .print-doc th.c { text-align: center; }
  .print-doc .box { display: inline-block; width: 3.4mm; height: 3.4mm; border: .7pt solid #333; border-radius: .6mm; vertical-align: -0.6mm; }
  .print-doc .box.done { background: #222 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-doc .p-group { break-inside: avoid; }
  .print-doc .p-kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1mm 8mm; font-size: 8.6pt; margin: 3mm 0; }
  .print-doc .p-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 10mm; margin-top: 12mm; font-size: 8pt; color: #444; }
  .print-doc .p-sign .line { border-bottom: .7pt solid #333; height: 9mm; margin-bottom: 1.5mm; }
  .print-doc .p-sign .lines { border-bottom: .7pt solid #333; height: 16mm; margin-bottom: 1.5mm; }
  .print-doc .p-group-row td { background: #f2f2ef !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 8.2pt; padding: 1.4mm 1.6mm; }
  .print-doc .p-decl { margin-top: 8mm; font-size: 8pt; line-height: 1.5; }
  .print-doc .p-letter { font-family: "Times New Roman", Times, serif; font-size: 9.1pt; line-height: 1.3; }
  .print-doc .p-letter h1 { font-family: "Times New Roman", Times, serif; font-size: 11.6pt; }
  .print-doc .p-letter p { margin: 0 0 1.7mm; }
  .print-doc .p-letter .addr { margin-bottom: 3mm; font-size: 9pt; }
  .print-doc .p-letter .lh { display: flex; justify-content: space-between; font-size: 8.8pt; margin-bottom: 3mm; }
  .print-doc .p-letter table { font-size: 7.3pt; line-height: 1.25; }
  .print-doc .p-letter th, .print-doc .p-letter td { padding: .45mm 1.1mm; }
  .print-doc .p-letter ol { padding-left: 5mm; }
  .print-doc .p-letter li { margin-bottom: 1.2mm; }
  .print-doc .p-letter p, .print-doc .p-letter li { orphans: 2; widows: 2; }
  .print-doc .p-photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2mm; }
  .print-doc .p-photo { border: .5pt solid #999; padding: 1mm; break-inside: avoid; }
  .print-doc .p-photo img { width: 100%; height: 34mm; object-fit: cover; display: block; }
  .print-doc .p-photo span { display: block; font-size: 7pt; color: #444; margin-top: .8mm; }
  .pagebreak { break-before: page; }
  .avoid-break { break-inside: avoid; }
  .print-doc .p-foot { display: flex; justify-content: space-between; margin-top: 5mm; padding-top: 1.5mm; border-top: .4pt solid #bbb; font-size: 7.4pt; color: #666; }
  .print-doc .p-small { font-size: 7.4pt; color: #444; }
  .print-doc .p-signoff h1 { margin-bottom: 1mm; }
  .print-doc .p-summary { width: 100%; margin-top: 4mm; font-size: 8.6pt; }
  .print-doc .p-sign-table { width: 100%; margin-top: 6mm; font-size: 8.6pt; }
  .print-doc .p-sign-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-doc .p-sign-table td { height: 9mm; vertical-align: top; }
  .print-doc .p-sign-table td:first-child { height: 16mm; }
  .print-doc .p-line { border-bottom: .5pt solid #999; height: 6mm; margin: 1mm 0 2.5mm; }
  .print-doc .p-line.tall { height: 12mm; }
  .print-doc .p-notes { margin-top: 7mm; font-size: 8.4pt; }
  .print-doc .p-notes .p-rule { border-bottom: .4pt solid #bbb; height: 7mm; }
  .print-doc .p-group-row td { background: #f2f2ef !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 8.2pt; padding: 1.4mm 1.6mm; }
  .print-doc .p-decl { margin-top: 4mm; font-size: 8.4pt; line-height: 1.5; color: #222; }
  .print-doc .sign-table { margin-top: 6mm; }
}

/* ---------- Inspection checklist ---------- */
.insp-row { display: grid; grid-template-columns: 20px 1fr auto; gap: 11px; align-items: start; padding: 9px 2px; border-bottom: 1px solid var(--line-soft); }
.insp-row:last-child { border-bottom: 0; }
.insp-row .insp-check { margin-top: 2px; }
.insp-title { font-size: 12.8px; line-height: 1.4; color: var(--ink-2); }
.insp-row.on .insp-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, var(--muted) 55%, transparent); }
.insp-loc { font-size: 11px; color: var(--muted); margin-top: 1px; }
.insp-add { opacity: 0; transition: opacity .12s; }
.insp-row:hover .insp-add, .insp-row:focus-within .insp-add { opacity: 1; }
@media (max-width: 640px) { .insp-add { opacity: 1; } }

/* ---------- Language switch ---------- */
.lang-switch { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--bg-soft); border: 1px solid var(--line); gap: 2px; }
.lang-switch button { border: 0; background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 650; padding: 4px 8px; border-radius: 6px; cursor: pointer; line-height: 1.2; }
.lang-switch button:hover { color: var(--ink); }
.lang-switch button.on { background: var(--card); color: var(--brand-ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
@media (max-width: 560px) { .lang-switch button { padding: 4px 6px; } }
