:root {
  --bg: #f5f8fb;
  --surface: #fff;
  --soft: #f8fbfd;
  --text: #0c1825;
  --muted: #637386;
  --line: #dce7ef;
  --navy: #082b4c;
  --navy2: #123f66;
  --teal: #0f9f9a;
  --green: #14835f;
  --green-bg: #e8f7f0;
  --red: #c43e4b;
  --red-bg: #fff0f2;
  --amber: #ad741c;
  --amber-bg: #fff5dd;
  --shadow: 0 16px 34px rgba(8, 43, 76, .09);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; min-width: 0; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #fbfdff, var(--bg));
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

html,
body,
#app,
.app-shell {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

button, input, textarea, select { font: inherit; }
button { border: 0; cursor: pointer; }
input, textarea, select {
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}
textarea { min-height: 94px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: rgba(15, 159, 154, .75);
  box-shadow: 0 0 0 4px rgba(15, 159, 154, .12);
}
label { display: grid; gap: 7px; color: var(--muted); font-size: .88rem; font-weight: 850; }
h1, h2, h3 { margin: 0; line-height: 1.12; letter-spacing: 0; }
p { margin: 0; }

.app-shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 14px calc(92px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
.boot-screen { min-height: 45dvh; display: grid; place-items: center; align-content: center; gap: 10px; text-align: center; color: var(--muted); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand h1 { font-size: clamp(1.16rem, 5vw, 1.8rem); }
.brand p, .muted { color: var(--muted); margin-top: 3px; }
.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--navy), var(--teal));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 950;
  box-shadow: 0 12px 24px rgba(8, 43, 76, .22);
  flex: 0 0 auto;
  overflow: hidden;
}
.logo-mark img { width: 100%; height: 100%; object-fit: cover; }

.hero {
  border-radius: 24px;
  background: linear-gradient(135deg, var(--navy), #10496f 55%, #0c8985);
  color: #fff;
  padding: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero h2 { font-size: clamp(1.5rem, 8vw, 3rem); margin-bottom: 8px; }
.hero p { color: rgba(255, 255, 255, .84); }
.card {
  background: var(--surface);
  border: 1px solid rgba(220, 231, 239, .92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 100%;
  overflow: hidden;
}
.panel { padding: 16px; }
.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; }
.stat { padding: 15px; min-height: 106px; display: flex; flex-direction: column; justify-content: space-between; }
.stat small { color: var(--muted); font-weight: 850; }
.stat strong { font-size: 1.72rem; line-height: 1; }
.progress { height: 10px; border-radius: 999px; overflow: hidden; background: #e7eff5; margin-top: 12px; }
.hero .progress { background: rgba(255, 255, 255, .2); }
.bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), #fff); border-radius: inherit; transition: .25s; }
.card .bar { background: linear-gradient(90deg, var(--teal), var(--navy2)); }

.actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }
.btn {
  min-height: 48px;
  border-radius: 14px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 950;
  color: var(--navy);
  background: #eaf2f7;
  border: 1px solid #d7e5ee;
  text-decoration: none;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
}
.btn:active { transform: scale(.985); }
.btn.primary { color: #fff; background: linear-gradient(135deg, var(--navy), var(--navy2)); border-color: transparent; }
.btn.teal { color: #fff; background: linear-gradient(135deg, var(--teal), #0b8782); border-color: transparent; }
.btn.danger { color: var(--red); background: var(--red-bg); border-color: #ffd2d8; }
.btn.ghost { background: #fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 22px 0 12px; }
.form-grid { display: grid; gap: 12px; }
.notice { background: #eef8f8; color: #0b615e; border: 1px solid #cdeceb; border-radius: 16px; padding: 12px; font-weight: 760; font-size: .9rem; }
.warning { background: var(--amber-bg); color: var(--amber); border-color: #ffe0a6; }

.chips, .tags { display: flex; gap: 8px; overflow-x: auto; max-width: 100%; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar, .tags::-webkit-scrollbar { display: none; }
.chip, .tag {
  min-height: 42px;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--line);
  font-weight: 950;
  white-space: normal;
  overflow-wrap: anywhere;
}
.chip.active, .tag.active { color: #fff; background: var(--navy); border-color: var(--navy); }
.toolbar { display: grid; gap: 10px; margin: 12px 0; }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: .78rem;
  font-weight: 950;
  white-space: nowrap;
}
.pending { color: var(--amber); background: var(--amber-bg); }
.completed { color: var(--green); background: var(--green-bg); }
.defects { color: var(--red); background: var(--red-bg); }
.floor, .role { color: var(--navy); background: #eef5fa; }

.list { display: grid; gap: 11px; }
.row { display: grid; gap: 10px; padding: 13px; background: var(--soft); border: 1px solid var(--line); border-radius: 15px; margin-bottom: 10px; }
.floor-group { display: grid; gap: 11px; margin: 16px 0; }
.floor-title {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(245, 248, 251, .94);
  backdrop-filter: blur(12px);
  padding: 9px 2px;
}
.room-grid { display: grid; gap: 12px; }
.room-card { padding: 14px; display: grid; gap: 11px; }
.room-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.room-no { font-size: 1.18rem; font-weight: 950; }
.meta { color: var(--muted); font-size: .9rem; }

.sticky-inspect {
  position: sticky;
  top: 0;
  z-index: 15;
  margin: 0 -14px 12px;
  padding: 10px 14px;
  background: rgba(245, 248, 251, .96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(220, 231, 239, .8);
}
.check-section { padding: 15px; display: grid; gap: 13px; margin-bottom: 13px; width: 100%; overflow: hidden; }
.check-item { padding: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 16px; display: grid; gap: 10px; width: 100%; overflow: hidden; }
.check-title { font-weight: 950; }
.seg { display: grid; grid-template-columns: 1fr; gap: 8px; }
.seg button {
  min-height: 48px;
  border-radius: 13px;
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--line);
  font-weight: 950;
  width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  padding: 10px 8px;
}
.seg button.active.ok { background: var(--green); color: #fff; border-color: var(--green); }
.seg button.active.defect { background: var(--red); color: #fff; border-color: var(--red); }
.seg button.active.na { background: #5f6f82; color: #fff; border-color: #5f6f82; }
.defect-fields { display: none; gap: 10px; width: 100%; overflow: hidden; }
.defect-fields.show { display: grid; }
.defect-fields > * { max-width: 100%; }
.check-item .tags { flex-wrap: wrap; overflow-x: visible; }
.check-item .tag { flex: 1 1 auto; line-height: 1.15; }
.photo-preview { display: grid; gap: 8px; }
.photo-preview img, .thumb {
  width: 100%;
  max-width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #edf3f7;
}
.thumb { width: 84px; height: 84px; }

.bottom-actions {
  position: sticky;
  bottom: 0;
  z-index: 25;
  margin: 18px -14px calc(-92px - env(safe-area-inset-bottom));
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  background: rgba(245, 248, 251, .97);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(220, 231, 239, .9);
  display: grid;
  gap: 9px;
}
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 8px max(10px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(15px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
.bottom-nav button { min-height: 46px; border-radius: 13px; background: #eef5fa; color: var(--navy); font-weight: 900; }
.bottom-nav button.active { color: #fff; background: var(--navy); }
.signature-pad { width: 100%; height: 190px; border: 1px dashed #b7c9d7; border-radius: 16px; background: #fff; touch-action: none; }
.signature-preview { max-width: 100%; max-height: 130px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; margin-top: 10px; max-width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 980px; font-size: .84rem; }
th, td { padding: 10px 9px; border-bottom: 1px solid #edf2f6; text-align: left; vertical-align: top; }
th { background: #f3f8fb; color: var(--navy); text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; }
.mobile-report-card { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; margin: 10px 0; background: #fff; overflow: hidden; }
.mark-ok { color: var(--green); font-weight: 950; }
.mark-defect { color: var(--red); font-weight: 950; }
.mark-na { color: #687686; font-weight: 950; }
.asset-preview { width: 72px; height: 72px; border-radius: 16px; border: 1px solid var(--line); background: #eef5fa; display: grid; place-items: center; overflow: hidden; font-weight: 950; color: var(--navy); }
.asset-preview img { width: 100%; height: 100%; object-fit: cover; }
.asset-preview.splash { width: 100%; height: 170px; border-radius: 18px; }
.empty { padding: 24px 14px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; background: rgba(255, 255, 255, .68); }
.hide { display: none !important; }
.toast {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(76px, env(safe-area-inset-bottom));
  z-index: 80;
  transform: translateY(130%);
  opacity: 0;
  transition: .2s;
  background: var(--navy);
  color: #fff;
  border-radius: 15px;
  padding: 13px 15px;
  box-shadow: 0 18px 36px rgba(8, 43, 76, .28);
  font-weight: 850;
}
.toast.show { opacity: 1; transform: none; }

@media (min-width: 900px) {
  .app-shell { padding: 26px 22px 96px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .actions { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 280px 1fr; align-items: center; }
  .room-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .row { grid-template-columns: 1.2fr 1fr auto auto; align-items: end; }
  .seg { grid-template-columns: repeat(3, 1fr); }
  .defect-fields { grid-template-columns: 1fr 180px; }
  .defect-fields .wide { grid-column: 1 / -1; }
  .check-item .tags { flex-wrap: nowrap; overflow-x: auto; }
  .check-item .tag { flex: 0 0 auto; white-space: nowrap; }
  .bottom-actions { grid-template-columns: repeat(6, 1fr); margin-left: 0; margin-right: 0; border-radius: 18px 18px 0 0; }
  .bottom-nav { left: 50%; transform: translateX(-50%); max-width: 760px; border-radius: 20px 20px 0 0; }
}

@media (max-width: 560px) {
  .desktop-table { display: none; }
  .mobile-report { display: block; }
}
@media (min-width: 561px) {
  .mobile-report { display: none; }
}

@media print {
  body { background: #fff; padding: 0; }
  .topbar, .no-print, .bottom-actions, .bottom-nav, .section-head .btn { display: none !important; }
  .app-shell { max-width: none; padding: 0; }
  .card { box-shadow: none; }
  .report { border: 0; box-shadow: none; border-radius: 0; }
  .report-cover { background: #fff !important; color: var(--text) !important; border-bottom: 2px solid var(--navy); }
  table { min-width: 0; font-size: 8px; }
  th, td { padding: 4px; }
  .desktop-table { display: block !important; }
  .mobile-report { display: none !important; }
  @page { size: landscape; margin: 10mm; }
}
