/* ══════════════════════════════════════════════════════════════════
   Equity Estates — Inspection platform design system
   Mirrors the "Property Inspection" mockup: Plus Jakarta Sans + Newsreader,
   navy #14233b / gold #e9c98a / blue #2e6bdb on warm paper #f4f3ef.
   ══════════════════════════════════════════════════════════════════ */

/* Disable double-tap zoom (pinch is blocked via JS gesture events in head.ejs)
   so inspectors don't accidentally zoom the page during capture. */
html { touch-action: manipulation; }

:root {
  --navy: #14233b;
  --gold: #e9c98a;
  --blue: #2e6bdb;
  --paper: #f4f3ef;
  --ink: #1c2733;
  --muted: #5b626c;
  --faint: #8a8f98;
  --line: #e6e3da;
  --card: #fff;
  --good: #1f7a55;
  --good-bg: #e7f5ee;
  --warn: #c23a3a;
  --warn-bg: #fbe9e9;
  --amber: #ad6a16;
  --amber-bg: #fbeedd;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background: var(--paper);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  /* Keep flow-page content out from under the iOS status bar / rounded corners
     in the installed PWA. env() is 0 when the OS already reserves the bar. */
  padding-top: env(safe-area-inset-top);
}
input, textarea, button, select { font-family: inherit; }
textarea { resize: vertical; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.serif { font-family: 'Newsreader', Georgia, serif; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d6d3ca; border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }

@keyframes eeRec { 0%,100%{opacity:1;} 50%{opacity:.35;} }
@keyframes eeIn { from{opacity:0;transform:translateY(8px);} to{opacity:1;transform:none;} }
@keyframes eePop { from{opacity:0;transform:scale(.96);} to{opacity:1;transform:none;} }
@keyframes eeSpin { to { transform: rotate(360deg); } }

/* Offline sync-status pill (shown on walkthrough / consumables / review). */
.status-pills { position:fixed; bottom:calc(54px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%); z-index:50; display:flex; align-items:center; gap:8px; }
.net-badge { font-size:12px; font-weight:600; padding:7px 12px; border-radius:20px; display:inline-flex; align-items:center; gap:7px; box-shadow:0 2px 8px rgba(20,35,59,.14); }
.net-badge .dot { width:8px; height:8px; border-radius:50%; background:currentColor; flex:none; }
.net-badge.on  { background:#e8f5ee; color:#16653e; }
.net-badge.off { background:#fdeaea; color:#b3251f; }
.sync-badge { font-size:12px; font-weight:600; padding:7px 12px; border-radius:20px; display:none; align-items:center; gap:7px; box-shadow:0 2px 8px rgba(20,35,59,.14); }
.sync-badge.show { display:inline-flex; }
.sync-badge .dot { width:8px; height:8px; border-radius:50%; background:currentColor; flex:none; }
.sync-badge.ok   { background:#e8f5ee; color:#16653e; }
.sync-badge.sync { background:#eaf0fb; color:#1b4fa0; }
.sync-badge.sync .dot { animation:eeRec 1s infinite; }
.sync-badge.wait { background:#fdf3e3; color:#9a5600; }
.sync-badge.warn { background:#fdeaea; color:#b3251f; }
.sync-badge.ok { cursor:pointer; }
.sync-bar { display:none; width:46px; height:4px; border-radius:2px; background:rgba(0,0,0,.14); overflow:hidden; flex:none; }
.sync-bar > i { display:block; height:100%; width:0; background:currentColor; transition:width .25s ease; }

/* Activity-log popup (opened by tapping the synced pill). */
.log-modal { position:fixed; inset:0; z-index:90; background:rgba(12,20,31,.5); display:flex; align-items:flex-end; justify-content:center; animation:eeIn .15s ease; }
.log-card { background:#fff; width:100%; max-width:560px; max-height:72vh; border-radius:18px 18px 0 0; display:flex; flex-direction:column; box-shadow:0 -10px 40px rgba(0,0,0,.25); }
@media (min-width:600px){ .log-modal{ align-items:center; padding:20px; } .log-card{ border-radius:18px; } }
.log-head { display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid #eee; font-weight:800; font-size:15px; color:var(--navy); flex:none; }
.log-close { width:34px; height:34px; border-radius:50%; border:1px solid #e4e1d8; background:#fff; color:#6b7280; cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:15px; }
.log-list { overflow-y:auto; padding:6px 0 10px; -webkit-overflow-scrolling:touch; }
.log-row { display:flex; align-items:flex-start; gap:11px; padding:10px 18px; border-bottom:1px solid #f3f1ec; }
.log-row > .ph { font-size:18px; flex:none; margin-top:1px; }
.log-row.q > .ph { color:#9a5600; }
.log-row.s > .ph { color:#16653e; }
.log-main { flex:1; min-width:0; display:flex; flex-direction:column; gap:1px; }
.log-act { font-weight:700; font-size:13.5px; color:var(--navy); }
.log-where { font-size:12.5px; color:#6b7280; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.log-detail { font-size:12px; color:#9aa1ac; }
.log-time { font-size:11.5px; color:#9aa1ac; white-space:nowrap; flex:none; font-variant-numeric:tabular-nums; margin-top:1px; }
.log-empty { padding:30px 18px; text-align:center; color:#9aa1ac; font-size:13px; }
.log-ver { display:inline-block; margin-left:8px; font-size:11px; font-weight:700; color:#6b7280; background:#f3f1ec; padding:1px 7px; border-radius:9px; vertical-align:middle; }

/* Build-version chip (parsed from the active service-worker cache name). */
.app-version { position:fixed; right:calc(8px + env(safe-area-inset-right)); bottom:calc(8px + env(safe-area-inset-bottom)); z-index:40; font-size:10px; font-weight:700; letter-spacing:.4px; color:rgba(20,35,59,.45); background:rgba(255,255,255,.72); padding:2px 7px; border-radius:10px; pointer-events:none; font-variant-numeric:tabular-nums; box-shadow:0 1px 3px rgba(20,35,59,.1); }

/* ── Brand mark ── */
.brand { display: flex; align-items: center; gap: 14px; }
.brand .mark {
  width: 42px; height: 42px; border-radius: 12px; background: var(--navy);
  color: var(--gold); display: flex; align-items: center; justify-content: center;
  font-family: 'Newsreader', serif; font-weight: 600; font-size: 18px; letter-spacing: .5px; flex: none;
}
.brand .name { font-size: 12px; font-weight: 700; letter-spacing: 2.5px; color: var(--navy); }
.brand .tag { font-size: 12px; letter-spacing: 1px; color: var(--faint); }

/* ── Layout containers ── */
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 22px 80px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 28px 22px 80px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: 48px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 700; font-size: 14.5px; cursor: pointer;
  transition: all .15s; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); box-shadow: 0 6px 18px rgba(46,107,219,.28); }
.btn-dark { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-ghost { background: #fff; color: var(--muted); }
.btn-sm { height: 38px; padding: 0 14px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--warn); border-color: #f0cfcf; }

/* ── Forms ── */
label.field { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid #e0ddd4; border-radius: 12px; padding: 0 14px;
  font-size: 15px; color: var(--ink); background: #faf9f6; outline: none; height: 50px;
}
.textarea { padding: 12px 14px; min-height: 80px; height: auto; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); background: #fff; }
.form-row { margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Cards ── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px; box-shadow: 0 1px 2px rgba(20,35,59,.04);
}
.card + .card { margin-top: 16px; }

/* ── Pills / badges ── */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.pill-good { background: var(--good-bg); color: var(--good); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-na { background: #eef0f3; color: #586273; }
.pill-blue { background: #e8f0fd; color: var(--blue); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-muted { background: #f0eee7; color: var(--faint); }

.status-upcoming { background: #eef0f3; color: #586273; }
.status-in_progress { background: #e8f0fd; color: var(--blue); }
.status-completed { background: var(--good-bg); color: var(--good); }

/* ── Progress bar ── */
.progress { height: 7px; border-radius: 4px; background: #edeae2; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 4px; background: var(--blue); transition: width .3s; }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; letter-spacing: 1px; color: var(--faint); text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid #f0eee7; font-size: 14px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

/* ── Section heads ── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-family: 'Newsreader', serif; font-size: 40px; line-height: 1.05; font-weight: 500; letter-spacing: -.5px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 2px; color: var(--faint); margin-bottom: 6px; }
.section-title { font-weight: 700; font-size: 17px; margin: 28px 0 12px; }

/* ── Flash messages ── */
.flash { border-radius: 12px; padding: 13px 16px; margin-bottom: 18px; font-size: 14px; font-weight: 600; }
.flash-success { background: var(--good-bg); color: var(--good); }
.flash-error { background: var(--warn-bg); color: var(--warn); }

/* ── Auth screen ── */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; }

/* ── Admin shell ── */
.admin { display: flex; min-height: 100vh; }
.admin-side {
  width: 246px; flex: none; background: var(--navy); color: #eef1f6;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.admin-side .head { padding: 20px 20px; border-bottom: 1px solid rgba(255,255,255,.08); display:flex; align-items:center; gap:12px; }
.admin-side .head .mark { width: 34px; height: 34px; border-radius: 10px; background: var(--gold); color: var(--navy); display:flex; align-items:center; justify-content:center; font-family:'Newsreader',serif; font-weight:600; font-size:15px; flex:none; }
.admin-side .head .name { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; }
.admin-side .head .tag { font-size: 10.5px; opacity: .55; letter-spacing: .5px; }
.admin-nav { flex: 1; padding: 14px 12px; }
.admin-nav a {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 10px;
  color: #cdd5e2; font-weight: 600; font-size: 14px; margin-bottom: 3px; text-decoration: none;
}
.admin-nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.admin-nav a.on { background: rgba(255,255,255,.1); color: #fff; }
.admin-nav a .ph { font-size: 19px; width: 22px; text-align: center; }
.admin-side .foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.admin-side .foot .who { opacity: .7; margin-bottom: 8px; }
.admin-main { flex: 1; min-width: 0; }
.admin-topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 26px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; }
@media (max-width: 820px) {
  .admin { flex-direction: column; }
  .admin-side { width: 100%; height: auto; position: static; flex-direction: column; }
  .admin-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .admin-nav a { margin: 0; }
}

/* ── Tabs ── */
.tabs { display: inline-flex; gap: 4px; background: #eceae3; padding: 4px; border-radius: 12px; margin-bottom: 20px; }
.tab-btn { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.tab-btn.on { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tab-panel[hidden] { display: none; }
.search-box { position: relative; }
.search-box .ph { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 16px; }
.search-box input { height: 40px; padding-left: 36px; width: 280px; max-width: 60vw; }

/* ── Stat tiles ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
@media (max-width: 760px) { .stat-grid { grid-template-columns: repeat(2,1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.stat .n { font-family: 'Newsreader', serif; font-size: 38px; font-weight: 600; line-height: 1; }
.stat .l { font-size: 12.5px; color: var(--faint); margin-top: 6px; }

/* ── Inspection list cards ── */
.ins-card { display: flex; gap: 15px; align-items: stretch; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: 0 1px 2px rgba(20,35,59,.04); text-decoration: none; color: inherit; margin-bottom: 14px; }
.ins-card:hover { border-color: #d4cfc2; text-decoration: none; }
.ins-card .thumb { width: 92px; height: 92px; border-radius: 12px; overflow: hidden; flex: none; background: #e7e4dd; }
.ins-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ins-card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.ins-title { font-weight: 700; font-size: 17px; }
.muted { color: var(--faint); }
.small { font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
hr.sep { border: none; border-top: 1px solid #f0eee7; margin: 16px 0; }

/* ── Phone optimization (≤480px) ────────────────────────────────────────
   The base design is tuned for iPad width; on a ~390px phone the iPad-sized
   display type, gutters and horizontal rows feel oversized and crowd (the
   "have to zoom out" symptom). These rules tighten things so phones read well
   at 100% zoom. Inline-sized hero headings use clamp() in their templates. */
@media (max-width: 480px) {
  /* Tighter page gutters → more usable content width. */
  .wrap, .wrap-narrow { padding: 20px 16px 80px; }

  /* Oversized display type scales down. */
  .page-title { font-size: 28px; }
  .stat .n { font-size: 30px; }
  .section-title { font-size: 16px; margin: 22px 0 10px; }

  /* Inspection cards: smaller thumb + the trailing "View" action drops to its
     own line, so the body gets full width (title/address no longer wrap badly)
     and the pill+date row reads cleanly instead of squeezing to 3 lines. */
  .ins-card { gap: 12px; padding: 12px; flex-wrap: wrap; }
  .ins-card .thumb { width: 64px; height: 64px; }
  .ins-card .body .row { flex-wrap: wrap; row-gap: 4px; }
  .ins-card .body .row .small { white-space: nowrap; }
  .ins-card > .row { width: 100%; justify-content: flex-end; margin-top: 2px; }

  /* Stat tiles already go 2-up at 760px; tighten their padding on phones. */
  .stat { padding: 14px; }

  /* Header / action button rows wrap instead of crowding. */
  .spread { flex-wrap: wrap; }
  .btn-sm { padding: 0 12px; }

  /* My Inspections is read at arm's length in the field; the default phone type
     was too small. Bump it ~25% — scoped to .dash-home so only this page changes
     (every other screen keeps the sizes above; iPad/>480px is never touched). */
  .dash-home .eyebrow { font-size: 14px; }
  .dash-home .page-title { font-size: 35px; }
  .dash-home .dash-sub { font-size: 19px; }
  .dash-home .section-title { font-size: 20px; }
  .dash-home .brand .name, .dash-home .brand .tag { font-size: 15px; }
  .dash-home .ins-title { font-size: 21px; }
  .dash-home .small { font-size: 15.5px; }
  .dash-home .pill { font-size: 14px; }
  .dash-home .card { font-size: 19px; }
  .dash-home .btn-sm { font-size: 16px; }
}
