/* ===== ProKing Alarm Monitor - Styles ===== */

:root {
  --bg-primary: #0c0c0e;
  --bg-secondary: #141416;
  --bg-card: #1c1c20;
  --bg-hover: #26262b;
  --text-primary: #f0f0f2;
  --text-secondary: #a0a0a8;
  --text-muted: #5c5c66;
  --border: #2a2a30;
  --accent: #D42B2B;
  --accent-hover: #b82424;
  --accent-light: rgba(212, 43, 43, 0.12);
  --risk-high: #ef4444;
  --risk-high-bg: rgba(239, 68, 68, 0.10);
  --risk-medium: #f59e0b;
  --risk-medium-bg: rgba(245, 158, 11, 0.10);
  --risk-low: #22c55e;
  --risk-low-bg: rgba(34, 197, 94, 0.10);
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 4px;
  --radius-lg: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== Header ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 16px; }

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-img {
  height: 36px;
  width: auto;
}
.logo h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.logo h1 span {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 14px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pulse {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 3s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--bg-hover); }
.btn-icon {
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-patrol {
  background: var(--risk-high-bg);
  border-color: var(--risk-high);
  color: var(--risk-high);
  font-weight: 600;
}
.btn-patrol:hover { background: var(--risk-high); color: #fff; }
.btn-patrol.dispatched {
  background: var(--risk-low-bg);
  border-color: var(--risk-low);
  color: var(--risk-low);
  cursor: default;
}
.btn-patrol.auto-dispatched {
  background: rgba(168,85,247,0.12);
  border-color: #a855f7;
  color: #a855f7;
  cursor: default;
  font-weight: 600;
}

.btn-view-img {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: #8ab4ff;
}
.btn-view-img:hover { border-color: #8ab4ff; background: rgba(138,180,255,0.1); }

/* ===== Navigation Tabs ===== */
.tabs {
  display: flex;
  gap: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.tab {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== Tab Content ===== */
.tab-content { display: none; padding: 24px; }
.tab-content.active { display: block; }

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  border-top: 2px solid var(--border);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-high { border-top-color: var(--risk-high); }
.stat-high .stat-value { color: var(--risk-high); }
.stat-medium { border-top-color: var(--risk-medium); }
.stat-medium .stat-value { color: var(--risk-medium); }
.stat-low { border-top-color: var(--risk-low); }
.stat-low .stat-value { color: var(--risk-low); }
.stat-unack { border-top-color: var(--accent); }
.stat-unack .stat-value { color: var(--text-primary); }
.stat-patrol { border-top-color: var(--risk-medium); }
.stat-patrol .stat-value { color: var(--risk-medium); }

/* ===== Charts ===== */
.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.chart-card h3 {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.chart-card.full-width { margin-bottom: 24px; }

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bar-chart.horizontal {
  flex-direction: row;
  align-items: flex-end;
  height: 120px;
  gap: 4px;
}

.bar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.bar-item .bar-label {
  min-width: 100px;
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-item .bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.bar-item .bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 2px;
}
.bar-item .bar-value {
  min-width: 40px;
  font-weight: 600;
  color: var(--text-primary);
}
.bar-item[onclick]:hover {
  background: var(--bg-hover);
  border-radius: var(--radius);
}
.bar-item[onclick] .bar-label { text-decoration: underline; text-underline-offset: 2px; }

/* Vertical bars for daily trend */
.bar-vertical {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.bar-vertical .vbar-track {
  width: 100%;
  max-width: 40px;
  height: 100%;
  background: var(--bg-primary);
  border-radius: 4px 4px 0 0;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.bar-vertical .vbar-fill {
  width: 100%;
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease;
}
.bar-vertical .vbar-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.bar-vertical .vbar-value {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

/* ===== Filters ===== */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filters select {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
}
.filters select:focus,
.filters input:focus { outline: none; border-color: var(--accent); }
.filters input[type="date"] {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  color-scheme: dark;
}

/* ===== Events Table ===== */
.table-container {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.events-table {
  width: 100%;
  border-collapse: collapse;
}
.events-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.events-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.events-table tr:last-child td { border-bottom: none; }
.events-table tr:hover { background: var(--bg-hover); }
.events-table tr.unacknowledged { background: rgba(212,43,43,0.04); }
.events-table tr.risk-high-row { border-left: 3px solid var(--risk-high); }
.events-table tr.risk-medium-row { border-left: 3px solid var(--risk-medium); }
.events-table tr.risk-low-row { border-left: 3px solid var(--risk-low); }

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px !important;
}

/* Risk Badge */
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.risk-badge.high { background: var(--risk-high-bg); color: var(--risk-high); }
.risk-badge.medium { background: var(--risk-medium-bg); color: var(--risk-medium); }
.risk-badge.low { background: var(--risk-low-bg); color: var(--risk-low); }

.risk-bar {
  width: 50px;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.risk-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.status-badge.new { background: var(--accent-light); color: var(--accent); }
.status-badge.ack { background: rgba(34,197,94,0.15); color: var(--success); }

/* Statistics tab */
.stat-filters { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.stat-filters select, .stat-filters input[type="date"] {
  padding: 8px 12px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 14px;
}
.stat-filters input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); }
#stat-custom-dates { display: flex; gap: 6px; align-items: center; }

.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 16px; }
.stats-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-card.stat-high { border-color: var(--danger); }
.stat-num { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.stat-card.stat-high .stat-num { color: var(--danger); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.text-muted { color: var(--text-muted); }
.chart-container { min-height: 100px; }

/* Bar rows */
.stat-bar-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; }
.stat-bar-label { min-width: 120px; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.stat-bar-track { flex: 1; height: 14px; background: rgba(255,255,255,0.04); border-radius: 3px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.stat-bar-value { min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Hour chart */
.hour-chart { display: flex; align-items: flex-end; gap: 2px; height: 90px; padding-top: 8px; }
.hour-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hour-fill { width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; transition: height 0.3s; }
.hour-bar span { font-size: 9px; color: var(--text-muted); }

/* Day chart (trend) */
.day-chart { display: flex; align-items: flex-end; gap: 2px; height: 100px; }
.day-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.day-bars { width: 100%; height: 80px; position: relative; display: flex; flex-direction: column; justify-content: flex-end; }
.day-fill { width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; transition: height 0.3s; opacity: 0.5; }
.day-fill-high { width: 100%; background: var(--danger); border-radius: 2px 2px 0 0; transition: height 0.3s; position: absolute; bottom: 0; }
.resp-fill { background: #8b5cf6 !important; opacity: 1 !important; }
.day-col span { font-size: 8px; color: var(--text-muted); white-space: nowrap; overflow: hidden; }
.day-legend { display: flex; gap: 12px; align-items: center; font-size: 11px; color: var(--text-muted); margin-top: 8px; }
.day-leg-all { width: 12px; height: 12px; background: var(--accent); opacity: 0.5; border-radius: 2px; display: inline-block; }
.day-leg-high { width: 12px; height: 12px; background: var(--danger); border-radius: 2px; display: inline-block; }

/* Objects tab */
.obj-search-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.obj-search-bar input { flex: 1; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-primary); font-size: 14px; }
.obj-search-bar input:focus { outline: none; border-color: var(--accent); }

.object-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.obj-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; cursor: pointer; flex-wrap: wrap; gap: 8px; user-select: none; }
.obj-header:hover { background: rgba(255,255,255,0.02); }
.obj-header-left { display: flex; align-items: center; gap: 8px; }
.obj-header h3 { margin: 0; font-size: 15px; }
.obj-chevron { transition: transform 0.2s; color: var(--text-muted); flex-shrink: 0; }
.object-card:not(.collapsed) .obj-chevron { transform: rotate(90deg); }
.obj-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.obj-badge { font-size: 10px; padding: 2px 7px; background: rgba(255,255,255,0.05); border-radius: 3px; color: var(--text-muted); }
.obj-badge-high { background: rgba(239,68,68,0.12); color: var(--danger); }
.obj-badge-ok { background: rgba(34,197,94,0.1); color: var(--success); }

.obj-body { padding: 0 16px 16px; }
.object-card.collapsed .obj-body { display: none; }

.obj-form { display: flex; flex-direction: column; gap: 10px; }
.obj-row { display: flex; flex-direction: column; gap: 4px; }
.obj-row label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.obj-row input, .obj-row textarea { padding: 8px 10px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-primary); font-size: 14px; }
.obj-row input:focus, .obj-row textarea:focus { outline: none; border-color: var(--accent); }
.obj-row textarea { resize: vertical; font-family: inherit; }
.obj-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.obj-row-2col label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.obj-row-2col input { padding: 8px 10px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-primary); font-size: 14px; }
.obj-row-2col input:focus { outline: none; border-color: var(--accent); }

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid-2col { grid-template-columns: 1fr; }
  .stat-bar-label { min-width: 80px; max-width: 100px; }
}

/* Stat table */
.stat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stat-table th { text-align: left; padding: 6px 8px; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.stat-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.stat-table tr:hover { background: rgba(255,255,255,0.02); }
.stat-table td:not(:first-child), .stat-table th:not(:first-child) { text-align: right; }

/* Heatmap */
.heatmap { display: flex; flex-direction: column; gap: 1px; overflow-x: auto; }
.hm-row { display: flex; gap: 1px; align-items: center; }
.hm-label { width: 24px; font-size: 10px; color: var(--text-muted); text-align: center; flex-shrink: 0; }
.hm-cell { width: 100%; min-width: 16px; height: 22px; border-radius: 2px; display: flex; align-items: center; justify-content: center; font-size: 9px; color: rgba(255,255,255,0.6); flex: 1; }
.hm-header .hm-cell { background: transparent !important; color: var(--text-muted); font-size: 9px; height: 14px; }
.hm-hour { font-variant-numeric: tabular-nums; }

/* Shift reports */
.shift-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.shift-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.2s; }
.shift-card:hover { border-color: var(--accent); }
.shift-night { border-left: 3px solid #6366f1; }
.shift-day { border-left: 3px solid #f59e0b; }
.shift-card-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.shift-icon { font-size: 16px; margin-right: 4px; }
.shift-card-stats { display: flex; gap: 12px; font-size: 13px; color: var(--text-muted); }
.shift-stat-high { color: var(--danger); }
.shift-stat-threat { color: #f59e0b; }
.shift-summary { margin-top: 10px; font-size: 13px; color: var(--text-secondary); line-height: 1.6; white-space: pre-line; }
.shift-event { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 13px; }
.shift-event:last-child { border-bottom: none; }

/* Event detail */
.event-desc-link { cursor: pointer; }
.event-desc-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.ecard-desc { cursor: pointer; }

.detail-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.detail-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.detail-label { color: var(--text-muted); min-width: 80px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 14px; padding: 10px; background: var(--bg-primary); border-radius: var(--radius); }
.detail-img { width: 100%; border-radius: var(--radius); margin-bottom: 14px; cursor: pointer; }
.detail-section-title { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-bottom: 10px; }

.timeline { display: flex; flex-direction: column; gap: 0; border-left: 2px solid var(--border); margin-left: 8px; padding-left: 16px; }
.timeline-item { display: flex; gap: 10px; padding: 6px 0; font-size: 13px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: -21px; top: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.timeline-item:first-child::before { background: var(--accent); }
.tl-time { color: var(--text-muted); min-width: 90px; font-variant-numeric: tabular-nums; }
.tl-event { color: var(--text-primary); }

/* Patrol status */
.patrol-status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}
.ps-arrived { background: rgba(34,197,94,0.12); color: var(--success); }
.ps-false { background: rgba(107,114,128,0.15); color: #9ca3af; }
.ps-police { background: rgba(239,68,68,0.12); color: var(--danger); }
.ps-monitoring { background: rgba(59,130,246,0.12); color: #60a5fa; }
.ps-no-threat { background: rgba(34,197,94,0.12); color: var(--success); }
.ps-noted { background: rgba(107,114,128,0.10); color: #6b7280; }

.patrol-select {
  padding: 5px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}
.patrol-select:focus { outline: none; border-color: var(--accent); }

/* Repeat badge */
.repeat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(245,158,11,0.15);
  color: var(--risk-medium);
  vertical-align: middle;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px;
}
.pagination button {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}
.pagination button:hover { border-color: var(--accent); color: var(--text-primary); }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ===== Modals ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.75);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.modal.open { display: flex; }

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}
.modal-content img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: var(--radius);
}
.modal-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 28px;
  height: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 3px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-info {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 90%;
}
.modal-dialog h3 { margin-bottom: 16px; }
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: flex-end;
}

#dispatch-info {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}
#dispatch-info strong { color: var(--text-primary); }

/* ===== Management ===== */
.manage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px;
}

.manage-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.manage-card h3 {
  font-size: 16px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.manage-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.manage-card input,
.manage-card select {
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
}
.manage-card input:focus,
.manage-card select:focus {
  outline: none;
  border-color: var(--accent);
}
.manage-card input::placeholder { color: var(--text-muted); }

.items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius);
  font-size: 14px;
}
.list-item .item-name { font-weight: 500; }
.list-item .item-detail { color: var(--text-muted); font-size: 12px; }
.list-item .btn-delete {
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.list-item .btn-delete:hover { color: var(--danger); background: var(--risk-high-bg); }

/* ===== API Info ===== */
.api-info p { color: var(--text-secondary); font-size: 14px; margin-bottom: 12px; }
.api-info pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
  font-size: 13px;
  margin-bottom: 16px;
}
.api-info code { color: var(--text-primary); }
.api-info h4 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.api-info .note {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== Settings Panel ===== */
.settings-panel {
  position: fixed;
  top: 60px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  z-index: 200;
  box-shadow: var(--shadow);
  min-width: 260px;
}
.settings-panel h3 { margin-bottom: 16px; font-size: 15px; }
.settings-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}
.settings-panel input[type="checkbox"] { accent-color: var(--accent); }
.hidden { display: none !important; }

/* ===== Section ===== */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.section h3 {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.events-mini-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mini-event {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius);
  border-left: 3px solid var(--risk-high);
}
.mini-event .mini-time {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 100px;
}
.mini-event .mini-object { font-weight: 500; min-width: 120px; }
.mini-event .mini-desc { color: var(--text-secondary); font-size: 13px; flex: 1; }
.mini-event .mini-risk { font-weight: 700; }

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  top: 70px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--risk-medium); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Alarm flash on high-risk */
.header.alarm-flash {
  animation: headerFlash 0.5s ease 4;
}
@keyframes headerFlash {
  0%, 100% { border-bottom-color: var(--accent); }
  50% { border-bottom-color: #ff0000; box-shadow: 0 2px 20px rgba(255,0,0,0.3); }
}

.toast.error {
  border-left: 3px solid var(--danger);
  background: rgba(239,68,68,0.08);
  font-weight: 600;
}

/* ===== Desktop/Mobile visibility ===== */
.mobile-only { display: none; }
.desktop-only { display: block; }

/* ===== Event Cards (mobile) ===== */
.event-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border-left: 3px solid var(--border);
}
.event-card.risk-high-card { border-left-color: var(--risk-high); }
.event-card.risk-medium-card { border-left-color: var(--risk-medium); }
.event-card.risk-low-card { border-left-color: var(--risk-low); }

.ecard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.ecard-time {
  font-size: 13px;
  color: var(--text-muted);
}
.ecard-location {
  font-size: 15px;
  margin-bottom: 8px;
}
.ecard-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}
.ecard-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.ecard-actions .btn {
  padding: 10px 16px;
  font-size: 14px;
  min-height: 44px;
}
.ecard-actions .btn-patrol {
  flex: 1;
  justify-content: center;
}
.ecard-actions .status-badge {
  padding: 6px 12px;
  font-size: 13px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }

  /* Header */
  .header { padding: 10px 12px; }
  .logo-img { height: 28px; }
  .logo h1 { font-size: 15px; }
  .logo h1 span { display: none; }

  /* Tabs */
  .tabs { padding: 0 8px; }
  .tab {
    padding: 14px 16px;
    font-size: 15px;
    flex: 1;
    text-align: center;
  }

  /* Content */
  .tab-content { padding: 12px; }

  /* Stats grid - 2 columns, bigger text */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-card { padding: 14px 10px; }
  .stat-value { font-size: 28px; }
  .stat-label { font-size: 12px; }

  /* Charts */
  .charts-row {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
  }
  .chart-card { padding: 14px; }
  .chart-card.full-width { margin-bottom: 16px; }
  .bar-item .bar-label { min-width: 70px; font-size: 12px; }

  /* Filters */
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .filters select,
  .filters input[type="date"] {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    min-height: 44px;
  }
  .filters .btn {
    grid-column: 1 / -1;
    justify-content: center;
    padding: 12px;
    min-height: 44px;
  }

  /* Pagination */
  .pagination { gap: 4px; }
  .pagination button {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 44px;
  }

  /* Modals */
  .modal-content { max-width: 95vw; }
  .modal-content img { max-width: 95vw; border-radius: var(--radius); }
  .modal-close {
    top: -8px;
    right: -8px;
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  .modal-dialog {
    max-width: 95%;
    padding: 20px 16px;
  }
  .modal-actions {
    flex-direction: column;
  }
  .modal-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 14px;
    min-height: 48px;
    font-size: 16px;
  }

  /* Settings panel */
  .settings-panel {
    top: 50px;
    right: 8px;
    left: 8px;
    min-width: auto;
  }
  .settings-panel label { font-size: 15px; padding: 4px 0; }

  /* Toast */
  .toast-container { right: 8px; left: 8px; }
  .toast { max-width: 100%; font-size: 15px; }

  /* Mini events (dashboard) */
  .mini-event {
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px;
  }
  .mini-event .mini-time { min-width: auto; font-size: 13px; }
  .mini-event .mini-object { min-width: auto; font-size: 14px; }
  .mini-event .mini-desc { flex-basis: 100%; font-size: 13px; }

  /* Section */
  .section { padding: 14px; }
}
