:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1d2430; --muted: #6b7280; --line: #e3e6ea;
  --primary: #2563eb; --primary-ink: #fff; --danger: #c0392b; --ok: #15803d; --warn: #b45309;
  --focus: #f59e0b; --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141b; --panel: #171e27; --text: #e6e9ee; --muted: #9aa3b2; --line: #2a3340; --primary: #60a5fa; --primary-ink: #0b1220; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
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 { font-weight: 700; color: var(--text); text-decoration: none; }
.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; }
.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; }
.bulkbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .5rem .8rem; margin-bottom: .6rem; background: var(--panel); border: 1px solid var(--primary); border-radius: var(--radius); }
.bulkbar[hidden] { display: none; }
.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: .7rem; }
.actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .5rem; }

input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]), select, textarea { width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.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; }
.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-selected { background: rgba(37,99,235,.12) !important; }
.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; }
.tabulator-menu .tabulator-menu-item { padding: .4rem .8rem; }
.tabulator-menu .tabulator-menu-item:hover, .tabulator-menu .tabulator-menu-item:focus { background: rgba(37,99,235,.12); }
.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; }
