* { box-sizing: border-box; }

:root {
  --bg: #020617;
  --panel: rgba(15, 23, 42, 0.94);
  --panel-border: #172554;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --shadow: 0 18px 45px rgba(2, 6, 23, 0.45);
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.14), transparent 30%),
    linear-gradient(180deg, #020617, #0f172a 45%, #020617);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(rgba(2, 6, 23, 0.62), rgba(15, 23, 42, 0.72)),
    url("/background.png") center/cover no-repeat;
  z-index: 10;
}

.login-card,
.card {
  background: var(--panel);
  border: 1px solid rgba(56, 189, 248, 0.14);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 32px;
  border-radius: 20px;
}

.login-submit {
  margin-top: 18px;
}

.login-logo {
  width: 96px;
  height: 96px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  overflow: hidden;
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-notice {
  margin: 18px 0 0;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.5;
}

.login-card h1,
.card h3,
.section h2 {
  margin: 0 0 10px;
}

.login-sub,
.muted {
  color: var(--muted);
}

.login-card label,
.card label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(2, 6, 23, 0.78);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

textarea {
  min-height: 112px;
  resize: vertical;
}

.login-error,
.note {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
}

.login-error {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

.note {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.12);
  color: #bae6fd;
  margin-bottom: 14px;
}

.login-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 12px;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 270px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.98), rgba(15, 23, 42, 0.96));
  border-right: 1px solid rgba(56, 189, 248, 0.12);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-title div {
  font-weight: 700;
}

.sidebar-title small,
.sidebar-user {
  color: var(--muted);
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(56, 189, 248, 0.12);
  color: var(--text);
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.5);
  flex: 0 0 auto;
}

.status-dot.warning {
  background: var(--warning);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-item {
  border: none;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(56, 189, 248, 0.14);
  color: white;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
}

.btn.secondary {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--text);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

.btn.full {
  width: 100%;
}

.main {
  flex: 1;
  padding: 24px;
}

.section {
  display: block;
}

.section > * + * {
  margin-top: 16px;
}

.grid {
  display: grid;
  gap: 16px;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.card {
  border-radius: 20px;
  padding: 18px;
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.card-header.compact {
  margin-bottom: 8px;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  color: #7dd3fc;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--muted);
}

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

.group-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-items,
.list,
#pastAlertsList,
#userDirectoryList,
#adminGroupList,
#memberRequestsList,
#nws-alert-feed,
.alerts-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#groupMeMembersList {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

#nws-alert-feed,
#county-alerts-feed {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.group-items {
  max-height: 420px;
  overflow: auto;
  margin-top: 12px;
}

.selection-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.alert-compose {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.alert-meta-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.alert-compose-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.alert-compose-actions .btn {
  flex: 1 1 220px;
}

.state-group {
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 16px;
  padding: 10px;
  background: rgba(2, 6, 23, 0.42);
}

.state-group-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.county-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 6px;
}

.county-item {
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.7);
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.2;
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-direction: column;
}

.county-item input {
  margin: 0;
}

.group-item,
.member-card,
.request-card,
.alert-card,
.admin-row {
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 16px;
  padding: 12px;
  background: rgba(2, 6, 23, 0.5);
}

.member-card,
.request-card,
.alert-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.row-actions,
.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}

.check-row input {
  width: auto;
}

.admin-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-card {
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 16px;
  padding: 14px;
  background: rgba(2, 6, 23, 0.5);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.tag,
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.tag {
  background: rgba(56, 189, 248, 0.12);
  color: #bae6fd;
}

.source-chip.manual {
  background: rgba(34, 197, 94, 0.14);
  color: #bbf7d0;
}

.source-chip.automatic {
  background: rgba(245, 158, 11, 0.14);
  color: #fde68a;
}

.severity-moderate { border-left: 4px solid var(--warning); }
.severity-severe { border-left: 4px solid var(--danger); }
.severity-extreme { border-left: 4px solid #f97316; }
.severity-minor { border-left: 4px solid var(--accent); }

.radar-frame,
.map-frame {
  width: 100%;
  min-height: 520px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.14);
  background: rgba(2, 6, 23, 0.78);
}

.radar-frame.large {
  min-height: 700px;
}

.radar-frame iframe,
.map-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

#routingMap {
  min-height: 640px;
}

#userDirectoryList,
#adminGroupList {
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.forecast-canvas {
  width: 100%;
  min-height: 320px;
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.78);
  border: 1px solid rgba(56, 189, 248, 0.14);
  margin-top: 10px;
}

#severeAlertCanvas,
.forecast-product-frame {
  min-height: 420px;
}

.file-input-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 190px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.file-input-control {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: 20px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid rgba(56, 189, 248, 0.14);
  box-shadow: var(--shadow);
}

.alert-placeholder {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.small {
  font-size: 12px;
  color: var(--muted);
}

.forecast-product-frame {
  width: 100%;
  border: 1px solid rgba(56, 189, 248, 0.14);
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.78);
}

@media (max-width: 980px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .sidebar-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

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