/* Aperture Estate client portal. Layout and parts follow Door Leads (michael-sales-crm): phone-first,
   sticky top bar, bottom tabs, cards, pill buttons. Colors are the Aperture site's (ink + amber on warm paper). */
:root {
  color-scheme: light;
  --paper: #f4f2ee; --surface: #ffffff; --surface-2: #ebe8e1;
  --ink: #111418; --ink-2: #3b4149; --muted: #5d636b;
  --accent: #f2a541; --accent-ink: #111418; --accent-soft: #fbe7c6;
  --focus: #1f4f7a; --link: #1f4f7a;
  --line: rgba(17, 20, 24, .12); --line-2: rgba(17, 20, 24, .22);
  --err: #b42318; --ok: #1d7a46; --warn: #8a5300;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 14px; --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0f1114; --surface: #181b20; --surface-2: #22262c;
    --ink: #eef0f2; --ink-2: #c9ced4; --muted: #9aa1a9;
    --accent: #f5b25a; --accent-ink: #111418; --accent-soft: #3d2f1a;
    --focus: #7fb2e5; --link: #8fbdea;
    --line: rgba(238, 240, 242, .12); --line-2: rgba(238, 240, 242, .24);
    --err: #ff8a7a; --ok: #5cc98f; --warn: #e8b562;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0f1114; --surface: #181b20; --surface-2: #22262c;
  --ink: #eef0f2; --ink-2: #c9ced4; --muted: #9aa1a9;
  --accent: #f5b25a; --accent-ink: #111418; --accent-soft: #3d2f1a;
  --focus: #7fb2e5; --link: #8fbdea;
  --line: rgba(238, 240, 242, .12); --line-2: rgba(238, 240, 242, .24);
  --err: #ff8a7a; --ok: #5cc98f; --warn: #e8b562;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--sans); min-height: 100svh; overflow-x: clip; -webkit-tap-highlight-color: transparent; }
a { color: var(--link); }
button, input { font: inherit; color: inherit; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--err); font-size: 14px; min-height: 1.2em; }
.err:empty { min-height: 0; }
h2 { font-size: 15px; font-weight: 700; letter-spacing: .01em; color: var(--ink-2); margin-bottom: 10px; }

/* splash */
.splash { min-height: 100svh; display: grid; place-items: center; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 999px; border: 0; font-weight: 600; text-decoration: none; cursor: pointer; background: var(--surface-2); color: var(--ink); transition: transform .15s, background .15s, opacity .15s; touch-action: manipulation; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn.link { background: none; min-height: 40px; padding: 0 4px; color: var(--ink-2); font-weight: 600; }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn.busy { opacity: .6; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: none; border-radius: 50%; cursor: pointer; color: inherit; }
.icon-btn svg { width: 22px; height: 22px; }

/* sign-in */
.auth { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px 22px; display: grid; gap: 16px; box-shadow: 0 20px 50px -30px rgba(17, 20, 24, .45); }
.auth-card h1 { font-size: 26px; letter-spacing: -.02em; line-height: 1.2; }
.auth-card form { display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-weight: 800; font-size: 14px; position: relative; }
.brand-mark::after { content: ""; position: absolute; left: 9px; right: 9px; bottom: 6px; height: 2px; background: var(--accent); }
.code-input { font-size: 28px !important; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }

/* fields */
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--ink-2); }
input:not([type=checkbox]) { width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); font-size: 17px; appearance: none; -webkit-appearance: none; }
input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }

/* chrome */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: calc(6px + var(--safe-t)) 8px 6px 8px; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); min-height: 56px; }
.top .title { font-weight: 700; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 8px; }
.top .back { margin-right: -8px; }
.view { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--tabs-h) + 32px + var(--safe-b)); outline: none; display: grid; gap: 16px; align-content: start; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr); height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--line); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.tabs a svg { width: 24px; height: 24px; }
.tabs a.active { color: var(--ink); }
.tabs a.active svg { color: var(--accent); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.cards { list-style: none; display: grid; gap: 10px; }

/* tours list */
.search { position: relative; display: block; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; }
.search input { padding-left: 44px; }
.tour-card { display: flex; align-items: stretch; text-decoration: none; color: inherit; padding: 0; overflow: hidden; }
.tour-cover { width: 104px; flex: none; background: var(--surface-2); position: relative; }
.tour-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tour-body { flex: 1; min-width: 0; padding: 12px 14px; display: grid; gap: 4px; align-content: center; }
.tour-street { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tour-city { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.tag.off { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }
.tag svg { width: 14px; height: 14px; }
.count { font-size: 14px; color: var(--muted); }
.empty { text-align: center; padding: 40px 16px; display: grid; gap: 12px; justify-items: center; color: var(--muted); }

/* tour page */
.tour-head { display: grid; gap: 6px; }
.tour-head h1 { font-size: 22px; line-height: 1.25; letter-spacing: -.01em; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.status.offline::before { background: var(--err); }
.link-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.link-row:first-of-type { border-top: 0; padding-top: 0; }
.link-row .label { font-weight: 700; }
.link-row .hint { grid-column: 1; color: var(--muted); font-size: 13px; }
.link-row .url { grid-column: 1; font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row .btn { grid-row: 1 / span 3; grid-column: 2; }
.qr-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.qr { width: 132px; background: #fff; padding: 6px; border-radius: 10px; flex: none; }
.qr svg { width: 100%; height: auto; }
.qr-text { flex: 1; min-width: 160px; display: grid; gap: 8px; justify-items: start; }
.feature-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.feature-row:first-of-type { border-top: 0; padding-top: 0; }
.feature-row .state { font-size: 14px; font-weight: 600; color: var(--muted); }
.feature-row .state.on { color: var(--ok); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 3 / 2; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-open { all: unset; display: block; width: 100%; height: 100%; cursor: pointer; }
.thumb-open:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.thumb-n { position: absolute; left: 4px; top: 4px; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, .6); color: #fff; }
.viewer { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100svh; margin: auto; }
.viewer::backdrop { background: rgba(0, 0, 0, .92); }
.viewer img { max-width: 100vw; max-height: 100svh; object-fit: contain; display: block; }
.viewer .close, .viewer .nav { position: fixed; color: #fff; background: rgba(0, 0, 0, .5); }
.viewer .close { top: calc(8px + var(--safe-t)); right: 8px; }
.viewer .nav { top: 50%; transform: translateY(-50%); }
.viewer .prev { left: 8px; } .viewer .next { right: 8px; }
.soon { font-size: 13px; color: var(--muted); }

/* status: live / offline */
.seg { display: flex; gap: 6px; }
.seg .opt { flex: 1 1 0; display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 12px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); font-weight: 700; font-size: 16px; cursor: pointer; }
.seg .opt:disabled { cursor: default; opacity: .6; }
.seg .opt.on.live { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg .opt.on.off { background: var(--err); border-color: var(--err); color: #fff; }
.status-seg { margin-top: 6px; max-width: 360px; }
.warn-text { color: var(--err); font-weight: 600; }

/* switches */
.switch-row { cursor: pointer; }
.switch-wrap { display: inline-flex; align-items: center; gap: 10px; }
.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 32px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; cursor: default; }

/* photo selection and downloads */
.photos-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.photos-head h2 { margin: 0 auto 0 0; }
.photos.selecting .thumb img { transition: transform .12s; }
.thumb.picked img { transform: scale(.9); border-radius: 8px; }
.thumb.picked { outline: 3px solid var(--accent); outline-offset: -3px; }
.tick { position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, .35); color: var(--accent-ink); display: grid; place-items: center; font-size: 14px; font-weight: 800; pointer-events: none; }
.thumb.picked .tick { background: var(--accent); border-color: var(--accent); }
.select-bar { position: sticky; bottom: calc(var(--tabs-h) + var(--safe-b) + 10px); margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 16px; background: var(--ink); color: var(--paper); border-radius: 999px; font-weight: 600; box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5); z-index: 5; }
.viewer .dl { position: fixed; top: calc(8px + var(--safe-t)); right: 60px; color: #fff; background: rgba(0, 0, 0, .5); }

/* hidden photos and arrange mode */
.thumb.is-hidden img { opacity: .35; filter: grayscale(1); }
.hidden-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, .7); color: #fff; pointer-events: none; }
.arrange-help { margin: -4px 0 12px; }
.photos.arranging { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.thumb.arr { cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.thumb.arr img { pointer-events: none; }
.thumb.arr.dragging { opacity: .25; outline: 2px dashed var(--accent); outline-offset: -2px; }
.arr-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; padding: 0; }
.arr-btn svg { width: 18px; height: 18px; }
.arr-btn:disabled { opacity: .3; cursor: default; }
.arr-btn.eye { position: absolute; top: 4px; right: 4px; }
.arr-btn.eye[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.arr-moves { position: absolute; left: 4px; right: 4px; bottom: 4px; display: flex; justify-content: space-between; }

/* history */
.history { list-style: none; display: grid; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.history li:first-child { border-top: 0; padding-top: 0; }

/* profile */
.profile-grid { display: grid; gap: 0; }
.profile-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.profile-row:first-child { border-top: 0; padding-top: 0; }
.profile-row .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.profile-row .v { overflow-wrap: anywhere; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.shown { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.hidden-b { background: var(--surface-2); color: var(--muted); }
.note { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; }

/* profile editor */
.profile-card { display: grid; gap: 14px; }
.profile-card h2 { margin: 0; font-size: 18px; color: var(--ink); }
.note.warn { background: color-mix(in srgb, var(--err) 12%, transparent); }
.pending { border: 1.5px solid var(--accent); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; background: var(--accent-soft); }
.pending ul { padding-left: 18px; font-size: 14px; }
.preview-wrap { display: grid; gap: 6px; }
.preview { border: 1px dashed var(--line-2); border-radius: 12px; padding: 12px 14px; background: var(--paper); }
.agent-preview { display: flex; gap: 12px; align-items: center; }
.logo-chip { flex: none; max-width: 40%; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-weight: 700; font-size: 13px; text-align: center; }
.pv-name { font-weight: 700; font-size: 17px; }
.pv-contact { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--link); margin-top: 2px; }
.profile-form { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-width: 0; }
.field-row { display: flex; align-items: flex-end; gap: 12px; }
.field-row > :first-child { flex: 1; min-width: 0; }
.mini-switch { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); padding-bottom: 9px; cursor: pointer; }
.mini-switch.master { justify-content: space-between; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 15px; color: var(--ink); }
.logo-name { min-height: 50px; display: flex; align-items: center; padding: 0 14px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); }
textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); font: inherit; font-size: 16px; resize: vertical; }
textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.field em { font-style: normal; font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
@media (max-width: 420px) { .field-row:has(.row2) { flex-direction: column; align-items: stretch; } .field-row:has(.row2) .mini-switch { padding-bottom: 0; } }

/* help */
.faq { display: grid; gap: 0; }
.faq details { border-top: 1px solid var(--line); padding: 12px 0; }
.faq details:first-child { border-top: 0; padding-top: 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin-top: 8px; color: var(--ink-2); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 84px); transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 999px; font-weight: 600; font-size: 15px; z-index: 50; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--err); color: #fff; }

@media (min-width: 760px) {
  .tour-cover { width: 140px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
