/* Member login, account and owner dashboard (/login, /account, /admin). Loaded after site.css on those pages only. */
.portal {
  color-scheme: light;
  --surface: #ffffff; --surface-2: #f8fafc; --text-2: #475569; --text-3: #64748b; --grid: #e2e8f0; --axis: #94a3b8;
  --series-1: #2a78d6; --series-2: #eb6834; --line-1: #0e7490;
  --good: #047857; --good-bg: #ecfdf5; --warn: #b45309; --warn-bg: #fffbeb; --crit: #b91c1c; --crit-bg: #fef2f2; --neutral-bg: #f1f5f9;
  background: var(--surface-2);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .portal {
    color-scheme: dark;
    --bg: #0f172a; --ink: #f1f5f9; --muted: #cbd5e1; --line: #334155; --tint: #0c4a6e; --soft: #0b2236; --brand-ink: #38bdf8; --brand-dark: #7dd3fc;
    --surface: #111c33; --surface-2: #0b1324; --text-2: #cbd5e1; --text-3: #94a3b8; --grid: #24324a; --axis: #64748b;
    --series-1: #3987e5; --series-2: #d95926; --line-1: #22d3ee;
    --good: #6ee7b7; --good-bg: #052e22; --warn: #fcd34d; --warn-bg: #3a2a05; --crit: #fca5a5; --crit-bg: #3b0d0d; --neutral-bg: #1e293b;
  }
  :root:where(:not([data-theme="light"])) .portal .btn { color: #0b1324; }
  :root:where(:not([data-theme="light"])) .portal .btn.ghost { color: var(--brand-ink); }
  :root:where(:not([data-theme="light"])) .portal .ptop .logo img { background: #fff; border-radius: 10px; padding: 2px 6px; }
}
.portal { color: var(--ink); }
.portal h1, .portal h2, .portal h3 { color: var(--ink); }
.wide-wrap { max-width: 1320px; }
.ptop { background: var(--surface); border-bottom: 1px solid var(--line); }
.prow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.pnav { display: flex; align-items: center; gap: 12px; font-size: .9rem; white-space: nowrap; }
@media (min-width: 560px) { .pnav { gap: 18px; font-size: .95rem; } }
.ptop .logo img { width: 84px; height: auto; }
@media (min-width: 560px) { .ptop .logo img { width: 100px; } }
.pnav a { text-decoration: none; font-weight: 600; }
.pnav a[aria-current] { text-decoration: underline; }
.pmain { padding-top: 28px; padding-bottom: 48px; min-height: 60vh; }
.ph1 { font-size: clamp(1.6rem, 5vw, 2.2rem); margin-bottom: .3em; }
.pfoot { border-top: 1px solid var(--line); padding: 16px 0; background: var(--surface); }
.pfoot p { margin: 0; }

/* cards + forms */
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 0 0 16px; min-width: 0; }
.pcard h2 { font-size: 1.15rem; margin-bottom: .6em; letter-spacing: -.01em; }
.pcard > :last-child { margin-bottom: 0; }
.pform label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
.pform input, .pform select, .pform textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.pform textarea { min-height: 80px; resize: vertical; }
.pform .row2 { display: grid; gap: 12px; }
@media (min-width: 560px) { .pform .row2 { grid-template-columns: 1fr 1fr; } }
.pform p { margin: 0 0 12px; }
.msg { padding: 10px 12px; border-radius: 10px; font-size: .95rem; }
.msg.ok { background: var(--good-bg); color: var(--good); }
.msg.err { background: var(--crit-bg); color: var(--crit); }
.msg.info { background: var(--neutral-bg); color: var(--text-2); }
.notice { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 12px; padding: 16px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .95rem; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.grid2 { display: grid; gap: 16px; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2 > .pcard { margin: 0; } }

/* status badge: always a word, never color alone */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; background: var(--neutral-bg); color: var(--text-2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.active { background: var(--good-bg); color: var(--good); }
.badge.past_due { background: var(--warn-bg); color: var(--warn); }
.badge.canceled { background: var(--crit-bg); color: var(--crit); }

/* tables scroll inside their own box */
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ptable { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ptable th, .ptable td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ptable th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 700; background: var(--surface-2); }
.ptable td.num, .ptable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ptable tbody tr:last-child td { border-bottom: 0; }
.ptable tr[data-id] { cursor: pointer; }
.ptable tr[data-id]:hover td, .ptable tr[data-id]:focus-visible td { background: var(--soft); }
.ptable .em2 { display: block; color: var(--text-3); font-size: .82rem; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.kpi .k { font-size: .8rem; color: var(--text-3); font-weight: 600; margin: 0; }
.kpi .v { font-size: clamp(1.25rem, 3.2vw, 1.7rem); font-weight: 800; letter-spacing: -.02em; margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: .8rem; color: var(--text-2); margin: 2px 0 0; }
.charts { display: grid; gap: 16px; margin-bottom: 16px; }
@media (min-width: 1000px) { .charts { grid-template-columns: 3fr 2fr; } .charts > .pcard { margin: 0; } }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridl { stroke: var(--grid); stroke-width: 1; }
.chart .axisl { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--text-3); font: 500 11px var(--font); }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .ln { fill: none; stroke: var(--line-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--line-1); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart .hit:hover, .chart .hit:focus { fill: var(--grid); fill-opacity: .45; outline: none; }
.chart .lbl { fill: var(--text-2); font-weight: 700; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--text-2); margin: 0 0 8px; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.l { height: 3px; border-radius: 2px; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); font-size: .82rem; line-height: 1.35; padding: 7px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)); z-index: 5; }
.tip[hidden] { display: none; }
details.tview { margin-top: 10px; font-size: .9rem; }
details.tview summary { cursor: pointer; color: var(--brand-ink); }
.funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.funnel .fl { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; margin-bottom: 3px; }
.funnel .fb { height: 12px; border-radius: 4px; background: var(--neutral-bg); overflow: hidden; }
.funnel .fb span { display: block; height: 100%; border-radius: 4px; background: var(--series-1); min-width: 2px; }
.feed { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--text-3); white-space: nowrap; font-size: .82rem; }
.reasons { list-style: none; margin: 0; padding: 0; }
.reasons li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.reasons li:last-child { border-bottom: 0; }

/* customer list */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { font: inherit; font-size: .88rem; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; min-height: 36px; }
.tabs button[aria-pressed="true"] { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.toolbar input[type=search] { flex: 1 1 220px; min-width: 0; font: inherit; font-size: 16px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: .9rem; }
.pager .btn, .toolbar .btn { min-height: 38px; padding: .35em 1em; font-size: .9rem; box-shadow: none; }

/* detail panel */
.drawer { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; background: rgba(2, 6, 23, .45); }
.drawer[hidden] { display: none; }
.drawer .panel { width: min(560px, 100%); height: 100%; overflow-y: auto; background: var(--surface-2); padding: 18px 16px 40px; box-shadow: -10px 0 30px rgba(0, 0, 0, .2); }
.drawer .panel h2 { font-size: 1.3rem; margin: 0; }
.drawer .phead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.drawer .x { font-size: 1.2rem; background: none; border: 0; color: var(--ink); cursor: pointer; min-width: 44px; min-height: 44px; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.timeline li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--text-3); font-size: .82rem; display: block; }
html.drawer-open { overflow: hidden; }

/* website traffic section */
.sec-h { font-size: 1.25rem; margin: 8px 0 12px; letter-spacing: -.01em; }
.h3s { font-size: 1rem; margin: 18px 0 8px; }

/* SMS coach: safety alerts panel and the Texts tab */
.alerts.has-open { border-color: var(--crit); box-shadow: 0 0 0 1px var(--crit) inset; }
.alerts .count { font-size: .8rem; font-weight: 700; color: var(--crit); background: var(--crit-bg); border-radius: 999px; padding: 2px 9px; margin-left: 6px; vertical-align: middle; }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.alert-item:last-child { border-bottom: 0; }
.alert-item.done { opacity: .8; }
.ai-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ai-head time { margin-left: auto; color: var(--text-3); font-size: .82rem; }
.ai-quote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--crit); background: var(--neutral-bg); border-radius: 0 8px 8px 0; font-size: .95rem; overflow-wrap: anywhere; }
.ai-resolve { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.ai-resolve input { flex: 1 1 220px; min-width: 0; }
.dtabs { margin: 0 0 12px; }
.texts { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.texts .t { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: var(--neutral-bg); }
.texts .t.out { align-self: flex-end; background: var(--series-1); color: #fff; }
.texts .t.out .tm { color: rgba(255,255,255,.8); }
.texts .t.bad { outline: 2px solid var(--crit); }
.texts .tb { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.texts .tm { margin: 4px 0 0; font-size: .75rem; color: var(--text-3); }
.texts .terr { color: var(--crit); }
.texts .t.out .terr { color: #ffd2d2; }
