:root {
  --navy-dark: #0B2545;
  --navy-light: #134074;
  --saffron: #F28C28;
  --saffron-light: #FFF3E0;
  --green: #138808;
  --green-light: #E8F5E9;
  --bg-main: #F5F7FA;
  --bg-card: #FFFFFF;
  --border-color: #E2E8F0;
  --text-main: #1E293B;
  --text-muted: #64748B;

  --p-low: #2E7D32;
  --p-medium: #F9A825;
  --p-high: #EF6C00;
  --p-critical: #C62828;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 4px 12px rgba(11, 37, 69, 0.06), 0 1px 3px rgba(11, 37, 69, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", "Noto Sans Devanagari", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  background-color: var(--navy-dark);
  color: #ffffff;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 3px solid var(--saffron);
}

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

.brand-logo {
  width: 44px;
  height: 44px;
}

.brand-text h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: #94A3B8;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.live-clock {
  font-family: monospace;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: #E2E8F0;
}

/* Status Pill */
.status-pill {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.pill-live {
  background: #E8F5E9;
  color: var(--green);
  border: 1px solid #A5D6A7;
}

.pill-replay {
  background: #F3E5F5;
  color: #7B1FA2;
  border: 1px solid #CE93D8;
}

.pill-ratelimited {
  background: #FFF3E0;
  color: #E65100;
  border: 1px solid #FFCC80;
}

.pill-offline {
  background: #FFEBEE;
  color: #C62828;
  border: 1px solid #EF9A9A;
}

.pill-paused {
  background: #ECEFF1;
  color: #546E7A;
  border: 1px solid #CFD8DC;
}

/* Language Toggle */
.lang-toggle {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.lang-btn {
  background: transparent;
  border: none;
  color: #CBD5E1;
  padding: 4px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
}

.lang-btn.active {
  background: var(--saffron);
  color: #ffffff;
}

/* Sub-banner disclaimer */
.persistent-banner {
  background: #FEF3C7;
  color: #92400E;
  font-size: 0.8rem;
  padding: 6px 20px;
  text-align: center;
  border-bottom: 1px solid #FDE68A;
  font-weight: 500;
}

/* Main Navigation Tabs */
.app-nav-bar {
  background: #ffffff;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.nav-tab {
  background: transparent;
  border: none;
  padding: 14px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--navy-dark);
}

.nav-tab.active {
  color: var(--navy-dark);
  border-bottom-color: var(--saffron);
}

.nav-tab-badge {
  background: var(--p-high);
  color: #ffffff;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}

/* App Container & Panes */
.app-container {
  padding: 20px 24px;
  max-width: 1440px;
  margin: 0 auto;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

/* KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-box {
  background: #ffffff;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.kpi-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.kpi-number {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy-dark);
}

/* Scanner control bar */
.scanner-control-bar {
  background: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.scanner-left-group, .scanner-right-group {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* Live Monitor Grid */
.monitor-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1100px) {
  .monitor-layout {
    grid-template-columns: 1fr;
  }
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.camera-tile {
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

.camera-tile-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.cam-id-badge {
  background: var(--navy-dark);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
}

.cam-name-wrap strong {
  font-size: 0.9rem;
  display: block;
}

.cam-name-wrap small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.sensitivity-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  background: #EEF2F6;
  color: var(--text-main);
  white-space: nowrap;
}

.sensitivity-badge.school { background: #E0F2FE; color: #0369A1; }
.sensitivity-badge.water_body { background: #E0F2FE; color: #0284C7; }
.sensitivity-badge.market { background: #FEF3C7; color: #B45309; }

.video-container {
  position: relative;
  background: #000000;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cam-canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  background: #334155;
  color: #E2E8F0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

.cam-live-indicator {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: #22C55E;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

.scene-summary-tag {
  position: absolute;
  bottom: 6px;
  left: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #CBD5E1;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.camera-tile-actions {
  padding: 10px 14px;
  background: #F8FAFC;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

/* Alert Feed on the Right */
.alert-feed-panel {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-feed-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 540px;
  overflow-y: auto;
}

.alert-card {
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--p-high);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #ffffff;
  transition: all 0.2s;
}

.alert-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.alert-cam-id {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.alert-card-body strong {
  font-size: 0.88rem;
  display: block;
  line-height: 1.3;
}

.alert-loc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.alert-dept {
  font-size: 0.75rem;
  color: var(--navy-light);
  display: block;
  margin-top: 2px;
}

.alert-card-actions {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alert-id {
  font-size: 0.72rem;
  font-family: monospace;
  color: var(--text-muted);
}

/* Priority & Status Chips */
.priority-chip {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-block;
  text-transform: uppercase;
}

.priority-low { background: #E8F5E9; color: var(--p-low); border: 1px solid #A5D6A7; }
.priority-medium { background: #FFFDE7; color: var(--p-medium); border: 1px solid #FFF59D; }
.priority-high { background: #FFF3E0; color: var(--p-high); border: 1px solid #FFCC80; }
.priority-critical { background: #FFEBEE; color: var(--p-critical); border: 1px solid #EF9A9A; }

.status-chip {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid currentColor;
  display: inline-block;
}

.status-open { color: var(--p-high); }
.status-assigned { color: #0284C7; }
.status-marked_resolved { color: #8B5CF6; }
.status-closed_verified { color: var(--p-low); }
.status-reopened { color: var(--p-critical); }

/* SLA Badges */
.sla-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}
.sla-ok { background: #E8F5E9; color: var(--p-low); }
.sla-breached { background: #FFEBEE; color: var(--p-critical); }
.sla-closed { background: #ECEFF1; color: #546E7A; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.btn-sm {
  font-size: 0.78rem;
  padding: 4px 10px;
}

.btn-primary {
  background: var(--navy-dark);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--navy-light);
}

.btn-secondary {
  background: var(--saffron);
  color: #ffffff;
}
.btn-secondary:hover {
  background: #D97706;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #F1F5F9;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: #F1F5F9;
  color: var(--text-main);
}

.btn-danger {
  background: var(--p-critical);
  color: #ffffff;
}
.btn-danger:hover {
  background: #B71C1C;
}

.hidden-file-input {
  display: none;
}

.btn-upload-label {
  cursor: pointer;
  margin: 0;
}

/* Incidents Table */
.incidents-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-tabs-filter {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.status-filter-tab {
  background: #ffffff;
  border: none;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}
.status-filter-tab.active {
  background: var(--navy-dark);
  color: #ffffff;
}

.search-input, .select-input {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  background: #ffffff;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.incidents-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.86rem;
}

.incidents-table th {
  background: #F8FAFC;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.incidents-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}

.incident-row {
  cursor: pointer;
  transition: background 0.15s;
}
.incident-row:hover {
  background: #F1F5F9;
}

/* Detail Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: none;
}
.drawer-backdrop.open {
  display: block;
}

.incident-drawer {
  position: fixed;
  top: 0;
  right: -560px;
  width: 540px;
  max-width: 100%;
  height: 100%;
  background: #ffffff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 1001;
  transition: right 0.25s ease;
  display: flex;
  flex-direction: column;
}
.incident-drawer.open {
  right: 0;
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.evidence-side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) {
  .evidence-side-by-side { grid-template-columns: 1fr; }
}

.evidence-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.evidence-box span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}
.evidence-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #000000;
}

.verify-box {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.verify-success { background: #E8F5E9; border: 1px solid #A5D6A7; color: #1B5E20; }
.verify-fail { background: #FFEBEE; border: 1px solid #EF9A9A; color: #B71C1C; }

/* Explainable score section */
.explain-card {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.explain-card h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy-dark);
  margin-bottom: 6px;
}
.explain-list {
  padding-left: 20px;
  font-size: 0.82rem;
  color: var(--text-main);
}

/* WhatsApp Card Preview */
.whatsapp-card {
  background: #EFEAE2;
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid #D1D7DB;
}
.wa-bubble {
  background: #DCF8C6;
  padding: 12px 14px;
  border-radius: 10px 10px 0 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.82rem;
  color: #111B21;
}

/* Timeline */
.timeline-item {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--navy-dark);
  margin-top: 5px;
}
.timeline-content {
  flex: 1;
  background: #F8FAFC;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.timeline-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}
.timeline-kind { font-size: 0.78rem; }
.timeline-time { font-size: 0.72rem; color: var(--text-muted); }
.timeline-msg { font-size: 0.8rem; }

.drawer-actions-bar {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: #ffffff;
}

/* Map */
.map-layout {
  height: 620px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.custom-cam-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}
.cam-marker-bubble {
  background: #334155;
  color: #ffffff;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  position: relative;
  font-size: 16px;
}
.cam-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--p-high);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
}

/* Analytics */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.chart-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-card);
}
.chart-box h3 {
  font-size: 0.95rem;
  color: var(--navy-dark);
  margin-bottom: 14px;
}

.bar-chart-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.82rem;
}
.bar-label {
  width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  flex: 1;
  height: 14px;
  background: #EEF2F6;
  border-radius: 7px;
  overflow: hidden;
  display: flex;
}
.bar-fill {
  height: 100%;
}
.fill-orange { background: var(--saffron); }
.fill-green { background: var(--green); }
.bar-value {
  width: 60px;
  text-align: right;
  font-weight: 600;
}

.hotspot-card {
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--p-critical);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.hotspot-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.hotspot-rec {
  font-size: 0.82rem;
  color: var(--text-main);
}

/* Settings */
.settings-section {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.settings-section h3 {
  font-size: 1.1rem;
  color: var(--navy-dark);
  margin-bottom: 6px;
}
.settings-section p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.watchlist-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.watchlist-chip {
  background: var(--navy-dark);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip-remove-btn {
  background: none;
  border: none;
  color: #CBD5E1;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.highlight-error {
  border-color: var(--p-critical) !important;
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.2) !important;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast-bubble {
  background: var(--navy-dark);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Animations */
.slide-in {
  animation: slideIn 0.25s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-out {
  opacity: 0;
  transition: opacity 0.35s;
}

.hidden {
  display: none !important;
}
