:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafc;
  --text: #111522;
  --muted: #667085;
  --border: #e6e9f0;
  --danger: #f50f28;
  --danger-dark: #b80e22;
  --danger-soft: #ffedf0;
  --green: #18a94f;
  --green-soft: #e9f8ef;
  --violet: #5d38d4;
  --shadow: 0 18px 44px rgba(17, 21, 34, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(245, 15, 40, 0.08), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
}

.app-shell.auth-layout {
  grid-template-columns: minmax(320px, 430px);
  align-content: center;
  justify-content: center;
  padding: 28px;
}

.app-shell.auth-layout .sidebar {
  width: min(430px, calc(100vw - 28px));
}

.app-shell.auth-layout .brand {
  justify-content: center;
  min-height: 132px;
  text-align: left;
}

.app-shell.auth-layout .brand-mark {
  width: 78px;
  height: 78px;
  font-size: 1.55rem;
}

.app-shell.auth-layout .panel {
  padding: 22px;
}

.app-shell.auth-layout .panel-header {
  justify-content: center;
  text-align: center;
}

.sidebar,
.workspace {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand,
.panel,
.status-card,
.sos-card,
.map-card,
.alerts-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border-radius: 14px;
  background: var(--danger);
  color: white;
  font-size: 1.35rem;
  font-weight: 1000;
  letter-spacing: 0;
  box-shadow: 0 16px 28px rgba(245, 15, 40, 0.28);
  object-fit: cover;
}

.brand h1,
.topbar h2,
.panel-header h2,
.status-copy h3,
.map-card h2,
.alerts-panel h2 {
  margin: 0;
}

.brand h1 {
  font-size: 1.35rem;
  font-weight: 950;
}

.brand-sos {
  color: var(--danger);
}

.brand p,
.hint,
.status-copy p {
  margin: 5px 0 0;
  color: var(--muted);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h2 {
  font-size: 1.12rem;
  font-weight: 950;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 3px solid rgba(245, 15, 40, 0.13);
  border-color: var(--danger);
}

.field-with-icon {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
}

.field-with-icon span {
  text-align: center;
  color: var(--muted);
}

.field-with-icon input {
  border: 0;
}

.primary-button,
.ghost-button,
.inline-control button {
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 900;
}

.primary-button {
  border: 0;
  background: var(--danger);
  color: white;
  box-shadow: 0 12px 22px rgba(245, 15, 40, 0.23);
}

.primary-button:hover {
  background: var(--danger-dark);
}

.ghost-button {
  padding: 0 14px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
}

.inline-control button {
  border: 0;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 1.35rem;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
}

.topbar h2 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 1000;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
  gap: 18px;
}

.sos-card {
  display: grid;
  gap: 22px;
  padding: 18px;
}

.active-group-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
}

.active-group-pill span,
.status-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.active-group-pill strong,
.status-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
}

.avatar-stack {
  display: flex;
  min-width: 88px;
}

.avatar-stack span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: -8px;
  border: 2px solid white;
  border-radius: 50%;
  background: #2b6cb0;
  color: white;
  font-size: 0.75rem;
  font-weight: 950;
}

.avatar-stack span:nth-child(2) {
  background: #b45309;
}

.avatar-stack span:nth-child(3) {
  background: #047857;
}

.sos-button {
  position: relative;
  place-self: center;
  display: grid;
  place-items: center;
  align-content: center;
  width: min(310px, 72vw);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--danger) 0 34%, transparent 35%),
    radial-gradient(circle at center, rgba(245, 15, 40, 0.22) 0 48%, transparent 49%),
    radial-gradient(circle at center, rgba(245, 15, 40, 0.14) 0 62%, transparent 63%),
    radial-gradient(circle at center, rgba(245, 15, 40, 0.08) 0 75%, transparent 76%);
  color: white;
}

.sos-button::before {
  content: "";
  position: absolute;
  inset: 31%;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 18px 34px rgba(245, 15, 40, 0.42);
}

.sos-button span,
.sos-button small {
  position: relative;
  z-index: 1;
}

.sos-button span {
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  font-weight: 1000;
}

.sos-button small {
  width: 96px;
  margin-top: 6px;
  font-size: 0.76rem;
  font-weight: 850;
  line-height: 1.15;
}

.status-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-content: start;
  gap: 18px;
  padding: 22px;
}

.status-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 2rem;
  font-weight: 1000;
}

.status-copy h3 {
  font-size: 1.5rem;
  font-weight: 950;
}

.status-metrics {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.status-metrics div {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 410px);
  gap: 18px;
  min-height: 0;
  flex: 1;
}

.map-card,
.alerts-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 18px;
}

.map-region {
  position: relative;
  min-height: 440px;
  flex: 1;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #eef2f1;
}

.map-canvas {
  width: 100%;
  height: 100%;
  min-height: 440px;
}

.map-region .leaflet-container {
  width: 100%;
  height: 100%;
  min-height: 440px;
  background: #edf2f1;
  color: var(--text);
  font-family: inherit;
}

.map-region .leaflet-control-attribution {
  font-size: 0.66rem;
}

.aunor-map-pin {
  position: relative;
  width: 32px;
  height: 42px;
}

.aunor-map-pin::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 24px;
  height: 24px;
  border: 4px solid white;
  border-radius: 50% 50% 50% 0;
  background: var(--danger);
  box-shadow: 0 8px 20px rgba(17, 21, 34, 0.24);
  transform: rotate(-45deg);
}

.aunor-map-pin::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
}

.map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
  background:
    linear-gradient(rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.62)),
    repeating-linear-gradient(23deg, transparent, transparent 52px, rgba(17, 21, 34, 0.07) 54px),
    repeating-linear-gradient(111deg, transparent, transparent 60px, rgba(17, 21, 34, 0.07) 62px),
    #dce7e3;
}

.list {
  display: grid;
  gap: 10px;
  overflow: auto;
}

.list-item {
  width: 100%;
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  text-align: left;
}

.list-item.active {
  border-color: rgba(245, 15, 40, 0.42);
  background: var(--danger-soft);
}

.item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 950;
}

.item-title span:last-child {
  color: var(--muted);
  font-size: 0.86rem;
}

.group-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.group-row .avatar-stack {
  min-width: 72px;
}

.item-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.item-actions button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  font-weight: 850;
}

.item-actions button[data-action="cancel"] {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: white;
  box-shadow: var(--shadow);
  font-weight: 850;
}

.hidden {
  display: none !important;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.auth-layout {
    grid-template-columns: minmax(320px, 430px);
  }

  .sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    align-items: start;
  }

  .auth-layout .sidebar {
    display: flex;
  }

  .brand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 14px;
  }

  .sidebar,
  .hero-grid,
  .content-grid,
  .status-metrics {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .map-region,
  .map-canvas,
  .map-region .leaflet-container {
    min-height: 360px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
    gap: 12px;
  }

  .brand,
  .panel,
  .status-card,
  .sos-card,
  .map-card,
  .alerts-panel {
    box-shadow: none;
  }

  .status-card {
    grid-template-columns: 1fr;
  }
}
