:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1d2430; --muted: #6b7280; --line: #e3e6ea;
  --brand: #dd3f3e; --primary: #dd3f3e; --primary-ink: #fff; --danger: #b42318; --ok: #15803d; --warn: #b45309;
  --focus: #f59e0b; --radius: 8px;
  --new-bg: #eef9f0; --hover-bg: #e9eef6; --selected-bg: #fbdcdc; --selected-hover-bg: #f7c9c9; --selected-text: #1d2430; --reply-bg: #d1fae5; --reply-strong-bg: #a7f3d0; --reply-text: #064e3b; --reply-bar: #059669;
}
:root { color-scheme: light; }
/* Theme: data-theme="light" | "dark" on <html> is the user's choice; without it, follow the OS. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f141b; --panel: #171e27; --text: #e6e9ee; --muted: #9aa3b2; --line: #2a3340; --brand: #e8605f; --primary: #e8605f; --primary-ink: #0b1220; --danger: #f08b8a; --new-bg: #16281f; --hover-bg: #2a3647; --selected-bg: #7a2a2a; --selected-hover-bg: #8f3333; --selected-text: #ffffff; --reply-bg: #123b2a; --reply-strong-bg: #1b5a3f; --reply-text: #d1fae5; --reply-bar: #34d399; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #0f141b; --panel: #171e27; --text: #e6e9ee; --muted: #9aa3b2; --line: #2a3340; --brand: #e8605f; --primary: #e8605f; --primary-ink: #0b1220; --danger: #f08b8a; --new-bg: #16281f; --hover-bg: #2a3647; --selected-bg: #7a2a2a; --selected-hover-bg: #8f3333; --selected-text: #ffffff; --reply-bg: #123b2a; --reply-strong-bg: #1b5a3f; --reply-text: #d1fae5; --reply-bar: #34d399; color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .brand, .tabs a, .btn, .table th, .tabulator .tabulator-header .tabulator-col-title { letter-spacing: -.01em; }
a { color: var(--primary); }
h1 { font-size: 1.4rem; margin: 0 0 .5rem; } h2 { font-size: 1.1rem; margin: 0 0 .5rem; } h3 { font-size: 1rem; margin: 1rem 0 .3rem; }
small, .small { font-size: .85em; } .muted { color: var(--muted); } .nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.topbar { display: flex; align-items: center; gap: 1.2rem; padding: .5rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; font-size: 1.05rem; color: var(--brand); text-decoration: none; letter-spacing: .01em; }
.brand-icon { width: 28px; height: 28px; display: block; }
.login-card { text-align: center; }
.login-card .stack, .login-card p { text-align: left; }
.login-logo { display: block; margin: -1rem auto 0; width: 220px; height: 220px; }
/* The header never wraps above phone width either: the tab strip takes the free space and scrolls if it must. */
.tabs { display: flex; gap: .2rem; flex-wrap: nowrap; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.tabs a { flex-shrink: 0; white-space: nowrap; }
.tabs a { padding: .4rem .7rem; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--primary); color: var(--primary-ink); }
.tabs a.is-disabled { color: var(--muted); cursor: not-allowed; }
.account { margin-left: auto; display: flex; gap: .8rem; align-items: center; flex-shrink: 0; white-space: nowrap; }
.theme-toggle { margin-left: auto; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; width: 2rem; height: 2rem; cursor: pointer; font-size: 1rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle:hover { border-color: var(--primary); }
.account + .theme-toggle, .tabs ~ .theme-toggle { margin-left: 0; }
.account a { color: var(--text); text-decoration: none; }
.page { padding: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin: 3rem auto; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 1rem; }
.muted-card { background: transparent; }

.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.toolbar .spacer { flex: 1; }
/* Floating bulk-action bar: fixed to the bottom of the window so the grid never moves when rows are selected. */
.bulkbar { position: fixed; left: 1rem; right: 1rem; bottom: 1rem; width: fit-content; margin: 0 auto; z-index: 30; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: center; padding: .55rem .9rem; max-width: calc(100vw - 2rem); background: var(--panel); border: 1px solid var(--primary); border-radius: 1.75rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.bulkbar[hidden], .bulkbar [hidden] { display: none; }
/* Statistics, contacts card: the address-check boxes (v3.58). */
.check-row { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .9rem; margin: .1rem 0 .6rem; }
.check-row .check { gap: .3rem; cursor: pointer; }
.check-row .vdot { margin-right: 0; }
/* Inbox placement tests (v3.55): the line and the inline report in the compose dialog. */
#placement-box:empty { display: none; }
#placement-box { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.placement-line { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.placement-line .btn:last-child { margin-left: auto; }
.placement-status .table { margin-top: .5rem; }
.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: .7rem; }
.stack > .btn { align-self: center; min-width: 12rem; justify-content: center; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: .5rem; }

input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
/* Dropdowns never stretch across a wide card (v3.35): the browser draws the open list as its own window, and on a computer whose
   monitors use different scaling Chrome cut a 1856 px wide list to 1536 px and pushed the option texts off its left edge. */
select:not([multiple]) { max-width: 28rem; }
/* Time zone picker (v3.72): a search box in front of the posted <select>; the list opens in the flow below it. */
.tz-picker { max-width: 40rem; }
.tz-list { list-style: none; margin: .25rem 0 0; padding: .25rem 0; max-height: 13rem; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.tz-list li { padding: .3rem .6rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tz-list li.active, .tz-list li:hover { background: var(--hover-bg); }
.tz-list li.current { font-weight: 600; }
.tz-list li.empty { color: var(--muted); cursor: default; }
.tz-system[hidden] { display: none !important; }
/* Radio groups (Django RadioSelect renders nested <div>s): options in a row, label text next to the dot. */
.field > div:has(> div > label > input[type=radio]) { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; }
.field > div > div > label:has(input[type=radio]) { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; margin: 0; cursor: pointer; }
.field input[type=radio], .field input[type=checkbox] { width: auto; margin: 0; accent-color: var(--primary); }
.toolbar input:not([type=checkbox]), .toolbar select, .bulkbar select { width: auto; min-width: 9rem; }
.toolbar .check { justify-content: flex-start; }
.toolbar input[type=checkbox], .check input[type=checkbox] { width: auto; min-width: 0; margin: 0; }
input[type=search] { min-width: 16rem; }
/* One-line toolbars (v3.22): above phone width nothing ever wraps. Every item can shrink; the search box
   gives way first, then the filter selects and the checkbox labels; buttons keep their size down to 1250 px. Text that no longer
   fits is cut with an ellipsis (the full text stays in the title attribute / accessible name). */
.toolbar.one-line { flex-wrap: nowrap; }
.toolbar.one-line h1 { flex-shrink: 0; white-space: nowrap; }
.toolbar.one-line input[type=search] { flex: 1 10 18rem; min-width: 4.5rem; max-width: 26rem; }
.toolbar.one-line select { flex: 0 4 auto; min-width: 3.5rem; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.toolbar.one-line .check { flex: 0 3 auto; min-width: 2.5rem; overflow: hidden; }
.toolbar.one-line .check > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar.one-line .btn { flex: 0 0 auto; min-width: 2.5rem; display: block; overflow: hidden; text-overflow: ellipsis; text-align: center; }
@media (max-width: 1250px) { .toolbar.one-line .btn { flex-shrink: 1; } }
.toolbar.one-line .toolbar { flex-wrap: nowrap; min-width: 0; margin: 0; }
.field label { display: block; font-weight: 600; margin-bottom: .2rem; }
.field .help { display: block; color: var(--muted); }
.field .error, .errors { color: var(--danger); } .field.has-error input, .field.has-error select { border-color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: .4rem; }
.toolbar .check, .bulkbar .check { white-space: nowrap; }
.req { color: var(--danger); }
.btn { display: inline-flex; align-items: center; gap: .3rem; padding: .45rem .8rem; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.danger { color: var(--danger); } .btn.danger:hover { border-color: var(--danger); }
.btn.link, button.link { border: 0; background: none; color: var(--primary); padding: .2rem .4rem; cursor: pointer; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
button.icon { border: 0; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.table th, .table td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 600; color: var(--muted); font-size: .85em; }
.table.compact td, .table.compact th { padding: .3rem .5rem; }
.table tr.row-unread td { background: var(--selected-bg); color: var(--selected-text); }
.table tr.row-unread td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
/* Replies stand out from every other activity (v3.84): green row and tag; an unread reply is stronger still. */
.table tr.row-replied td { background: var(--reply-bg); color: var(--reply-text); font-weight: 600; } /* bold since v3.99 */
.table tr.row-replied td:first-child { box-shadow: inset 3px 0 0 var(--reply-bar); }
.table tr.row-replied.row-unread td { background: var(--reply-strong-bg); }
.table tr.row-replied td a { color: inherit; }
.tag-new { background: var(--primary); color: var(--primary-ink); }
.tag { display: inline-block; padding: .05rem .45rem; border-radius: 99px; font-size: .8em; background: var(--line); }
a.tag-link { color: inherit; text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 2px; }
a.tag-link:hover { color: var(--primary); text-decoration-color: currentColor; }
.tag-suspect { background: #fde68a; color: #78350f; border: 1px dashed #b45309; }
.tag-dnc { background: #fecaca; color: #7f1d1d; }
.tag-status-new { background: #e5e7eb; color: #374151; } .tag-status-doc_shared { background: #cffafe; color: #155e75; }
.tag-status-contacted { background: #dbeafe; color: #1e3a8a; }
.tag-status-replied { background: #d1fae5; color: #065f46; } .tag-status-in_discussion { background: #ede9fe; color: #4c1d95; }
.tag-status-pending { background: #fef3c7; color: #78350f; } .tag-status-success { background: #bbf7d0; color: #14532d; }
.tag-status-rejected { background: #fee2e2; color: #7f1d1d; } .tag-status-do_not_contact { background: #fecaca; color: #7f1d1d; text-decoration: line-through; }
.tag-email { background: var(--line); }
.tag-email_replied { background: var(--reply-bar); color: #fff; font-weight: 600; white-space: nowrap; }

.stats-row { display: flex; flex-wrap: wrap; gap: 1rem; margin: .5rem 0 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem 1rem; display: flex; flex-direction: column; min-width: 7rem; }
.stat .num { font-size: 1.5rem; font-weight: 700; }
.notes { list-style: none; padding: 0; } .notes li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.report { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1.2rem; }

.modal { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; width: min(640px, 94vw); max-height: 90vh; max-height: 90dvh; overflow: auto; background: var(--panel); color: var(--text); }
.modal::backdrop { background: rgba(0,0,0,.4); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.modal-head h2 { margin: 0; }
/* Pending work (v3.24): a thin bar slides along the top while any request is in flight (HTMX, grid
   loads); it appears only when a request lasts longer than 150 ms so quick ones do not flicker. */
.busy { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; pointer-events: none; background: linear-gradient(90deg, transparent 0%, var(--primary) 50%, transparent 100%); background-size: 40% 100%; background-repeat: no-repeat; animation: busy-slide 1.1s ease-in-out infinite; }
.busy[hidden] { display: none; }
/* A button's own display rule beats the browser's [hidden]: without this, "Enable on this device" and
   "Disable on this device" (My settings) both showed whatever the state. */
.btn[hidden] { display: none; }
@keyframes busy-slide { from { background-position: -60% 0; } to { background-position: 160% 0; } }
/* The element that sent a request (a form on submit, a button with hx-get/hx-post) carries htmx-request
   while it waits: its buttons lock and the primary one shows a spinner. */
form.htmx-request .actions .btn, .btn.htmx-request { pointer-events: none; opacity: .75; }
form.htmx-request .actions button[type=submit]::before, .btn.htmx-request::before { content: ""; display: inline-block; width: .8em; height: .8em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .4rem; z-index: 50; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); padding: .5rem .8rem; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.toast-error, .toast-danger { border-left-color: var(--danger); } .toast-warning { border-left-color: var(--warn); }
.messages { margin-bottom: .8rem; display: flex; flex-direction: column; gap: .4rem; }

/* Tabulator tweaks */
.tabulator { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); font-size: 13px; }
.tabulator .tabulator-header { background: var(--panel); border-bottom: 1px solid var(--line); }
.tabulator .tabulator-header .tabulator-col { background: var(--panel); border-right: 1px solid var(--line); }
.tabulator-row { background: var(--panel); color: var(--text); border-bottom: 1px solid var(--line); }
.tabulator-row.tabulator-row-even { background: var(--bg); }
.tabulator-row.tabulator-selectable:hover { background: var(--hover-bg) !important; color: var(--text); }
.tabulator-row.tabulator-selectable:hover .tabulator-cell { color: var(--text); }
.tabulator-row.tabulator-selected { background: var(--selected-bg) !important; color: var(--selected-text); }
.tabulator-row.tabulator-selected .tabulator-cell, .tabulator-row.tabulator-selected a { color: var(--selected-text); }
.tabulator-row.tabulator-selected a { text-decoration: underline; }
.tabulator-row.tabulator-selected:hover { background: var(--selected-hover-bg) !important; }
body.drag-select, body.drag-select * { user-select: none !important; }
/* Google's file picker (Drive page, v3.30) positions itself with absolute coordinates that land
   off-screen in our layout; pin it to the viewport instead. */
.picker-dialog-bg { position: fixed !important; inset: 0 !important; width: auto !important; height: auto !important; }
.picker-dialog { position: fixed !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%); max-width: calc(100vw - 2rem); max-height: calc(100vh - 2rem); }
.lasso { position: fixed; border: 1px solid var(--primary); background: color-mix(in srgb, var(--primary) 18%, transparent); pointer-events: none; z-index: 40; border-radius: 2px; }
::selection { background: var(--primary); color: var(--primary-ink); }
/* Contacts added in the last 24 hours: a light tint that hover and selection override. */
.tabulator-row.row-new, .tabulator-row.row-new.tabulator-row-even { background: var(--new-bg); }
.tabulator-row.row-dnc .tabulator-cell { color: var(--muted); }
.tabulator-row.row-archived { opacity: .6; }
.tabulator-row.row-unread { box-shadow: inset 3px 0 0 var(--primary); }
.tabulator-row.row-suspect { box-shadow: inset 3px 0 0 var(--warn); border-left: 1px dashed var(--warn); }
.tabulator-menu { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 13px; min-width: 240px; max-height: calc(100vh - 24px); overflow-y: auto; overscroll-behavior: contain; }
.tabulator-menu .tabulator-menu-item { padding: .4rem .8rem; }
.tabulator-menu .tabulator-menu-item:not(.tabulator-menu-item-disabled):hover,
.tabulator-menu .tabulator-menu-item:not(.tabulator-menu-item-disabled):focus { background: var(--hover-bg) !important; color: var(--text); cursor: pointer; }
.tabulator-menu .tabulator-menu-item.tabulator-menu-item-disabled { opacity: .45; cursor: default; }
.tabulator-menu .tabulator-menu-item.tabulator-menu-item-disabled:hover { background: transparent !important; }
.tabulator-menu .tabulator-menu-separator { border-top: 1px solid var(--line); }
/* Responsive collapse: columns that do not fit the window fold into a row that the "+" toggle opens. */
/* width: 0 + min-width: 100% keeps the folded content from widening the inline-block row. */
.tabulator-row .tabulator-responsive-collapse { width: 0; min-width: 100%; border-top: 1px solid var(--line); border-bottom: 0; padding: .3rem .8rem .5rem 5.5rem; }
.tabulator-row .tabulator-responsive-collapse table { width: 100%; table-layout: fixed; font-size: 12.5px; border-collapse: collapse; }
.tabulator-row .tabulator-responsive-collapse table tr td { padding: .15rem 1rem .15rem 0; vertical-align: top; white-space: normal; overflow-wrap: anywhere; }
.tabulator-row .tabulator-responsive-collapse table tr td:first-of-type { width: 8rem; color: var(--muted); white-space: nowrap; }
.tabulator-row.tabulator-selected .tabulator-responsive-collapse table tr td:first-of-type { color: var(--selected-text); opacity: .8; }
.tabulator-row .tabulator-cell .tabulator-responsive-collapse-toggle { background: var(--muted); }
.tabulator-row .tabulator-cell .tabulator-responsive-collapse-toggle svg { stroke: var(--panel); }
/* Residents grid with every column visible (v3.42): narrow columns keep their titles because a title may wrap onto two lines and
   the sort arrow takes no room until the column is hovered or sorted. */
.tabulator.grid-dense .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title { white-space: normal; line-height: 1.15; padding-right: 0; }
.tabulator.grid-dense .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="none"] .tabulator-col-sorter { display: none; }
.tabulator.grid-dense .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="none"]:hover .tabulator-col-sorter { display: flex; background: var(--panel); }
.tabulator.grid-dense .tabulator-header .tabulator-col.tabulator-sortable:not([aria-sort="none"]) .tabulator-col-content .tabulator-col-title { padding-right: 16px; }
/* Filter boxes line up along the bottom of the header even when a neighbour's title takes two lines. */
.tabulator.grid-dense .tabulator-header .tabulator-col .tabulator-col-content { display: flex; flex-direction: column; height: 100%; box-sizing: border-box; }
.tabulator.grid-dense .tabulator-header .tabulator-col .tabulator-header-filter { margin-top: auto; }
.tabulator-footer { background: var(--panel) !important; border-top: 1px solid var(--line) !important; color: var(--text); }
.tabulator .tabulator-footer .tabulator-page { color: var(--text); border-color: var(--line); background: var(--panel); }
.tabulator .tabulator-footer .tabulator-page.active { color: var(--primary); }
.tabulator-footer .tabulator-footer-contents { flex-wrap: wrap; gap: .3rem; }
.tabulator-footer .tabulator-pages { display: inline-flex; align-items: center; gap: .25rem; }
.tabulator-footer .page-dots { color: var(--muted); padding: 0 .1rem; user-select: none; }
.tabulator-footer .tabulator-paginator { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .25rem; }
.tabulator-footer .page-goto { display: inline-flex; align-items: center; gap: .3rem; margin-left: .35rem; font-size: .85rem; color: var(--muted); }
.tabulator-footer .page-goto input { width: 4.6rem; min-width: 0; padding: .15rem .3rem; font-size: .85rem; }
.tabulator-footer .tabulator-page-counter { font-size: .85rem; color: var(--muted); padding: 0 .35rem; white-space: nowrap; } /* v3.92 */
.tabulator-footer .page-count strong { color: var(--text); font-weight: 600; }
@media (max-width: 700px) { .tabulator-footer .page-count-range { display: none; } }
.tabulator-footer select.tabulator-page-size { width: auto; min-width: 0; padding: .15rem .3rem; }
.tabulator .tabulator-cell.cell-num { color: var(--muted); font-variant-numeric: tabular-nums; }
.cell-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-right: .3rem; vertical-align: middle; }
/* Address verification dot (spec 7b): green valid, amber risky, red invalid, grey unknown, hollow = not verified. */
.vdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .35rem; vertical-align: middle; border: 1px solid var(--muted); background: transparent; }
.vdot-valid { background: var(--ok); border-color: var(--ok); }
/* One shape per result (v3.40), so the mark reads without colour: dot valid, square risky, cross invalid, diamond unknown, ring not verified. */
.vdot-risky { background: var(--warn); border-color: var(--warn); border-radius: 1px; }
/* Invalid is a red cross, not a dot (v3.39): the shape tells it apart without relying on colour. Two diagonal strokes drawn as gradients. */
.vdot-invalid { width: 10px; height: 10px; margin-left: -1px; margin-right: calc(.35rem - 1px); border: 0; border-radius: 0; background:
  linear-gradient(45deg, transparent calc(50% - 1px), var(--danger) calc(50% - 1px), var(--danger) calc(50% + 1px), transparent calc(50% + 1px)),
  linear-gradient(-45deg, transparent calc(50% - 1px), var(--danger) calc(50% - 1px), var(--danger) calc(50% + 1px), transparent calc(50% + 1px)); }
.vdot-unknown { width: 7px; height: 7px; margin-left: 1px; margin-right: calc(.35rem + 1px); background: var(--muted); border-color: var(--muted); border-radius: 0; transform: rotate(45deg); }
/* Override ("send anyway"): a red ring around the cross. */
.vdot-ignored { position: relative; margin-left: 3px; margin-right: calc(.35rem + 3px); }
.vdot-ignored::after { content: ""; position: absolute; inset: -4px; border: 1px solid var(--danger); border-radius: 50%; }
.vdot-pending { animation: vdot-pulse 1.2s ease-in-out infinite; }
@keyframes vdot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* Template editor / preview */
.preview-box { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .7rem; background: var(--bg); min-height: 12rem; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; } .preview-head p { margin: .2rem 0; min-width: 0; overflow-wrap: anywhere; } .preview-copy { display: inline-flex; gap: .3rem; flex: 0 0 auto; }
.preview-frame { width: 100%; height: 18rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pre { white-space: pre-wrap; font: 12px/1.4 ui-monospace, monospace; background: var(--bg); padding: .5rem; border-radius: 6px; }
.warn { background: #fef3c7; color: #78350f; border: 1px solid #f59e0b; border-radius: 6px; padding: .3rem .6rem; margin-bottom: .4rem; }
.btn.small { padding: .2rem .5rem; font-size: .85em; }
.modal.wide { width: min(1100px, 96vw); }
code { font-size: .9em; background: var(--bg); padding: 0 .25rem; border-radius: 3px; }

/* Resume review */
.resume-frame { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.resume-img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; }
.resume-text { max-height: 75vh; overflow: auto; }
.field.conf-low input, .field.conf-low select, .field.conf-low textarea { border-color: var(--warn); background: #fffbeb; }
.field.conf-medium input, .field.conf-medium select { border-color: #93c5fd; }
.tag.small { font-size: .7em; vertical-align: middle; }

/* Notifications bell */
.bell-wrap { position: relative; }
.bell { border: 0; background: none; font-size: 1.1rem; cursor: pointer; position: relative; padding: .2rem .4rem; }
.bell .badge { position: absolute; top: -2px; right: -4px; background: var(--danger); color: #fff; border-radius: 99px; font-size: .65rem; padding: 0 .35rem; }
.bell-menu { position: absolute; right: 0; top: 2rem; width: min(22rem, calc(100vw - 1.5rem)); max-height: 24rem; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 40; }
.bell-head { display: flex; gap: .6rem; align-items: center; padding: .5rem .8rem; border-bottom: 1px solid var(--line); }
.bell-head a, .bell-head button { margin-left: auto; }
.bell-menu ul { list-style: none; margin: 0; padding: 0; }
.bell-menu li { padding: .45rem .8rem; border-bottom: 1px solid var(--line); }
.bell-menu li.unread { background: rgba(37,99,235,.08); }
.bell-menu li.replied { background: var(--reply-bg); box-shadow: inset 3px 0 0 var(--reply-bar); font-weight: 600; } /* v3.94, bold since v3.99 */
.bell-menu li.replied.unread { background: var(--reply-strong-bg); }
.bell-menu li a { color: var(--text); text-decoration: none; display: block; }
.signature-frame { height: 8rem; }


/* --- Statistics (dataviz palette: categorical slots 1-4, sequential blue; dark steps are selected, not flipped) --- */
:root { --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a; --viz-4: #e34948; --viz-seq: #2a78d6; --viz-seq-light: #cde2fb; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #e66767; --viz-seq: #3987e5; --viz-seq-light: #184f95; } }
:root[data-theme="dark"] { --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #e66767; --viz-seq: #3987e5; --viz-seq-light: #184f95; }
.kpis { flex-wrap: wrap; }
.viz-box { position: relative; height: 280px; }
.viz-box.short { height: 160px; }
#stats.loading .viz-card { opacity: .6; transition: opacity .2s; }
.heatmap { overflow-x: auto; }
table.heat { border-collapse: separate; border-spacing: 2px; font-size: .75rem; }
table.heat th { color: var(--muted); font-weight: 500; text-align: center; padding: 0 .1rem; }
table.heat td { padding: 0; }
table.heat .cell { display: block; width: 1.6rem; height: 1.3rem; line-height: 1.3rem; text-align: center; border-radius: 3px; color: var(--text);
  background: color-mix(in oklab, var(--viz-seq) calc(var(--v) * 100%), var(--panel)); }
table.heat .cell[style*="--v:1"] , table.heat .cell[style*="--v:0.9"], table.heat .cell[style*="--v:0.8"], table.heat .cell[style*="--v:0.7"] { color: #fff; }
.ctx-menu { position: absolute; z-index: 60; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 13px; min-width: 240px; padding: .25rem 0; }
.ctx-item { padding: .4rem .8rem; cursor: pointer; }
.ctx-item:hover { background: var(--hover-bg); }
.ctx-item.disabled { opacity: .45; cursor: default; }
.ctx-item.disabled:hover { background: transparent; }
.budget-meter { width: 100%; height: 8px; margin-top: .3rem; }
#usage-filters { margin: 0; }
/* Stat tiles inside cards wrap to the card width; the chart below takes the remaining height so sibling cards line up. */
.viz-card { display: flex; flex-direction: column; }
.viz-card .viz-box.short { flex: 1; height: auto; min-height: 160px; }
.viz-card .stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: .6rem; margin: .4rem 0 .8rem; }
.viz-card .stats-row .stat { min-width: 0; padding: .5rem .7rem; }
.viz-card .stats-row .stat .num { font-size: 1.3rem; }

/* --- Ask AI panel --- */
.ai-button { margin-right: .4rem; }
.ai-panel { position: fixed; top: 0; right: 0; height: 100vh; height: 100dvh; width: min(440px, 100vw); z-index: 40; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(0,0,0,.18); }
.ai-panel[hidden] { display: none; }
.ai-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.ai-head .spacer { flex: 1; }
.ai-log { flex: 1; overflow-y: auto; padding: .8rem; display: flex; flex-direction: column; gap: .6rem; }
.ai-msg { display: flex; flex-direction: column; gap: .25rem; max-width: 100%; }
.ai-user { align-items: flex-end; }
.ai-bubble { padding: .5rem .7rem; border-radius: 10px; white-space: pre-wrap; line-height: 1.45; font-size: .93rem; }
.ai-user .ai-bubble { background: var(--selected-bg); color: var(--selected-text); }
.ai-assistant .ai-bubble { background: var(--hover-bg); }
.ai-msg.thinking .ai-bubble:empty::after { content: "…"; opacity: .6; animation: ai-pulse 1s infinite; }
.ai-error .ai-bubble { border: 1px solid #e34948; }
.ai-tools .tag { margin: .1rem 0; }
.ai-form { display: flex; gap: .5rem; padding: .6rem .8rem; border-top: 1px solid var(--line); }
.ai-form textarea { flex: 1; resize: none; }
@keyframes ai-pulse { 50% { opacity: .2; } }
.spinner { display: inline-block; width: .9em; height: .9em; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -.1em; }
@keyframes spin { to { transform: rotate(360deg); } }
.prose p { margin: .3rem 0; }

/* --- Small screens (phones and narrow tablets) --- */
@media (max-width: 1380px) {
  /* Header below 1380 px: brand, account and theme switch on the first row; the tabs become a full-width
     strip below that scrolls only on phones. One row with eleven tabs ("Email Templates", "Google Drive",
     v3.33) does not fit narrower windows. */
  .topbar { flex-wrap: wrap; gap: .4rem .6rem; padding: .45rem .75rem; }
  .tabs { order: 10; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -.75rem; padding: .1rem .75rem; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex-shrink: 0; padding: .35rem .6rem; }
}
@media (max-width: 900px) {
  .account { gap: .5rem; }
  .account a { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .account a small { display: none; }
  .page { padding: .75rem; }
  .card { padding: .8rem .9rem; }
}
@media (max-width: 700px) {
  html, body { font-size: 15px; }
  /* Toolbars: title on its own line, search full width, filters share rows, buttons wrap. */
  .toolbar h1 { flex: 1 0 100%; }
  .toolbar.one-line, .toolbar.one-line .toolbar { flex-wrap: wrap; }
  .toolbar .spacer { display: none; }
  .toolbar input[type=search], .toolbar.one-line input[type=search] { flex: 1 1 100%; max-width: none; min-width: 0; }
  .toolbar select, .toolbar input:not([type=checkbox]):not([type=search]) { flex: 1 1 10rem; min-width: 0; }
  .toolbar .btn { flex: 1 1 auto; justify-content: center; }
  .toolbar .check { flex: 0 1 auto; }
  .toolbar.one-line .btn, .toolbar.one-line select, .toolbar.one-line .check { flex-shrink: 1; min-width: 0; overflow: visible; }
  .page { padding: .6rem; }
  .card { padding: .7rem .75rem; margin-bottom: .7rem; }
  .card.narrow { margin: 1rem auto; }
  .login-logo { width: 160px; height: 160px; }
  h1 { font-size: 1.25rem; }
  /* iOS zooms into fields smaller than 16px; keep them readable without the jump. */
  input, select, textarea { font-size: 16px; }
  .btn { padding: .5rem .8rem; }
  .btn.small { padding: .3rem .55rem; }
  .modal, .modal.wide { width: calc(100vw - .8rem); max-height: calc(100dvh - .8rem); padding: .8rem .8rem; border-radius: 8px; }
  .modal-head h2 { font-size: 1rem; }
  .preview-frame, .resume-frame { height: 50vh; }
  .stat { flex: 1 1 7rem; min-width: 0; padding: .5rem .7rem; }
  .stat .num { font-size: 1.25rem; }
  .viz-box { height: 220px; }
  .bulkbar { left: .5rem; right: .5rem; bottom: .5rem; padding: .45rem .6rem; gap: .35rem; border-radius: 12px; max-width: calc(100vw - 1rem); }
  .bulkbar select, .bulkbar .btn { flex: 1 1 auto; min-width: 0; }
  .toasts { left: .6rem; right: .6rem; bottom: .6rem; }
  .ai-panel { width: 100vw; }
  .ctx-menu { min-width: 200px; max-width: calc(100vw - 1rem); }
  .tabulator-menu { min-width: 200px; max-width: calc(100vw - 1rem); }
  .tabulator { font-size: 12.5px; }
  .tabulator-row .tabulator-responsive-collapse { padding-left: 1rem; }
  .tabulator-row .tabulator-responsive-collapse table tr td:first-of-type { width: 6.5rem; }
  /* Tables scroll sideways in their wrapper; headers stay on one line and cells keep a usable width. */
  .table th { white-space: nowrap; }
  .table td { min-width: 6rem; }
  .table td.nowrap, .table td:empty { min-width: 0; }
  .table td.wide { min-width: 16rem; }
}
