
:root {
  --color-page: #1f2937;
  --color-surface: hsl(219, 30%, 21%);
  --color-surface-2: #172235;
  --color-header: #003b73;
  --color-footer: #111827;
  --color-text: #f9fafb;
  --color-muted: #a0aec0;
  --color-accent: #4fc3f7;
  --color-accent-2: #0288d1;
  --color-line: rgba(160,174,192,0.22);
  --color-input: rgba(17, 24, 39, 0.74);
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.15);
  --shadow-lift: 0 16px 48px rgba(0,0,0,.28);
  --radius-card: 16px;
  --content-width: 960px;

  /* Legacy variable names used throughout the existing app. */
  --bg: var(--color-page);
  --panel: var(--color-surface);
  --line: var(--color-line);
  --text: var(--color-text);
  --muted: var(--color-muted);
  --accent: var(--color-accent);
}

* { box-sizing: border-box; }
html, body { height: 100%; width: 100%; margin: 0; padding: 0; overflow-x: hidden; }
body {
  min-height: 100vh;
  font-family: Roboto, Arial, Helvetica, sans-serif;
  background: var(--color-page);
  color: var(--color-text);
}
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

button, input, select, textarea {
  border-radius: 10px;
  border: 1px solid var(--color-line);
  padding: 10px 12px;
  background: var(--color-input);
  color: var(--color-text);
  font: inherit;
  outline: none;
}
input::placeholder, textarea::placeholder { color: rgba(160,174,192,.76); }
button {
  background: var(--color-accent);
  border: 0;
  color: #003b73;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: .01em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: background .2s ease, color .2s ease, transform .15s ease, box-shadow .2s ease;
}
button:hover, button:focus-visible {
  background: var(--color-accent-2);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
button:active { transform: translateY(1px); }
button.secondary { background: rgba(255,255,255,.10); color: var(--color-text); border: 1px solid rgba(255,255,255,.10); box-shadow: none; }
button.secondary:hover, button.secondary:focus-visible { background: rgba(255,255,255,.16); color: var(--color-accent); }
button.danger { background: var(--danger); color: white; }
button.small { padding: 6px 9px; font-size: 12px; border-radius: 999px; }
button .mdi { font-size: 1.05em; vertical-align: -0.12em; }
input:focus, select:focus, textarea:focus { border-color: rgba(79,195,247,.75); box-shadow: 0 0 0 3px rgba(79,195,247,.12); }

.landing {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 20%, rgba(79,195,247,.18), transparent 26%),
    radial-gradient(circle at 78% 18%, rgba(0,59,115,.42), transparent 28%),
    linear-gradient(135deg, #1f2937 0%, #172235 48%, #111827 100%);
}
.landing::before {
  content: "";
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background:
    repeating-linear-gradient(115deg, transparent 0 34px, rgba(79,195,247,.13) 35px 37px, transparent 38px 74px),
    radial-gradient(ellipse at 25% 30%, rgba(255,255,255,.10), transparent 34%);
  animation: weatherDrift 22s linear infinite;
}
@keyframes weatherDrift { from { transform: translate3d(-3%,-2%,0) rotate(0deg); } to { transform: translate3d(3%,2%,0) rotate(1deg); } }
.card, .panel, .modal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.card { padding: 28px; max-width: 900px; width: 100%; }
.landing .card {
  position: relative;
  z-index: 1;
  background: rgba(34,48,72,.82);
  border: 1px solid rgba(148,163,184,.32);
  box-shadow: 0 24px 80px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(12px);
}
.hero-brand { display: flex; align-items: center; justify-content: center; gap: 18px; text-align: left; margin-bottom: 10px; }
.hero-brand img { width: 92px; height: 92px; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(0,0,0,.35)); }
.hero-brand-wide { flex-direction: column; text-align: center; gap: 12px; }
.hero-brand-wide img { width: min(620px, 96%); height: auto; max-height: 190px; object-fit: contain; }
.hero h1 { font-size: clamp(2.3rem, 7vw, 3.35rem); margin: 0 0 8px; letter-spacing: .04em; line-height: 1; }
.hero p { margin: 0; color: var(--color-muted); line-height: 1.55; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 22px 0; }
form { display: grid; gap: 10px; }
form h2 { margin: 0 0 6px; text-align: center; font-size: 1.35rem; }
#guestBtn { width: 100%; margin-top: 2px; }
.message { background: rgba(239, 68, 68, 0.16); border: 1px solid var(--danger); border-radius: 10px; color: #fecaca; padding: 10px; }
input.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.35); }
.password-help { color: var(--color-muted); font-size: 12px; line-height: 1.35; }
.password-help.invalid { color: #fecaca; }

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 390px;
  grid-template-rows: 74px 1fr;
  gap: 12px;
  padding: 12px;
  background:
    radial-gradient(circle at top left, rgba(79,195,247,.10), transparent 32%),
    linear-gradient(180deg, var(--color-page), #141c2a 74%, #111827);
}
header {
  grid-column: 1 / 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--color-header);
  border: 0;
  border-radius: var(--radius-card);
  padding: 0 16px;
  box-shadow: var(--shadow-card);
  position: relative;
}
.header-left, .header-right { display: flex; align-items: center; gap: 10px; }
.header-right { justify-content: flex-end; }
.app-brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.app-brand img { width: 48px; height: 48px; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0,0,0,.28)); }
.app-brand strong { display: block; font-size: 1.35rem; letter-spacing: .035em; line-height: 1; white-space: nowrap; }
.app-brand small { display: none; }
.clockbar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(249,250,251,.80);
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 999px;
  padding: 8px 13px;
}
.clockgap { display: inline-block; width: 24px; }
#userBadge { color: rgba(249,250,251,.86); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
header.warning-active { background: linear-gradient(90deg, #003b73, #7f1d1d); box-shadow: 0 0 28px rgba(239,68,68,.26), var(--shadow-card); }

.panel { overflow: hidden; }
.alerts, .right { padding: 14px; overflow: auto; }
.alerts h2, .collapsible h2 { margin: 0 0 12px; font-size: 1.2rem; letter-spacing: .02em; }
.collapsible h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.collapsible h2 > span, .alerts h2 > span { display: inline-flex; align-items: center; gap: 8px; }
h2 .mdi { color: var(--color-accent); font-size: 1.35em; }
.collapseBtn { width: 28px; height: 28px; padding: 0; line-height: 1; font-size: 18px; }
.collapsible.collapsed > *:not(h2) { display: none !important; }

.map-wrap { position: relative; background: #0c1625; }
#map { height: 100%; width: 100%; min-height: 400px; filter: saturate(.95) contrast(.98); }
.map-tools {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  display: flex; gap: 8px; z-index: 500;
  background: rgba(0,59,115,.92);
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: var(--shadow-card);
}
.map-tools input { flex: 1; }
.map-minimize-btn { position: absolute; top: 12px; left: 12px; z-index: 710; }
.map-settings-btn { position: absolute; top: 12px; right: 12px; z-index: 700; width: 42px; height: 42px; border-radius: 999px; background: rgba(0,59,115,.92); color: #fff; border: 1px solid rgba(255,255,255,.14); }
.map-settings-panel {
  position: absolute; top: 62px; right: 12px; z-index: 701; width: 285px;
  display: grid; gap: 10px;
  background: rgba(34,48,72,.96);
  border: 1px solid var(--color-line);
  border-radius: 14px; padding: 12px;
  box-shadow: var(--shadow-lift);
}
.map-settings-panel h3 { margin: 0; }
.map-settings-panel label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--color-muted); }
.map-settings-panel select { width: 100%; }
.map-tools.hidden-tools { display: none; }
.app.map-minimized { grid-template-columns: 320px 80px minmax(520px,1fr); }
.app.map-minimized #map { opacity: .35; }
.app.map-minimized .map-tools, .app.map-minimized .map-settings-btn { display: none; }

.pill {
  display: inline-block;
  margin-left: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.12);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.pill.active { background: rgba(34,197,94,.18); border-color: rgba(34,197,94,.42); color: #bbf7d0; }
.alert {
  border: 1px solid var(--color-line);
  border-radius: 14px;
  padding: 10px;
  margin: 10px 0;
  background: rgba(17,24,39,.62);
  cursor: pointer;
  box-shadow: inset 4px 0 0 var(--color-accent);
}
.alert strong { color: #fff; }
.alert small { color: var(--color-muted); line-height: 1.45; }
.alert.new { animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: inset 4px 0 0 var(--danger), 0 0 20px var(--color-accent); } }

.right { display: flex; flex-direction: column; gap: 12px; }
.right section { border-bottom: 1px solid var(--color-line); padding-bottom: 12px; margin-bottom: 0; }
.right section:last-child { border-bottom: 0; padding-bottom: 0; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.stack { display: grid; gap: 8px; }
.summary { color: var(--color-muted); line-height: 1.5; font-size: 14px; margin: 10px 0; }
#chatMessages {
  height: 230px;
  overflow: auto;
  background: rgba(17,24,39,.62);
  border: 1px solid var(--color-line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}
.chatline { margin-bottom: 8px; font-size: 14px; line-height: 1.35; }
.chatline time { color: var(--color-muted); font-size: 12px; }
.chatline.dim { opacity: .38; transition: opacity .4s ease; }
.chatline.gone { display: none; }

.participant-list { display: grid; gap: 8px; }
.station-card {
  position: relative;
  border: 1px solid var(--color-line);
  background: rgba(17,24,39,.62);
  border-radius: 12px;
  padding: 10px;
  padding-right: 76px;
}
.station-card .call { font-weight: 900; font-size: 16px; letter-spacing: .04em; }
.station-card .meta { color: var(--color-muted); font-size: 13px; margin-top: 3px; }
.station-card .time { color: var(--color-muted); font-size: 12px; margin-top: 4px; }
.station-card.rf { border-color: rgba(245,158,11,.62); box-shadow: inset 4px 0 0 var(--warning); }
.station-card.live { border-color: rgba(79,195,247,.42); box-shadow: inset 4px 0 0 var(--color-accent); }
.station-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.station-actions button { width: 28px; height: 28px; padding: 0; border-radius: 8px; font-size: 14px; }
.edit-station { background: var(--color-accent); }
.remove-station { background: var(--danger); color: white; }
.map-pin { width: 18px; height: 18px; border-radius: 999px; border: 3px solid #e5e7eb; box-shadow: 0 0 0 2px rgba(15,23,42,.95), 0 0 16px rgba(79,195,247,.65); }
.map-pin.live { background: var(--color-accent-2); }
.map-pin.rf { background: var(--warning); }
.map-pin.ncs { background: #facc15; }

.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.65); display: grid; place-items: center; padding: 20px; }
.modal-card { width: min(950px, 96vw); max-height: 88vh; overflow: auto; padding: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.alert-full-text { white-space: pre-wrap; line-height: 1.45; }
.user-role-list { display: grid; gap: 8px; margin-top: 12px; }
.user-role-row { display: grid; grid-template-columns: 1fr 140px 100px 80px 120px; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--color-line); border-radius: 12px; background: rgba(17,24,39,.62); }
.admin-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-tabs button.active { background: var(--color-accent); color: #003b73; }
.settings-note { color: var(--color-muted); margin: 0 0 12px; line-height: 1.45; }
.county-actions { margin-bottom: 12px; }
.county-check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; max-height: 48vh; overflow: auto; padding-right: 4px; }
.county-check-grid label { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(17,24,39,.52); border: 1px solid var(--color-line); border-radius: 10px; }
.county-check-grid input { width: auto; }
#alertCountyStatus { margin-bottom: 10px; }
.user-role-row .who strong { display: block; }
.user-role-row .who small { color: var(--color-muted); }

/* Leaflet controls styled to better fit the SKYWARN shell. */
.leaflet-bar a, .leaflet-bar a:hover { background: rgba(0,59,115,.94); color: #fff; border-bottom-color: rgba(255,255,255,.18); }
.leaflet-control-attribution { background: rgba(17,24,39,.72) !important; color: rgba(249,250,251,.72) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--color-surface); color: var(--color-text); }

@media (max-width: 1180px) {
  .app { grid-template-columns: 300px minmax(360px, 1fr) 360px; }
  .clockbar { font-size: 12px; }
}
@media (max-width: 1050px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 300px 420px auto; height: auto; min-height: 100vh; }
  header { grid-column: 1; flex-wrap: wrap; height: auto; min-height: 74px; padding: 10px 16px; }
  .clockbar { position: static; transform: none; order: 3; width: 100%; text-align: center; }
  .auth-grid { grid-template-columns: 1fr; }
  .hero-brand { flex-direction: column; text-align: center; }
  .user-role-row { grid-template-columns: 1fr; }
  .app.map-minimized { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .landing { padding: 14px; }
  .card { padding: 18px; }
  .hero-brand img { width: 76px; height: 76px; }
  .hero-brand-wide img { width: 96%; max-height: 130px; }
  .header-left, .header-right, .row, .map-tools { flex-wrap: wrap; }
  .app-brand strong { font-size: 1.1rem; }
  .pill { margin-left: 0; }
}

.pill.standby { background: rgba(250,204,21,.16); border-color: rgba(250,204,21,.48); color: #fde68a; }
.alert { position: relative; }
.alert .alert-dot { display: inline-block; width: 10px; height: 10px; border-radius: 999px; margin-right: 7px; background: var(--color-accent); box-shadow: 0 0 10px currentColor; }
.alert.warning { box-shadow: inset 4px 0 0 #ef4444; }
.alert.warning .alert-dot { background: #ef4444; color: #ef4444; }
.alert.watch { box-shadow: inset 4px 0 0 #facc15; }
.alert.watch .alert-dot { background: #facc15; color: #facc15; }
.alert.tornado { box-shadow: inset 4px 0 0 #a855f7, 0 0 18px rgba(168,85,247,.16); border-color: rgba(168,85,247,.46); }
.alert.tornado .alert-dot { background: #a855f7; color: #a855f7; }

.skydash-object-marker span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid #e5e7eb;
  color: #fff;
  font-weight: 900;
  font-size: 13px;
  box-shadow: 0 0 0 2px rgba(15,23,42,.95), 0 0 16px rgba(79,195,247,.55);
}
.skydash-object-marker span { background: #4fc3f7; color: #003b73; }
.settings-card {
  border: 1px solid var(--color-line);
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0;
  background: rgba(17,24,39,.52);
}
.settings-card h3 { margin: 0 0 8px; }
.settings-card label { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.settings-card input[type="checkbox"] { width: auto; }
.object-form-grid { display: grid; grid-template-columns: repeat(2, minmax(160px, 1fr)); gap: 8px; margin: 10px 0; }
.object-form-grid input:nth-child(5) { grid-column: 1 / -1; }
.object-admin-list { display: grid; gap: 8px; }
.object-admin-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px; border: 1px solid var(--color-line); border-radius: 10px; background: rgba(17,24,39,.55); }
.object-admin-row strong { display: block; }
.object-admin-row small { display: block; color: var(--color-muted); margin-top: 3px; }
@media (max-width: 620px) { .object-form-grid { grid-template-columns: 1fr; } .object-form-grid input:nth-child(5) { grid-column: auto; } }


/* UI refinements */
.leaflet-control-zoom { display: none !important; }
.map-minimize-btn {
  border: 1px solid rgba(2, 12, 27, .95) !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,.20), 0 8px 18px rgba(0,0,0,.35);
}
#userBadge .icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#userBadge .icon-only .mdi { font-size: 18px; }
.user-callsign { white-space: nowrap; }
.user-settings-modal-card { width: min(560px, 96vw); }
.muted-placeholder { opacity: .82; }

/* Object layer refinements */
.map-minimize-btn {
  color: #020617 !important;
  text-shadow: none !important;
}
.skydash-object-marker span {
  width: 32px;
  height: 32px;
  font-size: 17px;
}
.skydash-object-marker i { line-height: 1; }
.choice-heading { margin: 12px 0 6px; font-size: 14px; color: var(--color-muted); }
.object-choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 8px; margin-bottom: 8px; }
.object-choice {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--color-line);
  background: rgba(15,23,42,.58);
  color: var(--color-text);
  border-radius: 10px;
  font-size: 13px;
}
.object-choice.selected {
  border-color: rgba(79,195,247,.85);
  box-shadow: 0 0 0 2px rgba(79,195,247,.16);
}
.color-dot { width: 16px; height: 16px; border-radius: 999px; display: inline-block; border: 1px solid rgba(255,255,255,.55); }
.color-dot.blue { background: #4fc3f7; }
.color-dot.red { background: #ef4444; }
.color-dot.yellow { background: #facc15; }
.color-dot.green { background: #22c55e; }
.color-dot.purple { background: #a855f7; }
.color-dot.white { background: #f8fafc; }
.object-actions { margin-top: 12px; }
.email-pref-list {
  display: grid;
  gap: 6px;
}
.email-pref-list .setting-check {
  justify-content: flex-start;
}

#userSettingsStatus {
  margin-top: 12px;
}
