/* David's shared shell: the header and bottom bar of the work areas (Outreach, Calls, Growth), the segmented control, and the "Your work" tiles on the home screen.
   Uses the same colour variables as the rest of David, so it follows light and dark mode. */
.deskhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 0 6px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); text-decoration: none; font-family: var(--serif, Georgia, serif); font-size: 21px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.area { color: var(--teal); font-weight: 800; font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; text-align: right; }

body.desk { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.workbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line2); box-shadow: 0 -10px 30px rgba(0, 0, 0, .18); }
.workbar a { display: grid; justify-items: center; gap: 3px; padding: 8px 4px; min-height: 56px; border-radius: 14px; color: var(--ink2); text-decoration: none; font-size: 12.5px; font-weight: 700; }
.workbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.workbar a[aria-current="page"] { color: var(--teal); background: rgba(var(--glow, 16, 229, 168), .13); }
@media (min-width: 700px) { .workbar { left: 50%; right: auto; width: 640px; transform: translateX(-50%); border: 1px solid var(--line2); border-bottom: 0; border-radius: 18px 18px 0 0; } }

/* a row of sections inside one work area (Growth: Today, Plan, Streams, Money) */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; margin: 4px 0 14px; position: sticky; top: 0; z-index: 12; background: var(--surface); border: 1px solid var(--line2); border-radius: 16px; }
.seg[hidden] { display: none; }
.seg button { min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--ink2); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; }
.seg button.on { background: rgba(var(--glow, 16, 229, 168), .16); color: var(--teal); }

/* the home screen: your work first, quick questions second */
.worknav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 560px; margin: 4px auto 12px; }
.wk { display: grid; justify-items: start; gap: 2px; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line2); color: var(--ink); text-decoration: none; }
.wk svg { width: 24px; height: 24px; margin-bottom: 4px; fill: none; stroke: var(--teal); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wk b { font-size: 15px; }
.wk span { font-size: 12.5px; color: var(--ink2); line-height: 1.3; }
.wk:active { background: rgba(var(--glow, 16, 229, 168), .14); border-color: rgba(var(--glow, 16, 229, 168), .5); }
@media (max-width: 380px) { .worknav { gap: 8px; } .wk { padding: 10px; } .wk span { display: none; } }

/* Outreach sending session: the message looks like a WhatsApp message, the send button is big, the progress is visible */
.meter .grow { flex: 1; min-width: 0; }
.meter .bar { height: 6px; background: var(--surface2); border-radius: 6px; margin-top: 8px; overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: var(--teal); border-radius: 6px; }
label.check.quick { margin: 4px 0 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; font-size: 14px; color: var(--ink2); }
.pane.session .card { border-color: rgba(var(--glow, 16, 229, 168), .45); box-shadow: 0 12px 34px rgba(0, 0, 0, .18); }
.pane.session .card .name { font-size: 22px; }
.pane.session textarea { background: rgba(37, 211, 102, .12); border: 1px solid rgba(37, 211, 102, .38); border-radius: 18px 18px 4px 18px; font-size: 15.5px; line-height: 1.5; padding: 14px; }
.pane.session .btn.wa { min-height: 64px; width: 100%; font-size: 19px; border-radius: 18px; }

/* messages ("Recorded. Undo") sit above the bottom bar, wide enough to show the Undo button */
body.desk .toast { bottom: calc(92px + env(safe-area-inset-bottom)); width: max-content; max-width: min(92vw, 520px); text-align: left; }

/* Outreach, Auto tab: WhatsApp automation */
#tab-auto .card { margin-bottom: 12px; }
#tab-auto h2 { margin: 0 0 4px; font-size: 20px; }
#tab-auto h3 { font-size: 15.5px; margin: 14px 0 4px; }
#tab-auto .stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 12px 0; }
#tab-auto .stats small { display: block; color: var(--ink2); font-size: 11.5px; }
#tab-auto .stats b { font-size: 17px; overflow-wrap: anywhere; }
#tab-auto .actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
#tab-auto .actions select { flex: 1 1 140px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line2); background: var(--surface2); color: var(--ink); font: inherit; padding: 0 10px; }
#tab-auto .line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
#tab-auto .line:first-of-type { border-top: 0; }
#tab-auto .line > div { min-width: 0; } #tab-auto .line b { overflow-wrap: anywhere; } #tab-auto .line span { display: block; color: var(--ink2); font-size: 13.5px; }
#tab-auto .tpl { border: 1px solid var(--line2); border-radius: 14px; padding: 12px; margin: 10px 0; background: var(--surface2); }
#tab-auto .tpl pre { white-space: pre-wrap; word-wrap: break-word; font: inherit; margin: 8px 0; }
#tab-auto .tpl .who { color: var(--ink2); font-size: 13px; margin: 0; }
#tab-auto .tpl textarea { width: 100%; margin: 6px 0; }
#tab-auto .cmd { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
#tab-auto .cmd pre { flex: 1; min-width: 0; margin: 0; padding: 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }
details.sec { margin: 12px 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 0 14px; }
details.sec > summary { cursor: pointer; font-weight: 700; font-size: 17px; padding: 14px 0; }
details.sec .body { padding-bottom: 14px; }
details.sec .sub { color: var(--ink2); font-size: 14.5px; }
details.sec ol { margin: 6px 0 6px 20px; padding: 0; } details.sec li { margin: 6px 0; }

/* five items in the bottom bar; four tiles on the home screen */
.workbar { grid-template-columns: repeat(5, 1fr); }
.worknav { grid-template-columns: repeat(4, 1fr); max-width: 600px; }
@media (max-width: 520px) { .worknav { gap: 8px; } .wk { padding: 10px; } .wk span { display: none; } }
/* the Job ideas page: seven cards */
.ideas { display: grid; gap: 10px; margin: 10px 0 18px; }
.idea-card { display: grid; grid-template-columns: 38px 1fr; gap: 12px; align-items: start; text-align: left; width: 100%; padding: 12px; border-radius: 16px; border: 1px solid var(--line2); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.idea-card.on { border-color: var(--teal); background: rgba(var(--glow, 16, 229, 168), .08); }
.idea-card .num { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: rgba(var(--glow, 16, 229, 168), .16); color: var(--teal); font-weight: 800; font-size: 18px; }
.idea-card .ib b { display: block; font-size: 16.5px; overflow-wrap: anywhere; }
.idea-card .sh { display: block; color: var(--ink2); font-size: 13.5px; margin: 2px 0 6px; }
.idea-card .meta { display: flex; align-items: center; gap: 8px; }
.idea-card .meta .bar { flex: 1; height: 6px; margin: 0; }
.idea-card .meta small { color: var(--ink2); font-size: 12px; white-space: nowrap; }


/* ===== Modern app feel =====
   Smooth screen-to-screen transitions, loading placeholders, a header that stays put, initials avatars, live tiles, clear focus. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 140ms ease-out both vt-out; }
::view-transition-new(root) { animation: 260ms cubic-bezier(.2, .8, .2, 1) both vt-in; }
.workbar { view-transition-name: workbar; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* cards rise in when a screen opens (not every time something is ticked) */
#content.enter > *, .pane.rise > * { animation: rise .34s cubic-bezier(.2, .8, .2, 1) both; }
#content.enter > :nth-child(2) { animation-delay: .04s; } #content.enter > :nth-child(3) { animation-delay: .08s; } #content.enter > :nth-child(4) { animation-delay: .12s; } #content.enter > :nth-child(n+5) { animation-delay: .16s; }

/* a screen that is still loading shows placeholder shapes instead of nothing */
#content:empty::before, #stage:empty::before, #tab-today:empty::before { content: ""; display: block; height: 150px; margin: 6px 0 12px; border-radius: 20px; background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%) 0 0 / 200% 100%; animation: shimmer 1.3s linear infinite; }
#content:empty::after, #stage:empty::after, #tab-today:empty::after { content: ""; display: block; height: 96px; border-radius: 20px; background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%) 0 0 / 200% 100%; animation: shimmer 1.3s linear infinite; }

/* the header stays at the top, softly blurred, and the section bars sit just under it */
:root { --head: 58px; }
.deskhead { position: sticky; top: 0; z-index: 20; min-height: var(--head); margin: 0 -16px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: color-mix(in srgb, var(--bg) 84%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.seg, .tabs { top: calc(var(--head) + env(safe-area-inset-top) - 8px); }

/* people and businesses get an initials badge, always the same colour for the same name */
.avatar { flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; font-weight: 800; font-size: 16px; letter-spacing: .02em; color: #fff; background: linear-gradient(135deg, hsl(var(--h) 62% 44%), hsl(calc(var(--h) + 38) 62% 36%)); box-shadow: 0 6px 16px hsl(var(--h) 62% 30% / .35); }
.who2 { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who2 > div { min-width: 0; }
.who2 .name, .who2 h2.name { margin: 0; overflow-wrap: anywhere; }

/* the home tiles are live widgets: a number that tells you where things stand */
.wk .live { display: block; min-height: 1.2em; margin-top: 2px; font-size: 13.5px; font-weight: 700; color: var(--teal); font-variant-numeric: tabular-nums; line-height: 1.25; }
.wk .live.warn { color: var(--bad); }
.wk .live:empty::before { content: ""; display: block; width: 70%; height: 10px; margin-top: 4px; border-radius: 6px; background: linear-gradient(90deg, var(--line) 25%, var(--line2) 50%, var(--line) 75%) 0 0 / 200% 100%; animation: shimmer 1.3s linear infinite; }
.wk.lit { border-color: rgba(var(--glow, 16, 229, 168), .38); }
@media (max-width: 520px) { .wk span { display: none; } }

/* clear keyboard and screen-reader focus, comfortable taps, no accidental zoom on double tap */
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
a, button, summary, label { touch-action: manipulation; }
.btn, .small-btn, .chip, .seg button, .workbar a { transition: transform .12s ease, background-color .15s ease, border-color .15s ease, color .15s ease; }
.btn:active, .small-btn:active, .seg button:active, .workbar a:active { transform: scale(.96); }
.card, .meter, .tpl, .pkg { border-radius: 20px; }
.stats b, .meter b, .strip b, .pct { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  #content.enter > *, .pane.rise > *, #content:empty::before, #content:empty::after, #stage:empty::before, #stage:empty::after, #tab-today:empty::before, #tab-today:empty::after, .wk .live:empty::before { animation: none !important; }
  .btn:active, .small-btn:active, .seg button:active, .workbar a:active { transform: none; }
}

/* compact home tiles: icon, name and one number, so the home still fits on one screen */
.worknav { gap: 8px; margin: 2px auto 8px; }
.wk { padding: 9px 8px 8px; gap: 0; border-radius: 16px; }
.wk svg { width: 20px; height: 20px; margin-bottom: 3px; }
.wk b { font-size: 13.5px; line-height: 1.2; }
.wk .live { font-size: 12.5px; margin-top: 1px; }
.wk .live:empty::before { height: 8px; margin-top: 3px; }


/* ===== Gestures: swipe rows and pull to refresh ===== */
.swipe { position: relative; overflow: hidden; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.swipe > .swipe-in { position: relative; z-index: 1; display: flex; align-items: inherit; justify-content: inherit; gap: inherit; width: 100%; background: inherit; will-change: transform; }
.swipe > .swipe-in > * { min-width: 0; }
.swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; opacity: 0; padding: 0 18px; font-weight: 800; font-size: 14px; letter-spacing: .02em; color: #fff; z-index: 0; }
.swipe-bg.r { justify-content: flex-start; } .swipe-bg.l { justify-content: flex-end; }
.swipe-bg.good { background: #15803d; } .swipe-bg.bad { background: #b91c1c; } .swipe-bg.warn { background: #b45309; }
.swipe.armed .swipe-bg { filter: brightness(1.12); text-decoration: underline; }
/* a swiped row needs a solid face so the colour behind it only shows while it slides */
.tick.swipe, .line.swipe, .upnext .item.swipe { background: var(--surface); border-radius: 12px; }
.card .tick.swipe, .card .line.swipe { background: var(--surface); }
.ptr { position: fixed; top: calc(var(--head, 58px) + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -46px); opacity: 0; z-index: 25; display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line2); box-shadow: var(--shadow, 0 8px 24px rgba(0, 0, 0, .25)); color: var(--ink2); font-size: 13.5px; pointer-events: none; }
.ptr.go { color: var(--teal); border-color: var(--teal); }
.ptr .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line2); border-top-color: var(--teal); }
.ptr.busy .spin { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.desk { overscroll-behavior-y: contain; }
@media (prefers-reduced-motion: reduce) { .ptr.busy .spin { animation: none; } .swipe > .swipe-in { transition: none !important; } }


/* ===== Bottom sheets, search, offline banner ===== */
.sheet-back { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .52); opacity: 0; transition: opacity .2s ease; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet-back.in { opacity: 1; }
.bsheet { width: min(100%, 560px); max-height: 86vh; overflow-y: auto; padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); background: var(--surface); border: 1px solid var(--line2); border-bottom: 0; border-radius: 24px 24px 0 0; box-shadow: 0 -20px 50px rgba(0, 0, 0, .35); transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); }
.sheet-back.in .bsheet { transform: none; }
.sheet-handle { width: 46px; height: 5px; margin: 6px auto 14px; border-radius: 3px; background: var(--line2); touch-action: none; cursor: grab; }
.sheet-title { margin: 0 0 6px; font-size: 21px; line-height: 1.2; }
.sheet-text { margin: 0 0 14px; color: var(--ink2); white-space: pre-line; font-size: 15.5px; line-height: 1.5; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.bsheet .btn { min-height: 52px; border-radius: 16px; font-weight: 800; }
.bsheet .btn.danger { background: #b91c1c; color: #fff; border-color: transparent; }
.sheet-input { width: 100%; min-height: 54px; margin: 2px 0 10px; padding: 0 16px; border-radius: 16px; border: 1px solid var(--line2); background: var(--surface2); color: var(--ink); font: inherit; font-size: 17px; box-sizing: border-box; }
.results { max-height: 52vh; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.res-group { margin: 14px 4px 4px; font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink3); }
.res { display: block; padding: 11px 12px; border-radius: 14px; color: var(--ink); text-decoration: none; }
.res b { display: block; overflow-wrap: anywhere; font-size: 15.5px; }
.res span { display: block; color: var(--ink2); font-size: 13px; overflow-wrap: anywhere; }
.res.on, .res:active { background: rgba(var(--glow, 16, 229, 168), .14); }
.deskbtn { display: inline-grid; place-items: center; width: 44px; height: 44px; margin-left: auto; margin-right: 8px; border-radius: 14px; border: 1px solid var(--line2); background: var(--surface); color: var(--ink); cursor: pointer; }
.deskbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.deskbtn:active { transform: scale(.94); }
.offbar { position: sticky; top: 0; z-index: 40; padding: 8px 14px; text-align: center; font-size: 13.5px; font-weight: 700; background: #b45309; color: #fff; }
.offbar[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .bsheet, .sheet-back { transition: none; } }


/* ===== Drag to reorder ===== */
.upnext .item .grow { flex: 1; min-width: 0; }
.drag-handle { flex: none; width: 34px; min-height: 44px; margin-left: -6px; border: 0; border-radius: 10px; background: transparent; color: var(--ink3); font-size: 22px; line-height: 1; cursor: grab; touch-action: none; }
.drag-handle:active { cursor: grabbing; color: var(--teal); }
.upnext .item.dragging { position: relative; z-index: 6; background: var(--surface2); border-radius: 14px; box-shadow: 0 16px 34px rgba(0, 0, 0, .4); transition: none; }
.upnext .item.dragging .swipe-in { background: var(--surface2); }
.upnext .item.settling { transition: transform .18s ease; }
.ordernote { margin: 10px 0 0; }
.ordernote[hidden] { display: none; }


/* ===== Notes on a lead ===== */
.notes { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface2); padding: 0 12px; }
.notes > summary { cursor: pointer; font-weight: 700; padding: 12px 0; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.notes > summary::-webkit-details-marker { display: none; }
.notes > summary::after { content: "+"; color: var(--teal); font-size: 20px; }
.notes[open] > summary::after { content: "\2212"; }
.notes-body { padding-bottom: 12px; }
.notes-body textarea { width: 100%; min-height: 64px; box-sizing: border-box; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line2); background: var(--surface); color: var(--ink); font: inherit; font-size: 15.5px; resize: vertical; }
.notes-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0 8px; }
.nrow { display: flex; align-items: flex-start; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); background: var(--surface2); }
.nmain { flex: 1; min-width: 0; }
.ntext { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.45; }
.nwhen { color: var(--ink3); font-size: 12.5px; }
.nx { flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--ink3); font-size: 22px; line-height: 1; cursor: pointer; }
.nx:active { color: var(--bad); }
.nrow.swipe { border-radius: 10px; }
.deskbtn + .deskbtn { margin-left: 0; }


/* ===== First-time tour and one-time tips ===== */
.tour { position: fixed; inset: 0; z-index: 300; }
.tour.plain { background: rgba(0, 0, 0, .66); }
.tour-spot { position: fixed; display: none; border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .66), 0 0 0 3px var(--teal); transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease; pointer-events: none; }
.tour-card { position: fixed; left: 50%; transform: translateX(-50%); width: min(360px, calc(100vw - 24px)); box-sizing: border-box; padding: 16px 18px 14px; border-radius: 22px; background: var(--surface); color: var(--ink); border: 1px solid var(--line2); box-shadow: 0 24px 60px rgba(0, 0, 0, .5); transition: top .25s ease; }
.tour-card h2 { margin: 6px 0 6px; font-size: 21px; line-height: 1.2; }
.tour-card p { margin: 0 0 14px; color: var(--ink2); font-size: 15.5px; line-height: 1.5; }
.tour-dots { display: flex; gap: 6px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line2); }
.tour-dots i.on { background: var(--teal); width: 18px; border-radius: 4px; }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-actions .tour-next { margin-left: auto; min-width: 96px; }
.tour-actions .btn { min-height: 46px; border-radius: 14px; font-weight: 800; }
.tour-skip { min-height: 46px; padding: 0 6px; border: 0; background: transparent; color: var(--ink3); font: inherit; font-weight: 700; cursor: pointer; }
.tip { display: grid; gap: 4px; margin: 0 0 14px; padding: 14px 16px; border-radius: 18px; background: rgba(var(--glow, 16, 229, 168), .10); border: 1px solid rgba(var(--glow, 16, 229, 168), .45); }
.tip b { color: var(--teal); }
.tip p { margin: 0 0 6px; color: var(--ink); font-size: 15px; line-height: 1.5; }
.tip .btn { justify-self: start; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-card { transition: none; } }

/* keep the header on one line on a phone, even with the search and theme buttons */
.deskhead .area { white-space: nowrap; }
@media (max-width: 420px) {
  .deskhead { gap: 8px; }
  .deskhead .area { font-size: 10.5px; letter-spacing: .06em; }
  .deskbtn { width: 40px; height: 40px; margin-right: 6px; }
  .deskbtn + .deskbtn { margin-right: 8px; }
  .brand { font-size: 19px; gap: 8px; }
}
