/* Shared pieces for the owner dashboard and staff portal: pop-ups, toast Undo, "How is this calculated?"
   notes, avatars, tables, change badges. Uses only the design tokens from style.css. */

.toast .toast-undo {
  margin-left: 12px; padding: 4px 10px; min-height: 32px;
  background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 0;
  font: 700 13px/1 var(--sans); text-transform: uppercase; letter-spacing: .06em; cursor: pointer;
}

/* Pop-ups */
.pop .fact-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; margin: 14px 0; background: var(--line); border: 1px solid var(--line); }
.pop .fact-strip > div { padding: 10px 12px; background: var(--surface-2); }
.pop .fact-strip dt { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.pop .fact-strip dd { margin: 2px 0 0; font-size: 15px; }
.pop .tpl-chips { margin: 4px 0 0; padding: 0; overflow-x: auto; }
.pop textarea { width: 100%; font: 15px/1.5 var(--sans); }
.call-number { margin: 10px 0; font-family: var(--display); font-size: 40px; font-weight: 800; letter-spacing: .02em; }
.script { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 8px; font-size: 15px; line-height: 1.45; }
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.outcomes .btn { justify-content: flex-start; text-align: left; text-transform: none; letter-spacing: 0; font-family: var(--sans); font-weight: 600; }
@media (max-width: 480px) { .outcomes { grid-template-columns: 1fr; } }

/* Personal promo preview */
.promo-card { margin: 14px 0 4px; padding: 18px 16px; background: var(--night); color: #fff; border-left: 6px solid var(--accent); }
.promo-for { font: 800 13px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--brand-on-night); }
.promo-offer { margin: 10px 0; font-size: 17px; line-height: 1.4; }
.promo-code { margin: 6px 0; font: 700 30px/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; }
.promo-terms { font-size: 13px; color: #cfcbc4; }

/* Contact buttons in rows */
.contact-btns { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.contact-btns > .btn-sm:first-child:not(.btn-primary) { border-color: var(--text); } /* Call = the main action */
.dash-table .contact-btns { flex-wrap: nowrap; }
.dash-table td:has(> .contact-btns) { width: 1%; white-space: nowrap; }
.contact-label { display: block; margin-top: 2px; font-size: 13px; color: var(--ok); font-weight: 600; }

/* Call list toolbar */
.cl-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; } /* minmax(0) keeps the scrolling chip row from widening the page */
.cl-tools .search { min-height: 44px; padding-top: 0; padding-bottom: 0; }
.cl-tools .chips { margin-top: 0; }
label.cl-sort { flex-direction: row; align-items: center; justify-self: start; gap: 8px; font: 600 14px/1 var(--sans); color: var(--muted); }
.cl-sort-select { width: auto; min-height: 44px; padding: 0 36px 0 12px; font: 600 16px var(--sans); }
@media (min-width: 960px) {
  .cl-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
  .cl-tools .search { flex: 0 0 280px; min-height: 36px; font-size: 15px; }
  .cl-tools #cl-chips { flex: 1 1 auto; min-width: 0; }
  .cl-tools .chips { margin: 0; padding: 0; flex-wrap: wrap; overflow: visible; -webkit-mask-image: none; mask-image: none; }
  label.cl-sort { margin-left: auto; }
  .cl-sort-select { min-height: 36px; font-size: 14px; }
}

/* How is this calculated? */
.calc { margin-top: 8px; font-size: 14px; }
.calc summary { cursor: pointer; color: var(--muted); font-weight: 600; text-decoration: underline; text-decoration-color: var(--line-ctl); text-underline-offset: 3px; min-height: 32px; display: inline-flex; align-items: center; }
.calc-body { margin-top: 6px; padding: 10px 12px; background: var(--surface-2); border-left: 3px solid var(--line-ctl); line-height: 1.5; }
.calc-body code { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
/* Calc notes inside number tiles: pinned to the bottom, one quiet line; just the ? box when the tile is narrow */
.stat > .calc { align-self: stretch; margin-top: auto; padding-top: 12px; font-size: 12px; }
.stat > .calc > summary { gap: 6px; min-height: 24px; color: var(--muted); text-decoration: none; list-style: none; }
.stat > .calc > summary::-webkit-details-marker { display: none; }
.stat > .calc > summary::before { content: '?'; flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--line-ctl); color: var(--text); font: 700 11px/1 var(--sans); }
.stat > .calc > summary:hover { color: var(--text); }
.stat > .calc[open] > summary::before { background: var(--text); border-color: var(--text); color: var(--surface); }
@container (max-width: 179px) {
  .stat > .calc > summary { font-size: 0; min-height: 32px; }
  .stat > .calc > summary::before { width: 28px; height: 28px; font-size: 13px; }
}

/* Avatars: square monogram; ring-* = a status bar along the bottom */
.avatar { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 0; background: var(--surface-2); color: var(--text); font: 800 16px/1 var(--display); letter-spacing: .02em; }
.avatar.ring-red { box-shadow: inset 0 -3px 0 var(--accent); }
.avatar.ring-amber { box-shadow: inset 0 -3px 0 var(--mk-amber); }
.avatar.ring-green { box-shadow: inset 0 -3px 0 var(--st-green); }

/* Data tables: hairline rows on the page, one strong rule on top (same as .list-card) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-top: 2px solid var(--line-strong); }
.table-wrap :focus-visible { outline-offset: -2px; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: lining-nums tabular-nums; }
.dash-table th { height: 40px; padding: 0 12px; background: none; border-bottom: 1px solid var(--line-ctl); color: var(--muted); font: 700 12px/1.2 var(--sans); text-align: left; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; vertical-align: middle; }
.dash-table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dash-table tbody tr { transition: background-color .2s var(--ease-ui); }
.dash-table tbody tr:hover { background: var(--surface-2); }
.dash-table td.num, .dash-table th.num { text-align: right; }
.dash-table td .muted { font-size: 13px; }
.dash-table .who { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.dash-table .who strong { display: block; font-size: 15px; }
.dash-table .link-btn { text-decoration-color: var(--line-ctl); }
.dash-table .link-btn:hover { text-decoration-color: var(--accent-text); }
.dash-table tfoot td { border-bottom: 0; color: var(--muted); font-size: 13px; }
/* 1100px, not 960px: the 7-column Call list needs about 1030px of table, so below this it is shown as cards (see the .is-stack block) */
@media (min-width: 1100px) {
  .call-table td[data-label='Usually'] { min-width: 9.5em; }
  .call-table td[data-label='Usually'] .muted { max-width: 13em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .call-table td[data-label='Last contact'] { min-width: 8em; }
}
.bad-text { color: var(--error); font-weight: 700; }
.warn-text-2 { color: var(--st-amber); font-weight: 700; }
.good-text { color: var(--ok); font-weight: 700; }

/* Change badges and tiny trend lines on number cards */
.delta { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font: 700 12px/1.4 var(--sans); }
.delta.good { background: var(--st-green-tint); color: var(--st-green); }
.delta.bad { background: var(--brand-tint); color: var(--error); }
.delta.flat { background: var(--surface-2); color: var(--muted); }
.spark { display: block; width: 100%; height: 28px; margin-top: 8px; overflow: visible; }
.spark polyline { fill: none; stroke: var(--text); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark .spark-last { fill: var(--accent); }

/* Status pills (word + colour) */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; font: 700 12px/1 var(--sans); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.pill-red { background: var(--brand-tint); color: var(--error); }
.pill-amber { background: var(--st-amber-tint); color: var(--st-amber); }
.pill-green { background: var(--st-green-tint); color: var(--st-green); }
.pill-grey { background: var(--st-stone-tint); color: var(--st-stone); }
.pill-blue { background: var(--st-blue-tint); color: var(--st-blue); }
.call-table .badges .badge { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }
.sample-note { display: inline-block; margin: 6px 0 14px; padding: 4px 10px; background: var(--note-warn); color: var(--st-amber); font: 700 12px/1.4 var(--sans); text-transform: uppercase; letter-spacing: .06em; }
.nav-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font: 700 11px/1 var(--sans); letter-spacing: 0; }

/* "All clear" empty state: a drawn green check above the sentence (same drawing as .done-mark) */
.empty.is-clear { display: grid; justify-items: center; gap: 12px; padding: 32px 16px; color: var(--text); font-weight: 600; }
.empty.is-clear::before { content: ''; width: 10px; height: 18px; border: solid var(--ok); border-width: 0 3px 3px 0; transform: rotate(40deg); }

/* Tables marked .is-stack: one card per row below 1100px (data-label on every td except the first).
   1100px so the 7-column Call list never scrolls sideways on small laptops or an iPad in landscape (1024px);
   the cancellation and promo tables on the same page switch at the same width so the page reads as one. */
@media (max-width: 1099px) {
  .table-wrap:has(> .is-stack) { overflow: visible; }
  .is-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .is-stack, .is-stack tbody, .is-stack tfoot, .is-stack tr, .is-stack td { display: block; }
  .is-stack tbody tr { padding: 14px 12px; border-bottom: 1px solid var(--line); }
  .is-stack td { min-width: 0; padding: 0; border: 0; font-size: 15px; text-align: left; white-space: normal; }
  .is-stack td.num { text-align: left; }
  .is-stack td + td { margin-top: 6px; }
  .is-stack td[data-label] { position: relative; min-height: 20px; padding-left: 112px; }
  .is-stack td[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 1px; width: 104px; color: var(--muted); font: 600 13px/1.4 var(--sans); }
  .is-stack td > div.muted { display: inline; font-size: 14px; }
  .is-stack td > div.muted::before { content: ' \B7  '; } /* space, middle dot, space (the first space after \B7 ends the escape) */
  .is-stack td[data-label='Actions'] { width: auto; padding-left: 0; }
  .is-stack td + td[data-label='Actions'] { margin-top: 12px; }
  .is-stack td[data-label='Actions']::before { content: none; }
  .is-stack .who { min-width: 0; }
  .is-stack .contact-btns { display: flex; width: 100%; flex-wrap: nowrap; }
  .is-stack .contact-btns > .btn:first-child { flex: 1; }
  .is-stack tfoot td { padding: 12px 12px 0; color: var(--muted); font-size: 13px; }
  /* Call list: avatar + name with the status tags on the right, then the facts, then the buttons */
  .call-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 6px; }
  .call-table td { grid-column: 1 / -1; }
  .call-table td + td { margin-top: 0; }
  .call-table td:first-child { grid-column: 1; grid-row: 1; }
  .call-table td[data-label='Status'] { grid-column: 2; grid-row: 1; padding-left: 0; }
  .call-table td[data-label='Status']::before { content: none; }
  .call-table td[data-label='Status'] .badges { flex-direction: column; align-items: flex-end; gap: 4px; margin: 0; }
  .call-table td + td[data-label='Actions'] { margin-top: 6px; }
}
/* Tablets and small laptops: two cards side by side, so the Call button isn't stretched across the screen */
@media (min-width: 700px) and (max-width: 1099px) {
  .is-stack tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  .is-stack tbody tr { align-content: start; }
}

/* "Who is behind this number?" pop-up (peoplePop in staff.js): one row per person, each opens their card */
.people-pop .pp-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin: 28px 0 10px; }
.people-pop .pp-head .sub-head { margin: 0; }
.people-pop .pp-head .count { height: 26px; min-width: 26px; font-size: 16px; }
.people-pop .row-main em { font-size: 16px; }
.pp-open { flex: none; color: var(--muted); font: 700 15px/1 var(--sans); text-transform: uppercase; letter-spacing: .06em; }
.people-pop .row-link:hover .pp-open { color: var(--text); }
.pp-foot { margin-top: 16px; font-size: 15px; line-height: 1.5; }

/* Message boxes (Dashboard follow-up cards, Leads): Send email full width, then Text and one more button */
.msg-acts { display: grid; gap: 8px; }
.msg-acts .btn { width: 100%; padding: 0 12px; }
.msg-acts-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.person .message { font-size: 16px; }

/* Settings: the email account card sits above the first settings card; Members: the "Current" explanation */
.settings-email { margin-bottom: 16px; }
.settings-email > .section { margin-top: 0; }
.member-note { margin: 12px 0; font-size: 16px; }
