: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;
  --hover-bg: #e9eef6; --selected-bg: #fbdcdc; --selected-hover-bg: #f7c9c9; --selected-text: #1d2430;
}
: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; --hover-bg: #2a3647; --selected-bg: #7a2a2a; --selected-hover-bg: #8f3333; --selected-text: #ffffff; 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; --hover-bg: #2a3647; --selected-bg: #7a2a2a; --selected-hover-bg: #8f3333; --selected-text: #ffffff; 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; }
.tabs { display: flex; gap: .2rem; flex-wrap: wrap; }
.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; }
.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; max-width: 1600px; margin: 0 auto; }
.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(320px, 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: 50%; bottom: 1rem; transform: translateX(-50%); 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: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.bulkbar[hidden] { display: none; }
.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; 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); }
/* 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, .toolbar select, .bulkbar select { width: auto; min-width: 9rem; }
input[type=search] { min-width: 16rem; }
.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; 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 { 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); }
.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); }
.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-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); }

.stats-row { display: flex; 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; gap: 1.2rem; }

.modal { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; width: min(640px, 94vw); max-height: 90vh; 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; }
.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; }
.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); }
.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:hover, .tabulator-menu .tabulator-menu-item:focus { background: var(--selected-bg); }
.tabulator-menu .tabulator-menu-item.tabulator-menu-item-disabled { opacity: .45; }
.tabulator-menu .tabulator-menu-separator { border-top: 1px solid var(--line); }
.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); }
.cell-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-right: .3rem; vertical-align: middle; }
.row-menu-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 4px; padding: 0 .4rem; cursor: pointer; line-height: 1.3; }

/* Template editor / preview */
.preview-box { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .7rem; background: var(--bg); min-height: 12rem; }
.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: 22rem; 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 a { color: var(--text); text-decoration: none; display: block; }
.signature-frame { height: 8rem; }
