/* Villa Check 3.0 — the look (Supabase + Netlify). One family with the Staff Portal: SBV sand, sea green, gold.
   Built for a phone in one hand under the sun: large touch targets, strong contrast, one accent per state.
   The one signature element: the RING on every villa, a slow dial of the days since its last check (0 → 30). */
:root {
  --sand: #f3ead9; --paper: #fbf8f1; --paper-2: #f6efe2; --card: #ffffff; --card-2: #fdfbf6;
  --ink: #22312c; --ink-2: #3a4a44; --muted: #6f7a75; --faint: #a39a88; --line: rgba(176, 138, 62, .22); --line-2: rgba(176, 138, 62, .12);
  --sea: #3e8e73; --sea-d: #2f6f5a; --sea-soft: #e3efe8; --sea-ink: #1f5b48;
  --gold: #b08a3e; --gold-soft: #f3e8d0;
  --ok: #2f8f5b; --ok-soft: #e1f1e6; --no: #c9583f; --no-soft: #fbe6df; --am: #c3851f; --am-soft: #fbefd4; --na: #7b8a86; --na-soft: #eceeec;
  --guest: #3b7ea1; --guest-soft: #e1eef6; --prog: #4a5fc1; --prog-soft: #e6e9f8;
  --shadow: 0 1px 2px rgba(34, 49, 44, .06), 0 6px 20px -12px rgba(34, 49, 44, .25);
  --r: 14px; --r-s: 10px; --r-l: 20px; --nav: 76px;
}
* { box-sizing: border-box; }
html { background: var(--sand); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 16px; line-height: 1.45; color: var(--ink); background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 50%, var(--sand) 100%) fixed; font-feature-settings: 'tnum'; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.hidden { display: none !important; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

#app { max-width: 680px; margin: 0 auto; min-height: 100vh; padding: 0 0 calc(var(--nav) + 16px); }
main { padding: 10px 16px 16px; }

/* ---- headers */
header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px; background: linear-gradient(180deg, var(--paper) 70%, rgba(251, 248, 241, 0)); }
header.top .logo { height: 44px; width: auto; display: block; }
header.top .who { flex: 1; min-width: 0; }
header.top h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.2px; color: var(--sea-ink); line-height: 1.1; }
header.top .sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .iconbtn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, .7); display: inline-flex; align-items: center; justify-content: center; color: var(--sea-d); }
header.top .iconbtn.busy .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
header.sub { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--sea-ink); color: #fff; }
header.sub button { background: rgba(255, 255, 255, .14); border: 0; color: #fff; border-radius: 10px; min-height: 40px; padding: 0 12px 0 8px; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
header.sub h1 { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.sub h1 small { display: block; font-size: 12px; font-weight: 500; opacity: .8; }
.prog { height: 4px; background: rgba(255, 255, 255, .18); } .prog > div { height: 100%; background: var(--gold); transition: width .3s ease; }

/* ---- type helpers */
h2.sec { font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--gold); margin: 20px 0 8px; }
h2.sec:first-child { margin-top: 6px; }
.note { font-size: 13px; color: var(--muted); }
.lead { color: var(--muted); margin: 0 0 18px; }
.err { color: var(--no); font-size: 14px; margin: 8px 0 0; }
.center { text-align: center; padding: 40px 16px; color: var(--muted); }
.msg { border-radius: var(--r-s); padding: 10px 12px; margin: 0 0 10px; font-size: 14px; }
.msg.warn { background: var(--am-soft); color: #6b4100; } .msg.err { background: var(--no-soft); color: #7e2a19; } .msg.good { background: var(--ok-soft); color: #1b5b39; } .msg.info { background: var(--sea-soft); color: var(--sea-ink); }
.msg a { color: inherit; font-weight: 700; }

/* ---- cards, rows */
.card { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); padding: 14px 16px; margin: 0 0 10px; box-shadow: var(--shadow); }
.card::after { content: ""; display: block; clear: both; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); padding: 12px 14px; margin: 0 0 8px; min-height: 64px; box-shadow: var(--shadow); transition: transform .12s ease; }
.row:active { transform: scale(.99); }
.row .t { flex: 1; min-width: 0; } .row .t b { display: block; font-weight: 700; font-size: 16px; } .row .t span { display: block; color: var(--muted); font-size: 13px; }
.row .t .stay { margin-top: 2px; } .row .t .stay.soon { color: var(--am); font-weight: 600; }
.row .t .why { color: var(--sea-d); font-weight: 600; }

/* the ring: days since the last check, 0 -> 30 */
.ring { --p: 0%; --c: var(--ok); position: relative; width: 50px; height: 50px; border-radius: 50%; flex: 0 0 auto; background: conic-gradient(var(--c) var(--p), var(--line-2) 0); display: grid; place-items: center; }
.ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--card); }
.ring .ic { position: relative; color: var(--c); width: 22px; height: 22px; stroke-width: 2.4; }
.ring b { position: relative; font-size: 15px; font-weight: 800; color: var(--c); line-height: 1; }
.ring small { position: relative; font-size: 9px; font-weight: 700; color: var(--muted); letter-spacing: .02em; margin-top: 1px; }
.ring.never { --c: var(--na); } .ring.amber { --c: var(--am); } .ring.red { --c: var(--no); }
.ring.today { --c: var(--ok); --p: 100%; }
.row.pending .ring, .row.draft .ring { --c: var(--prog); }

.badge { border-radius: 999px; padding: 4px 10px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.badge.red, .badge.no { background: var(--no-soft); color: var(--no); } .badge.amber, .badge.am { background: var(--am-soft); color: #8a5a10; } .badge.green, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.na, .badge.never { background: var(--na-soft); color: var(--na); } .badge.guest { background: var(--guest-soft); color: var(--guest); } .badge.prog { background: var(--prog-soft); color: var(--prog); }
.tag { display: inline-block; border-radius: 7px; padding: 2px 8px; font-size: 12px; font-weight: 700; background: var(--na-soft); color: var(--ink-2); margin: 0 6px 6px 0; }
.tag.dept { background: var(--sea-soft); color: var(--sea-ink); } .tag.inprog { background: var(--prog-soft); color: var(--prog); } .tag.late { background: var(--no-soft); color: var(--no); } .tag.guest { background: var(--guest-soft); color: var(--guest); } .tag.urgent { background: var(--no-soft); color: var(--no); }

/* ---- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--sea); background: var(--sea); color: #fff; font-weight: 700; font-size: 15px; text-decoration: none; transition: background .15s ease, transform .1s ease; }
.btn:hover { background: var(--sea-d); } .btn:active { transform: scale(.98); }
.btn.alt { background: #fff; color: var(--sea-d); } .btn.alt:hover { background: var(--sea-soft); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); } .btn.ghost:hover { background: rgba(255, 255, 255, .6); }
.btn.danger { background: #fff; border-color: var(--no); color: var(--no); } .btn.danger:hover { background: var(--no-soft); }
.btn.big { min-height: 54px; font-size: 16px; padding: 0 24px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.photobtns { display: flex; gap: 8px; flex-wrap: wrap; } .photobtns .btn { min-height: 44px; }
.photo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.photo img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
img.big { width: 100%; border-radius: 12px; border: 1px solid var(--line-2); margin-top: 8px; display: block; }

/* chips, filters, segments */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.chips button { border: 1.5px solid var(--line); background: rgba(255, 255, 255, .7); border-radius: 999px; padding: 8px 14px; min-height: 40px; font-weight: 600; color: var(--ink-2); font-size: 14px; }
.chips button.on { border-color: var(--sea); background: var(--sea); color: #fff; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; } .chips.scroll::-webkit-scrollbar { display: none; } .chips.scroll button { flex: 0 0 auto; }
.seg { display: flex; gap: 6px; padding: 4px; background: var(--paper-2); border-radius: 12px; }
.seg button { flex: 1; min-height: 46px; border: 0; background: transparent; border-radius: 9px; font-weight: 700; font-size: 15px; color: var(--muted); transition: background .12s ease, color .12s ease; }
.seg button.on.ok { background: var(--ok); color: #fff; } .seg button.on.no { background: var(--no); color: #fff; } .seg button.on.na { background: var(--na); color: #fff; }
.seg.sev { background: transparent; padding: 0; gap: 8px; flex-wrap: wrap; } .seg.sev button { flex: 1 1 calc(50% - 4px); min-height: 42px; background: #fff; border: 1.5px solid var(--line); font-size: 14px; }
.seg.sev button.on { background: var(--sea-ink); border-color: var(--sea-ink); color: #fff; }
.filters { display: flex; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.filters select, .edit select, .edit input[type=text], textarea, input[type=text], select { width: 100%; min-height: 46px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; }
.filters select { flex: 1; min-width: 160px; width: auto; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }
label.chk { display: flex; gap: 10px; align-items: center; font-weight: 600; color: var(--ink-2); margin-top: 14px; } label.chk input { width: 22px; height: 22px; accent-color: var(--sea); }

/* ---- inspection points */
.pt { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); padding: 14px 16px; margin: 0 0 10px; box-shadow: var(--shadow); }
.pt p { margin: 0 0 10px; font-weight: 600; line-height: 1.35; }
.pt .more { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 4px; }
.pt .more label:first-child { margin-top: 8px; }

/* ---- bottom bars */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: rgba(251, 248, 241, .92); backdrop-filter: blur(10px); border-top: 1px solid var(--line-2); }
.bar > div { max-width: 680px; margin: 0 auto; display: flex; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.bar .btn { flex: 1; }
nav.tabs > div { gap: 4px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
nav.tabs button { flex: 1; background: none; border: 0; min-height: 54px; color: var(--muted); font-weight: 700; font-size: 11.5px; border-radius: 12px; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 4px 2px; }
nav.tabs button .ic { width: 22px; height: 22px; }
nav.tabs button.on { color: var(--sea-ink); background: var(--sea-soft); }
nav.tabs i { font-style: normal; position: absolute; top: 4px; right: calc(50% - 22px); background: var(--no); color: #fff; border-radius: 999px; font-size: 10.5px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 5px; font-weight: 800; }

/* ---- board */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; margin: 0 0 12px; }
.tile { border: 1.5px solid var(--line-2); border-radius: 12px; padding: 9px 10px; background: var(--card); text-align: left; min-height: 68px; position: relative; overflow: hidden; }
.tile b { display: block; font-size: 14px; font-weight: 800; } .tile span { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.tile.on { outline: 2.5px solid var(--sea-ink); outline-offset: 0; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: transparent; }
.tile.lv-red::before { background: var(--no); } .tile.lv-amber::before { background: var(--am); } .tile.lv-green::before { background: var(--ok); }
.tile.lv-red { background: #fff8f6; } .tile.lv-amber { background: #fffaf0; }
.bt { position: relative; padding-left: 20px; }
.bt::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 5px; border-radius: 0 4px 4px 0; background: var(--line); }
.bt.lv-red::before { background: var(--no); } .bt.lv-amber::before { background: var(--am); } .bt.lv-green::before { background: var(--ok); } .bt.lv-grey::before { background: var(--na); }
.bt b.title { display: block; font-size: 15.5px; margin: 2px 0 2px; }
.thumb { float: right; width: 78px; height: 78px; margin: 0 0 6px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--na-soft); padding: 0; overflow: hidden; font-size: 12px; font-weight: 700; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.edit { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 12px; }
.edit .btns { display: flex; gap: 8px; } .edit .btns .btn { flex: 1; min-height: 42px; padding: 0 10px; font-size: 14px; }
details.pick { border: 1.5px solid var(--line); border-radius: 12px; background: #fff; align-self: start; }
details.pick summary { list-style: none; cursor: pointer; min-height: 44px; padding: 11px 34px 11px 12px; position: relative; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.pick summary::-webkit-details-marker { display: none; }
details.pick summary::after { content: "\25BE"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
details.pick[open] summary::after { content: "\25B4"; }
details.pick summary.none { color: var(--muted); }
.pickl { max-height: 240px; overflow: auto; border-top: 1px solid var(--line-2); padding: 4px 0; }
.pickl label { display: flex; align-items: center; gap: 10px; margin: 0; padding: 9px 12px; font-size: 15px; color: var(--ink); cursor: pointer; font-weight: 500; }
.pickl label:hover { background: var(--paper); } .pickl input { width: 20px; height: 20px; margin: 0; accent-color: var(--sea); }
.sub-h { font-size: 13px; color: var(--muted); font-weight: 700; margin: 14px 0 6px; }

/* ---- ticket detail */
dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; } dt { color: var(--muted); font-size: 13px; padding-top: 2px; } dd { margin: 0; }
.statusline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; }
.statusline .big { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }

/* ---- tables (results) */
table { border-collapse: collapse; width: 100%; font-size: 14px; } th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line-2); } th { color: var(--muted); font-size: 12px; font-weight: 700; } td.n, th.n { text-align: right; font-feature-settings: 'tnum'; }
.scroll { overflow-x: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 0 0 12px; }
.kpi { background: var(--card); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; } .kpi span { font-size: 12.5px; color: var(--muted); }
.kpi.no b { color: var(--no); } .kpi.ok b { color: var(--ok); } .kpi.am b { color: var(--am); }

/* ---- toast, gate */
#toast { position: fixed; left: 50%; transform: translate(-50%, 20px); bottom: calc(var(--nav) + 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 9; max-width: 90%; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.gate { max-width: 420px; margin: 0 auto; padding: 70px 24px 40px; text-align: center; }
.gate-logo { height: 70px; width: auto; display: block; margin: 0 auto 26px; }
.gate h1 { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin: 0 0 8px; color: var(--sea-ink); }
.gate .btn { width: 100%; margin-top: 8px; }

@media (min-width: 720px) {
  #app { max-width: 1100px; }
  .edit { grid-template-columns: 1fr 2fr; } .edit .btns { grid-column: 1 / -1; }
  .thumb { width: 96px; height: 96px; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
}
@media print { header, nav, .bar, .noprint, button { display: none !important; } body, #app { background: #fff; } #app { padding: 0; max-width: none; } .card { break-inside: avoid; box-shadow: none; } img.big { max-width: 60%; } }
