/* ACHISE admin dashboard.
   Brand: flame palette. Cherry + Orange + Yellow are the major brand colours and are
   used for identity only (header, primary actions, focus) - NEVER for negative
   statuses such as failed / cancelled / declined, which use neutral greys. */
:root {
  --cherry: #a3123a;
  --orange: #f26522;
  --yellow: #fdb913;
  --white: #ffffff;
  --blue: #1f6fd1;
  --green: #1e9e5b;

  --flame: linear-gradient(90deg, var(--cherry) 0%, var(--orange) 60%, var(--yellow) 100%);

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e6eb;
  --text: #1c2430;
  --muted: #5f6b7a;
  --focus: #f26522;

  /* Status colours (no cherry / orange / yellow) */
  --st-pending: #55657a;
  --st-awaiting: #6b4fbb;
  --st-confirmed: var(--green);
  --st-rescheduled: var(--blue);
  --st-completed: #0f7469;
  --st-cancelled: #6b7280;
  --st-noshow: #3f4a5a;
  --st-expired: #8a94a3;
  --st-failed: #4b5563;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 0.95rem; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 0.85rem; }
h1.mono { font-size: 1.35rem; margin: 2px 0 6px; }
.hidden { display: none !important; }
.boot { padding: 48px; text-align: center; color: var(--muted); }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--flame); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.brand img { width: 26px; height: 26px; }
.brand span { color: var(--cherry); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 0.9rem; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 56px); }
.sidenav { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; }
.sidenav a {
  display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); font-weight: 500; margin-bottom: 2px;
}
.sidenav a:hover { background: var(--surface-2); text-decoration: none; }
.sidenav a.active { background: #fff3ec; color: var(--cherry); box-shadow: inset 3px 0 0 var(--orange); }
.sidenav .group { margin: 14px 12px 6px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
main { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidenav { display: flex; overflow-x: auto; gap: 4px; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidenav a { white-space: nowrap; margin: 0; }
  .sidenav .group { display: none; }
  main { padding: 16px; }
  .topbar .who { display: none; }
}

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); margin-top: 16px; align-items: start; }
.grid > .card + .card { margin-top: 0; }
.page-head + .grid.two { margin-top: 0; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 20px; }
.stat { cursor: pointer; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat:hover { border-color: #cfd5dd; }
.stat .n { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.stat.brand-accent { border-top: 3px solid var(--orange); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fffaf5; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; color: #fff; white-space: nowrap; }
.badge.pending { background: var(--st-pending); }
.badge.awaiting_payment { background: var(--st-awaiting); }
.badge.confirmed { background: var(--st-confirmed); }
.badge.rescheduled { background: var(--st-rescheduled); }
.badge.completed { background: var(--st-completed); }
.badge.cancelled { background: var(--st-cancelled); }
.badge.no_show { background: var(--st-noshow); }
.badge.expired { background: var(--st-expired); }
.badge.pay-paid { background: var(--green); }
.badge.pay-pending { background: var(--st-awaiting); }
.badge.pay-failed { background: var(--st-failed); }
.badge.pay-waived { background: var(--blue); }
.badge.pay-refunded { background: var(--st-completed); }
.badge.pay-expired, .badge.pay-cancelled { background: var(--st-expired); }
.badge.pay-not_required { background: #e7eaee; color: var(--muted); }
.badge.msg-sent, .badge.msg-delivered { background: var(--blue); }
.badge.msg-read, .badge.msg-received { background: var(--green); }
.badge.msg-queued, .badge.msg-sending { background: var(--st-pending); }
.badge.msg-failed { background: var(--st-failed); }
.badge.role { background: #eef1f5; color: var(--text); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .help { font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-top: 3px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #ccd2da; border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
input[type='checkbox'] { width: auto; margin-right: 8px; transform: translateY(1px); }
.check { display: flex; align-items: center; font-weight: 500; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 160px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar input[type='checkbox'] { min-width: 0; }
.toolbar input[type='search'] { min-width: 260px; flex: 1; }

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 8px; border: 1px solid #ccd2da; background: #fff; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.primary { background: var(--cherry); border-color: var(--cherry); color: #fff; }
button.primary:hover { background: #8a0f31; }
button.accent { background: var(--orange); border-color: var(--orange); color: #fff; }
button.accent:hover { background: #da5a1e; }
button.success { background: var(--green); border-color: var(--green); color: #fff; }
button.info { background: var(--blue); border-color: var(--blue); color: #fff; }
/* Destructive actions are neutral dark, never brand cherry/orange. */
button.danger { background: #374151; border-color: #374151; color: #fff; }
button.danger:hover { background: #1f2937; }
button.link { border: 0; background: none; color: var(--blue); padding: 4px 6px; }
button.small { padding: 5px 10px; font-size: 0.85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.slots { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.slots button { padding: 6px 12px; font-weight: 500; }
.slots button.selected { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.timeline .when { color: var(--muted); font-size: 0.8rem; }

/* ---------- Modal & toasts ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2); }
.modal h2 { margin-bottom: 14px; }
.modal .actions { justify-content: flex-end; margin-top: 18px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { padding: 11px 16px; border-radius: 8px; color: #fff; box-shadow: var(--shadow); max-width: 380px; background: #1f2937; }
.toast.ok { background: var(--green); }
.toast.err { background: #374151; border-left: 4px solid #9ca3af; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: min(400px, 100%); background: var(--surface); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08); overflow: hidden; }
.login .flame { height: 6px; background: var(--flame); }
.login .inner { padding: 28px; }
.login .brand { margin-bottom: 18px; font-size: 1.3rem; }
.error-box { background: #f3f4f6; border-left: 4px solid #6b7280; padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
pre.json { background: var(--surface-2); padding: 8px; border-radius: 6px; max-width: 420px; overflow: auto; font-size: 0.78rem; margin: 4px 0 0; }

/* ---------- Integrations ---------- */
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; min-width: 0; }
.warn-text { color: #4b5563; font-weight: 600; }
details.guide { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
details.guide summary { cursor: pointer; font-weight: 600; color: var(--blue); }
details.guide ol { margin: 10px 0 2px; padding-left: 20px; }
details.guide li { margin-bottom: 6px; line-height: 1.45; }

.proof-img { max-width: 100%; max-height: 360px; border: 1px solid var(--border); border-radius: 8px; display: block; }

/* ---------- Leads ---------- */
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.attachments { display: grid; gap: 12px; }
.attachments audio { width: 100%; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 480px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 85%; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.bubble.inbound { align-self: flex-start; }
.bubble.outbound { align-self: flex-end; background: #eef5ff; border-color: #d6e6fb; }

/* ---------- Inbox ---------- */
.chat.tall { max-height: calc(100vh - 360px); min-height: 280px; }
.bubble .who { font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.bubble.outbound.bot { background: #f3f4f6; border-color: #e5e7eb; }
.bubble.outbound.staff { background: #eef5ff; border-color: #cfe0fa; }
.reply-box { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; }
.reply-box textarea { min-height: 64px; }

/* ---- Quotations & invoices ---- */
.stat.static { cursor: default; }
.kv .k { color: var(--muted); }
.kv .v { overflow-wrap: anywhere; }
.badge.doc-draft { background: #8a90a0; }
.badge.doc-sent, .badge.doc-issued { background: var(--blue); }
.badge.doc-accepted, .badge.doc-paid { background: var(--green); }
.badge.doc-invoiced { background: #6f42c1; }
.badge.doc-part, .badge.doc-pending, .badge.doc-claimed { background: var(--st-awaiting); }
.badge.doc-unpaid { background: #b8003c; }
.badge.doc-declined, .badge.doc-cancelled, .badge.doc-rejected { background: var(--st-cancelled); }
.doc-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 130px 120px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.doc-row.head { font-size: 0.8rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.doc-row.disc { grid-template-columns: minmax(0, 1fr) 150px 36px; }
.doc-row.plan { grid-template-columns: minmax(0, 1fr) 90px 36px; }
.doc-row .amt { text-align: right; font-weight: 600; }
.doc-totals { margin-top: 16px; margin-left: auto; max-width: 380px; display: grid; gap: 6px; }
.doc-totals > div { display: flex; justify-content: space-between; gap: 12px; }
.doc-totals .final { background: #252733; color: #fff; padding: 10px 12px; border-radius: 6px; font-weight: 700; }
.pdf-frame { width: 100%; height: 760px; border: 1px solid var(--border); border-radius: var(--radius); background: #f2f3f6; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
@media (max-width: 700px) {
  .doc-row { grid-template-columns: 1fr 60px; }
  .doc-row.head { display: none; }
  .doc-row > input:first-child { grid-column: 1 / -1; }
  .pdf-frame { height: 520px; }
}

/* ---- Brand ---- */
.login-logo { text-align: center; margin: 4px 0 14px; }
.login-logo img { width: min(240px, 80%); height: auto; }
.login-title { text-align: center; color: var(--muted); font-weight: 600; margin-bottom: 18px; }
.brand img { object-fit: contain; }

/* ---- Projects ---- */
.chain { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; }
.chain .step { padding: 6px 12px; border-radius: 999px; background: #eceef3; color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.chain .step.done { background: #e5f4ea; color: #146c2e; }
.card.decision { border-top: 3px solid var(--orange); }

/* Verification documents */
.ver-list { list-style: none; padding: 0; margin: 12px 0 0; }
.ver-item { padding: 10px 0; border-top: 1px solid var(--border, #e3e6ee); }
.ver-item .actions { margin-top: 6px; gap: 6px; align-items: center; flex-wrap: wrap; }
.file-hidden { display: none; }
.error-text { color: var(--st-cancelled, #c0392b); }

/* Navigation: six daily places + "More" */
.sidenav a .ico, .sidenav .more-toggle .ico { display: inline-block; width: 1.5em; }
.sidenav .more-toggle { display: flex; align-items: center; width: 100%; margin-top: 10px; padding: 9px 12px; border: 0; border-top: 1px solid var(--border); border-radius: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.sidenav .more-toggle .caret { margin-left: auto; }
.sidenav .more { display: none; }
.sidenav .more.open { display: block; }
.sidenav .more a { font-size: 0.92rem; padding-left: 2.1em; }

/* Today */
.today-grid { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
.today-group h2 { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin: 6px 0 8px; }
.today-group h2 .count { font-size: 0.75rem; background: var(--surface-2); border-radius: 999px; padding: 1px 8px; color: var(--muted); }
.today-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.today-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: inherit; }
.today-item:hover { text-decoration: none; border-color: var(--orange); }
.today-item.p1 { box-shadow: inset 3px 0 0 var(--cherry); }
.today-item .ico { font-size: 1.25rem; width: 1.6em; text-align: center; }
.today-item .txt { display: flex; flex-direction: column; min-width: 0; }
.today-item .txt strong, .today-item .txt span { overflow: hidden; text-overflow: ellipsis; }
.today-item .go { margin-left: auto; color: var(--muted); font-size: 1.3rem; }
.today-clear { text-align: center; padding: 36px 16px; }
.today-clear .big { font-size: 2.2rem; }
.today-cal { list-style: none; margin: 0; padding: 0; }
.today-cal li { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--border); cursor: pointer; }
.today-cal li .muted { grid-column: 2; }
@media (max-width: 860px) {
  .today-grid { grid-template-columns: 1fr; }
  .sidenav .more-toggle { width: auto; margin: 0; border: 0; white-space: nowrap; }
  .sidenav .more.open { display: contents; }
  .sidenav .more a { padding-left: 12px; }
}
@media (max-width: 520px) {
  .topbar .brand span { display: none; }
  .topbar .btn.small, .topbar button.small { padding: 5px 8px; }
}
.today .glance > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); white-space: nowrap; }

/* Part F: client messages review */
.card.wording { padding: 12px 14px; margin: 8px 0; }
.card.wording.approved { border-left: 4px solid var(--green); }
.card.wording textarea { width: 100%; font-family: inherit; }
.card.gov { border: 2px solid #b45309; }
.card.gov .error-box { border-left-color: #b45309; background: #fffbeb; }
.rep-note { background: #eff6ff; border-left: 4px solid #2563eb; padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; }
.rep-note button { margin-left: 8px; }

/* Workspace core: search, tasks */
.top-search { max-width: 340px; flex: 3; margin-left: 18px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line, #e3e4ea); font: inherit; font-size: 0.92rem; }
/* Phones: the search gets its own full-width row under the logo and buttons. */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; height: auto; row-gap: 8px; column-gap: 8px; padding: 12px 12px 10px; }
  .topbar .btn, .topbar button { white-space: nowrap; }
  .top-search { order: 10; flex: 1 1 100%; max-width: none; margin: 0; padding: 9px 14px; font-size: 1rem; }
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h2 { margin: 0; }
.task-list { list-style: none; padding: 0; margin: 10px 0 0; }
.task { border: 1px solid var(--line, #e3e4ea); border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.task.late { border-left: 4px solid #5b5f6b; }
.task.blocked { background: #f3f4f6; }
.task.done strong { text-decoration: line-through; color: var(--muted); }
.task-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.checklist { list-style: none; padding-left: 30px; margin: 6px 0; }
.row.wrap { flex-wrap: wrap; gap: 8px; }
.work-list { list-style: none; padding: 0; margin: 0; }
.work-list li a { display: block; padding: 8px 4px; border-bottom: 1px solid var(--line, #e3e4ea); text-decoration: none; color: inherit; }
.work-list .ico { margin-right: 8px; }

/* ---------- Calendar (month view; a day-by-day list on phones) ---------- */
.cal-kinds { flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.cal-chip { opacity: 0.55; }
.cal-chip.on { opacity: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { font-size: 0.75rem; font-weight: 700; color: var(--muted, #6b7280); text-transform: uppercase; padding: 4px 6px; }
.cal-day { min-height: 104px; border: 1px solid var(--line, #e5e7eb); border-radius: 8px; padding: 4px; cursor: pointer; background: var(--surface, #fff); display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-day.empty { border: 0; background: transparent; cursor: default; }
.cal-day.today .cal-num { background: #a80f37; color: #fff; border-radius: 999px; padding: 0 7px; }
.cal-day.picked { outline: 2px solid #f57913; outline-offset: -1px; }
.cal-day.closed { background: #f7f7fa; }
.cal-num { font-weight: 700; font-size: 0.85rem; align-self: flex-start; }
.cal-ev { display: block; width: 100%; text-align: left; border: 0; border-radius: 5px; padding: 2px 5px; font-size: 0.76rem; line-height: 1.3; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #eef2ff; color: #1f2937; }
.cal-agenda .cal-ev { white-space: normal; font-size: 0.9rem; padding: 6px 8px; margin: 4px 0; }
.cal-ev.done { opacity: 0.55; text-decoration: line-through; }
.cal-ev.k-consultation, .cal-chip.k-consultation.on { background: #fde8ee; }
.cal-ev.k-task, .cal-chip.k-task.on { background: #e8f5ee; }
.cal-ev.k-work_order, .cal-chip.k-work_order.on { background: #fff1e5; }
.cal-ev.k-quotes_close, .cal-chip.k-quotes_close.on { background: #fff8db; }
.cal-ev.k-quotation_expires, .cal-chip.k-quotation_expires.on { background: #eaf1ff; }
.cal-ev.k-closed, .cal-chip.k-closed.on { background: #eceef3; }
.cal-agenda { margin-top: 16px; }
.cal-agenda-day h3 { margin: 14px 0 4px; font-size: 0.95rem; }
.cal-month-list { display: none; }
@media (max-width: 760px) {
  .cal-grid { display: none; }
  .cal-picked-only { display: none; }
  .cal-month-list { display: block; }
}

/* ---- Reply templates ---- */
.reply-actions { display: flex; flex-direction: column; gap: 8px; }
.badge.tpl-team { background: #eef0f4; color: #374151; font-weight: 600; margin-left: 6px; }
.tpl-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 55vh; overflow: auto; }
.tpl-item { text-align: left; display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); white-space: normal; font-weight: 400; }
.tpl-item:hover:not(:disabled) { border-color: var(--cherry); background: #fff7f5; }
.tpl-item:disabled { opacity: 0.55; cursor: not-allowed; }
.tpl-item .small { overflow-wrap: anywhere; }
.tpl-title { font-weight: 600; margin-bottom: 4px; }
.tpl-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.tpl-card .pre-wrap { overflow-wrap: anywhere; }
.tpl-card.hidden-tpl { opacity: 0.6; }
@media (max-width: 760px) {
  .reply-box { flex-direction: column; align-items: stretch; }
  .reply-actions { flex-direction: row; }
  .reply-actions button { flex: 1; }
}

/* ---- Reply timer ---- */
.wait { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.wait-ok { background: #eef0f4; color: #374151; }
.wait-soon { background: #fff4d6; color: #7a4b00; }
.wait-late { background: #fde2e4; color: #9b1028; }
.wait-line { margin: 6px 0; font-weight: 500; }
.install-steps { margin: 0 0 6px; padding-left: 22px; line-height: 1.7; }
.install-hint { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ---- Phone check (shared script) ---- */
.pc-screen { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 16, 0.5); }
.pc-card { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 24px 20px 18px; border-radius: 16px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3); text-align: center; }
.pc-logo { display: block; margin: 0 auto 8px; border-radius: 18px; }
.pc-title { margin: 6px 0 16px; font-size: 1.2rem; }
.pc-list { list-style: none; margin: 0; padding: 0; text-align: left; display: grid; gap: 8px; }
.pc-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); }
.pc-row.wait { opacity: 0.6; }
.pc-row.fail { border-color: #6b21a8; }
.pc-ic { flex: 0 0 auto; font-size: 1.1rem; line-height: 1.4; }
.pc-tx { display: grid; gap: 2px; min-width: 0; }
.pc-tip { color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }
.pc-foot { position: sticky; bottom: -18px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px -20px -18px; padding: 12px 20px 18px; background: var(--surface); border-top: 1px solid transparent; }
.pc-btn { padding: 9px 18px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-weight: 600; cursor: pointer; }
.pc-go { background: var(--cherry); border-color: transparent; color: #fff; }
.pc-btn[hidden] { display: none; }

/* ---- Department workspace: "View as" / department switch ---- */
.view-switch { display: inline-flex; align-items: center; gap: 6px; }
.view-switch select { width: auto; min-width: 0; padding: 5px 8px; font-size: 0.9rem; }
@media (max-width: 700px) { .view-switch { order: 5; } }
.nowrap { white-space: nowrap; }

/* ---- Workspace access: 2-step sign-in, invite, Staff ---- */
.qr-box { display: grid; place-items: center; margin: 12px 0; }
.qr-box img { border: 8px solid #fff; border-radius: 10px; box-shadow: var(--shadow); }
.backup-codes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.backup-codes span { padding: 8px; border: 1px dashed var(--border); border-radius: 8px; text-align: center; letter-spacing: 0.08em; }
.welcome-steps { padding-left: 20px; line-height: 1.6; }
.welcome-steps li { margin-bottom: 14px; }
.dept-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); gap: 4px 16px; margin: 6px 0 8px; }
.dept-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.staff-card .staff-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.staff-card.off { opacity: 0.6; }
.center { text-align: center; }

/* ---- "View as" a department: the yellow bar, Look only / Work as ---- */
.view-bar {
  position: sticky; top: 56px; z-index: 19;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 8px 20px; background: #fff4cc; border-bottom: 2px solid var(--yellow); color: #3d2e00;
}
.view-bar.work { background: #ffe9a8; }
.view-bar .what { flex: 1 1 320px; line-height: 1.35; }
.view-bar .seg { display: inline-flex; border: 1px solid #c99400; border-radius: 8px; overflow: hidden; }
.view-bar .seg button { border: 0; border-radius: 0; background: #fffaf0; color: #3d2e00; }
.view-bar .seg button.on { background: #3d2e00; color: #fff; }
.view-bar .back { background: #fff; }
body.view-look main .primary { opacity: 0.55; }
@media (max-width: 700px) { .view-bar { top: 0; position: relative; padding: 8px 12px; } .view-bar .what { flex-basis: 100%; } }
.card.refused { max-width: 560px; }

/* ---- Departments & access ---- */
.access-wrap { margin: 10px 0; }
.access-matrix { border-collapse: collapse; width: 100%; min-width: 900px; font-size: 0.85rem; }
.access-matrix th, .access-matrix td { border: 1px solid var(--border); padding: 6px; text-align: left; vertical-align: middle; }
.access-matrix thead th { background: var(--surface-2); }
.access-matrix th .sum { display: block; font-weight: 400; color: var(--muted); font-size: 0.78rem; }
.access-matrix tbody th { min-width: 150px; font-weight: 600; }
.access-matrix thead th { font-size: 0.78rem; }
.access-matrix td.fixed { color: var(--muted); white-space: nowrap; }
.access-matrix td.changed { background: #fff4cc; }
.access-matrix select.lvl { width: 100%; min-width: 86px; padding: 4px 2px 4px 6px; font-size: 0.82rem; }
.access-matrix select.lvl-do { border-color: var(--green); background-color: #e8f6ee; color: #12643a; font-weight: 600; }
.access-matrix select.lvl-see { border-color: #9cbbe6; background-color: #eef4fc; color: #1a4f94; }
.access-matrix select.lvl-none { color: var(--muted); background-color: var(--surface-2); }
/* While viewing as a department the switch in the top bar stays yellow (a reminder after scrolling on a phone). */
body.view-look .view-switch select, body.view-work .view-switch select { background-color: #fff4cc; border-color: var(--yellow); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; }
.changed-key { background: #fff4cc; padding: 1px 6px; border-radius: 4px; }
.view-as-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 520px) { .view-as-grid { grid-template-columns: 1fr; } }
.work-chain { padding-left: 20px; }
.work-chain li { margin-bottom: 8px; }
.work-chain li span { display: block; }

/* ---- Practice mode (pretend data, nothing saved) and the guided tutorial ---- */
.practice-bar {
  position: sticky; top: 56px; z-index: 19;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 8px 20px; background: #efe9fb; border-bottom: 2px solid #6b4fbb; color: #2c1d5c;
}
.practice-bar .what { flex: 1 1 320px; }
.practice-bar button { background: #fff; }
body.practice .view-bar { position: relative; top: 0; }
@media (max-width: 700px) { .practice-bar { position: relative; top: 0; padding: 8px 12px; } .practice-bar .what { flex-basis: 100%; } }
.toast.practice { background: #4b3a8f; }
.practice-card { border-left: 4px solid #6b4fbb; }
.tour-target { outline: 3px solid #6b4fbb !important; outline-offset: 3px; border-radius: 8px; animation: tour-pulse 1.6s ease-in-out infinite; }
@keyframes tour-pulse { 0%, 100% { outline-color: #6b4fbb; } 50% { outline-color: #b9a6ef; } }
@media (prefers-reduced-motion: reduce) { .tour-target { animation: none; } }
.tour-panel {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 60;
  width: min(520px, calc(100vw - 24px)); padding: 14px 16px; border-radius: 12px;
  background: #fff; border: 2px solid #6b4fbb; box-shadow: 0 10px 30px rgba(16, 24, 40, 0.22);
}
.tour-panel .tour-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #2c1d5c; }
.tour-panel p { margin: 8px 0 10px; line-height: 1.45; }
.tour-dots { display: flex; gap: 6px; margin-bottom: 10px; }
.tour-dots span { width: 9px; height: 9px; border-radius: 50%; background: #ddd5f5; }
.tour-dots span.done { background: #9b86de; }
.tour-dots span.on { background: #6b4fbb; }
.tour-panel .actions { justify-content: flex-end; }
body.practice main { padding-bottom: 170px; } /* room for the tutorial panel */
.topbar .practice-chip { background: #6b4fbb; color: #fff; border-color: #6b4fbb; font-weight: 600; }
body.practice .topbar { box-shadow: inset 0 -3px 0 #6b4fbb; }

/* Safety: photos from contacts not working with ACHISE yet are blurred until staff choose to look. */
.safe-blur { position: relative; display: inline-block; cursor: pointer; overflow: hidden; border-radius: 8px; }
.safe-blur:not(.shown) img { filter: blur(18px) grayscale(0.4); }
.safe-blur-note { position: absolute; inset: auto 8px 8px 8px; padding: 4px 8px; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: .8rem; text-align: center; }
.safe-blur.shown .safe-blur-note { display: none; }

/* Idea sorting: six choices in two rows of three. */
.sort-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 520px) { .sort-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Daily idea posts: the three times side by side, the accounts in a row. */
.grid.three { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); }
.check-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 6px 0 4px; }

/* Provider messages: one card per conversation (phone and computer). */
.pm-list { display: grid; gap: 10px; }
.pm-item { display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--line, #e5e7eb); border-radius: 12px; color: inherit; text-decoration: none; background: var(--surface, #fff); }
.pm-item:hover { border-color: #c8102e55; }
.pm-item.waiting { border-left: 4px solid #c8102e; }
.pm-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.pm-last { font-size: .92rem; overflow-wrap: anywhere; }
.pm-item .badge { justify-self: start; }
