/* Shared "console" shell: tab-rail layout, live feeds, grouped state/district/zone
   trees, and the modal — used by the Admin, NGO and Rescue consoles so all three
   staff-facing tools share one visual language instead of three near-duplicates. */

body { overflow-x: hidden; }

.context-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  background: #fff8f0; border-bottom: 1px solid var(--gray-100); font-size: 14px; flex-wrap: wrap;
}
.context-bar select { margin: 0; width: auto; padding: 8px 10px; font-size: 14px; }

.console-layout { display: flex; min-height: calc(100vh - 96px); }
.tab-rail {
  width: 180px; flex-shrink: 0;
  background: white; border-right: 1px solid var(--gray-100);
  display: flex; flex-direction: column;
  position: sticky; top: 96px; height: calc(100vh - 96px); overflow-y: auto;
}
.tab-rail button {
  background: none; border: none; text-align: left; padding: 14px 18px;
  font-size: 14px; cursor: pointer; border-left: 3px solid transparent; color: var(--gray-900);
}
.tab-rail button.active { border-left-color: var(--red); background: var(--gray-50); font-weight: 600; }

.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 999px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; vertical-align: middle;
  animation: tab-badge-pulse 1.4s ease-in-out infinite;
}
@keyframes tab-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(211, 47, 47, 0); }
}
.console-content { flex: 1; padding: 20px; max-width: 980px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

#console-map-wrap { position: relative; margin-bottom: 12px; }
#console-map { height: 45vh; width: 100%; border-radius: 12px; }
#map-summary-card {
  position: absolute; top: 12px; right: 12px; z-index: 500;
  background: white; border-radius: 10px; padding: 10px 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  font-size: 13px; max-width: 260px;
}
@media (prefers-color-scheme: dark) { #map-summary-card { background: #1e1e1e; } }
.map-summary-ngo-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--gray-100); cursor: pointer; }
.map-summary-ngo-row:hover { background: var(--gray-50); }

.map-fullscreen-btn {
  position: absolute; bottom: 12px; left: 12px; z-index: 600;
  width: 36px; height: 36px; border-radius: 8px; border: none;
  background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  font-size: 18px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.map-fullscreen-btn:hover { background: var(--gray-50); }
@media (prefers-color-scheme: dark) { .map-fullscreen-btn { background: #1e1e1e; color: white; } }

#console-map-wrap.map-fullscreen {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  margin: 0; z-index: 5000; background: white;
}
#console-map-wrap.map-fullscreen #console-map,
#console-map-wrap.map-fullscreen #rescue-map-el {
  height: 100vh !important; width: 100vw !important; border-radius: 0;
}
@media (prefers-color-scheme: dark) { #console-map-wrap.map-fullscreen { background: #121212; } }

.team-marker-icon, .camp-marker-icon { font-size: 18px; text-align: center; line-height: 22px; }
.team-name-label, .camp-name-label {
  background: white; border: none; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  font-size: 11px; font-weight: 600; padding: 2px 6px;
}
@media (prefers-color-scheme: dark) {
  .team-name-label, .camp-name-label { background: #1e1e1e; color: white; }
}

.map-layer-toggles {
  display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px;
}
.map-layer-toggles label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.map-layer-toggles input { margin: 0; width: auto; }

.summary-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.summary-row .card { text-align: center; }
.summary-row .value { font-size: 26px; font-weight: 700; }
.summary-row .label { font-size: 12px; color: var(--gray-600); }

.live-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.feed-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.feed-filters select, .feed-filters input[type=text], .feed-filters input[type=month] {
  margin: 0; width: auto; padding: 8px 10px; font-size: 13px;
}
.feed-filters .btn { width: auto; padding: 8px 14px; font-size: 13px; }
.feed-filters .btn.push-right { margin-left: auto; }

.feed-card { border-left: 5px solid var(--gray-300); margin-bottom: 12px; }
.feed-card.priority-critical, .feed-card.severity-high { border-left-color: var(--red); }
.feed-card.priority-high, .feed-card.severity-medium { border-left-color: var(--amber); }
.feed-card.priority-normal, .feed-card.severity-low { border-left-color: var(--gray-300); }
.feed-media { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.feed-media img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; cursor: pointer; }
.feed-media video { max-width: 220px; max-height: 160px; border-radius: 8px; }
.feed-flags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.feed-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.feed-actions .btn { width: auto; padding: 8px 12px; font-size: 13px; }

.group-state { margin-bottom: 16px; }
.group-state-header { margin: 0 0 8px; padding-bottom: 5px; border-bottom: 2px solid var(--red); font-size: 15px; cursor: pointer; user-select: none; }
.group-state-header:hover { opacity: 0.75; }
.group-district { margin-bottom: 10px; }
.group-district-header { margin: 0 0 6px; padding-left: 8px; border-left: 3px solid var(--gray-300); font-size: 12.5px; color: var(--gray-600); cursor: pointer; user-select: none; }
.group-district-header:hover { opacity: 0.75; }
.group-zone { margin: 0 0 8px 16px; }
.group-zone-header { margin: 0 0 5px; font-size: 11.5px; font-weight: 600; color: var(--gray-600); cursor: pointer; user-select: none; }
.group-zone-header:hover { opacity: 0.75; }
.group-toggle { display: inline-block; width: 14px; font-size: 10px; }
.media-approve-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

@media (max-width: 700px) {
  .console-layout { flex-direction: column; }
  .tab-rail { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; }
  .tab-rail button { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .tab-rail button.active { border-left-color: transparent; border-bottom-color: var(--red); }
}

.manage-list-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.row-actions .btn { width: auto; padding: 6px 10px; font-size: 12px; }
.camp-amenities { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.camp-amenity { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--gray-100); color: var(--gray-600); }
.camp-amenity.on { background: #dcfce7; color: #166534; }
.camp-occupancy-bar { height: 8px; border-radius: 4px; background: var(--gray-100); overflow: hidden; margin: 4px 0; }
.camp-occupancy-fill { height: 100%; background: var(--red); }
.camp-occupancy-fill.ok { background: #22c55e; }
.camp-occupancy-fill.warn { background: #f59e0b; }
.status-chip.status-open { background: #dcfce7; color: #166534; }
.status-chip.status-full { background: #fef3c7; color: #92400e; }
.status-chip.status-closed { background: var(--gray-100); color: var(--gray-600); }
.status-chip.status-proposed { background: #e0e7ff; color: #3730a3; }
.status-chip.status-in_progress { background: #fef3c7; color: #92400e; }
.status-chip.status-completed { background: #dcfce7; color: #166534; }
.status-chip.status-declined { background: #fee2e2; color: #991b1b; }

.initiative-progress-bar { height: 8px; border-radius: 4px; background: var(--gray-100); overflow: hidden; margin: 6px 0; }
.initiative-progress-fill { height: 100%; background: var(--red); }
.initiative-assignees { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.initiative-assignee-chip { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--gray-100); color: var(--gray-600); }
.initiative-vote-tally { font-size: 12px; color: var(--gray-600); }
.initiative-comment { border-top: 1px solid var(--gray-100); padding: 8px 0; }
.initiative-comment:first-child { border-top: none; }

.zone-status-legend span { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; margin-right: 6px; color: white; }

/* Live-request tables (Admin/NGO/Rescue "Live Requests"): dense, one row per request,
   colored by status so a lot of requests can be scanned without opening every one.
   Wrapped in .sos-table-wrap (not the page body) so wide tables scroll horizontally
   instead of forcing the whole page to, or getting clipped by body{overflow-x:hidden}. */
.sos-table-wrap { overflow-x: auto; margin-bottom: 14px; }
.sos-table { font-size: 12.5px; white-space: nowrap; }
.sos-table th { background: white; font-size: 11px; text-transform: uppercase; color: var(--gray-600); }
.sos-table td { vertical-align: top; white-space: normal; }
.sos-table select, .sos-table .btn { font-size: 11.5px; padding: 3px 6px; width: auto; margin: 0; }
.sos-table .row-actions { flex-wrap: wrap; }

.sos-group-row td { background: var(--gray-100); font-weight: 700; cursor: pointer; user-select: none; padding: 6px 8px; }
.sos-group-row.sos-group-district td { background: #fafafa; font-weight: 600; font-size: 12px; padding-left: 20px; }
.sos-group-row.sos-group-zone td { background: white; border-bottom: 2px solid var(--gray-100); font-weight: 600; font-size: 11.5px; padding-left: 32px; color: var(--gray-600); }

.sos-row.status-new { background: #fff; }
.sos-row.status-assigned { background: #eff6ff; }
.sos-row.status-in_progress { background: #fefce8; }
.sos-row.status-partially_resolved { background: #fff7ed; }
.sos-row.status-resolved { background: #f0fdf4; }
.sos-row.status-unreachable { background: #fef2f2; }
.sos-row.status-closed_not_resolved { background: var(--gray-100); }

@media (prefers-color-scheme: dark) {
  .sos-table th { background: #1e1e1e; }
  .sos-group-row td { background: #262626; }
  .sos-group-row.sos-group-district td { background: #1e1e1e; }
  .sos-group-row.sos-group-zone td { background: #121212; }
  .sos-row.status-new { background: #1a1a1a; }
  .sos-row.status-assigned { background: #16213a; }
  .sos-row.status-in_progress { background: #302b12; }
  .sos-row.status-partially_resolved { background: #2e2210; }
  .sos-row.status-resolved { background: #14251a; }
  .sos-row.status-unreachable { background: #2e1515; }
  .sos-row.status-closed_not_resolved { background: #222; }
}

#modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
#modal-overlay.open { display: flex; }
#modal-box { background: white; border-radius: 12px; padding: 20px; max-width: 440px; width: 100%; max-height: 90vh; overflow-y: auto; }
@media (prefers-color-scheme: dark) { #modal-box { background: #1e1e1e; } }

.guide-step { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.guide-step .guide-num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--red); color: white;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
