:root {
  --bg: #eef1f4;
  --bg-glow: #d9e2ec;
  --surface: #ffffff;
  --ink: #15202b;
  --muted: #5c6b7a;
  --line: #d5dde5;
  --accent: #0d6e6e;
  --accent-soft: #e4f2f2;
  --ok: #1a7f4b;
  --ok-soft: #e6f6ed;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --shadow: 0 12px 40px rgba(21, 32, 43, 0.08);
  --radius: 16px;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--bg-glow), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, #cfe8e6, transparent 55%),
    var(--bg);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.hero {
  margin-bottom: 28px;
  animation: rise 0.45s ease-out both;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.lede {
  margin: 0;
  max-width: 36rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
}

.error-banner {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.95rem;
  animation: rise 0.3s ease-out both;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.filter-field select,
.filter-field input {
  appearance: none;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

.filter-field select:focus,
.filter-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-grow { grid-column: span 1; }
.filter-actions { display: flex; align-items: end; }

.type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip span {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.chip.is-active {
  background: var(--accent-soft);
  border-color: #7eb5b5;
  color: var(--accent);
}

.chip.is-active span { color: var(--accent); }

.count-label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.btn-ghost {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.btn-ghost:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.unit-card {
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  animation: rise 0.4s ease-out both;
}

.unit-card:nth-child(2) { animation-delay: 0.05s; }
.unit-card:nth-child(3) { animation-delay: 0.1s; }

.unit-card:hover {
  transform: translateY(-2px);
  border-color: #9fc4c4;
  box-shadow: 0 16px 44px rgba(13, 110, 110, 0.12);
}

.unit-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.unit-status {
  justify-self: start;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef1f4;
  color: var(--muted);
}

.unit-status.is-active {
  background: var(--ok-soft);
  color: var(--ok);
}

.unit-name {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.unit-id {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.unit-cta {
  margin-top: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

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

.event-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  animation: rise 0.35s ease-out both;
}

.event-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.event-head h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.event-head time {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
}

.media-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.media-card {
  margin: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #0f171c;
  border: 1px solid #243039;
}

.media-label {
  padding: 8px 12px 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9db0bd;
}

.media-shell {
  position: relative;
  margin-top: 8px;
  background: #000;
  min-height: 180px;
}

.media-shell .poster {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 260px;
  object-fit: cover;
}

.poster-fallback {
  aspect-ratio: 16 / 9;
  max-height: 260px;
  background: linear-gradient(145deg, #1a242c, #0b1014);
}

.play-btn {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: rgba(13, 110, 110, 0.92);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, background 0.15s ease;
  z-index: 2;
}

.play-btn:hover { transform: scale(1.06); background: #0f8585; }

.media-shell video {
  display: none;
  width: 100%;
  max-height: 260px;
  background: #000;
}

.media-shell.is-playing .poster,
.media-shell.is-playing .play-btn {
  display: none;
}

.media-shell.is-playing video {
  display: block;
}

.no-media {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.hidden { display: none !important; }

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 900px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .filter-grow { grid-column: span 2; }
  .filter-actions { grid-column: span 2; }
}

@media (max-width: 560px) {
  .app { padding: 28px 16px 48px; }
  .event-head { flex-direction: column; align-items: flex-start; }
  .filters { grid-template-columns: 1fr; }
  .filter-grow,
  .filter-actions { grid-column: span 1; }
}
