/* Jeff's Home — warm, clean light theme (a homey utility look). */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --line: #e7e2d8;
  --ink: #2c2a26;
  /* Guided tour (tour.js reads these w/ dark Spotify-ish fallbacks — override to House Helper sage/light) */
  --accent: #5b8c6e; --bg-elevated: #ffffff; --bg-primary: #f6f4ef;
  --text-primary: #2c2a26; --text-secondary: #6b6459; --text-tertiary: #9a948a; --border: #e7e2d8;
  --muted: #6b6459; /* was #8c867b (3.3:1 on --bg, fails WCAG AA) — now ~5.3:1, passes AA */
  --sage: #5b8c6e;
  --sage-dark: #436b53;
  --sage-soft: #e9f0eb;
  --terra: #c4783f;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(44,42,38,.06), 0 6px 18px rgba(44,42,38,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: 'Inter', system-ui, -apple-system, sans-serif; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; letter-spacing: -.01em; margin: 0; }
a { color: var(--sage-dark); }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.bar { position: sticky; top: 0; z-index: 40; background: rgba(246,244,239,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.bar-in { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; min-height: 60px; flex-wrap: wrap; padding: 8px 0; padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.bar-in > div { flex-wrap: wrap; justify-content: flex-end; }
.bar-in .btn-link { padding: 2px 4px; }
.brand { display: flex; align-items: center; gap: 9px; font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.2rem; color: var(--ink); }
.brand .mk { width: 26px; height: 26px; border-radius: 7px; background: var(--sage); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; border: 1px solid transparent; transition: .14s; }
.btn-primary { background: var(--sage); color: #fff; }
.btn-primary:hover { background: var(--sage-dark); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--sage); }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.btn-icon { min-width: 44px; min-height: 44px; padding: 0; } /* icon-only (×) buttons — was ~35×37px, under the 44px touch-target minimum */
.btn-link { background: none; border: none; color: var(--sage-dark); cursor: pointer; font: inherit; padding: 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin: 16px 0 18px; }
.tabs button { flex: 1; background: none; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-weight: 600; padding: 10px; border-radius: 10px; cursor: pointer; }
.tabs button.active { background: var(--sage); color: #fff; border-color: var(--sage); }

/* Cards / grid */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card .ph { aspect-ratio: 4/3; background: var(--sage-soft); display: flex; align-items: center; justify-content: center; color: var(--sage); font-size: 2rem; overflow: hidden; }
.card .ph img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 13px 14px; }
.card .body h3 { font-size: 1.05rem; }
.card .room { display: inline-block; font-size: .72rem; font-weight: 600; color: var(--sage-dark); background: var(--sage-soft); padding: 2px 9px; border-radius: 999px; margin-bottom: 6px; }
.card .meta { color: var(--muted); font-size: .85rem; margin: 3px 0 0; }
.chip { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--sage-soft); color: var(--sage-dark); margin: 2px 3px 0 0; }
.chip.warn { background: #f6e7da; color: var(--terra); }

/* Selectable chip set (service picker) */
.chipset { display: flex; flex-wrap: wrap; gap: 6px; }
.chipset .pick { font-size: .8rem; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; user-select: none; transition: background .12s ease, border-color .12s ease, color .12s ease; }
.chipset .pick.on { background: var(--sage-dark); border-color: var(--sage-dark); color: #fff; }

/* Callout banner (listing status, gates) */
.callout { border: 1px solid var(--line); background: var(--sage-soft); color: var(--ink); border-radius: 12px; padding: 10px 13px; font-size: .88rem; margin: 0 0 12px; }
.callout.ok { background: #e7f1ea; border-color: #bfd9c8; }
.callout.warn { background: #f7ecdf; border-color: #e7cda6; color: var(--terra); }

/* Filter row */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters select, .filters input { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; color: var(--ink); }

/* Forms / modal */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; color: var(--ink); box-sizing: border-box; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }
.overlay { position: fixed; inset: 0; background: rgba(44,42,38,.45); z-index: 100; display: none; align-items: flex-start; justify-content: center; padding: calc(20px + env(safe-area-inset-top,0px)) 16px calc(20px + env(safe-area-inset-bottom,0px)); overflow: auto; -webkit-overflow-scrolling: touch; }
.overlay.open { display: flex; }
.modal { position: relative; background: var(--surface); border-radius: 16px; width: 100%; max-width: 480px; padding: 22px; box-shadow: var(--shadow); max-height: calc(100dvh - 40px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal h2 { margin-bottom: 14px; padding-right: 30px; }
/* Always-present close button so you can exit any modal without hunting for Cancel */
.modal-x { position: sticky; top: -22px; float: right; margin: -10px -8px 0 0; width: 34px; height: 34px; border: 0; background: var(--surface); color: var(--muted); border-radius: 50%; font-size: 24px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 3; }
.modal-x:hover { color: var(--ink); background: var(--sage-soft); }
/* "More" sheet rows */
.more-grid { display: flex; flex-direction: column; gap: 8px; }
.more-row { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; }
.more-row:hover { border-color: var(--sage); }
.more-ic { font-size: 1.4rem; flex: 0 0 28px; text-align: center; }
.more-tx { display: flex; flex-direction: column; gap: 1px; }
.more-tx b { font-size: .95rem; }
.more-tx .muted { font-size: .8rem; }
.more-row .badge { position: static; margin-left: auto; display: none; }
.more-row .badge.show { display: inline-flex; }
.more-grid .eyebrow { margin: 14px 0 2px; }
.more-grid .eyebrow:first-child { margin-top: 0; }
/* Inline spinner for the 15–20s AI calls, so they never look frozen */
.spin { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 7px; border: 2px solid var(--line); border-top-color: var(--sage-dark); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Long unbroken strings (model numbers, notes, emails) wrap instead of being clipped/overflowing */
.card, .task, .tile .s, .more-tx, .dlg-text, .empty { overflow-wrap: break-word; word-break: break-word; }
/* Collapsible "More details" block on the Add-item form — fewer fields up front */
.more-fields { margin: 4px 0 12px; border: 1px solid var(--line); border-radius: 10px; }
.more-fields > summary { cursor: pointer; padding: 12px 14px; font-size: .88rem; font-weight: 600; color: var(--sage-dark); list-style: none; background: var(--sage-soft); border-radius: 9px; }
.more-fields[open] > summary { border-bottom: 1px solid var(--line); border-radius: 9px 9px 0 0; margin-bottom: 10px; }
.more-fields > summary::-webkit-details-marker { display: none; }
.more-fields > *:not(summary) { margin-left: 13px; margin-right: 13px; }
.more-fields > .row2:last-child { margin-bottom: 12px; }
/* Account menu in the header — keeps "Switch role"/"Sign out" off the top bar so it stays one row */
.acct-menu { position: relative; }
.acct-menu > summary { list-style: none; cursor: pointer; }
.acct-menu > summary::-webkit-details-marker { display: none; }
.acct-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 150px; z-index: 60; }
.acct-item { text-align: left; padding: 10px 12px; border: 0; background: none; color: var(--ink); font: inherit; font-size: .9rem; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.acct-item:hover { background: var(--sage-soft); }
@media (max-width: 480px) {
  .brandName { display: none; }
  #homeSwitch { max-width: 44vw; }
}

/* Maintenance rows */
.task { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; margin-bottom: 10px; flex-wrap: wrap; }
.task.due { border-color: var(--terra); }
.task .due-tag { font-size: .76rem; font-weight: 600; color: var(--terra); }
.task .ok-tag { font-size: .76rem; color: var(--muted); }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.eyebrow { color: var(--sage-dark); text-transform: uppercase; letter-spacing: .14em; font-size: .7rem; font-weight: 700; }
.msg { font-size: .88rem; margin-top: 8px; }
.msg.err { color: #b3492f; } .msg.ok { color: var(--sage-dark); }

/* ============================================================= *
 *  Frontend pass: theming, bottom nav, badges, dashboard, etc.  *
 * ============================================================= */

/* --- Distinct SitePlan Pro palette (slate / blue) --- */
body.profile-pro {
  --sage: #3f6695; --sage-dark: #2c4a6e; --sage-soft: #e8eef6; --terra: #b5722f;
}
.bar, .overlay { transition: background .2s, border-color .2s; }

/* --- Dark mode (toggle adds .dark to <body>) --- */
body.dark {
  --bg: #16181b; --surface: #21252b; --line: #333a42; --ink: #e9e7e1;
  --muted: #9aa1a9; --sage-soft: #1e2d27; --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3);
  /* tour vars for dark mode */
  --accent: #86b699; --bg-elevated: #21252b; --bg-primary: #16181b;
  --text-primary: #e9e7e1; --text-secondary: #b8b2a7; --text-tertiary: #8c867b; --border: #333a42;
}
/* Guided tour: override the hardcoded Spotify-green primary button + soften the dim overlay */
.cft-tour-btn.primary { background: var(--sage-dark) !important; color: #fff !important; border-color: var(--sage-dark) !important; }
.cft-tour-ring { box-shadow: 0 0 0 9999px rgba(20,18,14,.55) !important; }
body.dark.profile-pro { --sage-soft: #1b2738; }
body.dark .bar { background: rgba(22,24,27,.92); }
body.dark .sso-google { background:#fff; }   /* keep Google button on white */
body.dark .chip.warn { background:#3a2a1c; }
.theme-toggle { background:none; border:1px solid var(--line); color:var(--muted); border-radius:8px; width:34px; height:30px; cursor:pointer; font-size:15px; line-height:1; display:inline-flex; align-items:center; justify-content:center; }

/* --- Tabs: icon + label, alert badges, bottom-nav on mobile --- */
.tabs button { position: relative; display:flex; flex-direction:column; align-items:center; gap:2px; padding:8px 6px; }
.tabs button .ti { font-size:1.1rem; line-height:1; }
.tabs button .tl { font-size:.74rem; font-weight:600; }
.tabs button .badge { position:absolute; top:3px; right:8px; min-width:16px; height:16px; padding:0 4px; border-radius:999px;
  background:var(--terra); color:#fff; font-size:.62rem; font-weight:700; display:none; align-items:center; justify-content:center; line-height:16px; }
.tabs button .badge.show { display:inline-flex; }
.tabs { overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
.tabs::-webkit-scrollbar { display:none; }
@media (max-width: 680px) {
  #mainTabs { position: fixed; left:0; right:0; bottom:0; z-index:60; margin:0; gap:0;
    background:var(--surface); border-top:1px solid var(--line); padding:4px 4px calc(4px + env(safe-area-inset-bottom,0px));
    box-shadow:0 -2px 12px rgba(0,0,0,.06); }
  #mainTabs button { border:0; background:none; border-radius:10px; flex:1 0 0; min-width:0; padding:6px 2px; }
  #mainTabs button .tl { font-size:.66rem; }
  #mainTabs button.active { background:none; color:var(--sage); border:0; }
  #mainTabs button.active .ti { transform:translateY(-1px); }
  #app { padding-bottom: 92px !important; }
}

/* --- Dashboard / overview tiles --- */
.tiles { display:grid; gap:12px; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); margin-bottom:18px; }
.tile { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:14px; box-shadow:var(--shadow); cursor:pointer; transition:.14s; }
.tile:hover { border-color:var(--sage); transform:translateY(-1px); }
.tile .k { font-size:.72rem; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); font-weight:700; }
.tile .v { font-family:'Fraunces',serif; font-size:1.7rem; font-weight:600; margin-top:4px; line-height:1.1; }
.tile .s { font-size:.8rem; color:var(--muted); margin-top:2px; }
.tile.alert { border-color:var(--terra); } .tile.alert .v { color:var(--terra); }
.ov-head { display:flex; align-items:baseline; justify-content:space-between; margin:4px 0 12px; }
.ov-plan { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:12px; box-shadow:var(--shadow); margin-bottom:18px; }
.ov-plan svg { width:100%; height:auto; max-height:220px; display:block; border-radius:8px; }
.quickrow { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:8px; }

/* --- Item view toggle + list layout --- */
.viewtoggle { display:inline-flex; border:1px solid var(--line); border-radius:9px; overflow:hidden; }
.viewtoggle button { border:0; background:var(--surface); color:var(--muted); padding:8px 11px; cursor:pointer; font:inherit; }
.viewtoggle button.on { background:var(--sage); color:#fff; }
.grid.list { grid-template-columns:1fr; gap:8px; }
.grid.list .card { display:flex; align-items:stretch; }
.grid.list .card .ph { aspect-ratio:auto; width:74px; flex:none; font-size:1.4rem; }
.grid.list .card .body { padding:10px 13px; flex:1; }
.cat-ico { margin-right:5px; }

/* --- Leaflet map (Esri imagery) labels, pins, footprint handles --- */
.leaflet-tooltip.map-label { background:rgba(20,22,20,.72); color:#fff; border:none; box-shadow:none; font-weight:700; font-size:11px; padding:1px 7px; border-radius:7px; white-space:nowrap; }
.leaflet-tooltip.map-label::before { display:none; }
.leaflet-div-icon.foot-handle { background:var(--sage,#2d6a4f); color:#fff; border:2px solid #fff; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:13px; box-shadow:0 1px 4px rgba(0,0,0,.5); cursor:grab; }
.leaflet-div-icon.map-pin { background:none; border:none; font-size:22px; line-height:1; text-align:center; filter:drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
#map .leaflet-control-attribution { font-size:9px; }
#map { z-index:1; }

/* --- Toasts + confirm/prompt dialogs --- */
#toastWrap { position:fixed; left:0; right:0; bottom:calc(16px + env(safe-area-inset-bottom,0px)); z-index:300; display:flex; flex-direction:column; align-items:center; gap:8px; pointer-events:none; padding:0 12px; }
.toast { pointer-events:auto; max-width:420px; width:max-content; background:var(--ink); color:var(--bg); font-size:.9rem; font-weight:500; padding:11px 16px; border-radius:12px; box-shadow:0 6px 24px rgba(0,0,0,.25); display:flex; align-items:center; gap:9px; animation:toastIn .22s cubic-bezier(.2,.8,.3,1); }
.toast.ok { background:var(--sage-dark); color:#fff; } .toast.err { background:#b3492f; color:#fff; }
.toast.hide { animation:toastOut .2s ease forwards; }
@keyframes toastIn { from { opacity:0; transform:translateY(14px) scale(.96); } to { opacity:1; transform:none; } }
@keyframes toastOut { to { opacity:0; transform:translateY(10px) scale(.97); } }
@media (max-width:680px){ #toastWrap { bottom:calc(78px + env(safe-area-inset-bottom,0px)); } } /* clear bottom nav */
.dlg-text { font-size:.95rem; color:var(--ink); margin:-4px 0 14px; white-space:pre-line; }
.dlg-actions { display:flex; gap:8px; justify-content:flex-end; }

/* --- Animations / micro-interactions --- */
@keyframes secIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
@keyframes modalIn { from { opacity:0; transform:translateY(12px) scale(.985); } to { opacity:1; transform:none; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
#app > section { animation: secIn .2s cubic-bezier(.2,.8,.3,1); }
.overlay.open { animation: fadeIn .16s ease; }
.overlay.open .modal { animation: modalIn .22s cubic-bezier(.2,.8,.3,1); }
.card, .tile, .btn, .chip { transition: transform .12s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease; }
.card:active, .tile:active { transform: scale(.992); }
.btn:active { transform: scale(.96); }
.tabs button { transition: color .14s ease, background .14s ease; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration:.001ms !important; transition-duration:.001ms !important; } }

/* --- Maintenance calendar --- */
.cal-head { display:flex; align-items:center; justify-content:space-between; margin:6px 0 10px; }
.cal-head h3 { font-size:1.05rem; }
.cal-nav button { border:1px solid var(--line); background:var(--surface); color:var(--ink); border-radius:8px; width:32px; height:32px; cursor:pointer; font-size:1rem; }
.cal { display:grid; grid-template-columns:repeat(7,1fr); gap:5px; }
.cal .dow { text-align:center; font-size:.7rem; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; padding-bottom:2px; }
.cal .cell { min-height:62px; border:1px solid var(--line); border-radius:9px; padding:4px 5px; background:var(--surface); overflow:hidden; }
.cal .cell.out { background:transparent; border-color:transparent; }
.cal .cell.today { border-color:var(--sage); box-shadow:inset 0 0 0 1px var(--sage); }
.cal .cell .dnum { font-size:.74rem; color:var(--muted); font-weight:600; }
.cal .cell.today .dnum { color:var(--sage-dark); }
.cal .ev { font-size:.66rem; line-height:1.25; margin-top:2px; padding:1px 4px; border-radius:5px; background:var(--sage-soft); color:var(--sage-dark); cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cal .ev.due { background:#f6e7da; color:var(--terra); }
.cal .more { font-size:.62rem; color:var(--muted); margin-top:1px; }
@media (max-width:560px){ .cal .cell { min-height:50px; } .cal .ev { font-size:.6rem; } }

/* --- Tablet / desktop: vertical sidebar nav on wide screens --- */
@media (min-width:1000px) {
  #mainTabs { position:fixed; top:60px; left:0; bottom:0; width:212px; margin:0; gap:4px;
    flex-direction:column; align-items:stretch; padding:16px 10px; overflow-y:auto;
    background:var(--surface); border-right:1px solid var(--line); z-index:30; }
  #mainTabs button { flex-direction:row; justify-content:flex-start; gap:11px; text-align:left;
    border:0; background:none; border-radius:10px; padding:11px 13px; color:var(--muted); }
  #mainTabs button .ti { font-size:1.15rem; }
  #mainTabs button .tl { font-size:.92rem; }
  #mainTabs button.active { background:var(--sage); color:#fff; }
  #mainTabs button .badge { position:static; margin-left:auto; }
  #app { margin-left:212px; max-width:1000px; padding-left:26px; padding-right:26px; }
  .tiles { grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); }
}

/* --- Role chooser (after sign-in) --- */
#roleChooser { position:fixed; inset:0; z-index:120; background:var(--bg); display:none; align-items:center; justify-content:center; padding:24px; padding-top:calc(24px + env(safe-area-inset-top,0px)); }
#roleChooser.open { display:flex; }
.role-wrap { max-width:780px; width:100%; text-align:center; }
.role-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(168px,1fr)); gap:14px; margin-top:22px; }
@media (max-width:520px){ .role-cards { grid-template-columns:1fr 1fr; } }
.role-card { background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:24px 16px; cursor:pointer; text-align:center; transition:.14s; box-shadow:var(--shadow); }
.role-card:hover { border-color:var(--sage); transform:translateY(-2px); }
.role-card .ic { font-size:2.3rem; line-height:1; }
.role-card h3 { margin:9px 0 5px; font-size:1.15rem; }
.role-card p { color:var(--muted); font-size:.85rem; margin:0; }

/* --- Tester survey --- */
.rate { display:flex; gap:6px; flex-wrap:wrap; }
.rate button { border:1px solid var(--line); background:var(--surface); color:var(--ink); border-radius:9px; padding:7px 13px; cursor:pointer; font:inherit; font-size:.9rem; }
.rate button.on { background:var(--sage); color:#fff; border-color:var(--sage); }
#surveyBanner { display:none; background:var(--terra); color:#fff; text-align:center; padding:9px 12px; font-size:.88rem; }
#surveyBanner button { font:inherit; }
#surveyBanner .sv-take { background:#fff; color:var(--terra); border:0; border-radius:8px; padding:4px 12px; font-weight:700; cursor:pointer; margin-left:8px; }
#surveyBanner .sv-x { background:none; border:0; color:#fff; cursor:pointer; margin-left:8px; opacity:.8; }
