:root {
  --bg: #eef3f9;
  --bg-2: #f8fbff;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-soft: #f4f8fd;
  --text: #101828;
  --muted: #667085;
  --muted-2: #8a97aa;
  --border: rgba(16, 24, 40, 0.10);
  --border-strong: rgba(16, 24, 40, 0.16);
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #60a5fa;
  --primary-soft: #eaf2ff;
  --cyan: #06b6d4;
  --violet: #7c3aed;
  --danger: #e11d48;
  --success: #059669;
  --warning: #d97706;
  --shadow-sm: 0 8px 22px rgba(16, 24, 40, 0.07);
  --shadow: 0 18px 60px rgba(16, 24, 40, 0.12);
  --shadow-lg: 0 28px 90px rgba(16, 24, 40, 0.18);
  --radius-sm: 14px;
  --radius: 22px;
  --radius-lg: 30px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 6% 2%, rgba(37, 99, 235, 0.16), transparent 30%),
    radial-gradient(circle at 94% 0%, rgba(124, 58, 237, 0.12), transparent 28%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 62%, #e9f0f8 100%);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.42;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.08) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.login-card {
  position: relative;
  width: min(100%, 450px);
  padding: 36px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 34px;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.74));
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(140%);
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--cyan), var(--violet));
}
.login-logo { display: block; width: 185px; margin: 0 auto 30px; }
.login-card h1 { margin: 0 0 8px; text-align: center; font-size: 32px; letter-spacing: -0.05em; }
.login-card p { margin: 0 0 28px; text-align: center; color: var(--muted); line-height: 1.55; }
.login-extra { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0 22px; color: var(--muted); font-size: 14px; }
.login-extra label { display: inline-flex; align-items: center; gap: 8px; }
.login-extra a { color: var(--primary); font-weight: 800; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 34px rgba(16, 24, 40, 0.06);
  backdrop-filter: blur(22px) saturate(160%);
}
.header-left, .header-right { display: flex; align-items: center; gap: 14px; }
.logo img { width: 152px; height: auto; display: block; }
.menu-button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(16, 24, 40, 0.09);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.menu-button:hover, .icon-button:hover { background: #fff; transform: translateY(-1px); box-shadow: 0 12px 30px rgba(16, 24, 40, 0.11); }
.page-title { margin: 0; padding-left: 4px; color: var(--muted); font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--violet));
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.24);
}

.drawer-backdrop { position: fixed; inset: 0; z-index: 40; display: none; background: rgba(15, 23, 42, 0.34); backdrop-filter: blur(4px); }
.drawer-backdrop.is-visible { display: block; }
.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: 316px;
  max-width: 86vw;
  padding: 22px;
  border-right: 1px solid rgba(255,255,255,.72);
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(247,250,255,0.88));
  box-shadow: 32px 0 80px rgba(15, 23, 42, 0.20);
  backdrop-filter: blur(24px) saturate(160%);
  transform: translateX(-105%);
  transition: transform .24s cubic-bezier(.2,.8,.2,1);
}
.drawer.is-open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.drawer-head img { width: 160px; }
.close-drawer { width: 38px; height: 38px; border: 0; border-radius: 13px; background: var(--surface-soft); color: var(--muted); font-size: 26px; line-height: 1; }
.close-drawer:hover { color: var(--text); background: #fff; }
.drawer-nav { display: grid; gap: 8px; padding-top: 18px; }
.drawer-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 15px;
  border: 1px solid transparent;
  border-radius: 17px;
  color: var(--muted);
  font-weight: 800;
  transition: .18s ease;
}
.drawer-nav a:hover, .drawer-nav a.active {
  color: var(--primary-dark);
  background: linear-gradient(135deg, rgba(37,99,235,.12), rgba(6,182,212,.09));
  border-color: rgba(37, 99, 235, 0.13);
  box-shadow: 0 10px 24px rgba(37,99,235,.08);
}

.page-shell { width: min(1420px, calc(100% - 44px)); margin: 0 auto; padding: 28px 0 52px; }
.map-shell { width: 100%; height: calc(100vh - 72px); position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; }

.address-search {
  position: absolute;
  top: 22px;
  left: 50%;
  z-index: 10;
  display: flex;
  gap: 10px;
  width: min(680px, calc(100% - 44px));
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(150%);
  transform: translateX(-50%);
}
.address-search input { min-width: 0; border: 0; background: transparent; padding-left: 16px; box-shadow: none; }
.address-search input:focus { border-color: transparent; box-shadow: none; }
.address-search .button { min-width: 112px; white-space: nowrap; border-radius: 999px; }
.address-suggestions {
  position: absolute;
  top: calc(100% + 10px);
  right: 10px;
  left: 10px;
  display: none;
  max-height: min(340px, calc(100vh - 180px));
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(150%);
}
.address-suggestions.is-visible { display: grid; gap: 4px; }
.address-suggestion {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text);
  background: transparent;
  text-align: left;
}
.address-suggestion:hover,
.address-suggestion.is-active {
  border-color: rgba(37, 99, 235, 0.14);
  background: var(--primary-soft);
}
.suggestion-title { font-size: 14px; font-weight: 850; }
.suggestion-detail { color: var(--muted); font-size: 12px; line-height: 1.35; }
.address-marker { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 4px solid #fff; border-radius: 50%; background: linear-gradient(135deg, #ef4444, #f97316); box-shadow: 0 12px 24px rgba(239,68,68,.32); }
.address-marker:after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }

.mapboxgl-popup-content {
  min-width: 280px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.86);
  border-radius: 20px;
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px) saturate(150%);
  font-family: inherit;
}
.mapboxgl-popup-close-button { width: 28px; height: 28px; color: var(--muted); font-size: 20px; }
.popup-card h3 { margin: 0 0 10px; font-size: 19px; letter-spacing: -0.03em; }
.popup-card p { margin: 8px 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.popup-card a { color: var(--primary); font-weight: 800; }
.popup-card .button { margin-top: 12px; width: 100%; }
.popup-list { display: grid; gap: 8px; max-height: 260px; overflow: auto; padding-right: 2px; }
.popup-list-item { display: grid; gap: 3px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: rgba(244, 248, 253, 0.82); }
.popup-list-item strong { font-size: 13px; line-height: 1.25; }
.popup-list-item span, .popup-list-item small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.popup-note { color: var(--muted-2); font-size: 12px; }
.provider-marker {
  position: relative;
  width: 28px;
  height: 28px;
  border: 4px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  transform: rotate(-45deg);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.35);
  transition: transform .18s ease, box-shadow .18s ease;
}
.provider-marker:hover { transform: rotate(-45deg) scale(1.12); box-shadow: 0 18px 34px rgba(37,99,235,.45); }
.provider-marker:after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #fff; }

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 4px 2px;
}
.page-heading h1 { margin: 0 0 8px; font-size: 38px; line-height: 1.05; letter-spacing: -0.055em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card, .table-card, .modal-card, .stat-card, .settings-card {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px) saturate(140%);
}
.card, .stat-card, .settings-card { padding: 22px; }
.card:hover, .stat-card:hover, .settings-card:hover, .table-card:hover { box-shadow: var(--shadow); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 15px;
  font-weight: 850;
  letter-spacing: -0.01em;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-light)); box-shadow: 0 13px 28px rgba(37,99,235,.25); }
.button.primary:hover { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); box-shadow: 0 16px 34px rgba(37,99,235,.28); }
.button.secondary { color: var(--primary-dark); background: linear-gradient(135deg, var(--primary-soft), #f5f9ff); border: 1px solid rgba(37,99,235,.12); }
.button.secondary:hover { background: #dfeeff; }
.button.ghost { color: var(--muted); background: rgba(255,255,255,.72); border: 1px solid var(--border); }
.button.ghost:hover { color: var(--text); background: #fff; }
.button.danger { color: #fff; background: linear-gradient(135deg, var(--danger), #fb7185); box-shadow: 0 13px 28px rgba(225, 29, 72, .18); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 20px; }
.stat-card { position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; width: 120px; height: 120px; right: -44px; top: -48px; border-radius: 50%; background: rgba(37, 99, 235, .09); }
.stat-card span { display: block; color: var(--muted); font-weight: 800; }
.stat-card strong { display: block; margin-top: 12px; font-size: 38px; line-height: 1; letter-spacing: -0.055em; }
.stat-card small { color: var(--muted-2); }
.dashboard-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }
.bar-list { display: grid; gap: 15px; }
.bar-row span { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-weight: 800; }
.bar-row em { color: var(--text); font-style: normal; }
.bar-track { overflow: hidden; height: 13px; border-radius: 999px; background: #e3edf8; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--cyan)); }
.activity-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.activity-list li { padding: 14px; border: 1px solid rgba(16, 24, 40, 0.08); border-radius: 17px; color: var(--muted); background: rgba(255,255,255,.72); }

.table-card { overflow: hidden; }
.table-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 18px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.44); }
.search-row { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255,255,255,.88);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea { min-height: 110px; padding-top: 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(37, 99, 235, .62); box-shadow: 0 0 0 5px rgba(37,99,235,.11); background: #fff; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; min-width: 850px; border-collapse: collapse; }
.data-table th, .data-table td { padding: 15px 18px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { color: var(--muted); background: rgba(248, 251, 255, .72); font-size: 12px; text-transform: uppercase; letter-spacing: .065em; }
.data-table tbody tr { transition: background .18s ease; }
.data-table tbody tr:hover { background: rgba(255,255,255,.64); }
.badge { display: inline-flex; padding: 7px 11px; border-radius: 999px; color: var(--primary-dark); background: var(--primary-soft); font-size: 12px; font-weight: 900; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.empty-table { color: var(--muted); text-align: center !important; }
.empty-state { margin: 0; color: var(--muted); line-height: 1.55; }
.table-subtext { max-width: 360px; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.header-logout { min-height: 40px; padding: 0 14px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-card h2 { margin: 0 0 8px; letter-spacing: -0.03em; }
.settings-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.55; }

.modal-backdrop { position: fixed; inset: 0; z-index: 70; display: none; place-items: center; padding: 20px; background: rgba(15,23,42,.42); backdrop-filter: blur(7px); }
.modal-backdrop.is-visible { display: grid; }
.modal-card { display: flex; flex-direction: column; width: min(100%, 580px); max-height: calc(100vh - 40px); padding: 22px; overflow: hidden; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { margin: 0; letter-spacing: -0.04em; }
#modalForm { display: flex; min-height: 0; flex: 1; flex-direction: column; }
#modalBody { min-height: 0; flex: 1; overflow-y: auto; padding-right: 8px; }
#modalBody::-webkit-scrollbar { width: 10px; }
#modalBody::-webkit-scrollbar-track { border-radius: 999px; background: rgba(16, 24, 40, 0.06); }
#modalBody::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: rgba(102, 112, 133, 0.42); background-clip: content-box; }
#modalBody::-webkit-scrollbar-thumb:hover { background: rgba(102, 112, 133, 0.62); background-clip: content-box; }
.form-grid { display: grid; gap: 13px; }
.form-grid.two-columns { grid-template-columns: 1fr 1fr; }
.form-note { margin: 0; color: var(--muted); line-height: 1.5; }
.coverage-editor { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 18px; background: rgba(255,255,255,.54); }
.coverage-editor-head, .coverage-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.coverage-editor-head strong, .coverage-row-head span { color: var(--text); font-size: 14px; font-weight: 900; }
.coverage-list { display: grid; gap: 12px; }
.coverage-row { display: grid; gap: 12px; padding: 13px; border: 1px solid rgba(16, 24, 40, 0.08); border-radius: 16px; background: rgba(255,255,255,.68); }
.coverage-row .button { min-height: 36px; padding: 0 12px; border-radius: 12px; }
.form-actions { display: flex; flex-shrink: 0; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.alert {
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid rgba(225, 29, 72, .24);
  border-radius: 16px;
  color: #9f1239;
  background: rgba(255, 241, 242, .86);
  line-height: 1.45;
}
.login-card .alert { margin: -8px 0 18px; }
.floating-alert {
  position: absolute;
  top: 96px;
  left: 50%;
  z-index: 12;
  width: min(680px, calc(100% - 44px));
  transform: translateX(-50%);
}
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 90; max-width: 380px; padding: 15px 17px; border: 1px solid rgba(37,99,235,.22); border-radius: 18px; color: var(--primary-dark); background: rgba(255,255,255,.92); box-shadow: var(--shadow); backdrop-filter: blur(18px); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .stats-grid, .dashboard-grid, .settings-grid { grid-template-columns: 1fr 1fr; }
  .page-heading, .table-toolbar { align-items: stretch; flex-direction: column; }
}
@media (max-width: 700px) {
  .address-search { top: 12px; left: 12px; right: 12px; width: auto; border-radius: 22px; transform: none; flex-direction: column; }
  .address-search .button { width: 100%; }
  .floating-alert { top: 152px; left: 12px; right: 12px; width: auto; transform: none; }
  .app-header { height: 66px; padding: 0 14px; }
  .map-shell { height: calc(100vh - 66px); }
  .page-title { display: none; }
  .page-shell { width: min(100% - 24px, 1420px); padding-top: 18px; }
  .stats-grid, .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .form-grid.two-columns { grid-template-columns: 1fr; }
  .logo img { width: 140px; }
  .header-right { display: none; }
  .login-card { padding: 30px 22px; }
}
