/* ============================================================
   Admin panel — overrides for tables, sidebar, etc.
   Inherits variables.css + main.css + components.css
   ============================================================ */

body.admin-body {
  background: #f1f4f9;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Restore native cursor in admin (override the custom-cursor styles from main.css) */
body.admin-body,
body.admin-body * { cursor: auto !important; }
body.admin-body a,
body.admin-body button,
body.admin-body label[for],
body.admin-body summary,
body.admin-body [role="button"],
body.admin-body .toggle-row,
body.admin-body .upload-zone { cursor: pointer !important; }
body.admin-body input[type="text"],
body.admin-body input[type="email"],
body.admin-body input[type="tel"],
body.admin-body input[type="search"],
body.admin-body input[type="password"],
body.admin-body input[type="number"],
body.admin-body input[type="url"],
body.admin-body textarea { cursor: text !important; }
body.admin-body .cursor-dot,
body.admin-body .cursor-ring { display: none !important; }

/* ---- LOGIN ---- */
.login-shell {
  flex: 1;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background:
    radial-gradient(ellipse at top right, rgba(245,134,52,0.10), transparent 50%),
    linear-gradient(135deg, #f1f4f9 0%, #e6efff 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: var(--r-xl);
  padding: clamp(2rem, 4vw, 2.75rem);
  box-shadow: var(--sh-lg);
  border: 1px solid var(--c-border);
}
.login-card .logo-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.login-card .logo-row img { height: 48px; }
.login-card .logo-row .meta { display: flex; flex-direction: column; line-height: 1.2; }
.login-card .logo-row .name { font-weight: 800; color: var(--c-navy-900); }
.login-card .logo-row .sub { font-size: var(--fs-xs); color: var(--c-text-muted); }
.login-card h1 {
  font-size: var(--fs-xl);
  margin-bottom: var(--space-2);
}
.login-card .lead {
  font-size: var(--fs-sm);
  margin-bottom: var(--space-6);
}
.login-error {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-4);
  border-right: 4px solid var(--c-danger);
}
.login-error.hidden { display: none; }
.login-back {
  margin-top: var(--space-5);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

/* ---- ADMIN LAYOUT ---- */
.admin-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
}

.admin-sidebar {
  background: var(--c-navy-900);
  color: rgba(255,255,255,0.85);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
@media (max-width: 900px) {
  .admin-sidebar { padding: var(--space-4); }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand img {
  height: 40px;
  background: white;
  padding: 6px 10px;
  border-radius: var(--r-sm);
}
.sidebar-brand .name { color: white; font-weight: 800; line-height: 1.2; }
.sidebar-brand .sub { font-size: var(--fs-xs); opacity: 0.7; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.sidebar-nav button {
  background: transparent;
  border: 0;
  text-align: right;
  padding: 10px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  color: rgba(255,255,255,0.78);
  font-family: var(--ff-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all var(--t-fast) var(--ease);
  position: relative;
}
.sidebar-nav button:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}
.sidebar-nav button.active {
  background: rgba(245,134,52,0.15);
  color: var(--c-orange-400);
}
.sidebar-nav button.active::before {
  content: "";
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background: var(--c-orange-400);
  border-radius: 4px;
}
.sidebar-nav svg { width: 18px; height: 18px; stroke: currentColor; }
.sidebar-nav .badge {
  margin-inline-start: auto;
  background: var(--c-orange-500);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--r-full);
  padding: 2px 8px;
  min-width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: var(--fs-xs);
}

.admin-main {
  padding: clamp(1.5rem, 3vw, 2.5rem);
  overflow-x: hidden;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-3);
}
.admin-topbar h1 {
  font-size: var(--fs-2xl);
  color: var(--c-navy-900);
  margin: 0;
}
.admin-topbar .sub { color: var(--c-text-muted); font-size: var(--fs-sm); }
.admin-topbar-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---- Tab content panels ---- */
.admin-panel { display: none; }
.admin-panel.is-active { display: block; }

/* ---- Stat cards (dashboard overview) ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: white;
  border-radius: var(--r-lg);
  padding: var(--space-5);
  border: 1px solid var(--c-border);
  position: relative;
  overflow: hidden;
}
.stat-card .stat-label {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-size: var(--fs-3xl);
  font-weight: 800;
  color: var(--c-navy-900);
  line-height: 1.1;
}
.stat-card .stat-meta {
  font-size: var(--fs-xs);
  color: var(--c-success);
  margin-top: 4px;
}
.stat-card .stat-icon {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  width: 40px;
  height: 40px;
  background: var(--c-blue-50);
  color: var(--c-navy-800);
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
}
.stat-card .stat-icon svg { width: 20px; height: 20px; stroke: currentColor; }
.stat-card.accent .stat-icon { background: var(--c-orange-50); color: var(--c-orange-500); }

/* ---- Table card ---- */
.table-card {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-xs);
}
.table-toolbar {
  padding: var(--space-4) var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--c-border);
  gap: var(--space-3);
  flex-wrap: wrap;
}
.table-toolbar input[type="search"] {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  font-size: var(--fs-sm);
  font-family: var(--ff-sans);
  min-width: 220px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.data-table th, .data-table td {
  padding: 14px 18px;
  text-align: right;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
.data-table th {
  background: var(--c-surface);
  font-weight: 600;
  color: var(--c-text-muted);
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr.row-new { background: linear-gradient(90deg, rgba(245,134,52,0.05), transparent); }
.data-table tr:hover { background: var(--c-surface); }
.data-table .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.data-table .icon-btn {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast) var(--ease);
}
.data-table .icon-btn:hover { background: var(--c-blue-50); border-color: var(--c-blue-500); }
.data-table .icon-btn.danger:hover { background: #fee2e2; border-color: var(--c-danger); }
.data-table .icon-btn svg { width: 16px; height: 16px; stroke: currentColor; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
}
.status-pill.new { background: #fef3c7; color: #92400e; }
.status-pill.contacted { background: var(--c-blue-50); color: var(--c-navy-800); }
.status-pill.done { background: #d1fae5; color: #047857; }

/* ---- Detail modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-4);
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: white;
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sh-lg);
}
.modal-head {
  padding: var(--space-5) var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--c-border);
}
.modal-head h3 { margin: 0; font-size: var(--fs-lg); }
.modal-close {
  background: var(--c-surface);
  border: 0;
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.modal-body { padding: var(--space-6); }
.detail-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px var(--space-4);
  font-size: var(--fs-sm);
}
.detail-grid dt {
  font-weight: 600;
  color: var(--c-text-muted);
}
.detail-grid dd {
  margin: 0;
  color: var(--c-text);
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: var(--space-9) var(--space-5);
  color: var(--c-text-muted);
}
.empty-state svg { width: 60px; height: 60px; opacity: 0.3; margin-bottom: var(--space-3); }

/* ---- Coverage tab ---- */
.coverage-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--space-5);
}
@media (max-width: 900px) { .coverage-grid { grid-template-columns: 1fr; } }
.coverage-panel {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.coverage-panel h3 { font-size: var(--fs-md); }
.coverage-panel .hint { font-size: var(--fs-xs); color: var(--c-text-muted); line-height: 1.7; }

.upload-zone {
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--r-md);
  padding: var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  background: var(--c-surface);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--c-blue-500);
  background: var(--c-blue-50);
}
.upload-zone svg { width: 32px; height: 32px; stroke: var(--c-navy-800); margin-bottom: 8px; }
.upload-zone p { font-size: var(--fs-sm); }
.upload-zone .small { font-size: var(--fs-xs); color: var(--c-text-muted); }
.upload-zone input[type="file"] { display: none; }

/* Toggle switches */
.display-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--c-surface);
  border-radius: var(--r-md);
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast) var(--ease);
}
.toggle-row:hover { background: var(--c-blue-50); }
.toggle-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle-switch {
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  background: var(--c-border-strong);
  border-radius: 999px;
  position: relative;
  transition: background var(--t-fast) var(--ease);
}
.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: right var(--t-base) var(--ease), transform var(--t-base) var(--ease);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-row input:checked + .toggle-switch {
  background: var(--c-navy-800);
}
.toggle-row input:checked + .toggle-switch::after {
  right: 18px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  font-weight: 500;
  flex: 1;
}
.toggle-label .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

/* Stored KMZ files list */
.kmz-files-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}
.kmz-file-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease);
}
.kmz-file-row.is-disabled {
  opacity: 0.55;
  background: #f6f6f6;
}
.kmz-file-row .info { min-width: 0; }
.kmz-file-row .info .name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.kmz-file-row .info .meta {
  font-size: 11px;
  color: var(--c-text-muted);
  margin-top: 2px;
}
.kmz-file-row .meta .pill-mini {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: white;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 1px 7px;
  margin-inline-start: 3px;
}
.kmz-file-row .meta .pill-mini .swatch {
  width: 6px; height: 6px;
  border-radius: 50%;
}
.kmz-file-row .toggle-mini {
  width: 32px;
  height: 18px;
  background: var(--c-border-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.kmz-file-row .toggle-mini::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: right var(--t-base) var(--ease);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.kmz-file-row.is-enabled .toggle-mini {
  background: var(--c-navy-800);
}
.kmz-file-row.is-enabled .toggle-mini::after {
  right: 16px;
}
.kmz-file-row .del-btn {
  background: white;
  border: 1px solid var(--c-border);
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  transition: all var(--t-fast) var(--ease);
}
.kmz-file-row .del-btn:hover {
  border-color: var(--c-danger);
  color: var(--c-danger);
  background: #fee2e2;
}
.kmz-file-row .del-btn svg { width: 14px; height: 14px; stroke: currentColor; }
.kmz-empty {
  padding: 18px;
  text-align: center;
  color: var(--c-text-muted);
  font-size: var(--fs-xs);
  background: var(--c-surface);
  border: 1px dashed var(--c-border);
  border-radius: var(--r-md);
}

.cov-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  text-align: center;
}
.cov-stats > div {
  padding: 10px;
  background: var(--c-surface);
  border-radius: var(--r-md);
}
.cov-stats .n {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--c-navy-900);
}
.cov-stats .l {
  font-size: 11px;
  color: var(--c-text-muted);
}

#admin-map-wrap {
  height: clamp(420px, 70vh, 700px);
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--c-border);
  position: relative;
}
#admin-map { width: 100%; height: 100%; }

.toast {
  position: fixed;
  bottom: var(--space-5);
  inset-inline-start: var(--space-5);
  background: var(--c-navy-900);
  color: white;
  padding: 12px 18px;
  border-radius: var(--r-md);
  box-shadow: var(--sh-md);
  z-index: 200;
  transform: translateY(20px);
  opacity: 0;
  transition: all var(--t-base) var(--ease);
  max-width: 380px;
  font-size: var(--fs-sm);
}
.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}
.toast.success { background: #047857; }
.toast.error { background: var(--c-danger); }

/* ---- Demo notice ---- */
.demo-banner {
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  color: #78350f;
  border: 1px solid #fcd34d;
  border-radius: var(--r-md);
  padding: 12px 18px;
  font-size: var(--fs-sm);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.7;
}
.demo-banner strong { color: #78350f; }
