:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #eef2f7;
}
* { box-sizing: border-box; }
body { margin: 0; }
.topbar {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: #111827; color: white;
}
h1 { margin: 0; font-size: 21px; }
.topbar p { margin: 3px 0 0; color: #cbd5e1; font-size: 13px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.status { padding: 7px 11px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.status.online { background: #166534; }
.status.connecting { background: #92400e; }
.status.offline { background: #7f1d1d; }
.clear-button { background: transparent; color: white; border: 1px solid #f87171; padding: 7px 10px; }
main { padding: 14px; }
.config-card, .panel { background: white; border-radius: 12px; }
.config-card { padding: 14px; margin-bottom: 12px; }
.config-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; }
.config-section h2, .panel h2 { font-size: 16px; margin: 0 0 10px; }
.subheading { margin-top: 18px !important; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; font-size: 14px; }
.radio-row.stacked { flex-direction: column; gap: 7px; }
.zone-modes { border: 1px solid #e2e8f0; border-radius: 9px; padding: 9px; }
.program-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.program-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px;
  border: 1px solid #cbd5e1; border-radius: 999px; font-size: 13px; font-weight: 700;
}
.program-chip small { font-weight: 500; color: #64748b; }
.program-chip.ppota { border-color: #93c5fd; background: #eff6ff; }
.program-chip.llota { border-color: #86efac; background: #f0fdf4; }
.geo-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.geo-filters label { font-size: 12px; font-weight: 700; }
.geo-filters select { margin-top: 5px; background: white; }
.search, textarea, .numbers input, .geo-filters select, .duration-field input {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 9px 10px; font: inherit;
}
textarea:disabled { background: #f1f5f9; color: #94a3b8; }
.list-actions { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.list-actions span { margin-left: auto; font-size: 12px; color: #64748b; }
.reference-list {
  height: 250px; overflow: auto; border: 1px solid #e2e8f0; border-radius: 9px; background: #fff;
}
.reference-row {
  display: grid; grid-template-columns: 22px 1fr; gap: 7px; align-items: start;
  padding: 7px 9px; border-bottom: 1px solid #f1f5f9; font-size: 13px; cursor: pointer;
}
.reference-row:last-child { border-bottom: 0; }
.reference-row.selected { background: #eff6ff; }
.reference-row small { display: block; color: #64748b; margin-top: 2px; }
.program-badge { display: inline-block; min-width: 45px; font-size: 10px; border-radius: 999px; padding: 2px 5px; margin-right: 5px; text-align: center; }
.program-badge.PPOTA { background: #dbeafe; color: #1e40af; }
.program-badge.LLOTA { background: #dcfce7; color: #166534; }
.field-label { display: block; font-size: 12px; font-weight: 700; margin: 12px 0 5px; }
.help { font-size: 12px; color: #64748b; margin: 6px 0 10px; }
.numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.numbers.three { grid-template-columns: 1fr 1fr 1fr; }
.numbers label { font-size: 12px; font-weight: 700; }
.numbers input { margin-top: 5px; }
.check-row { display: block; font-size: 14px; margin: 0; }
.alarm-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #f1f5f9; }
.alarm-with-duration { grid-template-columns: minmax(0, 1fr) 104px auto; }
.duration-field { font-size: 11px; font-weight: 700; color: #475569; }
.duration-field span { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-weight: 500; }
.duration-field input { width: 64px; padding: 6px 7px; }
.stop-sound { width: 100%; margin: 3px 0 5px; }
button { border: 0; border-radius: 8px; padding: 9px 12px; font-weight: 700; cursor: pointer; }
.primary { width: 100%; background: #2563eb; color: white; padding: 11px 14px; margin-top: 8px; }
.secondary { background: #e2e8f0; color: #172033; font-size: 12px; }
.manual-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px; margin: 8px 0; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 9px; font-size: 13px; }
.manual-box span { flex: 1; color: #7c2d12; }
.hidden { display: none !important; }
.alert-box:empty { display: none; }
.alert-box {
  margin-bottom: 12px; padding: 12px 14px; border-radius: 10px; font-weight: 700;
}
.alert-box.approach { background: #fff7ed; border: 1px solid #f59e0b; color: #92400e; }
.alert-box.inside { background: #fee2e2; border: 1px solid #ef4444; color: #7f1d1d; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 12px; }
.map-wrap { position: relative; }
#map { height: 64vh; min-height: 480px; border-radius: 12px; overflow: hidden; background: #dbeafe; }
.map-note { position: absolute; z-index: 500; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(17,24,39,.90); color: white; border-radius: 8px; padding: 7px 10px; font-size: 12px; pointer-events: none; }
.panel { padding: 12px; min-height: 480px; }
.panel h2 { margin: 14px 0 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.three-stats { grid-template-columns: repeat(3, 1fr); }
.stats div { background: #f1f5f9; border-radius: 10px; padding: 10px 5px; text-align: center; }
.stats span { display: block; font-size: 24px; font-weight: 800; }
.stats small { color: #64748b; }
.station-list { display: grid; gap: 7px; max-height: calc(64vh - 100px); overflow: auto; }
.station { display: grid; gap: 4px; padding: 9px; border: 1px solid #e2e8f0; border-radius: 9px; }
.station.approaching { border-color: #f59e0b; background: #fffbeb; }
.station.inside { border-color: #ef4444; background: #fef2f2; }
.station strong { font-size: 14px; }
.station small { color: #64748b; }
.muted { color: #64748b; font-size: 13px; }
.station-marker { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.station-marker span {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid white; box-shadow: 0 1px 5px rgba(0,0,0,.35); background: #2563eb; color: white;
}
.station-marker.approaching span { background: #d97706; }
.station-marker.inside span { background: #dc2626; }
.station-marker b { background: rgba(255,255,255,.92); border: 1px solid #cbd5e1; border-radius: 5px; padding: 2px 4px; font-size: 12px; color: #111827; }
.ref-marker { border: 2px solid white; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.ref-marker.ppota { fill: #2563eb; stroke: #1d4ed8; }
.ref-marker.llota { fill: #16a34a; stroke: #15803d; }
.ref-marker.coord { fill: #9333ea; stroke: #7e22ce; }
@media (max-width: 980px) {
  .config-grid, .layout { grid-template-columns: 1fr; }
  #map { height: 58vh; min-height: 400px; }
  .station-list { max-height: none; }
}
@media (max-width: 700px) {
  .numbers.three { grid-template-columns: 1fr; }
  .alarm-with-duration { grid-template-columns: 1fr auto; }
  .alarm-with-duration .check-row { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .geo-filters { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .header-actions { align-items: flex-end; flex-direction: column; }
  .numbers { grid-template-columns: 1fr; }
  #map { min-height: 360px; }
}
.track-option { padding: 8px 0 2px; }
.alert-box.exit { background: #e0f2fe; border: 1px solid #0ea5e9; color: #075985; }
.profiles-box { border-top: 1px solid #e2e8f0; margin-top: 8px; padding-top: 4px; }
.subheading.compact { margin-top: 10px !important; margin-bottom: 7px !important; }
.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; margin: 7px 0; }
.profile-grid:last-child { grid-template-columns: minmax(0, 1fr) auto auto; }
.profile-grid input, .profile-grid select {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 9px; font: inherit; background: white;
}
.danger-soft { background: #fee2e2; color: #991b1b; }
.station { cursor: pointer; }
.station:hover { border-color: #94a3b8; }
.station-meta { display: flex; gap: 8px; flex-wrap: wrap; color: #475569; font-size: 11px; }
.history-card { background: white; border-radius: 12px; padding: 14px; margin-top: 12px; }
.history-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.history-head h2 { margin: 0; font-size: 16px; }
.history-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.link-button { display: inline-block; text-decoration: none; }
.history-table-wrap { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th, .history-table td { text-align: left; padding: 8px 9px; border-top: 1px solid #e2e8f0; white-space: nowrap; }
.history-table th { color: #475569; font-size: 12px; }
.event-badge { display: inline-block; border-radius: 999px; padding: 2px 7px; font-size: 11px; font-weight: 700; }
.event-badge.approach { background: #ffedd5; color: #9a3412; }
.event-badge.inside { background: #fee2e2; color: #991b1b; }
.event-badge.exit { background: #e0f2fe; color: #075985; }
.station-track { stroke: #2563eb; stroke-width: 3; opacity: .55; }
@media (max-width: 700px) {
  .history-head { flex-direction: column; }
  .history-actions { justify-content: flex-start; }
}
