* {
  box-sizing: border-box;
}

:root {
  --navy: #0b1739;
  --navy-light: #14244d;
  --blue: #2563eb;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #182033;
  --muted: #718096;
  --border: #e5eaf2;
  --green: #16a36a;
  --orange: #f59e0b;
  --red: #dc3545;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--navy);
  color: white;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--blue);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 19px;
}

.brand span {
  font-size: 11px;
  letter-spacing: 2px;
  opacity: .65;
  margin-top: 2px;
}

.demo-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  background: rgba(245,158,11,.15);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,.3);
  border-radius: 7px;
  padding: 8px 10px;
  margin-bottom: 28px;
}

nav {
  display: grid;
  gap: 7px;
}

nav a {
  color: #aebbd7;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
}

nav a:hover,
nav a.active {
  background: var(--navy-light);
  color: white;
}

nav a.active {
  border-left: 3px solid #4d8dff;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.sidebar-footer span,
.sidebar-footer strong {
  display: block;
}

.sidebar-footer span {
  color: #7f90b5;
  font-size: 11px;
}

.sidebar-footer strong {
  margin-top: 5px;
  font-size: 13px;
}

.main {
  margin-left: 240px;
  padding: 34px;
  max-width: 1700px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

h1 {
  margin: 0;
  font-size: 29px;
}

.subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.system-status {
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(22,163,106,.12);
}

.alert-banner {
  background: #fff4f4;
  border: 1px solid #ffd2d6;
  border-left: 4px solid var(--red);
  border-radius: 10px;
  padding: 15px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.alert-banner strong,
.alert-banner span {
  display: block;
}

.alert-banner strong {
  color: #b42331;
  font-size: 14px;
}

.alert-banner span {
  color: #8b5960;
  font-size: 12px;
  margin-top: 3px;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.alert-banner button {
  background: var(--red);
  color: white;
  border-radius: 7px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 2px 8px rgba(17,30,65,.03);
}

.kpi span,
.kpi strong,
.kpi small {
  display: block;
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.kpi strong {
  font-size: 30px;
  margin: 7px 0 4px;
}

.kpi small {
  color: #8c98aa;
  font-size: 11px;
}

.kpi.danger {
  border-top: 3px solid var(--red);
}

.kpi.danger strong {
  color: var(--red);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(310px, .8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(17,30,65,.03);
}

.map-panel,
.incident-panel,
.engineer-panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.live-pill,
.critical-pill {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .8px;
  border-radius: 20px;
  padding: 6px 9px;
}

.live-pill {
  color: var(--green);
  background: #eaf9f2;
}

.critical-pill {
  color: var(--red);
  background: #fff0f1;
}

.map-placeholder {
  position: relative;
  min-height: 390px;
  border-radius: 10px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,.65), rgba(255,255,255,.65)),
    repeating-linear-gradient(0deg, #dce5ef 0, #dce5ef 1px, transparent 1px, transparent 42px),
    repeating-linear-gradient(90deg, #dce5ef 0, #dce5ef 1px, transparent 1px, transparent 42px),
    #edf2f7;
}

.map-message {
  position: absolute;
  left: 20px;
  bottom: 18px;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 13px;
}

.map-message strong,
.map-message span {
  display: block;
}

.map-message strong {
  font-size: 12px;
}

.map-message span {
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
}

.map-pin {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 8px;
  transform: rotate(-45deg);
  display: grid;
  place-items: center;
  color: white;
  font-size: 10px;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(0,0,0,.15);
}

.map-pin::after {
  content: attr(data-label);
}

.map-pin.green { background: var(--green); }
.map-pin.orange { background: var(--orange); }
.map-pin.red { background: var(--red); }

.map-pin {
  line-height: 34px;
  text-align: center;
}

.pin-one { left: 22%; top: 31%; }
.pin-two { left: 57%; top: 24%; }
.pin-three { left: 68%; top: 58%; }
.pin-four { left: 39%; top: 68%; }

.incident-worker {
  display: flex;
  align-items: center;
  gap: 11px;
  background: #fff6f6;
  border-radius: 9px;
  padding: 12px;
  margin-bottom: 16px;
}

.avatar {
  width: 39px;
  height: 39px;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
}

.incident-worker strong,
.incident-worker span {
  display: block;
}

.incident-worker strong {
  font-size: 13px;
}

.incident-worker span {
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
}

.incident-details {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.incident-details div {
  border-bottom: 1px solid var(--border);
  padding-bottom: 9px;
}

.incident-details span,
.incident-details strong {
  display: block;
}

.incident-details span {
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 3px;
}

.incident-details strong {
  font-size: 12px;
}

.incident-panel h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  margin: 0 0 10px;
}

.nearby-worker {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 9px 0;
}

.worker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.worker-dot.green {
  background: var(--green);
}

.nearby-worker strong,
.nearby-worker small {
  display: block;
}

.nearby-worker strong {
  font-size: 11px;
}

.nearby-worker small {
  color: var(--muted);
  font-size: 9px;
  margin-top: 2px;
}

.resolve-button {
  width: 100%;
  margin-top: 15px;
  background: var(--navy);
  color: white;
  border-radius: 8px;
  padding: 11px;
  font-size: 12px;
  font-weight: 700;
}

.secondary-button {
  background: #f3f6fa;
  color: #4b5870;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 11px;
  font-size: 10px;
  font-weight: 700;
}

.engineer-table {
  width: 100%;
}

.table-row {
  display: grid;
  grid-template-columns: 1.3fr .8fr 1.2fr .8fr .8fr;
  align-items: center;
  min-height: 47px;
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.table-row strong {
  font-size: 11px;
}

.table-head {
  min-height: 32px;
  border-top: 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.status-text {
  font-weight: 700;
}

.status-text.green { color: var(--green); }
.status-text.orange { color: var(--orange); }
.status-text.red { color: var(--red); }

@media (max-width: 1050px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .sidebar {
    display: none;
  }

  .main {
    margin-left: 0;
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    gap: 15px;
  }

  .system-status {
    display: none;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .table-row {
    grid-template-columns: 1.3fr .8fr 1fr;
  }

  .table-row span:nth-child(4),
  .table-row span:nth-child(5) {
    display: none;
  }
}

.incident-panel {
  transition: box-shadow .25s ease, border-color .25s ease, transform .25s ease;
}

.incident-panel.incident-focus {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(220,53,69,.12), 0 12px 28px rgba(17,30,65,.10);
  transform: translateY(-2px);
}

/* CareFall Worker live map */
.workforce-map {
  position: relative;
  width: 100%;
  height: 500px;
  min-height: 500px;
  overflow: hidden;
  border-radius: 12px;
  background: #eef2f7;
}

.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
}

.map-loading strong {
  color: var(--text);
}

/* CareFall Worker map status markers */
.worker-map-marker {
  width: 22px;
  height: 22px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(11, 23, 57, .35);
}

.worker-map-marker.safe {
  background: #16a36a;
}

.worker-map-marker.height {
  background: #f59e0b;
}

.worker-map-marker.incident {
  background: #dc3545;
}

.worker-map-marker.offline {
  background: #718096;
}

/* Active incident map marker */
.worker-map-marker.incident {
  position: relative;
  animation: incidentPulse 1.4s ease-out infinite;
}

@keyframes incidentPulse {
  0% {
    box-shadow:
      0 0 0 0 rgba(220, 53, 69, .65),
      0 2px 8px rgba(11, 23, 57, .35);
  }

  70% {
    box-shadow:
      0 0 0 14px rgba(220, 53, 69, 0),
      0 2px 8px rgba(11, 23, 57, .35);
  }

  100% {
    box-shadow:
      0 0 0 0 rgba(220, 53, 69, 0),
      0 2px 8px rgba(11, 23, 57, .35);
  }
}

@media (prefers-reduced-motion: reduce) {
  .worker-map-marker.incident {
    animation: none;
  }
}

/* Nearby engineer status colours */
.worker-dot.orange {
  background: var(--orange);
}

.worker-dot.red {
  background: var(--red);
}

/* Clickable nearby engineer rows */
.nearby-worker[data-nearby-worker-id] {
  cursor: pointer;
}

/* Operational Support map markers */
.worker-map-marker.support {
  background: #2563eb;
}

/* Operational Support colour in incident response lists */
.worker-dot.blue {
  background: #2563eb;
}
