/* Portal (body.app.portal) and operator console (body.app.ops). Uses the tokens in base.css.
   Owner: portal part A. Other builders: use these classes, put page-only extras in your own css file.

   ── SHELL (layout.js writes it; ops may reuse) ───────────────────────────────────────────────────────
   .shell > .side + .main-col          desktop sidebar + main column (sidebar hidden under 900px)
   .side-brand .side-group .side-group-label .side-link(.is-active) .side-foot
   .topbar .topbar-biz .topbar-lamp    phone top bar (dark). Hidden on desktop.
   .tabbar .tab-link(.is-active)       phone bottom tab bar. Hidden on desktop.
   .nav-count                          amber count pill inside any nav link
   .lamp.lamp-live|lamp-partial|lamp-off  the "Answering" indicator (.lamp-light is the bulb)
   .banner.banner-accent|warn|danger|quiet|neutral   full-width strip under the top bar
   .viewas-bar                         operator "viewing as" strip
   .app-main (.app-main-wide)          page content column; .page-head > .app-title + .page-actions
   .back-link                          "< Back to calls" link above the title
   body.ops                            operator console: same shell, dark sidebar, roomier tables
   .app-nav                            legacy simple top nav (horizontal scroller), kept for stubs

   ── PAGE PIECES ──────────────────────────────────────────────────────────────────────────────────────
   .section-head > h2 + a              a section title with a link on the right
   .chips > .chip(.is-active) .count  filter chips (links or buttons), scroll sideways on a phone
   .toolbar                            search box + buttons in one row (wraps on a phone)
   .search > input[type=search]        search field with an icon
   .tickets > .ticket                  list of job-ticket cards (calls, chats, leads, anything clickable)
     .ticket.tone-ok|danger|accent|info|neutral  coloured left edge; .ticket.is-unread bolds and dots it
     .ticket-main .ticket-top .ticket-who .ticket-when .ticket-what .ticket-meta .ticket-side
   .need-list > .need(.need-danger|.need-accent|.need-info)   "needs you" one-tap cards
   .dl > div > dt + dd                 definition list (label / value rows); .dl-2 two columns on desktop
   .kv                                 inline "label value" pairs in a wrapping row
   .timeline > .tl-item(.tl-call|.tl-chat|.tl-email|.tl-sms|.tl-note|.tl-stage|.tl-appt|.tl-alert)
     .tl-icon .tl-body .tl-title .tl-text .tl-time   vertical timeline with an icon per event
   .ladder > .ladder-step(.is-ok|.is-fail)   emergency ladder (who was rung, how long, result)
   .kanban > .kanban-col > .kanban-head + .kanban-body > .kanban-card   pipeline board
     (phone: one column per screen width, swipe sideways; desktop: all columns side by side)
     .kanban-col.is-drop (drag target), .kanban-card.is-dragging, .age-warn, .age-danger
   .form-section > .form-section-head + .form-section-body   a settings card that saves on its own
   .form-actions                       button row at the end of a form (sticky on a phone with .is-sticky)
   .switch > input[type=checkbox] + span   on/off toggle (a real checkbox, works without JS)
   .segmented > label > input[type=radio] + span   pick one of a few (tone, mode)
   .tag-list > .tag (> button.tag-x)   removable chips (towns, zips, "things we do not do")
   .copy-field > input|code + button[data-copy]   a value with a Copy button (app.js copies it)
   .big-tel                            the receptionist number as a huge tap-to-call button
   .welcome                            first-run hero card (dark)
   .numbers                            the receptionist number / code in big mono type
   .money-strip                        "won this month" totals strip
   .inline-form                        a form that sits in one row (input + button)
   .callout(.callout-warn|.callout-danger|.callout-ok)   boxed note with an icon
   .sheet > .sheet-backdrop + .sheet-panel   bottom sheet on a phone, centred modal on desktop
     open: button[data-sheet-open="id"]; close: [data-sheet-close]; also works as <dialog class="modal">
   .toast                              floating confirmation (app.js: window.RxToast('Copied'))
   .stand-in                           "stand-in mode" note (striped amber)
   .muted-box                          quiet grey box for small print
   [data-confirm="Are you sure?"]      on a form or button: app.js asks before submitting
   [data-autosubmit]                   on a select or checkbox: submits its form on change
   [data-reveal="id"]                  button that shows the element with that id (and hides itself)
*/

/* ═════════════════════════════════════ shell ═════════════════════════════════════ */
body.app { background: var(--bg); min-height: 100vh; min-height: 100dvh; }
body.app h1 { font-size: clamp(1.9rem, 6.5vw, 2.6rem); }
body.app h2 { font-size: clamp(1.35rem, 4.5vw, 1.7rem); }
body.app h3 { font-size: 1.2rem; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: var(--r-sm); font-weight: 700; }
.skip-link:focus { left: 8px; }
svg.icon.flip { transform: scaleX(-1); }

.shell { display: block; }
.main-col { min-width: 0; }
.side { display: none; }

/* phone top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top));
  background: var(--ink-900); color: #f5f2ea;
  border-bottom: 1px solid #000;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.topbar-biz { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; }
.topbar-biz span { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-biz img { flex: none; border-radius: 7px; }

/* the "Answering" lamp: a bulb in a recessed housing */
.lamp { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.lamp-light { flex: none; position: relative; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-600); box-shadow: 0 0 0 3px var(--ink-950), 0 0 0 4px #2f3339; }
.lamp-live .lamp-light { background: radial-gradient(circle at 35% 35%, #9bf5bf, #2ebd69 55%, #178a47); box-shadow: 0 0 0 3px var(--ink-950), 0 0 0 4px #2f3339, 0 0 14px 3px rgba(46, 189, 105, 0.55); }
.lamp-live .lamp-light::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; animation: lamp-breathe 2.4s ease-in-out infinite; }
@keyframes lamp-breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(46, 189, 105, 0.45); } 55% { box-shadow: 0 0 0 8px rgba(46, 189, 105, 0); } }
.lamp-partial .lamp-light { background: radial-gradient(circle at 35% 35%, #ffe7a3, var(--accent) 55%, var(--accent-700)); box-shadow: 0 0 0 3px var(--ink-950), 0 0 0 4px #2f3339, 0 0 12px 2px rgba(255, 176, 0, 0.45); }
.lamp-off .lamp-light { background: radial-gradient(circle at 35% 35%, #8b9099, var(--ink-600)); }
.topbar-lamp {
  flex: none; min-height: 40px; padding: 6px 12px 6px 10px; border-radius: 999px;
  background: var(--ink-950); border: 1px solid var(--ink-700); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6) inset;
  font-weight: 700; font-size: 0.86rem; white-space: nowrap;
}
.topbar-lamp.lamp-live { color: #9bf5bf; }
.topbar-lamp.lamp-partial { color: var(--accent-hi); }
.topbar-lamp.lamp-off { color: var(--ink-300); }
@media (max-width: 345px) { .topbar-lamp .lamp-label { display: none; } .topbar-lamp { padding: 6px 10px; min-width: 44px; justify-content: center; } }

/* account menu (details/summary: works without JS) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-button { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; border-radius: 50%; }
.avatar-sm { width: 34px; height: 34px; font-size: 0.82rem; background: var(--ink-700); color: var(--accent); border: 1px solid #000; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: min(290px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 6px;
}
.menu-head { display: grid; padding: 10px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 12px;
  border: 0; background: none; border-radius: var(--r-sm); color: inherit; font: 600 1rem var(--font);
  text-decoration: none; cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--paper-2); }
.logout-form { margin: 0; }

/* phone bottom tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--ink-900); border-top: 1px solid #000;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -8px 24px -12px rgba(0, 0, 0, 0.45);
}
.tab-link {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 62px; padding: 8px 4px 6px; border: 0; background: none; cursor: pointer;
  color: var(--ink-300); font: 600 0.78rem/1 var(--font); letter-spacing: 0.01em; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.tab-link::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: transparent; }
.tab-link.is-active { color: var(--accent); }
.tab-link.is-active::before { background: var(--accent); box-shadow: 0 0 10px rgba(255, 176, 0, 0.6); }
.tab-link:active { background: var(--ink-950); }
.tab-link .nav-count { position: absolute; top: 6px; left: calc(50% + 6px); }

.nav-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font: 800 0.74rem/1 var(--font); font-variant-numeric: tabular-nums; border: 2px solid var(--ink-900);
}

/* banners under the top bar */
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 10px 16px; font-weight: 600; font-size: 0.95rem; border-bottom: 1px solid var(--border); }
.banner-text { flex: 1 1 220px; }
.banner-accent { background: var(--accent-soft); color: #5a3a00; border-color: #f2dc9c; }
.banner-warn { background: var(--warn-soft); color: #7a3e00; border-color: #f3d3a2; }
.banner-danger { background: var(--danger-soft); color: #8f1f10; border-color: #f2c2b9; }
.banner-quiet { background: var(--paper-2); color: var(--text-2); font-weight: 500; }
.banner-neutral { background: var(--paper-3); color: var(--ink-700); }
.viewas-bar { position: relative; z-index: 35; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 8px 16px; background: repeating-linear-gradient(135deg, var(--ink-700) 0 12px, var(--ink-800) 12px 24px); color: #fff; font-weight: 600; font-size: 0.92rem; border-bottom: 2px solid var(--accent); }
.viewas-bar form { margin: 0; }

/* main column */
.app-main { width: 100%; max-width: 1040px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.app-main-wide { max-width: 1400px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 16px; margin: 4px 0 16px; }
.app-title { margin: 0; line-height: 1.02; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; color: var(--text-2); text-decoration: none; }
.back-link:hover { color: var(--text); }

/* More sheet (and any sheet/modal) */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none !important; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(12, 13, 15, 0.55); }
.sheet-panel {
  position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--paper); color: var(--text); border-radius: 22px 22px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: sheet-up 0.2s ease-out;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 44px; height: 5px; border-radius: 999px; background: var(--line-strong); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 1.1rem; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-link {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: 0 2px 0 var(--line);
  color: var(--text); font: 600 1rem/1.15 var(--font); text-decoration: none; cursor: pointer; width: 100%; text-align: left;
}
.sheet-link svg { color: var(--ink-600); }
.sheet-link.is-active { border-color: var(--ink-900); box-shadow: 0 2px 0 var(--ink-900); }
.sheet-link .nav-count { margin-left: auto; border-color: var(--surface); }
.sheet-logout { margin-top: 10px; justify-content: center; color: var(--text-2); }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-panel { border-radius: 22px; padding-bottom: 18px; } }
dialog.modal { border: 0; padding: 20px; border-radius: 18px; background: var(--paper); color: var(--text); width: min(560px, calc(100vw - 24px)); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(12, 13, 15, 0.55); }
.noscript-nav { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 16px 90px; }

/* desktop: sidebar, no tab bar */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
  .side {
    display: flex; flex-direction: column; gap: 14px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 16px 12px; background: var(--paper-2); border-right: 1px solid var(--line);
  }
  .topbar, .tabbar, .more-sheet { display: none !important; }
  .app-main { padding: 24px 32px 56px; }
  .page-head { margin-top: 8px; }
  .noscript-nav { display: none; }
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; text-decoration: none; color: var(--text); }
.side-brand img { border-radius: 8px; flex: none; }
.side-brand-name { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; line-height: 1.05; }
.side-lamp {
  align-items: flex-start; padding: 12px; border-radius: var(--r);
  background: var(--ink-900); color: #f5f2ea; box-shadow: 0 2px 0 #000;
}
.side-lamp .lamp-light { margin-top: 5px; }
.side-lamp .lamp-text { display: grid; gap: 2px; }
.side-lamp strong { font-size: 0.98rem; }
.side-lamp.lamp-live strong { color: #9bf5bf; }
.side-lamp.lamp-partial strong { color: var(--accent-hi); }
.lamp-hint { font-size: 0.8rem; line-height: 1.35; color: #c9c5ba; }
.side-nav { display: grid; gap: 14px; }
.side-group { display: grid; gap: 2px; }
.side-group-label { padding: 0 10px 4px; font-size: 0.8rem; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
.side-link {
  position: relative; display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 8px 10px;
  border: 0; background: none; border-radius: var(--r-sm); width: 100%;
  color: var(--ink-700); font: 600 0.98rem/1.1 var(--font); text-decoration: none; cursor: pointer; text-align: left;
}
.side-link svg { color: var(--ink-500); }
.side-link:hover { background: var(--paper-3); color: var(--text); }
.side-link.is-active { background: var(--ink-900); color: #fff; box-shadow: 0 2px 0 #000; }
.side-link.is-active svg { color: var(--accent); }
.side-link .nav-count { margin-left: auto; border-color: var(--paper-2); }
.side-link.is-active .nav-count { border-color: var(--ink-900); }
.side-foot { margin-top: auto; display: grid; gap: 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 4px 10px; font-weight: 600; font-size: 0.92rem; }
.side-user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* legacy simple nav (stub layouts) */
.app-nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; background: var(--ink-900); scrollbar-width: none; }
.app-nav::-webkit-scrollbar { display: none; }
.app-nav a { flex: none; padding: 10px 14px; min-height: 44px; display: inline-flex; align-items: center; border-radius: var(--r-sm); color: #d7d3c8; font-weight: 600; text-decoration: none; }
.app-nav a.is-active { background: var(--ink-700); color: var(--accent); }

/* ═════════════════════════════════════ operator console ═════════════════════════════════════ */
body.ops .side { background: var(--ink-900); border-right-color: #000; color: #f5f2ea; }
body.ops .side-brand { color: #fff; }
body.ops .side-group-label { color: #8b9099; }
body.ops .side-link { color: #c9c5ba; }
body.ops .side-link svg { color: #8b9099; }
body.ops .side-link:hover { background: var(--ink-800); color: #fff; }
body.ops .side-link.is-active { background: var(--ink-700); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
body.ops .side-link.is-active svg { color: var(--accent); }
body.ops .side-link .nav-count { border-color: var(--ink-900); }
body.ops .side-foot { border-top-color: var(--ink-700); }
body.ops .side-user { color: #d7d3c8; }
body.ops .side-lamp { background: var(--ink-950); }
body.ops .app-main { max-width: 1400px; }
body.ops .table td { padding: 11px 14px; }

/* ═════════════════════════════════════ page pieces ═════════════════════════════════════ */
/* thumb-sized everywhere in the app: small buttons and tabs still get a 44px target */
body.app .btn-sm { min-height: 44px; }
body.app .tab { min-height: 44px; display: inline-flex; align-items: center; }
tr.row-unread td:first-child a { font-weight: 800; }
.block { margin: 0 0 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.section-head h2 { margin: 0; }
.section-head a { font-weight: 600; font-size: 0.95rem; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; }
.sub-head { font-family: var(--font); font-weight: 700; font-size: 1.05rem; margin: 0 0 8px; }

/* filter chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px 12px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 16px;
  border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--surface);
  color: var(--ink-700); font: 600 0.95rem/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--ink-500); }
.chip.is-active { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }
.chip .count { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.is-active .count { color: var(--accent); }
@media (min-width: 900px) { .chips { flex-wrap: wrap; overflow: visible; } }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar > .search { flex: 1 1 240px; }
.search { position: relative; margin: 0; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input[type="search"] { padding-left: 44px; }

/* job-ticket cards */
.tickets { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ticket {
  --edge: var(--line-strong);
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px 12px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: 0 2px 0 var(--line); color: var(--text); text-decoration: none; overflow: hidden;
}
.ticket::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--edge); }
a.ticket:hover, .ticket.is-link:hover { border-color: var(--line-strong); background: #fffdf8; }
a.ticket:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--line); }
.ticket.tone-ok { --edge: var(--ok); }
.ticket.tone-danger { --edge: var(--danger); }
.ticket.tone-accent { --edge: var(--accent); }
.ticket.tone-warn { --edge: var(--warn); }
.ticket.tone-info { --edge: var(--info); }
.ticket.tone-neutral { --edge: var(--ink-300); }
.ticket-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.ticket-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ticket-who { display: block; font-weight: 700; padding-right: 2px; font-size: 1.06rem; line-height: 1.25; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-who svg { color: var(--muted); vertical-align: -2px; margin-right: 5px; }
.ticket-when { flex: none; font-size: 0.86rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ticket-what { color: var(--text-2); font-size: 0.97rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 4px; font-size: 0.86rem; color: var(--muted); }
.ticket-meta .badge { font-size: 0.76rem; }
.ticket-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ticket.is-unread .ticket-who::after { content: "New"; display: inline-block; vertical-align: 2px; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font: 800 0.72rem/1.5 var(--font); letter-spacing: 0.02em; }
.ticket.is-unread { background: #fffdf6; }
.ticket.is-muted { opacity: 0.72; }
.ticket .mini-play { position: relative; z-index: 2; }
.ticket-link-cover { position: absolute; inset: 0; z-index: 1; }
.ticket-link-cover:focus-visible { outline-offset: -3px; }
.age { font-weight: 700; }
.age-fresh { color: var(--accent-700); }
.age-late { color: var(--danger); }
.mini-play { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--accent-ink); background: linear-gradient(180deg, var(--accent-hi), var(--accent)); box-shadow: 0 3px 0 var(--accent-700); }
.mini-play:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-700); }
.mini-player audio { display: none; }
.icon-moon { color: var(--ink-500); }

/* "needs you" cards */
.need-list { display: grid; gap: 8px; }
.need {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: 0 2px 0 var(--line);
  text-decoration: none; color: var(--text);
}
.need:active { transform: translateY(1px); }
.need-icon { flex: none; width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--paper-2); color: var(--ink-700); }
.need-body { flex: 1; min-width: 0; display: grid; gap: 1px; }
.need-title { font-weight: 700; font-size: 1.04rem; line-height: 1.25; }
.need-text { font-size: 0.92rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.need-go { flex: none; color: var(--muted); }
.need-danger { border-color: #f2c2b9; background: #fff8f6; }
.need-danger .need-icon { background: var(--danger); color: #fff; }
.need-accent .need-icon { background: var(--accent); color: var(--accent-ink); }
.need-info .need-icon { background: var(--info-soft); color: var(--info); }
.need-ok { background: var(--ok-soft); border-color: #bfe5cd; }
.need-ok .need-icon { background: var(--ok); color: #fff; }

/* definition list */
.dl { margin: 0; display: grid; }
.dl > div { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); font-weight: 600; font-size: 0.92rem; }
.dl dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (min-width: 900px) { .dl-2 { grid-template-columns: 1fr 1fr; column-gap: 28px; } .dl-2 > div:nth-last-child(2):nth-child(odd) { border-bottom: 0; } }
.kv { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.95rem; }
.kv span { color: var(--muted); margin-right: 4px; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 19px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.tl-item { position: relative; display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 8px 0; }
.tl-icon { position: relative; z-index: 1; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); border: 2px solid var(--line-strong); color: var(--ink-600); }
.tl-body { min-width: 0; padding-top: 2px; }
.tl-title { font-weight: 700; line-height: 1.3; }
.tl-text { color: var(--text-2); font-size: 0.95rem; margin-top: 2px; overflow-wrap: anywhere; }
.tl-time { color: var(--muted); font-size: 0.84rem; margin-top: 2px; }
.tl-call .tl-icon { border-color: var(--accent-600); color: var(--accent-700); }
.tl-chat .tl-icon { border-color: var(--info); color: var(--info); }
.tl-email .tl-icon, .tl-sms .tl-icon { border-color: var(--ink-500); }
.tl-note .tl-icon { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-700); }
.tl-stage .tl-icon { border-color: var(--ink-900); color: var(--ink-900); }
.tl-appt .tl-icon { border-color: var(--ok); color: var(--ok); }
.tl-alert .tl-icon { border-color: var(--danger); color: var(--danger); }

/* emergency ladder */
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ladder-step { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r-sm); background: var(--paper-2); border: 1px solid var(--border); }
.ladder-n { width: 32px; height: 32px; border-radius: 50%; background: var(--ink-900); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; }
.ladder-step.is-ok { background: var(--ok-soft); border-color: #bfe5cd; }
.ladder-step.is-fail { background: var(--danger-soft); border-color: #f2c2b9; }
.ladder-step.is-skip { background: var(--paper); border-style: dashed; border-color: var(--line-strong); }
.ladder-step > span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }
.ladder-why { color: var(--warn); font-weight: 600; }
.ladder-summary { margin: -4px 0 10px; }

/* pipeline board */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: calc(100% - 28px); gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.kanban-col { scroll-snap-align: start; display: flex; flex-direction: column; min-width: 0; background: var(--paper-2); border: 1px solid var(--border); border-radius: var(--r-lg); }
.kanban-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; }
.kanban-head h3 { margin: 0; font-family: var(--font); font-size: 1rem; font-weight: 700; }
.kanban-head .count { color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.kanban-total { padding: 0 14px 8px; font-size: 0.86rem; color: var(--muted); font-weight: 600; }
.kanban-body { display: grid; gap: 8px; padding: 0 10px 12px; min-height: 80px; align-content: start; }
.kanban-card { display: grid; gap: 4px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: 0 2px 0 var(--line); color: var(--text); text-decoration: none; }
.kanban-card .name { font-weight: 700; }
.kanban-card .need { min-height: 0; padding: 0; border: 0; box-shadow: none; background: none; }
.kanban-card select { min-height: 40px; padding: 6px 34px 6px 10px; font-size: 0.92rem; }
.kanban-col.is-drop { outline: 3px dashed var(--accent); outline-offset: -3px; }
.kanban-card.is-dragging { opacity: 0.5; }
.age-warn { color: var(--warn); font-weight: 700; }
.age-danger { color: var(--danger); font-weight: 700; }
@media (min-width: 900px) { .kanban { grid-auto-columns: minmax(250px, 1fr); scroll-snap-type: none; } }

/* forms */
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden; }
.form-section-head { padding: 16px 18px 4px; }
.form-section-head h2, .form-section-head h3 { margin: 0 0 4px; font-family: var(--font); font-weight: 700; font-size: 1.15rem; line-height: 1.25; }
.form-section-head p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.form-section-body { padding: 12px 18px 18px; }
.form-section-body > .field:last-child { margin-bottom: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 4px; }
.form-actions.is-sticky { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 5; padding: 10px; margin: 0 -10px; background: linear-gradient(180deg, rgba(250, 248, 244, 0), var(--paper) 30%); }
@media (min-width: 900px) { .form-actions.is-sticky { bottom: 0; } }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 0; }
.inline-form > .field { flex: 1 1 160px; margin: 0; }
.inline-form input { min-width: 0; }
form.as-button { display: inline; margin: 0; }

.switch { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch > span:first-of-type { position: relative; flex: none; width: 52px; height: 30px; border-radius: 999px; background: var(--ink-300); box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.18); transition: background 0.15s ease; }
.switch > span:first-of-type::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3); transition: transform 0.15s ease; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 0; padding: 4px; background: var(--paper-3); border-radius: var(--r); }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: inline-flex; align-items: center; min-height: 42px; padding: 8px 16px; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--ink-700); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 0 var(--line-strong), 0 2px 6px -2px rgba(0, 0, 0, 0.2); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tag { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 2px 2px 2px 14px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line-strong); font-weight: 600; font-size: 0.92rem; }
.tag-x { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; cursor: pointer; color: var(--muted); }
.tag-x:hover { background: var(--paper-3); color: var(--danger); }

.copy-field { display: flex; gap: 8px; align-items: stretch; }
.copy-field > input, .copy-field > code, .copy-field > pre { flex: 1; min-width: 0; }
.copy-field > code, .copy-field > pre { display: block; margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--ink-900); color: #f5f2ea; font-family: var(--font-mono); font-size: 0.86rem; overflow-x: auto; white-space: pre; }

.big-tel {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 72px; padding: 14px 20px;
  font-family: var(--font-display); font-weight: 800; font-size: clamp(1.7rem, 7.5vw, 2.3rem); letter-spacing: 0.02em; font-variant-numeric: tabular-nums;
}
.numbers { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.6rem, 6vw, 2.2rem); letter-spacing: 0.03em; font-variant-numeric: tabular-nums; }

.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--info-soft); color: #22394d; border: 1px solid #cfdbe5; }
.callout > svg { margin-top: 2px; }
.callout-warn { background: var(--warn-soft); color: #6b3600; border-color: #f3d3a2; }
.callout-danger { background: var(--danger-soft); color: #7e1b0e; border-color: #f2c2b9; }
.callout-ok { background: var(--ok-soft); color: #0e5c30; border-color: #bfe5cd; }
.stand-in { padding: 12px 14px; border-radius: var(--r); border: 1.5px dashed var(--accent-700); background: repeating-linear-gradient(135deg, var(--accent-soft) 0 14px, #fff9e8 14px 28px); color: #4f3300; }
.stand-in strong { display: block; margin-bottom: 4px; }
.muted-box { padding: 12px 14px; border-radius: var(--r); background: var(--paper-2); color: var(--text-2); font-size: 0.92rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 80; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 999px; background: var(--ink-900); color: #fff;
  font-weight: 600; box-shadow: var(--shadow-lg); animation: toast-in 0.18s ease-out;
}
.toast.is-ok::before { content: "\2713  "; color: #9bf5bf; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ═════════════════════════════════════ Today ═════════════════════════════════════ */
.welcome { position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 22px 18px 20px; margin-bottom: 24px; background: var(--ink-900); color: #f5f2ea; box-shadow: var(--shadow); }
.welcome::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 176, 0, 0.28), rgba(255, 176, 0, 0) 70%); pointer-events: none; }
.welcome h2 { color: #fff; margin: 0 0 6px; font-size: clamp(1.7rem, 6vw, 2.3rem); }
.welcome p { color: #c9c5ba; margin: 0 0 14px; }
.welcome .muted { color: #9b9a94; }
.welcome a.alt { color: var(--accent); font-weight: 700; }
.welcome .steps > li { background: var(--ink-800); border-color: var(--ink-700); color: #f5f2ea; }
.welcome .steps > li::before { background: var(--accent); color: var(--accent-ink); }
.welcome .steps > li.is-done { color: #9b9a94; }
.welcome .steps > li.is-done::before { background: var(--ok); color: #fff; }
.welcome .steps > li.is-next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.welcome .steps a { color: inherit; font-weight: 700; }
.step-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.welcome .progress { background: var(--ink-700); margin: 4px 0 14px; }

/* "Calls you would have missed" during the free month: the first and biggest number on Today. */
.missed-hero { position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 20px 18px 18px; background: var(--ink-900); color: #f5f2ea; box-shadow: var(--shadow); border-top: 4px solid var(--accent); }
.missed-title { margin: 0; font-family: var(--font); font-size: 1.05rem; font-weight: 700; letter-spacing: 0.01em; color: #c9c5ba; }
.missed-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 2px 0 6px; }
.missed-n { font-family: var(--font-display); font-weight: 800; font-size: clamp(4rem, 22vw, 6.5rem); line-height: 0.95; color: var(--accent); font-variant-numeric: tabular-nums; }
.missed-money { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.5rem, 6.5vw, 2.1rem); line-height: 1.1; color: #fff; }
.missed-why { margin: 0 0 14px; font-size: 1.05rem; color: #f5f2ea; max-width: 34em; }
.missed-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 0; padding-top: 12px; border-top: 1px solid var(--ink-700); font-size: 0.92rem; color: #c9c5ba; }
.missed-foot .btn { min-height: 48px; }
.missed-ok { display: inline-flex; align-items: center; gap: 6px; color: #9bf5bf; font-weight: 600; }
.missed-more { margin: 10px 0 0; font-size: 0.92rem; }
.missed-more a { color: var(--accent-hi); font-weight: 700; }
.stats-today .stat-missed { grid-column: 1 / -1; }
.stats-today .stat-missed .stat-value { color: var(--accent-700); }
.today-greeting { margin: -6px 0 18px; color: var(--text-2); font-size: 1.02rem; }
.stats-today { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats-today .stat { padding: 12px; min-width: 0; }
.stats-today .stat-value { font-size: clamp(1.7rem, 7vw, 2.4rem); }
.stats-today .stat-accent { grid-column: 1 / -1; }
.stats-today .stat-accent .stat-value { font-size: clamp(2rem, 9vw, 2.6rem); }
.stats-today .stat-accent a { color: var(--accent-hi); }
@media (min-width: 900px) {
  .stats-today { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.5fr); gap: 12px; }
  .stats-today .stat { padding: 16px; }
  .stats-today .stat-accent { grid-column: auto; }
}
.chart-card { padding: 16px 14px 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.86rem; color: var(--muted); margin-top: 10px; }
.chart-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-legend .k-day { background: var(--accent); }
.chart-legend .k-night { background: var(--ink-800); }
.appt-row { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); text-decoration: none; color: var(--text); }
.appt-date { text-align: center; border-radius: 10px; background: var(--ink-900); color: #fff; padding: 6px 4px; line-height: 1.1; }
.appt-date .d { display: block; font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; color: var(--accent); }
.appt-date .m { font-size: 0.75rem; font-weight: 700; color: #c9c5ba; }
.blocked-line { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r); background: var(--paper-2); color: var(--text-2); }
.blocked-line strong { color: var(--text); }
.money-strip { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: baseline; padding: 14px 16px; margin-bottom: 14px; border-radius: var(--r); background: var(--ink-900); color: #f5f2ea; }
.money-strip .big { font-family: var(--font-display); font-weight: 800; font-size: 2rem; color: var(--accent); line-height: 1; }
.money-strip .label { color: #c9c5ba; font-size: 0.92rem; }

/* ═════════════════════════════════════ call page ═════════════════════════════════════ */
.call-hero { padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: 16px; position: relative; overflow: hidden; }
.call-hero::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 5px; background: var(--edge, var(--line-strong)); }
.call-hero.tone-ok { --edge: var(--ok); }
.call-hero.tone-danger { --edge: var(--danger); }
.call-hero.tone-accent { --edge: var(--accent); }
.call-hero.tone-info { --edge: var(--info); }
.call-summary { font-size: 1.15rem; line-height: 1.45; font-weight: 500; margin: 8px 0 12px; }
.call-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.call-actions .btn { min-height: 56px; padding: 8px 6px; flex-direction: column; gap: 4px; font-size: 0.92rem; }
.call-actions form { margin: 0; display: contents; }
.call-actions form .btn { width: 100%; }
.composer { margin-top: 12px; }
.composer textarea { min-height: 90px; }
.two-col { display: grid; gap: 16px; }
@media (min-width: 980px) { .two-col { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; } }
.stack-cards { display: grid; gap: 16px; align-content: start; }
.small-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.small-actions form { margin: 0; }
.gap-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.gap-item:last-child { border-bottom: 0; }
.contact-card { display: flex; gap: 12px; align-items: center; }
.contact-card .avatar { width: 48px; height: 48px; font-size: 1.05rem; }

/* ═════════════════════════════════════ leads ═════════════════════════════════════ */
.lead-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; position: relative; z-index: 2; }
.lead-actions form { margin: 0; }
.lead-actions .btn { min-height: 44px; }
.won-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; position: relative; z-index: 2; }
.won-form .money-input { position: relative; flex: 1 1 140px; max-width: 200px; }
.won-form .money-input::before { content: "$"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--muted); }
.won-form .money-input input { padding-left: 28px; }
.lead-value { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; line-height: 1; white-space: nowrap; }

/* ═════════════════════════════════════ sign-in pages ═════════════════════════════════════ */
body.bare { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: var(--paper); }
.bare-head { padding: 18px 16px 6px; display: flex; justify-content: center; }
.bare-logo img { height: 34px; width: auto; }
.bare-main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 16px; }
.bare-narrow { max-width: 460px; }
.bare-foot { text-align: center; padding: 18px 16px 24px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 22px 18px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: clamp(1.9rem, 7vw, 2.4rem); margin-bottom: 6px; }
.auth-card .lead { font-size: 1.02rem; margin-bottom: 18px; }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.9rem; margin: 18px 0; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.demo-logins { margin-top: 16px; }
.demo-logins table { width: 100%; font-size: 0.92rem; border-collapse: collapse; }
.demo-logins td { padding: 8px 4px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.demo-logins tr:last-child td { border-bottom: 0; }
.demo-logins .fill { min-height: 40px; }
.link-box { word-break: break-all; font-family: var(--font-mono); font-size: 0.9rem; padding: 10px 12px; background: var(--surface); border-radius: var(--r-sm); border: 1px solid var(--line-strong); display: block; margin: 8px 0 10px; }
.pw-field { position: relative; }
.pw-field input { padding-right: 76px; }
.pw-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); min-height: 44px; min-width: 60px; padding: 4px 10px; border: 0; background: none; font: 600 0.9rem var(--font); color: var(--text-2); cursor: pointer; border-radius: 8px; }
.pw-toggle:hover { background: var(--paper-2); }

/* ═════════════════════════════════════ print ═════════════════════════════════════ */
@media print {
  .topbar, .tabbar, .side, .sheet, .banner, .viewas-bar, .page-actions, .call-actions, .small-actions, .back-link { display: none !important; }
  .shell { display: block; }
  .app-main { padding: 0; max-width: none; }
  body.app { background: var(--card); }
}
@media (prefers-reduced-motion: reduce) {
  .lamp-live .lamp-light::after, .sheet-panel, .toast { animation: none; }
}

/* ═════════════════════════════════════ 360px safety ═════════════════════════════════════
   Long unbroken strings (emails, web addresses, phone codes) wrap instead of pushing the page sideways,
   and wide tables scroll inside their box. */
.app-main { overflow-wrap: break-word; }
.need-body, .tl-body { overflow-wrap: anywhere; }
.app-main .kbd { white-space: normal; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 720px) { table.table-cards td { overflow-wrap: anywhere; } }
.app-main img, .app-main video, .app-main iframe { max-width: 100%; }

/* ═════════════════════════════════════ fix pass: review of the portal (visual-portal.md) ═════════════════════════════════════ */

/* S18: the business name fits on a phone. Under 430px the lamp is a bulb and one word ("On"). */
.lamp-tiny { display: none; }
@media (max-width: 430px) {
  .topbar { gap: 8px; padding-left: 10px; padding-right: 8px; }
  .topbar-biz { gap: 7px; }
  .topbar-biz span { font-size: 1.14rem; }
  .topbar-lamp { padding: 6px 11px 6px 9px; gap: 7px; }
  .topbar-lamp .lamp-label { display: none; }
  .topbar-lamp .lamp-tiny { display: inline; }
}

/* S4: a chip row that scrolls sideways on a phone shows that it does: room at the end and a fade at the edge. */
@media (max-width: 899px) {
  .chips { padding-right: 28px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent); }
}

/* S13: no light blue or slate. Neutral states use the paper chip; new = amber, booked/done = green, emergency = red. */
body.app .badge-info { background: var(--paper-3); color: var(--ink-700); }
body.app .ticket.tone-info, body.app .ticket.tone-neutral { --edge: var(--ink-300); }
body.app .call-hero.tone-info, body.app .call-hero.tone-neutral { --edge: var(--ink-300); }
body.app .callout { background: var(--paper-2); color: var(--text); border-color: var(--line); }
body.app .callout-warn { background: var(--warn-soft); color: #6b3600; border-color: #f3d3a2; }
body.app .callout-danger { background: var(--danger-soft); color: #7e1b0e; border-color: #f2c2b9; }
body.app .callout-ok { background: var(--ok-soft); color: #0e5c30; border-color: #bfe5cd; }
body.app .need-info .need-icon { background: var(--paper-3); color: var(--ink-700); }
body.app .tl-chat .tl-icon { border-color: var(--ink-500); color: var(--ink-600); }

/* P13: every card heading in the headline face, like the page titles. */
body.app .card-title, body.app .set-title, body.app .form-section-head h2, body.app .section-head h2, body.app .sub-head {
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0.005em; line-height: 1.1;
}
body.app .card-title { font-size: 1.4rem; }
body.app .form-section-head h2 { font-size: 1.4rem; }
body.app .form-section-head h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
body.app .sub-head { font-size: 1.35rem; }

/* P12: on a computer, helper text 14px, chips 13px, table headers readable. */
@media (min-width: 900px) {
  body.app .hint, body.app .small, body.app .ticket-meta, body.app .tl-time, body.app .muted-box { font-size: 0.875rem; }
  body.app .badge, body.app .ticket-meta .badge { font-size: 0.8125rem; }
  body.app .table th { font-size: 0.8125rem; letter-spacing: 0.05em; }
}

/* Phone numbers never break in half. */
.tel { white-space: nowrap; word-spacing: 0.08em; }

/* ── Calls list (M8, P2, P3) ── */
.inbox-table .col-who { min-width: 190px; width: 24%; }
.inbox-table .col-who .row-link { white-space: nowrap; }
.inbox-table .col-result { width: 1%; white-space: nowrap; }
.inbox-table .col-when { width: 1%; }
.inbox-table .col-result .cluster { flex-wrap: nowrap; }
tr.row-unread td { background: #fffdf6; }
tr.row-unread .col-what { color: var(--text); font-weight: 600; }
.new-pill { display: inline-block; vertical-align: 1px; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font: 800 0.72rem/1.5 var(--font); }
.calls-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 16px 0 4px; }
.calls-pager-btns { display: flex; gap: 8px; margin-left: auto; }
@media (max-width: 520px) { .calls-pager-range { display: none; } }
.calls-hidden { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 14px 0 0; }

/* ── One call: the recording and every word of it ── */
.call-meta { margin: 0 0 14px; }
.call-meta > span { color: var(--muted); margin-right: 0; }
.call-rec-title { margin-bottom: 10px; }
.call-page .player { overflow: clip; }
.call-page .player-bar { position: sticky; top: 56px; z-index: 6; }
@media (min-width: 900px) { .call-page .player-bar { top: 0; } }
.call-page .transcript { max-height: none; overflow: visible; padding: 16px 14px 18px; gap: 12px; }
.call-page .turn { max-width: 92%; font-size: 1.02rem; line-height: 1.45; }
.call-page .turn-who { display: flex; align-items: baseline; gap: 8px; font-size: 0.74rem; opacity: 0.75; }
.turn-at { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: 0.02em; opacity: 0.85; text-transform: none; }
.call-page .turn[data-start]:not([data-start=""]) { cursor: pointer; }
.player-speed { flex: none; min-width: 48px; min-height: 40px; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--ink-600); background: transparent; color: #f5f2ea; font: 700 0.86rem var(--font); cursor: pointer; font-variant-numeric: tabular-nums; }
.player-speed:hover { border-color: var(--accent); color: var(--accent-hi); }
.call-page .player-none { align-items: flex-start; line-height: 1.4; }
.call-page .player-none svg { flex: none; margin-top: 2px; }
.transcript-none { padding: 14px; margin: 0; }
.message-box { margin: 10px 0 14px; padding: 14px 16px; border-radius: var(--r); background: var(--paper-2); border: 1px solid var(--line); border-left: 5px solid var(--accent); }
.message-from { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 6px; font-size: 1rem; }
.message-from svg { color: var(--accent-700); }
.message-text { margin: 0; font-size: 1.2rem; line-height: 1.45; font-weight: 600; color: var(--text); }
.private-link { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 999px; background: var(--paper-3); color: var(--ink-700); font-weight: 600; font-size: 0.92em; text-decoration: none; white-space: nowrap; }
.private-link:hover { background: var(--accent-soft); color: var(--text); }
/* the emergency ladder on a phone: the result sits on top of the words, not squeezed beside them */
@media (max-width: 640px) {
  .ladder-step { grid-template-columns: 32px 1fr; align-items: start; }
  .ladder-step > strong { grid-column: 2; grid-row: 1; justify-self: start; padding: 1px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
  .ladder-step > span:nth-child(2) { grid-column: 2; }
  .ladder-step .ladder-n { grid-row: 1 / span 2; align-self: start; }
}

/* ── Lab tools: the stand-in controls, one collapsed box at the bottom, never in the customer's screen ── */
.lab-tools { margin: 40px 0 8px; border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: var(--paper-2); color: var(--text-2); }
.lab-tools > summary { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 14px; cursor: pointer; font-weight: 700; font-size: 0.92rem; list-style: none; color: var(--ink-600); }
.lab-tools > summary::-webkit-details-marker { display: none; }
.lab-tools > summary::after { content: "Show"; margin-left: auto; font-weight: 600; color: var(--muted); }
.lab-tools[open] > summary::after { content: "Hide"; }
.lab-tools-body { padding: 0 14px 14px; display: grid; gap: 12px; }
.lab-tools-body > p { margin: 0; }
.lab-tool { padding: 12px; border-radius: var(--r-sm); background: var(--card); border: 1px solid var(--line); }
.lab-tool-title { margin: 0 0 6px; font-family: var(--font); font-size: 1rem; font-weight: 700; }
.lab-tool .cluster { margin-top: 8px; }
.lab-tool form { margin: 0; }
body.bare .lab-tools { margin-top: 24px; }

/* ── Schedule: the week at a glance (P14), two buttons per job (S8), the private calendar link (M5) ── */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 0 0 18px; }
.week-day { display: grid; justify-items: center; gap: 1px; padding: 8px 2px; min-height: 64px; border-radius: var(--r-sm); background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--text); text-align: center; }
.week-day:hover { border-color: var(--ink-500); }
.week-day-name { font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.week-day-num { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; line-height: 1.05; }
.week-day-n { font-size: 0.72rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.week-day.has-jobs { border-color: var(--ink-900); box-shadow: 0 2px 0 var(--ink-900); }
.week-day.has-jobs .week-day-n { color: var(--ok); font-weight: 800; }
.week-day.is-today { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }
.week-day.is-today .week-day-name { color: var(--accent); }
.week-day.is-today .week-day-n { color: #d7d3c8; }
.week-day.is-today.has-jobs .week-day-n { color: #9bf5bf; }
@media (min-width: 900px) { .week-day { padding: 10px 6px; } .week-day-n { font-size: 0.8125rem; } }
.crm-day { scroll-margin-top: 70px; }
body.app .crm-job-actions { align-items: flex-start; }
.job-more { position: static; }
.job-more > summary { list-style: none; }
.job-more > summary::-webkit-details-marker { display: none; }
.job-more[open] { flex-basis: 100%; }
.job-more .job-more-panel { position: static; width: 100%; margin-top: 6px; box-shadow: none; display: grid; gap: 2px; }
.job-more .job-more-panel form { margin: 0; }
@media (min-width: 900px) {
  body.app .crm-job-addr, body.app .crm-job-tel { min-height: 30px; }
  body.app .crm-job .ticket-meta { margin-top: 2px; }
}
.private-link-row .btn { flex: 0 1 auto; }
.feed-rotate { margin-top: 12px; }
.feed-rotate .btn-link { min-height: 44px; padding: 0; color: var(--text-2); }

/* ── Follow-up: "Email" or "Text" in words, and a "Read the email" button that looks tappable (S15) ── */
.chan-chip { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; padding: 1px 8px; border-radius: 999px; background: var(--paper-3); color: var(--ink-700); font: 700 0.78rem/1.6 var(--font); vertical-align: 1px; }
.chan-chip svg { color: var(--ink-500); }
.chan-sms { background: var(--accent-soft); color: #6b4500; }
body.app .peek { margin-top: 6px; position: relative; z-index: 2; }
body.app .peek > summary.peek-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--card); color: var(--ink-700); font-weight: 700; font-size: 0.9rem; cursor: pointer; list-style: none; }
body.app .peek > summary.peek-btn::-webkit-details-marker { display: none; }
body.app .peek > summary.peek-btn::after { content: none; }
body.app .peek > summary.peek-btn:hover { border-color: var(--ink-500); }
.peek-close { display: none; }
.peek[open] .peek-open { display: none; }
.peek[open] .peek-close { display: inline; }

/* ── Phone setup: the "no codes" card label sits left with one marker on the right ── */
body.app .alt-card > summary { justify-content: space-between; text-align: left; }
.sum-label { display: inline-flex; align-items: center; gap: 8px; text-align: left; }
.sum-label svg { flex: none; }

/* Calls: "Summary pending" chip and the small speaker on calls that have audio. */
.summary-pending { white-space: nowrap; }
.icon-speaker { vertical-align: -2px; color: var(--muted, currentColor); }
