
:root {
  --bg: #f4f3f8;
  --panel: #fbfafe;
  --panel-2: #efebfa;
  --text: #2d2440;
  --muted: #6a627e;
  --line: #ddd6ee;
  --primary: #8d6fd1;
  --primary-strong: #7554c7;
  --danger: #b94b6b;
  --shadow: 0 18px 40px rgba(92, 74, 140, 0.12);
  --sidebar-width: 290px;
  --sticky-top-offset: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8f7fb 0%, #f1eff7 100%);
}

a {
  color: var(--primary-strong);
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

h1,
h2 {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
button,
textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
}

button {
  cursor: pointer;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  color: var(--primary-strong);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 700;
}

/* Disable splash/loading overlay so dashboard shows immediately after login */
/* no splash screen before dashboard */
#splash-screen {
  display: none !important;
}

/* login page */
/* =====================================
   AUTH / LOGIN PAGE
   DO NOT MODIFY WITHOUT TESTING LOGIN
===================================== */

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #f8f7fb 0%, #f1eff7 100%);
}
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #f8f7fb 0%, #f1eff7 100%);
}

.auth-card {
  width: min(680px, 100%);
  background: #fbfafe;
  border: 1px solid #ddd6ee;
  border-radius: 28px;
  box-shadow: 0 18px 40px rgba(92, 74, 140, 0.12);
  padding: 42px 36px;
  text-align: center;
}

.login-logo {
  width: auto;
  max-width: 320px;
  height: 110px;
  object-fit: contain;
  margin: 0 auto 20px;
  display: block;
}

.auth-card-wide {
  width: min(680px, 100%);
}

.auth-subtitle {
  margin: -6px 0 22px;
  font-size: 24px;
  font-weight: 700;
  color: #6f55c7;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: #2d2440;
}

.auth-form input {
  width: 100%;
  border: 1px solid #ddd6ee;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
}

.primary-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  background: #8d6fd1;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.auth-footer {
  margin-top: 6px;
  font-size: 14px;
  text-align: center;
}

.auth-footer-link {
  margin-bottom: 10px;
}

.auth-footer a {
  color: #7554c7;
  text-decoration: none;
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-install {
  margin-top: 14px;
  text-align: center;
  font-size: 14px;
  color: #6a627e;
  cursor: pointer;
}

.auth-install:hover {
  text-decoration: underline;
}

/* App layout */
.app-layout {
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  height: 100vh;
  overflow-y: auto;
  z-index: 1000;
}

.main-content {
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding: 14px 18px;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  margin-bottom: 22px;
}

.sidebar-logo {
  width: 200px;
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  margin: 0 auto;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.sidebar-brand .eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-transform: none;
  color: #6f55c7;
}

.sidebar-brand strong {
  display: block;
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
  font-weight: 800;
  color: #2d2440;
}

.sidebar-brand .muted,
.sidebar-brand p,
.sidebar-brand small {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 14px;
  color: var(--text);
  font-weight: 700;
  font-size: 22px;
  background: #fff;
  border: 1px solid var(--line);
  text-align: center;
}

.sidebar-nav a:hover {
  background: var(--panel-2);
}

.sidebar-nav a:last-child {
  margin-top: auto;
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}


.sidebar-admin-group {
  display: grid;
  gap: 10px;
}

.sidebar-admin-link {
  margin-bottom: 0;
}

.sidebar-subnav {
  display: grid;
  gap: 8px;
  padding: 2px 0 4px 14px;
}

.sidebar-subnav a {
  min-height: 40px;
  justify-content: flex-start;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  background: #f8f5ff;
}

.sidebar-subnav a:hover {
  background: #f1ebff;
}

.sidebar-actions {
  display: grid;
  gap: 10px;
  margin: 8px 0 16px;
}

.sidebar-actions .primary-btn,
.sidebar-actions .ghost-btn {
  width: 100%;
  min-width: 0;
  justify-content: center;
  text-align: center;
  padding: 12px 14px;
  border-radius: 14px;
}

.sidebar-actions .primary-btn {
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
}

.sidebar-actions .ghost-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.dashboard-buttons {
  display: none;
}

.shell {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0;
}

.topbar {
  border-radius: 24px;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
}

.dashboard-header,
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.dashboard-logo,
.page-logo {
  width: auto;
  height: 78px;
  object-fit: contain;
  flex-shrink: 0;
}

.dashboard-title h1,
.page-header h1 {
  margin: 2px 0 0 0;
  font-size: 42px;
  line-height: 1.05;
}

.dashboard-buttons,
.top-actions,
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-buttons {
  margin-bottom: 18px;
}

.dashboard-buttons a {
  width: auto;
  min-width: 220px;
}

.primary-btn,
.ghost-btn,
.small-btn,
.primary-link {
  border-radius: 14px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-btn,
.primary-link {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.ghost-btn,
.small-btn {
  background: #fff;
  color: var(--text);
}

.danger-btn {
  color: #fff;
  background: var(--danger);
  border-color: transparent;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.auth-flash-stack {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 24px));
  z-index: 2000;
}

.flash {
  border-radius: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: #fff;
}

/* ===== Premium dashboard polish ===== */
:root {
  --panel-bg: #ffffff;
  --panel-border: #e9e1f1;
  --panel-shadow: 0 10px 30px rgba(91, 74, 125, 0.08);
  --panel-shadow-soft: 0 6px 18px rgba(91, 74, 125, 0.05);
  --radius-xl: 24px;
  --radius-lg: 18px;
}

/* Main dashboard panels */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--panel-shadow-soft);
  padding: 24px;
  margin-bottom: 24px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  line-height: 1.2;
}

.panel .muted {
  margin: 0;
  color: #7d6f96;
  font-size: 0.95rem;
}

/* Summary cards */
.summary-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.summary-card,
.stat-card {
  background: linear-gradient(180deg, #ffffff 0%, #faf7fd 100%);
  border: 1px solid #ece4f4;
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: var(--panel-shadow-soft);
}

.summary-card .value,
.stat-card .value {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: #5b4a7d;
  margin-top: 8px;
}

.summary-card .label,
.stat-card .label {
  color: #8c7da6;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

/* Map container */
.map-shell {
  width: 100%;
  max-width: 100%;
}

#map {
  width: 100%;
  height: 460px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid #e9e1f1;
  box-shadow: var(--panel-shadow);
}

/* Controls above map */
.map-toolbar,
.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.map-toolbar .control-group,
.chart-toolbar .control-group {
  background: #f8f4fc;
  border: 1px solid #eadff3;
  border-radius: 16px;
  padding: 10px 14px;
}

/* Analytics width and spacing */
.analytics-panel {
  overflow: hidden;
}

.analytics-panel .charts-container {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.analytics-panel-map-width .charts-container {
  width: 57.5%;
  max-width: 57.5%;
}

.chart-block {
  width: 100%;
  background: linear-gradient(180deg, #ffffff 0%, #fcfafe 100%);
  border: 1px solid #e9e1f1;
  border-radius: 22px;
  padding: 18px 20px;
  box-shadow: var(--panel-shadow-soft);
}

.chart-block canvas {
  display: block;
  width: 100% !important;
  height: 340px !important;
}

/* Table polish */
.table-wrap {
  background: #ffffff;
  border: 1px solid #ece4f4;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--panel-shadow-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
}

table thead th {
  background: #faf7fd;
  color: #6b5b88;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 14px 16px;
  border-bottom: 1px solid #ece4f4;
}

table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1ebf7;
  vertical-align: top;
}

table tbody tr:hover {
  background: #fcfafe;
}

/* Better buttons */
.small-btn,
button,
.btn {
  border-radius: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.small-btn:hover,
button:hover,
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(91, 74, 125, 0.12);
}

/* Filters and inputs */
input,
select,
textarea {
  border-radius: 14px;
  border: 1px solid #e6dcef;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #c8a2c8;
  box-shadow: 0 0 0 4px rgba(200, 162, 200, 0.16);
}

/* Mobile */
@media (max-width: 1180px) {
  .summary-grid,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-panel-map-width .charts-container {
    width: 100%;
    max-width: 100%;
  }

  #map {
    height: 400px;
  }

  .chart-block canvas {
    height: 320px !important;
  }
}

@media (max-width: 720px) {
  .panel {
    padding: 16px;
    border-radius: 18px;
  }

  .summary-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  #map {
    height: 320px;
    border-radius: 18px;
  }

  .chart-block {
    padding: 14px;
    border-radius: 18px;
  }

  .chart-block canvas {
    height: 280px !important;
  }

  table thead th,
  table tbody td {
    padding: 12px;
  }
}

/* Dashboard layout */
.dashboard-top-fixed {
  position: sticky;
  top: var(--sticky-top-offset);
  z-index: 900;
  background: linear-gradient(180deg, #f8f7fb 0%, #f1eff7 100%);
  padding: 0 0 14px;
  margin-bottom: 14px;
}

.dashboard-scroll-content {
  position: relative;
  z-index: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stat-card {
  border-radius: 22px;
  padding: 18px 20px;
  display: grid;
  gap: 6px;
}

.stat-card strong {
  font-size: 28px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.map-layout-wide {
  grid-template-columns: 1fr;
}

.panel {
  border-radius: 24px;
  padding: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-note {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f1ebfb;
  border: 1px solid #ddd6ee;
  color: #5d4b86;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-tabs .primary-btn,
.admin-tabs .ghost-btn,
.button-row .primary-btn,
.button-row .ghost-btn {
  width: auto;
}

.action-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

.editor-fieldset[disabled] {
  opacity: 0.72;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.filters-admin {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.charts-container {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
}

.chart-block {
  width: 100%;
}

.chart-block canvas {
  width: 100% !important;
  height: 340px !important;
}

.analytics-panel {
  overflow: hidden;
}

.analytics-panel .charts-container {
  width: 100%;
  max-width: 100%;
}

.analytics-panel-map-width .charts-container {
  width: 57.5%;
  max-width: 57.5%;
}

.analytics-panel .chart-block {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(92, 74, 140, 0.06);
}

.analytics-panel .chart-block canvas {
  display: block;
  width: 100% !important;
  height: 340px !important;
}

@media (max-width: 1180px) {
  .analytics-panel-map-width .charts-container {
    width: 100%;
    max-width: 100%;
  }

  .analytics-panel .chart-block canvas {
    height: 320px !important;
  }
}

@media (max-width: 720px) {
  .analytics-panel .chart-block {
    padding: 14px;
    border-radius: 16px;
  }

  .analytics-panel .chart-block canvas {
    height: 280px !important;
  }
}

.map-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.map-toggle button {
  width: auto;
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: #6b2fa3;
  color: #fff;
  font-weight: 600;
}

#map {
  height: 560px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.editor-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-span {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.info-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

#address {
  position: relative;
  z-index: 1001;
}

.pac-container {
  z-index: 99999 !important;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(92, 74, 140, 0.14);
  font-family: Arial, Helvetica, sans-serif;
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    width: 100%;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 16px;
    overflow: visible;
  }

  .sidebar-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .sidebar-nav a {
    font-size: 20px;
    min-height: 48px;
  }

  .main-content {
    margin-left: 0;
    padding: 320px 12px 12px;
  }

  .dashboard-top-fixed {
    position: static;
    padding-bottom: 0;
  }

  .filters {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .auth-wrap {
    padding: 12px;
  }

  .auth-card {
    padding: 30px 24px;
    border-radius: 20px;
  }

  .login-logo {
    max-width: 240px;
    height: 88px;
  }

  .auth-subtitle {
    font-size: 20px;
  }

  .sidebar {
    gap: 14px;
  }

  .sidebar-logo,
  .page-logo,
  .dashboard-logo,
  .nav-logo {
    height: 58px;
    width: auto;
  }

  .page-header,
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .page-header h1,
  .dashboard-title h1 {
    font-size: 30px;
    line-height: 1.1;
  }

  .dashboard-buttons,
  .top-actions,
  .form-actions,
  .map-toggle,
  .button-row,
  .action-group {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-buttons a,
  .primary-btn,
  .ghost-btn,
  .small-btn,
  .primary-link,
  .map-toggle button {
    width: 100%;
    min-width: 0;
  }

  .stats-grid,
  .editor-grid,
  .filters {
    grid-template-columns: 1fr;
  }

  /* make all form inputs equal height */
.editor-grid input,
.editor-grid select,
.editor-grid textarea {
  width: 100%;
  height: 48px;
  box-sizing: border-box;
}

/* keep labels consistent */
.editor-grid label {
  display: flex;
  flex-direction: column;
}

  .panel {
    padding: 14px;
    border-radius: 18px;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  #map {
    height: 380px;
    border-radius: 16px;
  }
}

/* ===== Professional Sidebar Upgrade ===== */

.sidebar {
  background: linear-gradient(180deg, #fcfbff 0%, #f5f1fb 100%);
  border-right: 1px solid #ddd6ee;
  box-shadow: 8px 0 30px rgba(92, 74, 140, 0.06);
  padding: 28px 22px 26px;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  margin-bottom: 24px;
}

.sidebar-logo {
  width: 140px;
  max-width: none;
  height: auto;
  flex-shrink: 0;
  object-fit: contain;
}

.sidebar-brand .eyebrow,
.sidebar-brand strong,
.sidebar-brand p,
.sidebar-brand small,
.sidebar-brand .muted {
  display: block;
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 800;
  color: #6f55c7;
  letter-spacing: 0;
  text-transform: none;
}

.sidebar-brand strong,
.sidebar-brand p,
.sidebar-brand small,
.sidebar-brand .muted {
  color: #2d2440;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  margin-top: 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid #e2daf2;
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  color: #2f2745;
  text-align: center;
}

.sidebar-nav a:hover {
  background: #f1ebfb;
}

.sidebar-nav a:last-child {
  margin-top: auto;
  background: #b94b6b;
  color: #fff;
  border-color: transparent;
}

@media (max-width: 1080px) {
  .sidebar-logo {
    width: 50px;
  }

  .sidebar-brand .eyebrow {
    font-size: 12px;
  }

  .sidebar-brand strong {
    font-size: 17px;
  }
}

  .sidebar-logo {
    width: 210px;
  }

  .sidebar-brand .eyebrow,
  .sidebar-brand strong,
  .sidebar-brand p,
  .sidebar-brand small,
  .sidebar-brand .muted {
    font-size: 16px;
  }

  .sidebar-nav a {
    min-height: 40px;
    font-size: 15px;
    padding: 8px 12px;
  }
}

/* ===== Form card layout (hospital style) ===== */

.form-section-card{
  background:#ffffff;
  border:1px solid var(--line);
  border-radius:18px;
  padding:18px 20px;
  margin-bottom:16px;
  box-shadow:0 8px 20px rgba(92,74,140,0.05);
}

.form-section-card h3{
  font-size:18px;
  font-weight:800;
  margin-bottom:12px;
  color:var(--text);
  border-bottom:2px solid var(--panel-2);
  padding-bottom:6px;
}

.form-section-card .editor-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}

@media (max-width:720px){
  .form-section-card .editor-grid{
    grid-template-columns:1fr;
  }
}


/* ===== Required fields and validation ===== */

.form-required-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* prevent star from dropping to next line */
.editor-grid label {
  flex-direction: column;
}

.editor-grid label .required-star {
  display: inline;
}


.form-section-card label {
  position: relative;
  display: grid;
  gap: 8px;
  margin-bottom: 2px;
}

.form-section-card label input,
.form-section-card label select,
.form-section-card label textarea {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.form-section-card label.field-error {
  color: #a33f5f;
}

.form-section-card label.field-error input,
.form-section-card label.field-error select,
.form-section-card label.field-error textarea {
  border-color: #cb5a7e;
  background: #fff8fa;
  box-shadow: 0 0 0 3px rgba(203, 90, 126, 0.12);
}

.form-section-card label.field-valid input,
.form-section-card label.field-valid select,
.form-section-card label.field-valid textarea {
  border-color: #7dba8a;
  background: #fbfffc;
  box-shadow: 0 0 0 3px rgba(125, 186, 138, 0.12);
}

.form-section-card input:focus,
.form-section-card select:focus,
.form-section-card textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(141, 111, 209, 0.16);
}

/* make all inputs the same size */
.editor-grid input,
.editor-grid select {
  width: 100%;
  height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-sizing: border-box;
}

/* fix date input specifically */
.editor-grid input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  height: 48px;
}

/* perfect form alignment */
.form-section-card .editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 16px;
  row-gap: 18px;
  align-items: start;
}

.form-section-card .editor-grid label {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  margin: 0;
  width: 100%;
  min-width: 0;
}

.form-section-card .editor-grid input,
.form-section-card .editor-grid select,
.form-section-card .editor-grid textarea {
  width: 100%;
  min-width: 0;
  height: 58px;
  margin: 0;
  padding: 12px 16px;
  box-sizing: border-box;
  border-radius: 14px;
}

.form-section-card .editor-grid input[type="date"] {
  height: 58px;
  min-height: 58px;
  appearance: none;
  -webkit-appearance: none;
}

.form-section-card h3 {
  margin: 0 0 18px 0;
}

@media (max-width: 720px) {
  .form-section-card .editor-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile only: let top toolbar scroll away, and hide file action buttons */
@media (max-width: 1080px) {
  .sidebar {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 16px;
  }

  .main-content {
    margin-left: 0;
    padding: 12px;
  }

  .sidebar-actions {
    display: none;
  }
}

.warning-row {
  background-color: #fff3cd;
}
.progress-bar.busy {
  background: repeating-linear-gradient(135deg, #8d6fd1 0 12px, #c8a2c8 12px 24px);
  background-size: 200% 100%;
  animation: progressBusy 1.1s linear infinite;
}

@keyframes progressBusy {
  from {
    background-position: 0 0;
  }
  to {
    background-position: -48px 0;
  }
}

.action-cell {
  white-space: nowrap;
}

.action-cell form {
  display: inline-flex;
}


/* Final dashboard cleanup overrides */

.panel {
  background: var(--panel-bg, #ffffff);
  border: 1px solid var(--panel-border, #e9e1f1);
  border-radius: 24px;
  box-shadow: 0 6px 18px rgba(91, 74, 125, 0.05);
  padding: 24px;
  margin-bottom: 24px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel .muted {
  margin: 0;
  color: #7d6f96;
  font-size: 0.95rem;
}

.map-shell {
  width: 100%;
  max-width: 100%;
}

#map {
  width: 100%;
  height: 460px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid #e9e1f1;
  box-shadow: 0 10px 30px rgba(91, 74, 125, 0.08);
}

.analytics-panel {
  overflow: hidden;
}

.analytics-panel .charts-container {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.analytics-panel-map-width .charts-container {
  width: 57.5%;
  max-width: 57.5%;
}

.analytics-panel .chart-block {
  width: 100%;
  background: linear-gradient(180deg, #ffffff 0%, #fcfafe 100%);
  border: 1px solid #e9e1f1;
  border-radius: 22px;
  padding: 18px 20px;
  box-shadow: 0 6px 18px rgba(91, 74, 125, 0.05);
}

.analytics-panel .chart-block canvas {
  display: block;
  width: 100% !important;
  height: 340px !important;
}

.table-wrap {
  background: #ffffff;
  border: 1px solid #ece4f4;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(91, 74, 125, 0.05);
}

table thead th {
  background: #faf7fd;
  color: #6b5b88;
  font-weight: 700;
}

table tbody tr:hover {
  background: #fcfafe;
}

.small-btn,
button,
.btn {
  border-radius: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.small-btn:hover,
button:hover,
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(91, 74, 125, 0.12);
}

input,
select,
textarea {
  border-radius: 14px;
  border: 1px solid #e6dcef;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #c8a2c8;
  box-shadow: 0 0 0 4px rgba(200, 162, 200, 0.16);
}

@media (max-width: 1180px) {
  .analytics-panel-map-width .charts-container {
    width: 100%;
    max-width: 100%;
  }

  #map {
    height: 400px;
  }

  .analytics-panel .chart-block canvas {
    height: 320px !important;
  }
}

@media (max-width: 720px) {
  .panel {
    padding: 16px;
    border-radius: 18px;
  }

  #map {
    height: 320px;
    border-radius: 18px;
  }

  .analytics-panel .chart-block {
    padding: 14px;
    border-radius: 18px;
  }

  .analytics-panel .chart-block canvas {
    height: 280px !important;
  }
}


/* Final mobile responsiveness fixes */
@media (max-width: 1080px) {
  .app-layout {
    display: block;
  }

  .sidebar {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    border-right: none !important;
    border-bottom: 1px solid var(--line) !important;
    padding: 14px 12px !important;
    gap: 14px !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 12px !important;
  }

  .shell {
    max-width: 100% !important;
  }

  .dashboard-top-fixed {
    position: static !important;
    padding-bottom: 0 !important;
    margin-bottom: 12px !important;
  }

  .sidebar-actions {
    display: grid !important;
    gap: 10px !important;
  }

  .sidebar-nav,
  .button-row,
  .action-group,
  .map-toggle,
  .top-actions,
  .form-actions,
  .dashboard-buttons {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .sidebar-nav a,
  .sidebar-actions .primary-btn,
  .sidebar-actions .ghost-btn,
  .button-row .primary-btn,
  .button-row .ghost-btn,
  .map-toggle button,
  .top-actions .primary-btn,
  .top-actions .ghost-btn,
  .form-actions .primary-btn,
  .form-actions .ghost-btn,
  .small-btn {
    width: 100% !important;
    min-width: 0 !important;
  }

  .stats-grid,
  .filters,
  .filters-admin,
  .editor-grid,
  .map-layout,
  .analytics-grid,
  .analytics-grid-two {
    grid-template-columns: 1fr !important;
  }

  .analytics-panel-map-width .charts-container,
  .analytics-panel .charts-container,
  .charts-container {
    width: 100% !important;
    max-width: 100% !important;
  }

  .panel {
    padding: 16px !important;
    border-radius: 18px !important;
    margin-bottom: 16px !important;
  }

  .panel-head,
  .page-header,
  .dashboard-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .page-header h1,
  .dashboard-title h1,
  .dashboard-header h1 {
    font-size: 30px !important;
    line-height: 1.1 !important;
  }

  #map {
    width: 100% !important;
    height: 360px !important;
    border-radius: 18px !important;
  }

  .chart-block,
  .analytics-panel .chart-block {
    padding: 14px !important;
    border-radius: 18px !important;
  }

  .chart-block canvas,
  .analytics-panel .chart-block canvas {
    height: 280px !important;
  }

  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  table {
    min-width: 720px;
  }
}

@media (max-width: 720px) {
  html,
  body {
    font-size: 15px;
  }

  .auth-wrap {
    padding: 12px !important;
  }

  .auth-card,
  .auth-card-wide {
    width: 100% !important;
    padding: 22px 16px !important;
    border-radius: 18px !important;
  }

  .login-logo {
    max-width: 220px !important;
    height: auto !important;
  }

  .sidebar-brand {
    margin-bottom: 8px !important;
  }

  .sidebar-logo,
  .page-logo,
  .dashboard-logo,
  .nav-logo {
    width: auto !important;
    height: 58px !important;
  }

  .sidebar-brand strong {
    font-size: 18px !important;
  }

  .sidebar-nav a {
    font-size: 18px !important;
    min-height: 46px !important;
    padding: 12px 14px !important;
  }

  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .stat-card {
    padding: 14px 16px !important;
  }

  .stat-card strong {
    font-size: 24px !important;
  }

  .filters,
  .filters-admin,
  .editor-grid {
    gap: 10px !important;
  }

  label {
    font-size: 13px !important;
  }

  input,
  select,
  button,
  textarea {
    padding: 11px 12px !important;
    font-size: 15px !important;
  }

  #map {
    height: 300px !important;
  }

  .map-toggle {
    gap: 8px !important;
  }

  .chart-block canvas,
  .analytics-panel .chart-block canvas {
    height: 240px !important;
  }

  table {
    min-width: 640px;
  }

  table thead th,
  table tbody td,
  th,
  td {
    padding: 10px 10px !important;
    font-size: 13px !important;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 10px !important;
  }

  .panel {
    padding: 12px !important;
    border-radius: 16px !important;
  }

  .page-header h1,
  .dashboard-title h1,
  .dashboard-header h1 {
    font-size: 26px !important;
  }

  .sidebar-actions {
    gap: 8px !important;
  }

  .sidebar-nav a,
  .sidebar-actions .primary-btn,
  .sidebar-actions .ghost-btn,
  .map-toggle button,
  .form-actions .primary-btn,
  .form-actions .ghost-btn,
  .small-btn {
    padding: 10px 12px !important;
    font-size: 14px !important;
  }

  #map {
    height: 260px !important;
    border-radius: 16px !important;
  }

  .chart-block canvas,
  .analytics-panel .chart-block canvas {
    height: 220px !important;
  }

  table {
    min-width: 560px;
  }
}


/* dashboard form grouping refresh */
.form-section-card {
  padding: 24px 24px 22px;
  margin-bottom: 22px;
  border: 1px solid #ddd6ee;
  box-shadow: 0 14px 32px rgba(92, 74, 140, 0.08);
}

.section-heading {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #ebe5f6;
}

.section-heading h3 {
  margin: 0;
  border: 0;
  padding: 0;
}

.section-heading p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: #75698f;
}

.section-grid {
  row-gap: 20px;
}

.section-grid .full {
  grid-column: 1 / -1;
}

.section-grid-deceased,
.section-grid-church,
.section-grid-address,
.section-grid-kin {
  padding-top: 2px;
}

.form-section-card + .form-section-card {
  margin-top: 4px;
}

@media (max-width: 720px) {
  .form-section-card {
    padding: 18px 16px;
    margin-bottom: 18px;
  }

  .section-heading {
    margin-bottom: 14px;
    padding-bottom: 12px;
  }
}


/* v8 layout refinement: place editor below map and polish section alignment */
.map-layout-stacked {
  grid-template-columns: 1fr;
  gap: 18px;
}

.map-layout-stacked .map-panel,
.map-layout-stacked .editor-panel {
  width: 100%;
}

.map-layout-stacked .editor-panel {
  max-width: none;
}

.map-layout-stacked #recordForm {
  width: 100%;
}

.map-layout-stacked .panel-head {
  align-items: flex-start;
}

.map-layout-stacked .form-section-card {
  padding: 28px 28px 24px;
  border-radius: 22px;
}

.map-layout-stacked .section-heading {
  margin-bottom: 22px;
  padding-bottom: 16px;
}

.map-layout-stacked .section-grid {
  column-gap: 22px;
  row-gap: 22px;
}

.map-layout-stacked .form-actions {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.map-layout-stacked .form-required-note {
  margin: 0;
}

@media (max-width: 900px) {
  .map-layout-stacked .form-section-card {
    padding: 20px 18px 18px;
  }

  .map-layout-stacked .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
}


/* Map clarity fixes */
#map,
#map .leaflet-container {
  background: #f8f7fb;
}

#map .leaflet-tile {
  image-rendering: auto;
}


.charts-page-wrap {
  display: block;
}

.charts-page-panel {
  width: 100%;
  max-width: none;
}

.charts-page-container {
  width: 100%;
}

.charts-page-panel .chart-block {
  min-height: 520px;
}

.charts-page-panel .chart-block canvas {
  min-height: 460px;
}


.sidebar-actions-bottom {
  margin-top: auto;
  margin-bottom: 0;
  padding-top: 12px;
}

.sidebar-links-small {
  display: grid;
  gap: 8px;
}

.sidebar-text-link {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--primary-strong);
  padding: 4px 0;
}

.sidebar-text-link:hover {
  text-decoration: underline;
}


.mobile-page-tabs {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 12px !important;
  }

  .mobile-page-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .mobile-page-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
    text-align: center;
  }

  .mobile-page-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: transparent;
  }

  .mobile-map-page .editor-panel,
  .mobile-map-page .analytics-panel,
  .mobile-map-page .records-panel,
  .mobile-map-page #chartsPanel {
    display: none !important;
  }

  .mobile-map-page .map-panel {
    margin-bottom: 0;
  }

  .mobile-map-page .filters,
  .mobile-charts-page .chart-toolbar {
    grid-template-columns: 1fr !important;
  }

  .mobile-charts-page .charts-page-panel .chart-block {
    min-height: 360px;
  }

  .mobile-charts-page .charts-page-panel .chart-block canvas {
    min-height: 320px;
  }
}


.mobile-app-header {
  display: none;
}

@media (max-width: 768px) {
  .mobile-app-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 4px 14px;
  }

  .mobile-app-header-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
    padding: 4px;
  }

  .mobile-app-header-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .mobile-app-header-title {
    font-size: 1.35rem;
    line-height: 1.1;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
  }

  .shell {
    min-height: auto;
  }
}


.sidebar-install-link,
.mobile-install-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.sidebar-install-link {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
}

.mobile-install-link {
  margin-left: auto;
  min-height: 40px;
  padding: 8px 12px;
}

.install-favicon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.mobile-logout-tab {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

@media (max-width: 768px) {
  .dashboard-top-fixed .stats-grid {
    display: none !important;
  }

  .mobile-page-tabs {
    grid-template-columns: 1fr 1fr 1fr;
    margin-bottom: 12px;
  }

  .mobile-map-page .dashboard-top-fixed,
  .mobile-map-page .map-toggle,
  .mobile-map-page .editor-panel,
  .mobile-map-page .analytics-panel,
  .mobile-map-page .records-panel,
  .mobile-map-page #chartsPanel {
    display: none !important;
  }

  .mobile-map-page .map-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .mobile-map-page .map-panel .filters {
    order: 3;
  }

  .mobile-map-page #map {
    order: 2;
    margin-top: 0;
  }

  .mobile-map-page .dashboard-grid > .panel {
    margin-top: 12px;
  }

  .mobile-charts-page .chart-toolbar {
    margin-top: 14px;
  }

  .mobile-charts-page .charts-container {
    margin-top: 0;
  }
}

.install-help-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #e9d5ff;
  background: #faf5ff;
  color: #5b21b6;
  font-size: 0.92rem;
  font-weight: 600;
}

@media (max-width: 768px) {
  .install-help-banner {
    margin: 0 0 10px;
    font-size: 0.85rem;
  }
}

.auth-install-help{margin-top:10px;padding:10px 12px;border-radius:12px;background:#f3e8ff;color:#6b21a8;font-size:0.9rem;font-weight:600;text-align:center;}
.auth-install{display:inline-flex;align-items:center;justify-content:center;gap:8px;width:100%;}
