/* ═══════════════════════════════════════
   GraveMap v3
   Design: Map-first. Everything floats.
   Type: Outfit (single family, weight range)
   Palette: Dark map bg, vivid status colors
═══════════════════════════════════════ */

:root {
  --available: #2ECC8A;
  --occupied: #E05A5A;
  --reserved: #F0B429;
  --accent: #3B82F6;
  --dark: #0F1923;
  --panel-bg: rgba(255, 255, 255, 0.97);
  --card-bg: #FFFFFF;
  --text: #111827;
  --text-mid: #4B5563;
  --text-lt: #9CA3AF;
  --border: #E5E7EB;
  --stone: #F9FAFB;
  --topbar-h: 54px;
  --panel-w: 300px;
  --r: 10px;
  --r-sm: 6px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .10);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .18);
  --t: .16s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: 'Outfit', system-ui, sans-serif;
  overflow: hidden;
  background: var(--dark);
  color: var(--text);
  font-size: 15px;
}

::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 3px;
}

/* ═══ FULL-SCREEN MAP ═══ */
#map-root {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ═══ TOPBAR ═══ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: rgba(15, 25, 35, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 400;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--available);
  color: var(--dark);
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  line-height: 1;
}

.brand-tag {
  font-size: .62rem;
  color: rgba(255, 255, 255, .45);
  letter-spacing: .03em;
  display: block;
}

.topbar-nav {
  display: flex;
  gap: 2px;
  flex: 1;
  justify-content: center;
}

.tnav {
  padding: .38rem .9rem;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, .55);
  font-family: inherit;
  font-size: .83rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t), color var(--t);
}

.tnav:hover {
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .85);
}

.tnav.active {
  background: var(--available);
  color: var(--dark);
  font-weight: 600;
}

.topbar-auth {
  flex-shrink: 0;
}

.btn-login {
  padding: .38rem .9rem;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: var(--r-sm);
  color: rgba(255, 255, 255, .8);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t);
}

.btn-login:hover {
  background: rgba(255, 255, 255, .18);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.user-chip img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--available);
}

.user-chip span {
  font-size: .78rem;
  color: rgba(255, 255, 255, .75);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#btn-logout {
  background: none;
  border: none;
  color: rgba(255, 255, 255, .4);
  font-size: .8rem;
  cursor: pointer;
  font-family: inherit;
}

/* ═══ FLOATING LEFT PANEL (map view) ═══ */
.float-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  z-index: 200;
  background: var(--panel-bg);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-left {
  left: 12px;
  width: var(--panel-w);
  max-height: calc(100vh - var(--topbar-h) - 24px);
}

.fp-title {
  padding: .85rem 1rem .5rem;
  font-weight: 700;
  font-size: .9rem;
  color: var(--text);
}

.fp-search {
  padding: 0 .75rem .6rem;
}

.fp-search input {
  width: 100%;
  padding: .45rem .7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .83rem;
  background: var(--stone);
}

.fp-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.cem-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 .5rem .5rem;
}

.cem-list-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .6rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t);
  border-bottom: 1px solid var(--border);
}

.cem-list-item:hover {
  background: var(--stone);
}

.cem-list-item.active {
  background: #EFF6FF;
}

.cem-list-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--available);
  flex-shrink: 0;
}

.cem-list-info {
  flex: 1;
  min-width: 0;
}

.cem-list-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cem-list-loc {
  font-size: .72rem;
  color: var(--text-lt);
}

.cem-list-count {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-mid);
  flex-shrink: 0;
}

.fp-legend {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem 1rem;
  border-top: 1px solid var(--border);
  font-size: .72rem;
  color: var(--text-mid);
  flex-shrink: 0;
}

.leg {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.leg.available {
  background: var(--available);
}

.leg.occupied {
  background: var(--occupied);
}

.leg.reserved {
  background: var(--reserved);
}

/* ═══ FLOATING TOOLS (admin, right side) ═══ */
.float-tools {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: 12px;
  z-index: 200;
  background: var(--panel-bg);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: .75rem;
  width: 180px;
}

.tool-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-lt);
  margin-bottom: .6rem;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .5rem .7rem;
  border: 1.5px solid var(--border);
  background: var(--stone);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t), border-color var(--t);
  color: var(--text);
  margin-bottom: .4rem;
}

.tool-btn:hover {
  background: var(--border);
}

.tool-btn.active {
  background: #EFF6FF;
  border-color: var(--accent);
  color: var(--accent);
}

.tool-btn.tool-danger {
  color: var(--occupied);
  border-color: var(--occupied);
}

.tool-btn.tool-danger:hover {
  background: #FEF2F2;
}

.tool-divider {
  height: 1px;
  background: var(--border);
  margin: .5rem 0;
}

.tool-hint {
  font-size: .72rem;
  color: var(--text-lt);
  line-height: 1.4;
  margin-top: .4rem;
}

/* ═══ VIEW PANELS (search/cemeteries/admin — overlay on right) ═══ */
.view-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  width: 420px;
  height: calc(100vh - var(--topbar-h));
  background: var(--panel-bg);
  z-index: 200;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border-left: 1px solid var(--border);
  padding: 1.5rem;
  animation: slide-in .2s ease;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(30px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.vp-header {
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.vp-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .2rem;
}

.vp-header p {
  font-size: .82rem;
  color: var(--text-lt);
}

/* ═══ SEARCH PANEL ═══ */
.search-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--stone);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: .55rem .85rem;
  margin-bottom: .75rem;
  transition: border-color var(--t);
}

.search-bar:focus-within {
  border-color: var(--accent);
  background: #fff;
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: .9rem;
  background: transparent;
  color: var(--text);
}

#search-clear-btn {
  background: none;
  border: none;
  color: var(--text-lt);
  cursor: pointer;
  font-size: .85rem;
}

.search-chips {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.search-chips select {
  padding: .3rem .55rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-family: inherit;
  font-size: .75rem;
  background: var(--stone);
  cursor: pointer;
}

.search-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-lt);
  font-size: .88rem;
}

#search-results {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.result-card {
  background: var(--card-bg);
  border-radius: var(--r);
  padding: 1rem;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color var(--t), box-shadow var(--t);
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.result-card[data-status="occupied"]::before {
  background: var(--occupied);
}

.result-card[data-status="empty"]::before {
  background: var(--available);
}

.result-card[data-status="reserved"]::before {
  background: var(--reserved);
}

.result-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.rc-name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .15rem;
}

.rc-father {
  font-size: .78rem;
  color: var(--text-lt);
  margin-bottom: .55rem;
}

.rc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
}

.chip {
  font-size: .7rem;
  padding: .15rem .45rem;
  border-radius: 20px;
  background: var(--stone);
  color: var(--text-mid);
  font-weight: 500;
}

.status-pill {
  font-size: .68rem;
  padding: .15rem .5rem;
  border-radius: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.status-pill.occupied {
  background: #FEF2F2;
  color: var(--occupied);
}

.status-pill.empty {
  background: #ECFDF5;
  color: #059669;
}

.status-pill.reserved {
  background: #FFFBEB;
  color: #92400E;
}

/* ═══ CEMETERIES PANEL ═══ */
.cem-card {
  background: var(--card-bg);
  border-radius: var(--r);
  padding: 1.1rem;
  border: 1.5px solid var(--border);
  margin-bottom: .75rem;
  border-top: 3px solid var(--available);
  transition: box-shadow var(--t);
}

.cem-card:hover {
  box-shadow: var(--shadow);
}

.cem-card-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .2rem;
}

.cem-card-loc {
  font-size: .76rem;
  color: var(--text-lt);
  margin-bottom: .6rem;
}

.cem-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cem-mini-stats {
  display: flex;
  gap: .75rem;
}

.cms-item {
  text-align: center;
}

.cms-num {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  line-height: 1;
}

.cms-lbl {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-lt);
}

.btn-view {
  padding: .32rem .75rem;
  background: var(--dark);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--t);
}

.btn-view:hover {
  opacity: .8;
}

.req-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.req-section-title {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: .65rem;
}

.btn-outline {
  padding: .45rem 1rem;
  border: 1.5px solid var(--border);
  background: transparent;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .83rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-mid);
  transition: border-color var(--t), color var(--t);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ═══ ADMIN PANEL ═══ */
.dash-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .65rem;
  margin-bottom: 1.25rem;
}

.dash-tile {
  background: var(--stone);
  border-radius: var(--r-sm);
  padding: .85rem;
  text-align: center;
  border: 1px solid var(--border);
}

.dash-tile .dn {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: .2rem;
}

.dash-tile .dl {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-lt);
}

.dash-tile.occ .dn {
  color: var(--occupied);
}

.dash-tile.avl .dn {
  color: var(--available);
}

.dash-tile.res .dn {
  color: var(--reserved);
}

.dash-tile.req .dn {
  color: var(--accent);
}

.admin-tabs {
  display: flex;
  gap: 2px;
  background: var(--stone);
  border-radius: var(--r-sm);
  padding: 3px;
  margin-bottom: 1rem;
}

.atab {
  flex: 1;
  padding: .38rem;
  border: none;
  background: transparent;
  border-radius: 5px;
  font-family: inherit;
  font-size: .8rem;
  cursor: pointer;
  color: var(--text-mid);
  transition: background var(--t), color var(--t);
  position: relative;
}

.atab.active {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.req-badge {
  background: var(--occupied);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 20px;
  margin-left: .3rem;
}

.atab-content {
  display: block;
}

.atab-content.hidden {
  display: none;
}

/* Admin grave rows */
.ag-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .5rem;
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
}

.ag-row:last-child {
  border-bottom: none;
}

.ag-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ag-row .ag-name {
  flex: 1;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ag-row .ag-cem {
  font-size: .72rem;
  color: var(--text-lt);
  flex-shrink: 0;
}

.ag-actions {
  display: flex;
  gap: .25rem;
}

.ibt {
  background: none;
  border: none;
  cursor: pointer;
  padding: .15rem .3rem;
  border-radius: 4px;
  font-size: .85rem;
  transition: background var(--t);
}

.ibt:hover {
  background: var(--stone);
}

/* Requests */
.req-card {
  background: var(--stone);
  border-radius: var(--r-sm);
  padding: .85rem;
  margin-bottom: .65rem;
  border: 1px solid var(--border);
}

.req-card-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: .4rem;
}

.req-card-type {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
}

.req-card-date {
  font-size: .72rem;
  color: var(--text-lt);
}

.req-card-msg {
  font-size: .83rem;
  color: var(--text);
  margin-bottom: .55rem;
  line-height: 1.5;
}

.req-card-meta {
  font-size: .75rem;
  color: var(--text-lt);
  margin-bottom: .55rem;
}

.req-card-actions {
  display: flex;
  gap: .4rem;
}

/* ═══ MODALS ═══ */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 25, .55);
  z-index: 600;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.overlay.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--r);
  padding: 1.75rem;
  max-width: 500px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modal-in .2s ease;
}

.modal-wide {
  max-width: 680px;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
}

.modal-x {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--stone);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t);
  z-index: 1;
}

.modal-x:hover {
  background: var(--border);
}

/* ═══ WIZARD ═══ */
.wizard-header {
  margin-bottom: 1.5rem;
}

.wizard-steps {
  display: flex;
  gap: .5rem;
}

.wstep {
  flex: 1;
  text-align: center;
  padding: .5rem;
  border-radius: var(--r-sm);
  font-size: .78rem;
  font-weight: 600;
  background: var(--stone);
  color: var(--text-lt);
  border: 1.5px solid var(--border);
  transition: background var(--t), color var(--t), border-color var(--t);
}

.wstep.active {
  background: var(--dark);
  color: #fff;
  border-color: var(--dark);
}

.wstep.done {
  background: var(--available);
  color: var(--dark);
  border-color: var(--available);
}

.wpage {
  display: none;
}

.wpage.active {
  display: block;
}

.wpage-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .35rem;
}

.wpage-hint {
  font-size: .82rem;
  color: var(--text-mid);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.wpage-actions {
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ═══ FORMS ═══ */
.field {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-bottom: .75rem;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .6rem;
}

.field label {
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-mid);
}

.field input,
.field select,
.field textarea {
  padding: .48rem .7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .88rem;
  color: var(--text);
  background: var(--stone);
  transition: border-color var(--t), background var(--t);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.boundary-status {
  text-align: center;
  padding: .65rem;
  background: var(--stone);
  border-radius: var(--r-sm);
  font-size: .82rem;
  color: var(--text-mid);
  border: 1.5px dashed var(--border);
}

.boundary-status.ok {
  background: #ECFDF5;
  border-color: var(--available);
  color: #059669;
  font-weight: 600;
}

/* Cemetery radio list */
.cem-radio-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: .75rem;
}

.cem-radio {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
}

.cem-radio:hover {
  background: var(--stone);
}

.cem-radio.selected {
  border-color: var(--accent);
  background: #EFF6FF;
}

.cem-radio-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
}

.cem-radio-loc {
  font-size: .74rem;
  color: var(--text-lt);
}

.hint-box {
  background: var(--stone);
  border-radius: var(--r-sm);
  padding: .7rem .85rem;
  font-size: .82rem;
  color: var(--text-mid);
  line-height: 1.5;
  border: 1px solid var(--border);
  margin-top: .5rem;
}

/* ═══ BUTTONS ═══ */
.btn-primary {
  padding: .52rem 1.2rem;
  background: var(--dark);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .86rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--t);
}

.btn-primary:hover {
  opacity: .85;
}

.btn-secondary {
  padding: .52rem 1.2rem;
  background: var(--stone);
  color: var(--text-mid);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .86rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-green {
  padding: .48rem .95rem;
  background: var(--available);
  color: var(--dark);
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-red {
  padding: .48rem .95rem;
  background: var(--occupied);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}

/* ═══ GRAVE DETAIL ═══ */
.gd-hero {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  margin-bottom: 1.1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.gd-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.gd-avatar.male {
  background: #EFF6FF;
}

.gd-avatar.female {
  background: #FDF2F8;
}

.gd-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .15rem;
}

.gd-father {
  font-size: .8rem;
  color: var(--text-lt);
}

.gd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  margin-bottom: 1rem;
}

.gd-item label {
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-lt);
  display: block;
  margin-bottom: .12rem;
}

.gd-item p {
  font-size: .86rem;
  font-weight: 500;
  color: var(--text);
}

.gd-bio {
  background: var(--stone);
  border-radius: var(--r-sm);
  padding: .75rem;
  font-size: .83rem;
  line-height: 1.6;
  color: var(--text-mid);
  margin-bottom: 1rem;
}

.gd-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.gd-qr-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-lt);
  margin-bottom: .5rem;
}

/* Shareable URL display below QR */
.gd-share-url {
  margin-top: .6rem;
  font-size: .72rem;
  color: var(--text-lt);
  background: var(--stone);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: .4rem .6rem;
  word-break: break-all;
  font-family: monospace;
  line-height: 1.4;
}

/* Copy link button */
.btn-copy-link {
  padding: .42rem .85rem;
  background: rgba(59, 130, 246, .1);
  border: 1.5px solid rgba(59, 130, 246, .35);
  border-radius: 6px;
  color: var(--accent);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t), border-color var(--t);
}

.btn-copy-link:hover {
  background: rgba(59, 130, 246, .18);
  border-color: var(--accent);
}


/* ═══ GRAVE DETAIL PHOTO ═══ */
.gd-photo {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--r);
  margin-bottom: 1rem;
  display: block;
}

/* ═══ CSV PREVIEW TABLE ═══ */
.csv-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: .75rem;
  white-space: nowrap;
}

.csv-tbl th {
  background: var(--stone);
  border: 1px solid var(--border);
  padding: .3rem .5rem;
  font-weight: 600;
  text-align: left;
  color: var(--text-mid);
}

.csv-tbl td {
  border: 1px solid var(--border);
  padding: .28rem .5rem;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csv-tbl tr:nth-child(even) td {
  background: var(--stone);
}

/* CSV template download row */
.csv-template-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin: .75rem 0 .25rem;
  padding: .65rem .75rem;
  background: var(--stone);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

/* Outline button variant */
.btn-outline {
  padding: .38rem .85rem;
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t);
  white-space: nowrap;
}

.btn-outline:hover {
  background: rgba(59, 130, 246, .08);
}

/* ═══ TOAST ═══ */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--dark);
  color: #fff;
  padding: .65rem 1.1rem;
  border-radius: var(--r);
  font-size: .84rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.ok {
  border-left: 3px solid var(--available);
}

.toast.err {
  border-left: 3px solid var(--occupied);
}

/* ═══ SATELLITE TOGGLE ═══ */
.sat-toggle-btn {
  background: rgba(15, 25, 35, 0.88);
  backdrop-filter: blur(8px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 8px;
  padding: .4rem .85rem;
  font-family: 'Outfit', sans-serif;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  margin: 0 0 10px 10px;
  transition: background .15s, color .15s;
  white-space: nowrap;
  user-select: none;
  letter-spacing: .02em;
}

.sat-toggle-btn:hover {
  background: rgba(46, 204, 138, .2);
  border-color: var(--available);
}

.sat-toggle-btn.active {
  background: var(--available);
  color: #0F1923;
  border-color: var(--available);
}

/* ═══ UTILS ═══ */
.hidden {
  display: none !important;
}

/* ═══ RESPONSIVE ═══ */

/* ─ Tablet / small desktop ─ */
@media (max-width: 900px) {
  :root {
    --panel-w: 260px;
  }
}

/* ─ Mobile ─ */
@media (max-width: 768px) {
  :root {
    --topbar-h: 50px;
    --panel-w: 100vw;
  }

  /* Topbar: stack brand + nav vertically when needed */
  .topbar {
    padding: 0 .75rem;
    gap: .5rem;
    flex-wrap: nowrap;
    justify-content: space-between;
  }

  .brand-tag {
    display: none;
  }

  .topbar-nav {
    flex: unset;
    gap: 2px;
  }

  /* Shrink nav labels on small screens */
  .tnav {
    padding: .35rem .55rem;
    font-size: .72rem;
  }

  /* Left panel → bottom sheet on mobile */
  .float-panel.panel-left {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-height: 42vh;
    border-radius: var(--r) var(--r) 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, .18);
  }

  /* Hide drawing tools on mobile — too complex for touch */
  .float-tools {
    display: none !important;
  }

  /* View panels take full width */
  .view-panel {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
  }

  /* Modals: full screen on mobile */
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--r) var(--r) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    overflow-y: auto;
  }

  .overlay {
    align-items: flex-end;
  }

  /* Grave detail grid → single column */
  .gd-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Grave action buttons wrap */
  .gd-actions {
    flex-wrap: wrap;
    gap: .4rem;
  }

  /* Admin tiles → 2 columns */
  .dash-tiles {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Field rows stack */
  .field-row {
    flex-direction: column;
    gap: .6rem;
  }

  /* Wizard maps smaller */
  #cem-locate-map,
  #cem-boundary-map,
  #gw-draw-map {
    height: 220px !important;
  }

  /* Wide modals lose their extra width */
  .modal-wide {
    padding: 1.25rem 1rem;
  }

  /* Result cards readable on mobile */
  .result-card {
    padding: .75rem;
  }

  /* Cemetery cards take full width */
  .cem-card {
    margin: 0 0 .75rem;
  }

  /* Topbar auth shrinks */
  .btn-login {
    font-size: .72rem;
    padding: .3rem .6rem;
  }

  .user-chip span {
    display: none;
  }

  /* Copy link button full width on mobile */
  .btn-copy-link {
    width: 100%;
    text-align: center;
  }
}

/* ═══ RTL LAYOUT OVERRIDES (Urdu Mode) ═══ */
html[dir="rtl"] body {
  text-align: right;
}

html[dir="rtl"] .topbar {
  flex-direction: row-reverse;
}

html[dir="rtl"] .topbar-brand {
  flex-direction: row-reverse;
}

html[dir="rtl"] .topbar-nav {
  flex-direction: row-reverse;
}

html[dir="rtl"] .topbar-auth {
  flex-direction: row-reverse;
}

html[dir="rtl"] .panel-left {
  left: auto;
  right: 12px;
}

html[dir="rtl"] .float-tools {
  right: auto;
  left: 12px;
}

html[dir="rtl"] .modal-x {
  left: 1.5rem;
  right: auto;
}

html[dir="rtl"] .req-section-title {
  text-align: right;
}

html[dir="rtl"] .field label {
  text-align: right;
  display: block;
}

html[dir="rtl"] .wpage-title {
  text-align: right;
}

html[dir="rtl"] .wpage-hint {
  text-align: right;
}

html[dir="rtl"] .gd-avatar {
  margin-right: 0;
  margin-left: 1rem;
}

html[dir="rtl"] .gd-hero {
  flex-direction: row-reverse;
}

html[dir="rtl"] .gd-item label {
  text-align: right;
}

html[dir="rtl"] .gd-item p {
  text-align: right;
}

html[dir="rtl"] .gd-bio {
  text-align: right;
  border-left: none;
  border-right: 3px solid var(--accent);
  padding-left: 0;
  padding-right: 1rem;
}

html[dir="rtl"] .gd-actions {
  flex-direction: row-reverse;
}

html[dir="rtl"] .result-card {
  text-align: right;
}

html[dir="rtl"] .rc-meta {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

html[dir="rtl"] .cem-card {
  text-align: right;
}

html[dir="rtl"] .cem-card-row {
  flex-direction: row-reverse;
}

html[dir="rtl"] .cem-mini-stats {
  flex-direction: row-reverse;
}

html[dir="rtl"] .toast {
  left: auto;
  right: 50%;
  transform: translateX(50%) translateY(60px);
}

html[dir="rtl"] .toast.show {
  transform: translateX(50%) translateY(0);
}

/* Bottom sheet slide override for mobile RTL */
@media (max-width: 768px) {
  html[dir="rtl"] .float-panel.panel-left {
    left: 0;
    right: 0;
  }
}

/* ═══ FAMILY TREE LINKING ═══ */
.family-tree {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin-bottom: .25rem;
}

.family-card {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .75rem;
  background: var(--stone);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .18s, background .18s;
  position: relative;
}

.family-card:hover {
  border-color: var(--accent);
  background: rgba(46, 204, 138, .07);
}

.family-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.family-avatar.male   { background: rgba(56, 139, 253, .2); color: #56a4ff; }
.family-avatar.female { background: rgba(248, 113, 113, .2); color: #f87171; }

.family-info {
  flex: 1;
  min-width: 0;
}

.family-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.family-rel {
  font-size: .73rem;
  color: var(--text-mid);
  margin-top: .1rem;
}

.family-unlink {
  background: transparent;
  border: none;
  color: var(--text-mid);
  cursor: pointer;
  font-size: .9rem;
  line-height: 1;
  padding: .2rem .35rem;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}

.family-unlink:hover {
  color: var(--occupied);
  background: rgba(224, 90, 90, .1);
}

.family-search-result {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem .6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}

.family-search-result:hover {
  background: rgba(46, 204, 138, .1);
}

html[dir="rtl"] .family-card    { flex-direction: row-reverse; }
html[dir="rtl"] .family-unlink  { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .family-search-result { flex-direction: row-reverse; }

/* ═══ OCCUPANCY ANALYTICS ═══ */
.analytics-wrap {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: .25rem 0;
}

.analytics-section {
  flex: 1;
  min-width: 200px;
}

.analytics-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .85rem;
}

.analytics-donut-wrap {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.analytics-donut-wrap canvas {
  border-radius: 50%;
  flex-shrink: 0;
}

.analytics-legend {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  font-size: .82rem;
}

.al-item {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.al-item span:last-of-type {
  flex: 1;
  color: var(--text-mid);
}

.al-item b {
  font-weight: 700;
  color: var(--text);
  min-width: 28px;
  text-align: right;
}

.al-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block !important;
}

.analytics-bars {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.analytics-bar-row {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.analytics-bar-label {
  font-size: .78rem;
  color: var(--text);
  width: 130px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analytics-bar-track {
  flex: 1;
  height: 14px;
  background: var(--stone);
  border-radius: 7px;
  overflow: hidden;
  display: flex;
  border: 1px solid var(--border);
}

.analytics-bar-seg {
  height: 100%;
  transition: width .4s ease;
  min-width: 0;
}

.analytics-bar-pct {
  font-size: .73rem;
  font-weight: 700;
  color: var(--text-mid);
  width: 34px;
  text-align: right;
  flex-shrink: 0;
}

html[dir="rtl"] .analytics-donut-wrap { flex-direction: row-reverse; }
html[dir="rtl"] .analytics-bar-label  { text-align: right; }
html[dir="rtl"] .analytics-bar-row    { flex-direction: row-reverse; }
html[dir="rtl"] .analytics-bar-pct    { text-align: left; }

/* ═══ FCM PUSH NOTIFICATION TOAST ═══ */
.fcm-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 99990;
  background: #1C2333;
  border: 1px solid rgba(46, 204, 138, .3);
  border-radius: 12px;
  padding: .85rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
  animation: fcm-slide-in .3s cubic-bezier(.175,.885,.32,1.275) forwards;
  font-family: 'Outfit', sans-serif;
}

@keyframes fcm-slide-in {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

.fcm-toast-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: .05rem;
}

.fcm-toast-content {
  flex: 1;
  min-width: 0;
}

.fcm-toast-title {
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: .2rem;
}

.fcm-toast-body {
  font-size: .78rem;
  color: #9CA3AF;
  line-height: 1.4;
}

.fcm-toast-close {
  background: transparent;
  border: none;
  color: #6B7280;
  cursor: pointer;
  font-size: .9rem;
  padding: 0 .15rem;
  flex-shrink: 0;
  transition: color .15s;
}

.fcm-toast-close:hover {
  color: #fff;
}

html[dir="rtl"] .fcm-toast {
  right: auto;
  left: 1.5rem;
  flex-direction: row-reverse;
}
