:root { --bg: #f7f7f5; --fg: #1d1d1b; --muted: #6b6b66; --line: #deded8; --accent: #1f5fbf; --err: #b3261e; }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--fg); }
header { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fff; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 20px 0 8px; }
main { padding: 0 16px 32px; max-width: 1200px; }
.who { color: var(--muted); }
#message { min-height: 1.4em; margin: 12px 0 0; }
#message.error { color: var(--err); }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: 13px; color: var(--muted); }
button { font: inherit; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
td button { margin-bottom: 4px; }
button[type="submit"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.empty { color: var(--muted); }
dialog { border: 1px solid var(--line); border-radius: 10px; max-width: 420px; width: calc(100% - 32px); }
dialog label { display: block; margin: 10px 0; }
dialog textarea, dialog select, dialog input { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 6px; }
.buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
@media (max-width: 720px) {
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  td { border: 0; padding: 2px 8px; }
}

/* Work the call */
dialog.work { max-width: none; width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.work-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.work .call { font-weight: 600; }
.work .desc { white-space: pre-wrap; color: #444; }
.work section { border-top: 1px solid #ddd; margin-top: 12px; padding-top: 8px; }
.work .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 12px; }
.work .grid label { display: flex; flex-direction: column; font-size: 0.9em; }
.work ul.notes { list-style: none; padding: 0; }
.work .notes li { border-bottom: 1px solid #eee; padding: 6px 0; }
.work .note-head { font-size: 0.85em; color: #666; }
.work .note-body { white-space: pre-wrap; }
#work-message.error { color: #b00020; }

/* Console v2: Today cards, My Active Tasks, live timers */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; }
.kpi .n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.count { color: var(--muted); font-weight: 400; }
.cards { display: grid; gap: 10px; }
.card { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 14px; }
.card.waiting { border-left-color: #b7791f; }
.card-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card h3 { margin: 0; font-size: 16px; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .state { display: flex; align-items: center; gap: 10px; }
.badge { font-size: 12px; font-weight: 700; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; background: #e7eefa; color: var(--accent); }
.card.waiting .badge { background: #fbf0dc; color: #8a5a12; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.card dl { display: grid; grid-template-columns: max-content 1fr max-content 1fr; gap: 4px 12px; margin: 10px 0; font-size: 14px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; }
.card .actions { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 720px) {
  .card dl { grid-template-columns: max-content 1fr; }
}

/* Waiting dialog: several people, a reason under each */
dialog.hold { max-width: 560px; }
dialog.hold fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; padding: 8px 12px; }
dialog.hold legend { font-weight: 600; padding: 0 4px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; margin: 4px 0; }
.party { border-bottom: 1px solid #eee; padding: 4px 0; }
.party:last-child { border-bottom: 0; }
dialog label.check { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
dialog label.check input { width: auto; display: inline; margin: 0; }
dialog label.why { margin: 4px 0 8px 26px; font-size: 13px; color: var(--muted); }
.when { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
p.error { color: var(--err); min-height: 1.2em; margin: 6px 0 0; }
.card dd.lines { white-space: pre-line; }

/* The hidden attribute must win over display rules above (unticked people show no reason box). */
[hidden] { display: none !important; }

/* Waiting on: multi-select dropdown with checkboxes; reasons listed under it */
.ms { position: relative; }
.ms-box { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; min-height: 38px; background: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: #e7eefa; color: var(--accent); border-radius: 999px; padding: 2px 8px; font-size: 13px; }
.placeholder { color: var(--muted); }
.caret { color: var(--muted); }
.ms-panel { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); padding: 6px 10px; max-height: 260px; overflow: auto; }
#hold-reasons label.why { margin: 10px 0 0; }
.why-head { display: block; font-weight: 600; color: var(--fg); }
.time-wrap { position: relative; display: flex; flex-direction: column; }
.time-wrap > label { margin: 0 0 4px; }
.combo { display: flex; }
.combo input { flex: 1; margin: 0 !important; border-radius: 6px 0 0 6px; }
.combo button { border-radius: 0 6px 6px 0; border-left: 0; }
.time-panel { max-height: 220px; padding: 4px; }
.time-panel .opt { display: block; width: 100%; text-align: left; border: 0; border-radius: 4px; padding: 4px 8px; }
.time-panel .opt:hover { background: #e7eefa; }

/* Time box lines up with the date box: same top margin, label gap and height. */
.when { align-items: start; }
.when > label, .time-wrap { margin: 10px 0 0; }
.when > label input { margin-top: 4px; height: 36px; box-sizing: border-box; }
.time-wrap > label { margin: 0; }
.combo { margin-top: 4px; height: 36px; }
.combo input { height: 36px; box-sizing: border-box; }
.combo button { height: 36px; padding: 0 10px; }

/* Task history: automatic entries, collapsed by default */
#work-history-box summary, #work-log-box summary, #mail-thread-details summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
#work-history .note-body { color: var(--muted); }
.call-preview { color: var(--muted); font-size: 0.9em; padding: 6px 10px; margin: 2px 0 4px; border-left: 3px solid var(--line); background: rgba(0,0,0,.025); border-radius: 0 6px 6px 0; cursor: pointer; }
.call-preview .note-head { font-weight: 600; }
.call-preview .note-body { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }

/* Caller: First | Last, Phone | Email, then Address (verified) across the full width */
.work .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.work .grid2 label { display: flex; flex-direction: column; font-size: 0.9em; }
.work .addr { margin-top: 8px; font-size: 0.9em; }
.work .addr input { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; height: 34px; padding: 6px; font: inherit; border: 1px solid var(--line); }
.work .matches { list-style: none; padding: 0; margin: 4px 0; }
.work .matches button { width: 100%; text-align: left; margin: 2px 0; }
#addr-status button, #res-status button { margin-left: 6px; }
@media (max-width: 560px) { .work .grid2 { grid-template-columns: 1fr; } }

/* Task history: three columns */
.hist-wrap { overflow-x: auto; margin-top: 6px; }
.hist { width: 100%; border-collapse: collapse; font-size: 0.88em; }
.hist th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.hist td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hist td:nth-child(1) { white-space: nowrap; width: 1%; }
.hist td:nth-child(2) { white-space: nowrap; width: 1%; }
.hist tr.crm td { background: rgba(31,95,191,.05); }
.hist tr.older td { color: var(--muted); }
.hist tr.call td { background: rgba(0,0,0,.025); }

/* Action bar under the Caller details */
/* Reach the client (Owner 2026-10-28): always on a claimed Task, under Schedule Follow-Up. */
.reach { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.reach button:disabled { opacity: .5; cursor: not-allowed; }
.reach .reach-alt { align-self: center; font-size: 12px; }
.actionbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.actionbar button:disabled { opacity: .5; cursor: not-allowed; }
.actionbar .more { position: relative; }
.more-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.12); display: flex; flex-direction: column; min-width: 200px; }
.more-menu[hidden] { display: none; }
.more-menu button { border: 0; border-radius: 0; text-align: left; padding: 8px 12px; background: transparent; }
.more-menu button:hover:not(:disabled) { background: #eef3fb; }
.sysstatus { text-align: right; color: var(--muted); font-size: 0.82em; margin: 6px 0 0; }
#spectora-menu { min-width: 360px; }

/* Text the caller (BeeTexting) */
.sms-box { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fafaf8; }
.sms-box textarea { width: 100%; margin: 6px 0; font: inherit; padding: 6px; border: 1px solid var(--line); border-radius: 6px; }
.sms-foot { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.sms-foot .hint { margin-right: auto; }
.mail-from { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 0.92em; }
.mail-from select { flex: 1; min-width: 0; font: inherit; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.sms-box input[type="text"] { width: 100%; margin-top: 6px; font: inherit; padding: 6px; border: 1px solid var(--line); border-radius: 6px; }

/* ---- My Workday layout (Owner design, 2026-10-02): navy sidebar, white panels, icon KPI cards. ---- */
:root { --navy: #0f3c8c; --navy2: #0b2f70; --bg: #f3f5f9; --line: #e3e7ee; --accent: #2f6fe0; }
body { display: flex; min-height: 100vh; }
.side { width: 200px; flex: 0 0 200px; background: var(--navy); color: #fff; padding: 18px 12px; }
.side .brand { font-weight: 800; font-size: 26px; letter-spacing: 1px; padding: 0 10px 18px; line-height: 1.1; }
.side .brand small { display: block; font-size: 10px; font-weight: 600; letter-spacing: .08em; opacity: .8; text-transform: uppercase; }
.side nav a { display: block; color: #dfe7f7; text-decoration: none; padding: 10px 12px; border-radius: 8px; margin-bottom: 4px; }
.side nav a.on, .side nav a:hover { background: var(--navy2); color: #fff; }
.page { flex: 1; min-width: 0; }
header { padding: 14px 20px; }
header h1 { font-size: 22px; }
header .sub { margin: 0; color: var(--muted); font-size: 14px; }
main { padding: 0 20px 32px; max-width: 1180px; }
.today h2 { display: none; }
.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.kpi { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; border-radius: 12px; padding: 14px; }
.kpi .ic { grid-row: 1 / 3; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 19px; }
.kpi .l { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--fg); font-weight: 600; }
.kpi .n { font-size: 26px; }
.i-blue { background: #e6efff; color: #2f6fe0; } .i-green { background: #e3f6ec; color: #1e9e5a; } .i-violet { background: #efe9ff; color: #7c5cdb; }
.i-gold { background: #fff6dc; color: #d4a017; } .i-grey { background: #eef0f4; color: #556; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-top: 16px; }
.panel h2 { margin: 0 0 10px; }
.panel table { border: 0; }
.panel .card { border-left-width: 0; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(15, 60, 140, .06); }
.panel .card .badge { background: #e3f6ec; color: #1e9e5a; }
.panel .card .timer { font-size: 18px; }
.panel .card .actions button:first-child { background: var(--accent); color: #fff; border-color: var(--accent); }
td.hot { color: var(--err); font-weight: 600; }
#available td:last-child button { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  body { flex-direction: column; }
  .side { width: auto; flex: none; padding: 8px 16px; }
  .side .brand { padding-bottom: 6px; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; }
  header, main { padding-left: 16px; padding-right: 16px; }
  .kpis { grid-template-columns: 1fr 1fr; }
}

/* A hidden element stays hidden even where a rule sets display (sidebar links). */
[hidden] { display: none !important; }

/* Interaction header and Contact states (Owner spec 2026-10-07). */
.chan-badge { display: inline-block; font-size: 0.75em; font-weight: 700; letter-spacing: .06em; padding: 2px 8px; border-radius: 4px; margin-right: 8px; background: var(--muted, #666); color: #fff; vertical-align: 1px; }
.chan-badge.phone { background: #2563eb; } .chan-badge.email { background: #7c3aed; } .chan-badge.text { background: #059669; } .chan-badge.other { background: #6b7280; }
.crm-state { font-size: 0.75em; font-weight: 600; margin-left: 8px; padding: 2px 8px; border-radius: 10px; background: #eef2ff; color: #3730a3; vertical-align: 2px; }
.crm-state.matched { background: #dcfce7; color: #166534; } .crm-state.none, .crm-state.multiple { background: #fef3c7; color: #92400e; } .crm-state.automated { background: #f3f4f6; color: #374151; }
.contact-state { border: 1px solid var(--line, #e5e7eb); border-radius: 8px; padding: 12px 14px; margin: 6px 0 10px; background: var(--panel, #fafafa); }
.contact-state p { margin: 0 0 8px; }
.cs-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cs-search { margin-top: 10px; }
.cs-search-row { display: flex; gap: 8px; }
.cs-search-row input { flex: 1; min-width: 0; }
.cs-actions button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.work-mail { margin: 4px 0 8px; }
.work-mail a { font-weight: 600; }
.work-mail .hint { color: var(--muted); font-size: 0.9em; margin-left: 6px; }

/* Tasks Ready to Claim, grouped (Owner 2026-10-08). */
.claim-group { margin: 6px 0 16px; }
.claim-group > h3, .claim-group > summary { font-size: 1em; margin: 10px 0 6px; }
details.claim-group > summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.claim-group .hint { color: var(--muted); font-size: 0.85em; margin: 2px 0 6px; }

/* Tasks Ready to Claim as columns (Owner 2026-10-08). */
#claim { overflow: visible; }
.claim-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; align-items: start; }
.claim-col { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 75vh; overflow-y: auto; }
.claim-col.muted { opacity: .92; }
/* Unanswered-message sweep (ESS-OPS-SWEEP-001): unclaimed 15+ minutes. */
.claim-col.urgent { border: 2px solid var(--err); background: #fff5f5; }
.claim-col.urgent > h3 { color: var(--err); background: #fff5f5; }
.claim-col.urgent .cc-why { background: #fde2e1; color: #991b1b; }
.claim-col > h3 { font-size: 1em; margin: 2px 2px 8px; position: sticky; top: -10px; background: var(--bg); padding: 4px 0; z-index: 1; }
.claim-col > .hint { color: var(--muted); font-size: .8em; margin: 0 2px 8px; }
.claim-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; }
.cc-title { font-weight: 600; line-height: 1.3; margin-bottom: 3px; word-break: break-word; }
.cc-sub { color: var(--muted); font-size: .82em; margin-bottom: 3px; word-break: break-all; }
.cc-why { display: inline-block; font-size: .75em; background: #f3f4f6; color: #374151; border-radius: 10px; padding: 1px 8px; margin: 2px 0 4px; }
.cc-meta { color: var(--muted); font-size: .8em; margin-bottom: 6px; }
.cc-claim { background: var(--accent); color: #fff; border-color: var(--accent); width: 100%; }

/* Follow-ups (Owner 2026-10-08): Schedule Follow-Up on the Task screen and its dialog. */
.work-next { margin: 8px 0 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.work-status { margin-left: auto; display: flex; gap: 8px; }
dialog.followup { max-width: 560px; }
dialog.followup label { display: block; margin: 10px 0; font-weight: 600; }
dialog.followup select, dialog.followup textarea { display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400; box-sizing: border-box; }
dialog.followup .fu-when { display: flex; gap: 16px; flex-wrap: wrap; }
dialog.followup .fu-when label { flex: 1 1 160px; }
dialog.followup .fu-when input { display: block; width: 100%; margin-top: 4px; box-sizing: border-box; }

/* Email conversation on a Task (Owner 2026-10-29): newest at the top; sent on the right in gold, received on the left in
   light blue. */
.mail-thread { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mail-thread li { max-width: 85%; padding: 8px 10px; border: 1px solid #c9ddf2; border-radius: 8px; background: #eaf3fc; align-self: flex-start; }
.mail-thread li.out { align-self: flex-end; background: #faf6ec; border-color: #e2cd98; }
.mail-thread .mt-head { font-size: 0.82em; color: #666; }
.mail-thread .mt-subj { font-weight: 600; margin: 2px 0; }
.mail-thread .mt-body { white-space: pre-wrap; }
.mail-thread .mt-more { font-size: 0.82em; color: #666; font-style: italic; }
.mail-thread-foot { display: flex; align-items: center; gap: 10px; }
.mail-thread li.note { align-self: center; max-width: 90%; background: #f3f2ef; border-color: #e2e0da; }
.mail-thread li.note .mt-head { font-style: italic; }

/* Contact layout (Owner 2026-10-29, columns switched the same day): the Contact's fields with their own actions on the
   left, the other options on the right. */
.work .contact-layout { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 12px 24px; align-items: start; }
.work .contact-layout > .contact-side { order: 2; }
.work .contact-main { display: flex; flex-direction: column; gap: 8px; }
.work .contact-main.limited .crm-only { display: none; }
.work .contact-main > label { display: flex; flex-direction: column; font-size: 0.9em; }
.work .contact-side.actionbar { flex-direction: column; align-items: stretch; justify-content: flex-start; margin-top: 18px; }
.work .contact-side .more > button { width: 100%; }
.work .contact-side .more-menu { right: 0; left: auto; }
.work .contact-side .sysstatus { text-align: left; }
.work .field-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -2px 0 4px; }
.work .field-actions button:disabled { opacity: .5; cursor: not-allowed; }
.work .contact-side > button:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 680px) { .work .contact-layout { grid-template-columns: 1fr; } .work .contact-side.actionbar { margin-top: 0; } }
