:root {
  --red: #e30613;
  --red-dark: #bd0010;
  --red-soft: #fff0f1;
  --ink: #172033;
  --muted: #687386;
  --line: #e4e8ef;
  --surface: #ffffff;
  --page: #f4f6f9;
  --shadow: 0 18px 46px rgba(22, 32, 51, .11);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--page); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { width: 1.2em; height: 1.2em; fill: currentColor; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }

.login-page {
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 18% 100%, rgba(255,255,255,.42) 0 7%, transparent 24%),
    radial-gradient(ellipse at 80% 105%, rgba(255,255,255,.38) 0 10%, transparent 27%),
    linear-gradient(145deg, #344b56 0%, #70828b 53%, #435963 100%);
}
.login-page::before { content: ""; position: fixed; inset: 0; background: linear-gradient(rgba(18,31,38,.1), rgba(18,31,38,.25)); pointer-events: none; }
.login-shell { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 42px 20px 82px; }
.login-card { width: min(100%, 460px); padding: 38px 40px 40px; background: rgba(255,255,255,.97); border: 1px solid rgba(255,255,255,.8); border-radius: 24px; box-shadow: 0 30px 80px rgba(8,20,26,.32); }
.compact-card { width: min(100%, 520px); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 26px; text-align: left; }
.login-logo { width: 66px; height: 66px; object-fit: contain; }
.login-brand strong { display: block; font-size: 15px; letter-spacing: -.35px; }
.login-brand span { display: block; margin-top: 3px; color: var(--red); font-size: 13px; font-weight: 750; }
.login-heading { margin-bottom: 28px; text-align: center; }
.eyebrow { margin: 0 0 7px; color: var(--red); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.login-heading h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; text-transform: uppercase; }
.login-heading > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.login-form { display: grid; gap: 17px; }
.field { display: grid; gap: 7px; color: #4e596d; font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea, .filters input, .filters select {
  width: 100%; min-height: 46px; padding: 11px 13px; color: var(--ink); background: #fff; border: 1px solid #d8dee8; border-radius: 10px; outline: none; transition: border-color .18s, box-shadow .18s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus { border-color: rgba(227,6,19,.7); box-shadow: 0 0 0 4px rgba(227,6,19,.08); }
.input-with-icon { position: relative; }
.input-with-icon input { min-height: 56px; padding: 17px 48px 17px 15px; background: #f1f5fb; border-color: #dbe3ef; }
.input-with-icon > svg, .password-toggle { position: absolute; top: 50%; right: 15px; transform: translateY(-50%); color: var(--red); }
.password-toggle { display: grid; place-items: center; padding: 4px; background: none; border: 0; cursor: pointer; }
.field-error { color: var(--red); font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 10px 17px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; line-height: 1; text-decoration: none; cursor: pointer; transition: transform .15s, background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--red), #c50010); box-shadow: 0 9px 20px rgba(227,6,19,.22); }
.btn-primary:hover { background: linear-gradient(135deg, #ee1420, #b6000e); }
.btn-secondary { color: #fff; background: #293449; }
.btn-ghost { color: #4f5b6d; background: #fff; border-color: #dce1e9; }
.btn-block { width: 100%; min-height: 54px; margin-top: 5px; text-transform: uppercase; letter-spacing: .035em; }
.btn-small { min-height: 36px; padding: 7px 12px; font-size: 13px; }
.login-footer { position: absolute; bottom: 22px; display: grid; gap: 7px; color: rgba(255,255,255,.88); font-size: 12px; font-weight: 650; text-align: center; }
.login-footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; }
.login-footer a { color: #fff; text-underline-offset: 3px; }

.legal-page { background: #f4f6f9; }
.legal-header { background: #fff; border-bottom: 1px solid var(--line); }
.legal-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; width: min(900px, calc(100% - 40px)); margin: 0 auto; padding: 17px 0; }
.legal-header .brand img { width: 44px; height: 44px; }
.legal-back { color: var(--red); font-size: 13px; font-weight: 750; text-decoration: none; }
.legal-shell { width: min(900px, calc(100% - 40px)); margin: 34px auto 60px; padding: clamp(26px, 5vw, 52px); background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 28px rgba(22,32,51,.06); }
.legal-title { padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.legal-title h1 { margin: 0; font-size: clamp(29px, 5vw, 42px); letter-spacing: -.04em; }
.legal-title p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.legal-content { color: #3e4a5d; font-size: 15px; line-height: 1.75; }
.legal-content h2 { margin: 34px 0 10px; color: var(--ink); font-size: 20px; letter-spacing: -.02em; }
.legal-content h3 { margin: 24px 0 8px; color: var(--ink); font-size: 16px; }
.legal-content p { margin: 9px 0; }
.legal-content ul, .legal-content ol { margin: 10px 0; padding-left: 22px; }
.legal-content li + li { margin-top: 7px; }
.legal-content a { color: var(--red); font-weight: 700; }
.legal-notice { margin: 22px 0; padding: 15px 17px; color: #714f00; background: #fff8e8; border: 1px solid #f1dfae; border-radius: 11px; }
.legal-contact { padding: 18px; background: #f7f8fa; border-radius: 12px; }
.legal-footer { width: min(900px, calc(100% - 40px)); margin: -35px auto 30px; color: var(--muted); font-size: 12px; text-align: center; }

.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 10px max(24px, calc((100vw - 1400px) / 2)); background: rgba(255,255,255,.95); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand img { width: 48px; height: 48px; object-fit: contain; }
.brand span, .user-copy { display: grid; }
.brand strong { letter-spacing: -.02em; }
.brand small, .user-copy small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.user-menu { position: relative; display: flex; align-items: center; gap: 10px; }
.user-avatar { display: grid; place-items: center; width: 40px; height: 40px; color: #fff; background: var(--red); border-radius: 50%; font-weight: 800; }
.user-copy strong { max-width: 180px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: #f0f2f5; }
.dropdown { position: absolute; top: calc(100% + 10px); right: 0; display: none; width: 190px; padding: 7px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.dropdown.is-open { display: block; }
.dropdown a, .dropdown button { display: block; width: 100%; padding: 10px 11px; color: #3f4a5b; background: none; border: 0; border-radius: 7px; font-size: 13px; text-align: left; text-decoration: none; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { color: var(--red); background: var(--red-soft); }
.dropdown form { margin: 0; }

.dashboard-shell { width: min(1400px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 60px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.page-heading h1 { margin: 0; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.04em; }
.page-heading > div > p:last-child { margin: 7px 0 0; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-card { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.stat-icon { display: grid; flex: 0 0 auto; place-items: center; width: 44px; height: 44px; border-radius: 11px; }
.stat-icon svg { width: 23px; height: 23px; }
.stat-icon.red { color: var(--red); background: var(--red-soft); }
.stat-icon.amber { color: #b66c00; background: #fff4dd; }
.stat-icon.blue { color: #1769ca; background: #eaf3ff; }
.stat-icon.green { color: #168357; background: #e8f8f0; }
.stat-card > span:last-child { display: grid; gap: 2px; }
.stat-card small { color: var(--muted); font-size: 12px; }
.stat-card strong { font-size: 25px; letter-spacing: -.04em; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 18px rgba(22,32,51,.035); }
.filter-panel { margin-bottom: 18px; padding: 15px; }
.filters { display: grid; grid-template-columns: minmax(240px, 1fr) 190px 160px 160px auto auto; gap: 10px; align-items: end; }
.search-field { position: relative; }
.search-field svg { position: absolute; z-index: 1; top: 50%; left: 13px; transform: translateY(-50%); color: #8b95a5; }
.search-field input { padding-left: 42px; }
.filters select, .filters input { min-height: 44px; }
.date-field { display: grid; gap: 4px; color: var(--muted); font-size: 10px; font-weight: 750; }
.table-panel { overflow: hidden; }
.table-heading { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 14px; }
.table-heading h2 { margin: 0; font-size: 18px; }
.table-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 18px; color: #7b8595; background: #f8f9fb; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .055em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 16px 18px; border-bottom: 1px solid #edf0f4; font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
td strong, td time { display: grid; gap: 3px; }
td small { display: block; color: #8a94a4; font-size: 10px; font-weight: 500; }
.phone-link { color: #32405a; font-weight: 700; text-decoration: none; }
.phone-link:hover { color: var(--red); }
.badge { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.badge-pending { color: #996000; background: #fff3d8; }
.badge-unreachable { color: #687386; background: #edf0f4; }
.badge-contacted { color: #1665bb; background: #e7f2ff; }
.badge-member { color: #11794e; background: #e4f7ed; }
.badge-negative { color: #b4232d; background: #ffe7e9; }
.badge-unavailable { color: #8a4d10; background: #fcebdc; }
.badge-other_district { color: #6750a4; background: #eee9ff; }
.note-preview { max-width: 260px; color: #566174; }
.action-cell { text-align: right; }
.empty-state { padding: 50px 20px; color: var(--muted); text-align: center; }
.empty-state span { font-size: 40px; }
.empty-state h3 { margin: 8px 0 5px; color: var(--ink); }
.empty-state p { margin: 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 16px; border-top: 1px solid var(--line); font-size: 12px; }
.pagination a { color: var(--red); font-weight: 750; text-decoration: none; }

.messages { position: fixed; z-index: 100; top: 88px; right: 24px; display: grid; gap: 8px; width: min(390px, calc(100% - 48px)); }
.alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 10px; font-size: 13px; font-weight: 650; }
.alert-error { color: #9e1822; background: #ffe7e9; border: 1px solid #ffcbd0; }
.alert-success { color: #116b47; background: #e7f8ef; border: 1px solid #c5edda; box-shadow: var(--shadow); }
.alert-warning { color: #8c5800; background: #fff3d8; border: 1px solid #ffe2a6; box-shadow: var(--shadow); }
.alert button { padding: 0; color: inherit; background: none; border: 0; font-size: 20px; cursor: pointer; }

.modal { width: min(580px, calc(100% - 28px)); max-height: calc(100vh - 36px); padding: 0; background: #fff; border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(15,23,42,.28); }
.modal::backdrop { background: rgba(17,24,39,.62); backdrop-filter: blur(3px); }
.modal-wide { width: min(1050px, calc(100% - 28px)); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 23px 25px 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 23px; letter-spacing: -.025em; }
.modal-header .phone-link { display: inline-block; margin-top: 5px; font-size: 13px; }
.modal-close { display: grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; padding: 0; color: #697486; background: #f1f3f6; border: 0; border-radius: 50%; font-size: 22px; cursor: pointer; }
.modal-body { padding: 22px 25px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 25px; background: #f9fafb; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-grid .full { grid-column: 1 / -1; }
.meta-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 12px; color: var(--muted); background: #f7f8fa; border-radius: 8px; font-size: 11px; }
.lead-dialog-grid { display: grid; grid-template-columns: .9fr 1.1fr; max-height: calc(100vh - 36px); }
.lead-dialog-grid > section { min-width: 0; overflow-y: auto; }
.notes-panel { display: flex; flex-direction: column; min-height: 590px; background: #f6f7f9; border-left: 1px solid var(--line); }
.notes-panel > header { padding: 23px 25px 16px; }
.notes-panel h3 { margin: 0; font-size: 19px; }
.notes-panel h3 span { display: inline-grid; place-items: center; min-width: 23px; height: 23px; padding: 0 6px; color: var(--red); background: var(--red-soft); border-radius: 20px; font-size: 11px; }
.notes-list { display: grid; flex: 1; align-content: start; gap: 10px; max-height: 390px; padding: 0 25px 18px; overflow-y: auto; }
.note-card { padding: 14px; background: #fff; border: 1px solid #e0e4ea; border-radius: 11px; }
.note-card p { margin: 0; color: #3d485a; font-size: 13px; line-height: 1.55; }
.note-card footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 11px; padding-top: 9px; color: #8a94a4; border-top: 1px solid #eef0f3; font-size: 10px; }
.note-card footer strong { color: #647083; }
.notes-empty { padding: 30px; color: var(--muted); background: #fff; border: 1px dashed #d4dae3; border-radius: 11px; font-size: 12px; text-align: center; }
.note-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; padding: 16px 25px 22px; background: #fff; border-top: 1px solid var(--line); }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .search-field { grid-column: span 2; }
}

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; }
  .brand small, .user-copy { display: none; }
  .dashboard-shell { width: min(100% - 24px, 1400px); padding-top: 22px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .btn { align-self: flex-start; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 13px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-card strong { font-size: 21px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field, .filters > select { grid-column: 1 / -1; }
  .filters .btn { width: 100%; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody { padding: 0 14px 14px; }
  tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; margin-top: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; }
  tbody tr:hover { background: #fff; }
  td { padding: 0; border: 0; }
  td::before { content: attr(data-label); display: block; margin-bottom: 5px; color: #929baa; font-size: 9px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
  .note-preview { grid-column: 1 / -1; max-width: none; }
  .action-cell { grid-column: 1 / -1; }
  .action-cell .btn { width: 100%; }
  .empty-state { grid-column: 1 / -1; }
  .empty-state::before { display: none; }
  .lead-dialog-grid { display: block; max-height: calc(100vh - 28px); overflow-y: auto; }
  .lead-dialog-grid > section { overflow: visible; }
  .notes-panel { min-height: 0; border-top: 1px solid var(--line); border-left: 0; }
  .notes-list { max-height: none; }
  .note-form { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .login-shell { padding: 18px 12px 62px; }
  .login-card { padding: 28px 22px; border-radius: 19px; }
  .login-brand { align-items: center; }
  .login-logo { width: 56px; height: 56px; }
  .login-brand strong { font-size: 13px; }
  .login-heading h1 { font-size: 25px; }
  .login-footer { bottom: 12px; padding: 0 10px; }
  .legal-header-inner { align-items: flex-start; flex-direction: column; gap: 8px; }
  .legal-shell { width: min(100% - 20px, 900px); margin-top: 16px; padding: 23px 20px; }
  .stats-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .search-field, .filters > select, .date-field { grid-column: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: 1; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
  tbody tr { grid-template-columns: 1fr; }
  .note-preview, .action-cell { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
