
:root {
  color-scheme: dark;
  --bg: #081018;
  --surface: #101b27;
  --surface-2: #152433;
  --line: rgba(174, 205, 225, .13);
  --text: #edf6fa;
  --muted: #8fa6b5;
  --accent: #53d8c2;
  --accent-2: #ffba69;
  --uncontacted: #7e91a0;
  --call_again: #f4a641;
  --in_work: #6b8cff;
  --succeeded: #3dcc89;
  --failed: #f06469;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -5%, rgba(83, 216, 194, .15), transparent 27rem),
    radial-gradient(circle at 90% 8%, rgba(107, 140, 255, .11), transparent 25rem),
    var(--bg);
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
a { color: inherit; }
.shell { width: min(1500px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 70px; }
.auth-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.auth-card { width: min(430px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 20px; background: rgba(16,27,39,.94); box-shadow: 0 28px 80px rgba(0,0,0,.35); }
.auth-logo { display: block; width: 190px; height: auto; margin: 0 auto 22px; }
.auth-card h1 { margin-bottom: 10px; }
.auth-copy { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
.field-label { display: block; margin: 14px 2px 6px; color: #b9cad3; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.auth-submit { width: 100%; margin-top: 18px; padding: 11px 14px; border: 0; border-radius: 10px; color: #071511; background: var(--accent); font-weight: 800; cursor: pointer; }
.auth-message, .admin-message { min-height: 20px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.auth-message.error, .admin-message.error { color: #f49a9e; }
.app-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.session-box { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.session-box span { color: #dce9ee; font-weight: 700; }
.page-brand { display: block; width: fit-content; margin-bottom: 18px; border-radius: 12px; }
.page-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
.page-logo { display: block; width: clamp(155px, 18vw, 235px); height: auto; }
.view-switch {
  display: inline-flex; gap: 5px; margin-bottom: 24px; padding: 5px;
  border: 1px solid var(--line); border-radius: 13px; background: rgba(16, 27, 39, .82);
  box-shadow: 0 12px 32px rgba(0,0,0,.16);
}
.view-button {
  padding: 9px 14px; border: 0; border-radius: 9px; color: var(--muted);
  background: transparent; font-size: 13px; font-weight: 720; transition: .18s ease;
}
.view-button:hover { color: var(--text); background: rgba(255,255,255,.04); }
.view-button.active { color: #071511; background: var(--accent); box-shadow: 0 5px 18px rgba(83,216,194,.22); }
.map-view {
  height: calc(100vh - 145px); min-height: 620px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  box-shadow: 0 20px 55px rgba(0,0,0,.24);
}
.map-view iframe { display: block; width: 100%; height: 100%; border: 0; }
.sql-view { min-height: calc(100vh - 145px); }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.eyebrow { margin-bottom: 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 46px); letter-spacing: -.04em; line-height: 1; }
.intro { max-width: 660px; margin: 12px 0 0; color: var(--muted); line-height: 1.55; }
.ghost-button, .small-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255,255,255,.035);
  transition: .18s ease;
}
.ghost-button { padding: 10px 14px; }
.small-button { padding: 6px 9px; font-size: 12px; text-decoration: none; white-space: nowrap; }
.ghost-button:hover, .small-button:hover { border-color: rgba(83,216,194,.55); background: rgba(83,216,194,.08); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 12px; margin: 28px 0 14px; }
.summary-card {
  position: relative;
  overflow: hidden;
  min-height: 125px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.018));
  box-shadow: 0 18px 40px rgba(0,0,0,.16);
}
.summary-card::after { content: ""; position: absolute; width: 105px; height: 105px; right: -40px; top: -45px; border-radius: 50%; background: var(--card-color, var(--accent)); opacity: .12; filter: blur(1px); }
.card-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.card-value { display: block; margin-top: 8px; font-size: 35px; font-weight: 760; letter-spacing: -.04em; }
.card-note { margin-top: 5px; color: var(--muted); font-size: 12px; }
.card-total { margin-top: 10px; color: #c5d4dc; font-size: 11px; }
.status-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 13px 0 22px; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.025);
}
.status-chip:hover, .status-chip.active { color: var(--text); border-color: var(--status-color); background: color-mix(in srgb, var(--status-color) 12%, transparent); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--status-color); box-shadow: 0 0 12px var(--status-color); }
.status-count { color: var(--text); font-weight: 750; }
.toolbar {
  position: sticky; top: 10px; z-index: 30; display: grid; grid-template-columns: minmax(260px, 1fr) 190px 180px 180px auto;
  gap: 9px; margin-bottom: 18px; padding: 10px; border: 1px solid var(--line); border-radius: 15px;
  background: rgba(11, 20, 30, .89); box-shadow: 0 16px 45px rgba(0,0,0,.25); backdrop-filter: blur(15px);
}
.control { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--text); background: #111e2a; }
.control:focus { border-color: rgba(83,216,194,.65); box-shadow: 0 0 0 3px rgba(83,216,194,.09); }
.toolbar-actions { display: flex; gap: 7px; }
.results-note { min-height: 22px; margin: 0 2px 9px; color: var(--muted); font-size: 13px; }
.tier {
  margin-bottom: 15px; overflow: clip; border: 1px solid var(--line); border-radius: 18px;
  background: rgba(14, 25, 36, .82); box-shadow: 0 18px 45px rgba(0,0,0,.13);
}
.tier > summary, .category > summary { list-style: none; cursor: pointer; }
.tier > summary::-webkit-details-marker, .category > summary::-webkit-details-marker { display: none; }
.tier-head { display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: center; gap: 14px; padding: 18px 20px; }
.tier-mark { display: grid; place-items: center; width: 43px; height: 43px; border: 1px solid color-mix(in srgb, var(--tier-color) 55%, transparent); border-radius: 12px; color: var(--tier-color); background: color-mix(in srgb, var(--tier-color) 11%, transparent); font-weight: 850; }
.tier-title { font-size: 18px; font-weight: 760; }
.tier-description { margin-top: 3px; color: var(--muted); font-size: 12px; }
.count-badge { padding: 6px 10px; border-radius: 999px; color: var(--tier-color); background: color-mix(in srgb, var(--tier-color) 10%, transparent); font-size: 12px; font-weight: 750; }
.conversion-badge { padding: 6px 9px; border: 1px solid rgba(61, 204, 137, .22); border-radius: 999px; color: #7ee2ae; background: rgba(61, 204, 137, .08); font-size: 11px; font-weight: 750; white-space: nowrap; }
.chevron { color: var(--muted); transition: transform .18s ease; }
details[open] > summary .chevron { transform: rotate(180deg); }
.tier-body { padding: 0 11px 11px; }
.category { margin-top: 8px; overflow: clip; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.018); }
.category-head { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 12px; padding: 13px 15px; }
.category-title { font-weight: 680; }
.category-meta { color: var(--muted); font-size: 12px; }
.mini-statuses { display: flex; gap: 4px; }
.mini-status { min-width: 23px; padding: 3px 5px; border-radius: 5px; text-align: center; color: var(--status-color); background: color-mix(in srgb, var(--status-color) 10%, transparent); font-size: 10px; font-weight: 750; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { padding: 10px 12px; color: #6f8999; background: rgba(0,0,0,.13); font-size: 10px; text-align: left; text-transform: uppercase; letter-spacing: .08em; }
.category th:nth-child(1) { width: 29%; } .category th:nth-child(2) { width: 18%; } .category th:nth-child(3) { width: 20%; } .category th:nth-child(4) { width: 18%; } .category th:nth-child(5) { width: 15%; }
td { padding: 12px; border-top: 1px solid rgba(174,205,225,.075); vertical-align: middle; }
.lead-row { --row-status: var(--uncontacted); background: linear-gradient(90deg, color-mix(in srgb, var(--row-status) 10%, transparent), transparent 55%); box-shadow: inset 3px 0 var(--row-status); transition: background .2s ease; }
.lead-row[data-status="call_again"] { --row-status: var(--call_again); }
.lead-row[data-status="in_work"] { --row-status: var(--in_work); }
.lead-row[data-status="succeeded"] { --row-status: var(--succeeded); }
.lead-row[data-status="failed"] { --row-status: var(--failed); }
.business-name { font-weight: 720; line-height: 1.25; }
.subtext { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.note-editor { margin-top: 10px; }
.note-input {
  width: 100%; min-height: 58px; resize: vertical; padding: 8px 9px;
  border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--text);
  background: rgba(5, 13, 20, .55); font-size: 11px; line-height: 1.4;
}
.note-input:focus { border-color: rgba(83,216,194,.55); box-shadow: 0 0 0 3px rgba(83,216,194,.07); }
.note-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 5px; }
.note-state { color: var(--muted); font-size: 10px; }
.phone { color: #b8f3e8; font-weight: 650; text-decoration: none; }
.phone:hover { text-decoration: underline; }
.call-counter { display: grid; grid-template-columns: 28px minmax(75px, auto) 28px; align-items: center; width: max-content; margin-top: 11px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; }
.counter-button { height: 28px; padding: 0; border: 0; color: var(--text); background: rgba(255,255,255,.045); font-size: 16px; }
.counter-button:hover { color: var(--accent); background: rgba(83,216,194,.09); }
.call-count { padding: 0 8px; color: #d8e5eb; font-size: 11px; font-weight: 720; text-align: center; }
.last-contact { margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.last-worker { margin-top: 7px; color: #9fcfc5; font-size: 10px; line-height: 1.35; }
.address { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: #c8d5dc; font-size: 12px; line-height: 1.4; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.leona-panel { display: grid; justify-items: start; gap: 5px; margin-top: 13px; }
.analysis-badge { padding: 4px 7px; border-radius: 999px; color: #f0a4a7; background: rgba(240,100,105,.09); font-size: 10px; font-weight: 750; }
.analysis-badge.analyzed { color: #7ee2ae; background: rgba(61,204,137,.09); }
.development-note { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }
.status-select { width: 100%; min-width: 125px; padding: 8px 9px; border: 1px solid color-mix(in srgb, var(--row-status) 55%, var(--line)); border-radius: 9px; outline: none; color: var(--text); background: #10202c; font-size: 12px; font-weight: 650; }
.status-select:disabled { opacity: .55; }
.empty { padding: 55px 20px; border: 1px dashed var(--line); border-radius: 15px; color: var(--muted); text-align: center; }
dialog { width: min(640px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; color: var(--text); background: #101c28; box-shadow: 0 28px 90px rgba(0,0,0,.55); }
dialog::backdrop { background: rgba(1,6,10,.72); backdrop-filter: blur(5px); }
.dialog-head { display: flex; justify-content: space-between; gap: 16px; padding: 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 21px; }
.dialog-body { padding: 20px; }
.detail-grid { display: grid; grid-template-columns: 145px 1fr; gap: 10px 16px; margin: 0; }
.detail-grid dt { color: var(--muted); font-size: 12px; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; }
.close-button { width: 33px; height: 33px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: transparent; }
.toast { position: fixed; z-index: 100; right: 20px; bottom: 20px; padding: 11px 15px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: #162635; box-shadow: 0 14px 45px rgba(0,0,0,.35); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(240,100,105,.55); }
.sql-editor {
  width: 100%; min-height: 250px; margin-top: 28px; padding: 18px; resize: vertical;
  border: 1px solid var(--line); border-radius: 16px; outline: none; color: #d9f6ee;
  background: #09131d; box-shadow: inset 0 0 35px rgba(0,0,0,.22);
  font: 13px/1.65 "Cascadia Code", "SFMono-Regular", Consolas, monospace; tab-size: 2;
}
.sql-editor:focus { border-color: rgba(83,216,194,.55); box-shadow: 0 0 0 3px rgba(83,216,194,.08); }
.sql-meta { min-height: 20px; margin: 10px 3px; color: var(--muted); font-size: 12px; }
.sql-results { max-height: 58vh; overflow: auto; border: 1px solid var(--line); border-radius: 15px; background: rgba(9,19,29,.78); }
.sql-results .empty { border: 0; }
.sql-table { width: max-content; min-width: 100%; table-layout: auto; }
.sql-table th { position: sticky; z-index: 2; top: 0; width: auto !important; min-width: 120px; color: #9fb4c0; background: #111f2b; }
.sql-table td { max-width: 420px; overflow-wrap: anywhere; color: #d7e3e9; font: 12px/1.45 "Cascadia Code", "SFMono-Regular", Consolas, monospace; }
.sql-null { color: #8d76b9; font-style: italic; }
.sql-error { color: #f49a9e; }
.users-view { min-height: calc(100vh - 145px); }
.admin-layout { display: grid; grid-template-columns: minmax(260px, .7fr) minmax(520px, 1.6fr); gap: 16px; margin-top: 28px; align-items: start; }
.admin-card { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(16,27,39,.82); box-shadow: 0 18px 45px rgba(0,0,0,.14); }
.admin-card h2 { margin: 0 0 14px; font-size: 18px; }
.permission-note { margin: 10px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.permission-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.permission-grid label { color: #b9cad3; font-size: 11px; font-weight: 750; }
.multi-select { width: 100%; margin-top: 6px; padding: 7px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--text); background: #111e2a; font-size: 11px; }
.multi-select:focus { border-color: rgba(83,216,194,.55); }
.lead-permission-list { min-height: 230px; }
@media (max-width: 950px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .search { grid-column: 1 / -1; }
  .toolbar-actions { justify-content: flex-end; }
  .admin-layout { grid-template-columns: 1fr; }
  .category th:nth-child(3), .category td:nth-child(3) { display: none; }
  .category th:nth-child(1) { width: 36%; } .category th:nth-child(2) { width: 23%; } .category th:nth-child(4) { width: 22%; } .category th:nth-child(5) { width: 19%; }
}
@media (max-width: 620px) {
  .shell { width: min(100% - 22px, 1500px); padding-top: 22px; }
  .page-brand { margin: 0 auto 15px; }
  .page-logo { width: 165px; }
  .view-switch { width: 100%; margin-bottom: 16px; }
  .view-button { flex: 1; }
  .map-view { height: calc(100vh - 100px); min-height: 520px; }
  .topbar { display: block; } .topbar > button { margin-top: 15px; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .summary-card { min-height: 105px; padding: 14px; } .card-value { font-size: 28px; }
  .toolbar { position: static; grid-template-columns: 1fr; } .toolbar .search { grid-column: auto; }
  .toolbar-actions { justify-content: stretch; } .toolbar-actions button { flex: 1; }
  .tier-head { grid-template-columns: auto 1fr auto auto; padding: 14px; } .tier-head .count-badge { display: none; }
  .category-head .conversion-badge { display: none; }
  .mini-statuses { display: none; }
  .category table, .category tbody, .category tr, .category td { display: block; width: 100%; } .category thead { display: none; }
  .lead-row { padding: 12px; } .category td { display: block !important; padding: 5px 8px; border: 0; }
  .status-select { margin-top: 5px; }
  .detail-grid { grid-template-columns: 1fr; gap: 4px; } .detail-grid dd { margin-bottom: 9px; }
  .app-header { display: block; }
  .session-box { justify-content: center; margin-bottom: 12px; }
  .permission-grid { grid-template-columns: 1fr; }
}
