:root {
  --teal: #0c4a44;
  --teal-light: #10665e;
  --green: #2f9e44;
  --amber: #e8590c;
  --red: #c0392b;
  --bg: #f5f7f6;
  --card: #ffffff;
  --border: #e1e6e4;
  --text: #16211f;
  --muted: #667670;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
/* Defensive: without this, the [hidden] attribute used by main.js to hide
   the topbar/tabbar/install-banner while logged out is silently overridden
   by the unconditional `display: flex` rules below (author CSS always beats
   the UA stylesheet's own `[hidden] { display: none }`, no matter the
   source order) -- so those elements stayed visibly on-screen even when
   JS had just set `.hidden = true`. Found while capturing the app
   walkthrough screenshots: the login page was showing a live "Log out"
   button and the install banner from a stale/logged-out state. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 72px;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--teal); color: #fff; padding: 14px 16px;
}
.brand { font-size: 15px; letter-spacing: 0.3px; }
.brand strong { font-weight: 700; }

.install-banner {
  display: flex; align-items: center; gap: 10px; background: #fff3cd; color: #664d03;
  padding: 10px 14px; font-size: 13px; border-bottom: 1px solid #ffe69c;
}
.install-banner span { flex: 1; }
.install-banner button { padding: 6px 12px; border-radius: 8px; border: none; background: var(--teal); color: #fff; font-weight: 600; }
.install-banner button.ghost { background: transparent; color: #664d03; padding: 4px 6px; }

main#app { max-width: 480px; margin: 0 auto; padding: 16px; min-height: 60vh; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: #fff; border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; text-align: center; text-decoration: none; color: var(--muted);
  font-size: 11px; padding: 6px 2px; border-radius: 10px;
}
.tabbar a .icon { display: block; font-size: 18px; margin-bottom: 2px; }
.tabbar a.active { color: var(--teal); font-weight: 700; }

button, .btn, .btn-primary, .btn-secondary, .btn-danger {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.25;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}
.btn-primary { background: var(--teal); color: #fff; width: 100%; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--teal); border: 1px solid var(--teal); width: 100%; }
.btn-danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn-small { padding: 8px 12px; font-size: 13px; border-radius: 8px; }
button.ghost { background: transparent; color: inherit; border: none; }

.card .btn-primary,
.card .btn-secondary {
  margin-top: 4px;
}

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card .meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.35;
  padding: 8px 0;
  margin: 0;
  cursor: pointer;
}
.field .check-row {
  display: flex;
  font-weight: 400;
  margin-bottom: 0;
}
.check-row input[type="checkbox"],
.check-row input[type="radio"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 2px 0 0;
  padding: 0;
  border: none;
  flex-shrink: 0;
  accent-color: var(--teal);
}

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-green { background: #ebfbee; color: var(--green); }
.badge-amber { background: #fff4e6; color: var(--amber); }
.badge-red { background: #fdeeee; color: var(--red); }
.badge-grey { background: #eef1f0; color: var(--muted); }
.badge-teal { background: #e2f3f1; color: var(--teal); }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.error-banner { background: #fdeeee; color: var(--red); padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.success-banner { background: #ebfbee; color: var(--green); padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 16px; }

.step-list { list-style: none; padding: 0; margin: 0; }
.step-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.step-list li:last-child { border-bottom: none; }

.progress-bar { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.progress-bar > div { height: 100%; background: var(--green); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tabs button { background: #fff; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.tabs button.active { background: var(--teal); color: #fff; border-color: var(--teal); }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.photo-grid .photo-tile { aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--border); position: relative; }
.photo-grid .photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid label.upload-tile {
  aspect-ratio: 1; border: 2px dashed var(--border); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 24px; cursor: pointer;
}

table.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.admin-table th, table.admin-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }

.login-hero { text-align: center; margin: 24px 0 28px; }
.login-hero .logo-mark {
  width: 56px; height: 56px; border-radius: 16px; background: var(--teal); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; margin: 0 auto 12px;
}

body.modal-open { overflow: hidden; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.modal[hidden] { display: none !important; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 33, 31, 0.48);
}

.modal__dialog {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: min(86vh, 640px);
  background: var(--card);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 48px rgba(22, 33, 31, 0.28);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal__header h3 { margin: 0; font-size: 16px; }
.modal__close {
  background: #eef1f0;
  color: var(--text);
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
}

.modal__body {
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.modal__body .meta { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.modal__actions { display: flex; gap: 10px; margin-top: 12px; }
.modal__actions > * { flex: 1; width: auto; min-width: 0; }
