/* Administration (owner 11-21): tabs, customer Manage window, fleet health and activity. Uses the theme tokens only. */
.operator-tabs { margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.operator-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.operator-tools input[type=search] { flex: 1 1 220px; min-width: 0; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-row .stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-row .stat.wide { grid-column: span 2; }
.stat-row .stat span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-row .stat b { font-size: 20px; font-variant-numeric: tabular-nums; }
.stat-row .stat small { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.stat-row .stat.bad { border-color: rgba(248, 113, 113, .45); }
.stat-row .stat.bad b { color: var(--red); }

.operator-table tr.problem td { background: color-mix(in srgb, var(--red-bg) 55%, transparent); }
.operator-table .state-text { max-width: 420px; color: var(--muted); }
.operator-table .agent { color: var(--muted); white-space: nowrap; }
.operator-table code, .activity-list code, .stat-row code { font-size: 12px; }

.manage-customer .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.manage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.manage-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.manage-block h3 { margin: 0 0 6px; font-size: 15px; }
.manage-block h3.spaced { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.manage-block .form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 10px 0; }
.manage-block label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.manage-block label.block { margin: 8px 0 10px; }
.manage-block label input, .manage-block label select { min-width: 150px; }
.pay-preview { margin: 8px 0 12px; }
.control-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; }
.control-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.control-list li > div { display: flex; flex-direction: column; min-width: 0; }
.control-list .muted { font-size: 12px; }
.activity-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.activity-list li { display: grid; grid-template-columns: 78px 1fr auto; gap: 8px; align-items: baseline; }
.activity-list li time { color: var(--muted); font-size: 12px; }
.activity-list li.problem span { color: var(--red); }

/* The customer's own notice under the section links: plan ending, ended or paused. */
.plan-notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 24px 0; padding: 10px 14px; border-radius: 10px; border: 1px solid; }
.plan-notice.soon { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.plan-notice.ended { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.plan-notice b { color: inherit; }
/* A message from support (owner 11-28): until the customer presses Got it. */
.plan-notice.support-message { align-items: flex-start; background: color-mix(in srgb, var(--accent) 10%, var(--surface, transparent)); color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.support-message-text { flex: 1 1 320px; min-width: 0; }
.support-message-text p { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere; }

@media (max-width: 700px) {
    .stat-row .stat.wide { grid-column: auto; }
    .plan-notice { margin: 12px 16px 0; }
    .activity-list li { grid-template-columns: 1fr; gap: 0; }
    .control-list li { flex-wrap: wrap; }
}

/* Accounts page with no accounts yet: the three first steps. */
.first-steps { list-style: none; counter-reset: first; margin: 18px auto 22px; padding: 0; max-width: 520px; text-align: left; display: grid; gap: 12px; }
.first-steps li { counter-increment: first; display: grid; grid-template-columns: 32px 1fr; column-gap: 12px; }
.first-steps li::before { content: counter(first); grid-row: 1 / span 2; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); font-weight: 700; }
.first-steps b { display: block; }
.first-steps span { color: var(--muted); font-size: 14px; }

/* Guided tour (js/tour.js): a lit window over the real element, the rest dimmed, and a card beside it. */
.tour-spot { position: fixed; z-index: 90; border-radius: 10px; pointer-events: none; box-shadow: 0 0 0 9999px rgba(3, 6, 12, .62), 0 0 0 2px var(--accent); transition: top .2s ease, left .2s ease, width .2s ease, height .2s ease; }
.tour-card { position: fixed; z-index: 91; width: min(340px, calc(100vw - 24px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px 12px; box-shadow: 0 18px 50px rgba(0, 0, 0, .45); outline: none; }
.tour-card .tour-count { margin: 0 0 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tour-card .tour-title { margin: 0 0 6px; font-size: 16px; }
.tour-card .tour-text { margin: 0 0 12px; color: var(--muted); line-height: 1.5; }
.tour-card .tour-actions { display: flex; align-items: center; gap: 6px; }
.tour-card .tour-grow { flex: 1; }
@media (prefers-reduced-motion: reduce) { .tour-spot { transition: none; } }
.demo-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 12px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--accent); }
.demo-banner .row { display: flex; gap: 8px; flex-wrap: wrap; }
.first-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* Rally leaderboard (owner 11-21): a ranked list that reads cleanly, with medals for the top three. */
.leaderboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.lb-row { display: grid; grid-template-columns: 2.4rem 1fr auto; align-items: center; gap: 12px; padding: 9px 4px; border-top: 1px solid var(--border); }
.lb-row:first-child { border-top: 0; }
.lb-rank { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; height: 1.6rem; padding: 0 .35rem; border-radius: 999px; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--muted); }
.lb-rank.lb-1 { background: rgba(217,158,43,.18); color: #d99e2b; }
.lb-rank.lb-2 { background: rgba(148,163,184,.20); color: #9aa6b8; }
.lb-rank.lb-3 { background: rgba(192,123,67,.20); color: #c07b43; }
.lb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb-row.lb-top .lb-name { font-weight: 700; }
.lb-points { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.lb-points small { color: var(--muted); font-weight: 400; margin-left: 3px; font-size: 11px; }
.lb-adjust { grid-template-columns: minmax(0,1fr) 7rem auto; align-items: end; }
.lb-adjust .lb-add { align-self: end; }
.lb-adjust .lb-add .btn { width: 100%; }
.lb-reset { margin-top: 14px; align-items: center; }
@media (max-width: 560px) { .lb-adjust { grid-template-columns: 1fr; } .lb-adjust .lb-add .btn { width: auto; } }

/* Administration → Group updates (owner 11-28). */
.group-updates .setup-steps ol { margin: 10px 0 0; padding-left: 22px; display: grid; gap: 12px; line-height: 1.5; }
.group-updates .setup-steps li.done { color: var(--muted); }
.group-updates .setup-steps li.done::marker { color: var(--green); content: "✓  "; }
.group-updates .setup-steps code { font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
.group-updates .avatar-link { display: inline-flex; align-items: center; gap: 8px; margin-left: 4px; }
.group-updates .avatar-link img { border-radius: 50%; }
.group-updates .ok-line { margin: 12px 0 0; color: var(--green); }
.group-updates .starters { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.group-updates textarea { width: 100%; min-height: 150px; resize: vertical; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; line-height: 1.5; }
.group-updates .compose-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0 12px; }
.group-updates .compose-foot .check { margin: 0; }
.group-updates .count { font-size: 12px; font-variant-numeric: tabular-nums; }
.tg-preview { display: flex; align-items: flex-end; gap: 8px; padding: 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.tg-avatar { border-radius: 50%; flex: none; }
.tg-bubble { min-width: 0; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; padding: 8px 12px; }
.tg-name { display: block; color: var(--accent); font-size: 13px; margin-bottom: 2px; }
.tg-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.post-history li { grid-template-columns: 90px 1fr; }
.post-history li small { grid-column: 2; }

/* Feature problems (owner 11-28): one row per feature, open it for reasons and the latest problems. */
.feature-list { display: grid; gap: 8px; }
.feature-row { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2, transparent); }
.feature-row.has-problems { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.feature-row > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 14px; cursor: pointer; list-style: none; }
.feature-row > summary::-webkit-details-marker { display: none; }
.feature-row > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.feature-row[open] > summary::before { transform: rotate(90deg); }
.feature-name { flex: 1 1 220px; min-width: 0; }
.feature-name code { font-size: 12px; color: var(--muted); margin-left: 6px; }
.feature-counts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.feature-last { font-size: 13px; }
.feature-body { padding: 0 14px 14px; }
.feature-body h3 { font-size: 14px; margin: 12px 0 6px; }

/* Sign-ups: how far new customers got. */
.funnel { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 6px; }
.funnel li { position: relative; display: grid; grid-template-columns: minmax(140px, 220px) 48px 52px 1fr; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2, transparent); overflow: hidden; }
.funnel li b { text-align: right; }
.funnel li small { color: var(--muted); }
.funnel li i { grid-column: 4; height: 8px; border-radius: 4px; background: var(--accent); min-width: 2px; }
.attempt-detail { display: block; margin-top: 4px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
.manage-customer textarea { width: 100%; resize: vertical; min-height: 84px; font: inherit; }
.sent-messages span { white-space: pre-line; overflow-wrap: anywhere; }

@media (max-width: 700px) {
    .funnel li { grid-template-columns: 1fr auto auto; }
    .funnel li i { grid-column: 1 / -1; }
}
/* Sign-ups and Feature problems tables: read-only rows, long text wraps. */
table.insight-table tbody tr { cursor: default; }
table.insight-table td.state-text { white-space: normal; min-width: 260px; max-width: 560px; overflow-wrap: anywhere; line-height: 1.4; }
.list-card > h3.spaced, .list-card h3.spaced { margin: 22px 0 8px; font-size: 15px; }
.message-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 10px; }
.message-options .check { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; }
@media (max-width: 700px) {
    /* Phone: two short facts per line; the long text (customer, what happened, details) takes the whole width. */
    table.fleet.insight-table tr { grid-template-columns: repeat(2, minmax(0, 1fr)); cursor: default; }
    table.fleet.insight-table td { white-space: normal; overflow-wrap: anywhere; }
    table.fleet.insight-table td.state-text, table.fleet.insight-table td[data-label="Customer"] { grid-column: 1 / -1; min-width: 0; max-width: none; }
    .list-head { flex-wrap: wrap; gap: 4px 12px; }
}
/* Draft with AI (owner 11-28): sits above the message box. */
.ai-draft { margin: 6px 0 10px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; }
.ai-draft .block { margin: 0; }
.ai-draft input { width: 100%; }
.ai-draft-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
.ai-draft-row .muted { font-size: 12px; }
.reason-note { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
