:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --panel: #ffffff;
  --ink: #18201c;
  --muted: #66736c;
  --line: #ddd8cd;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #157f3b;
  --soft: #eef5f2;
  --shadow: 0 12px 28px rgba(25, 32, 28, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.boot-screen,
.login-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.15;
}

.brand-subtitle,
.muted {
  color: var(--muted);
}

.brand-subtitle {
  margin: 3px 0 0;
  font-size: 0.93rem;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label,
.small-label {
  color: #39453f;
  font-size: 0.84rem;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 46px;
  padding: 11px 12px;
  outline: none;
}

.field textarea {
  min-height: 94px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.btn {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.btn.primary {
  background: var(--accent);
}

.btn.primary:hover {
  background: var(--accent-dark);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.icon {
  width: 44px;
  padding: 0;
  font-size: 1.1rem;
}

.btn.warn {
  background: #fff7ed;
  color: var(--warn);
  border: 1px solid #fed7aa;
}

.login-actions,
.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.login-actions .btn,
.stack .btn {
  width: 100%;
}

.notice {
  border-radius: 8px;
  border: 1px solid #bee3db;
  background: #effaf7;
  color: #164e46;
  padding: 12px;
  margin: 14px 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.notice.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.app-shell {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(247, 244, 238, 0.94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
}

.topbar-inner {
  max-width: 1060px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.main {
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 16px 14px 92px;
}

.dashboard-head {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.searchbar {
  display: block;
}

.searchbar input {
  min-width: 0;
}

.new-client-btn {
  width: 100%;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.client-list {
  display: grid;
  gap: 10px;
}

.client-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  display: grid;
  gap: 10px;
  text-align: left;
  color: inherit;
}

.client-card strong {
  font-size: 1rem;
}

.client-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--soft);
  color: #235149;
  font-size: 0.76rem;
  font-weight: 800;
}

.badge.ok {
  background: #dcfce7;
  color: var(--ok);
}

.badge.warn {
  background: #fff7ed;
  color: var(--warn);
}

.stepper {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
}

.stepper-inner {
  width: min(100%, 640px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.step-btn {
  min-height: 48px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  border: 1px solid transparent;
}

.step-btn.active {
  background: var(--accent);
  color: white;
}

.editor-head {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.editor-head h2,
.section-title {
  margin: 0;
  font-size: 1.18rem;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: 1fr;
}

.computed {
  display: grid;
  gap: 8px;
}

.computed-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.computed-row:last-child {
  border-bottom: 0;
}

.computed-row strong {
  text-align: right;
}

.qr-panel {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.qr-panel .muted {
  margin: 6px 0 0;
  font-size: 0.9rem;
}

.qr-preview {
  width: min(100%, 220px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  justify-self: center;
}

.room-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
}

.room-tab {
  flex: 0 0 auto;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
}

.room-tab.active {
  background: var(--ink);
  color: white;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.thumb {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f0eee8;
  position: relative;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb span {
  position: absolute;
  left: 6px;
  bottom: 6px;
  right: 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.58);
  color: white;
  font-size: 0.65rem;
  padding: 3px 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.anomaly-list {
  display: grid;
  gap: 10px;
}

.anomaly-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.anomaly-item p {
  margin: 0 0 8px;
}

.signature-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.signature-box canvas {
  width: 100%;
  height: 180px;
  display: block;
  touch-action: none;
  background: linear-gradient(#fff, #fff) padding-box,
    repeating-linear-gradient(0deg, transparent 0 35px, #f0eee8 35px 36px);
}

.signature-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(24, 32, 28, 0.42);
  display: grid;
  place-items: end center;
  padding: 14px;
}

.modal {
  width: min(100%, 520px);
  max-height: min(90svh, 740px);
  overflow: auto;
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.12rem;
}

.hidden {
  display: none !important;
}

.stack {
  display: grid;
  gap: 12px;
}

.split-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 720px) {
  .main {
    padding-top: 22px;
  }

  .dashboard-head {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .new-client-btn {
    width: auto;
    min-width: 160px;
  }

  .grid.two {
    grid-template-columns: repeat(2, 1fr);
  }

  .photo-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .split-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-backdrop {
    place-items: center;
  }
}
