:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --card: #fff;
  --text: #242833;
  --muted: #7d8493;
  --line: #e7eaf0;
  --primary: #6c5ce7;
  --primary-soft: #eeeaff;
  --danger: #e74c5b;
  --success: #1fa77a;
  --shadow: 0 12px 35px rgba(38, 44, 62, .07);
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, "Segoe UI", Arial, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(410px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 38px; }
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 22px; font-weight: 800; letter-spacing: .04em; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: #fff; background: linear-gradient(135deg, #ff4b55, #6c5ce7); }
.auth-card h1 { margin: 28px 0 6px; text-align: center; font-size: 22px; }
.auth-card .subtitle { margin: 0 0 28px; color: var(--muted); text-align: center; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { color: #555d6d; font-weight: 600; }
.field input, .field textarea, .field select, .toolbar input, .toolbar select { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--text); outline: none; padding: 12px 13px; }
.field input:focus, .field textarea:focus, .field select:focus, .toolbar input:focus, .toolbar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field small { margin-top: -2px; color: var(--muted); font-size: 12px; }
.btn { border: 0; border-radius: 11px; padding: 11px 16px; font-weight: 700; }
.btn-primary { width: 100%; color: #fff; background: var(--primary); }
.btn-primary:disabled { opacity: .55; cursor: wait; }
.btn-light { border: 1px solid var(--line); background: #fff; color: var(--text); }
.btn-danger { border: 1px solid #ffd2d7; background: #fff4f5; color: var(--danger); }
.message { min-height: 20px; margin-top: 14px; text-align: center; color: var(--danger); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; overflow: auto; background: #fff; border-right: 1px solid var(--line); padding: 22px 16px; }
.sidebar .brand { justify-content: flex-start; padding: 0 8px 24px; font-size: 17px; }
.nav-group { margin: 18px 0; }
.nav-title { padding: 0 10px 8px; color: #a0a6b2; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.nav-link { display: flex; align-items: center; width: 100%; margin: 3px 0; border: 0; border-radius: 10px; background: transparent; color: #5d6573; padding: 10px 11px; text-align: left; }
.nav-link:hover, .nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link .dot { width: 7px; height: 7px; margin-right: 10px; border-radius: 50%; background: currentColor; opacity: .55; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; height: 72px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); padding: 0 28px; }
.topbar h1 { margin: 0; font-size: 18px; }
.account { display: flex; align-items: center; gap: 12px; }
.account-name { font-weight: 700; }
.content { padding: 26px 28px 50px; }

.loading { display: grid; place-items: center; min-height: 220px; color: var(--muted); }
.error-box, .empty { border: 1px dashed #d6dae2; border-radius: 14px; background: #fff; color: var(--muted); padding: 28px; text-align: center; }
.error-box { border-color: #ffcdd2; color: var(--danger); }
.cards { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.metric { min-height: 128px; padding: 20px; }
.metric-label { color: var(--muted); }
.metric-value { margin-top: 16px; font-size: 29px; font-weight: 800; }
.metric-note { margin-top: 5px; color: #a0a6b2; font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .8fr); gap: 18px; margin-top: 18px; }
.panel { padding: 20px; }
.panel h2 { margin: 0 0 18px; font-size: 16px; }
.bar-chart { display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 12px; height: 210px; padding: 12px 4px 0; }
.bar-item { display: grid; grid-template-rows: 1fr auto auto; align-items: end; height: 100%; gap: 6px; text-align: center; color: var(--muted); font-size: 11px; }
.bar-value { color: var(--text); font-weight: 700; }
.bar { width: min(42px, 80%); min-height: 4px; margin: 0 auto; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #8f80f3, #6c5ce7); }
.stats-list { display: grid; gap: 11px; }
.stat-row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.stat-row:last-child { border: 0; }
.stat-row span { color: var(--muted); }
.stat-row strong { text-align: right; }

.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 120px auto; gap: 10px; margin-bottom: 16px; }
.toolbar.has-create { grid-template-columns: minmax(220px, 1fr) 120px auto auto; }
.toolbar-create { width: auto; white-space: nowrap; }
.table-card { overflow: hidden; }
.table-scroll { overflow: auto; max-height: calc(100vh - 210px); }
table { width: 100%; border-collapse: collapse; background: #fff; white-space: nowrap; }
th, td { max-width: 430px; border-bottom: 1px solid var(--line); padding: 12px 14px; text-align: left; overflow: hidden; text-overflow: ellipsis; }
th { position: sticky; top: 0; z-index: 2; background: #f9fafc; color: #646b78; font-size: 12px; }
th button { border: 0; background: transparent; color: inherit; font-weight: 800; padding: 0; }
tbody tr:hover { background: #faf9ff; }
.table-meta { display: flex; justify-content: space-between; color: var(--muted); padding: 13px 16px; }
.actions-column { position: sticky; right: 0; z-index: 1; background: #fff; box-shadow: -8px 0 14px rgba(38, 44, 62, .04); }
th.actions-column { z-index: 3; background: #f9fafc; }
.btn-edit { border: 1px solid #dcd6ff; background: var(--primary-soft); color: var(--primary); padding: 8px 12px; }

.modal-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; overflow: auto; background: rgba(24, 28, 38, .5); padding: 24px; }
.modal-card { width: min(780px, 100%); max-height: calc(100vh - 48px); overflow: auto; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 28px 80px rgba(19, 23, 34, .28); padding: 24px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.modal-header h2 { margin: 3px 0 0; font-size: 22px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.modal-close { width: 38px; height: 38px; border: 0; border-radius: 10px; background: #f4f5f8; color: #676e7c; font-size: 25px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
.field-wide { grid-column: 1 / -1; }
.field textarea { resize: vertical; min-height: 80px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-save { width: auto; min-width: 130px; }
.modal-message { min-height: 20px; color: var(--muted); }
.modal-message.success { color: var(--success); }
.modal-message.error { color: var(--danger); }
.promo-modal { width: min(850px, 100%); }
.info-box { margin: -4px 0 20px; border: 1px solid #dcd6ff; border-radius: 12px; background: var(--primary-soft); color: #5146ad; padding: 13px 15px; }

.state-map-card { overflow: hidden; border: 1px solid #23364b; border-radius: 18px; background: #071522; box-shadow: 0 18px 55px rgba(8, 18, 31, .2); color: #fff; }
.state-map-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 21px 22px 17px; background: linear-gradient(135deg, #0b1d2e, #102b3f); }
.state-map-head h2 { margin: 3px 0 4px; font-size: 22px; }
.state-map-head p { margin: 0; color: #8da2b7; }
.state-map-head .eyebrow { color: #34d399; }
.state-map-search { display: grid; grid-template-columns: minmax(230px, 360px) auto; gap: 9px; }
.state-map-search input { min-width: 0; border: 1px solid #294158; border-radius: 10px; outline: none; background: #091827; color: #fff; padding: 11px 13px; }
.state-map-search input:focus { border-color: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .12); }
.state-map-search .btn-light { border-color: #294158; background: #102438; color: #dbe8f4; }
.state-map-legend { display: flex; gap: 8px; overflow-x: auto; border-top: 1px solid #1d3348; border-bottom: 1px solid #1d3348; background: #091827; padding: 11px 14px; }
.map-filter { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; border: 1px solid #2a3e52; border-radius: 999px; background: transparent; color: #73879b; padding: 7px 11px; }
.map-filter span, .map-tooltip-kind i, .map-tooltip-list i { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--marker); box-shadow: 0 0 10px color-mix(in srgb, var(--marker) 65%, transparent); }
.map-filter strong { color: inherit; font-size: 11px; }
.map-filter.active { border-color: #3c566f; background: #10263a; color: #e7f1fa; }
.state-map-viewport { position: relative; min-height: 640px; height: calc(100vh - 255px); background: #0b2238; user-select: none; }
#state-map-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#state-map-canvas.dragging { cursor: grabbing; }
#state-map-canvas.has-marker:not(.dragging) { cursor: pointer; }
.map-controls { position: absolute; top: 16px; right: 16px; display: grid; overflow: hidden; border: 1px solid rgba(255,255,255,.25); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.map-controls button { width: 42px; height: 42px; border: 0; border-bottom: 1px solid rgba(255,255,255,.15); background: rgba(6, 19, 31, .9); color: #fff; font-size: 22px; }
.map-controls button:last-child { border-bottom: 0; }
.map-controls button:hover { background: #17364c; }
.map-hint, .map-visible-count, .map-coordinates { position: absolute; bottom: 14px; border: 1px solid rgba(255,255,255,.14); border-radius: 9px; background: rgba(5, 16, 27, .82); color: #c3d3e0; backdrop-filter: blur(7px); padding: 8px 10px; font-size: 12px; pointer-events: none; }
.map-hint { left: 14px; }
.map-visible-count { left: 50%; transform: translateX(-50%); }
.map-coordinates { right: 14px; font-variant-numeric: tabular-nums; }
.map-tooltip { position: absolute; z-index: 8; width: 290px; max-height: 420px; overflow: auto; border: 1px solid rgba(255,255,255,.2); border-radius: 14px; background: rgba(5, 16, 27, .96); box-shadow: 0 18px 45px rgba(0,0,0,.42); color: #fff; backdrop-filter: blur(12px); padding: 15px; pointer-events: none; }
.map-tooltip-kind { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; color: #8fa6b8; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.map-tooltip > strong { display: block; font-size: 16px; }
.map-status { display: inline-flex; margin: 8px 0 11px; border-radius: 999px; background: rgba(52,211,153,.14); color: #6ee7b7; padding: 4px 8px; font-size: 11px; font-weight: 800; }
.map-tooltip-details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 6px 12px; border-top: 1px solid rgba(255,255,255,.1); border-bottom: 1px solid rgba(255,255,255,.1); padding: 10px 0; }
.map-tooltip-details span { color: #8498aa; }
.map-tooltip-details b { overflow: hidden; text-align: right; text-overflow: ellipsis; }
.map-tooltip small { display: block; margin-top: 9px; color: #718597; }
.map-tooltip-list { display: grid; gap: 7px; margin: 12px 0; }
.map-tooltip-list span { display: flex; align-items: center; gap: 8px; color: #c6d4df; }
.map-tooltip-list b { margin-left: auto; }

@media (max-width: 1150px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; max-height: 300px; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 14px 40px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: 1fr; }
  .account-name { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .modal-overlay { padding: 10px; }
  .modal-card { max-height: calc(100vh - 20px); padding: 18px; }
  .state-map-head { align-items: stretch; flex-direction: column; }
  .state-map-search { grid-template-columns: 1fr; }
  .state-map-viewport { min-height: 560px; height: 68vh; }
  .map-hint { display: none; }
  .map-visible-count { left: 12px; transform: none; }
}
