:root {
  --bg: #061129;
  --panel: rgba(8, 21, 48, 0.84);
  --panel-border: rgba(150, 186, 255, 0.18);
  --text: #f4f8ff;
  --muted: #9ab1da;
  --chip: rgba(107, 182, 255, 0.12);
  --card: rgba(12, 28, 61, 0.9);
  --card-border: rgba(167, 198, 255, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(58, 114, 228, 0.42), transparent 30%),
    radial-gradient(circle at bottom left, rgba(90, 130, 255, 0.2), transparent 28%),
    linear-gradient(180deg, #091735 0%, #050d1f 100%);
  color: var(--text);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 20px auto 28px;
}

.toolbar-card,
.feed-card {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  padding: 16px 18px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.section-label,
.stat-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--muted);
}

.compact-header h1,
.feed-header h2 {
  margin: 6px 0 0;
  font-size: clamp(1.4rem, 2.3vw, 2rem);
  line-height: 1;
}

.compact-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
}

.layout {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.compact-header,
.feed-header,
.event-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.search-field {
  display: grid;
  gap: 6px;
  flex: 1;
  max-width: 540px;
}

.search-field span {
  color: #f3f8ff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.search-field input {
  width: 100%;
  border: 1px solid rgba(177, 212, 255, 0.52);
  background: rgba(232, 242, 255, 0.96);
  color: #08152d;
  border-radius: 14px;
  min-height: 62px;
  padding: 16px 18px;
  font: inherit;
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 8px 20px rgba(0, 0, 0, 0.18);
}

.search-field .search-input-strong {
  border: 2px solid #cfe1ff;
  background: #f7fbff;
  color: #08152d;
  min-height: 68px;
  padding: 18px 20px;
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.2;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

.search-field input::placeholder {
  color: #425776;
  opacity: 1;
}

.search-field input:focus {
  border-color: rgba(107, 182, 255, 0.95);
  box-shadow: 0 0 0 4px rgba(90, 154, 255, 0.28), 0 10px 24px rgba(0, 0, 0, 0.22);
}

.search-field .search-input-strong:focus {
  border-color: #5f9cff;
  box-shadow: 0 0 0 4px rgba(95, 156, 255, 0.28), 0 12px 30px rgba(0, 0, 0, 0.26);
}

.timestamp-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid rgba(159, 194, 255, 0.16);
  color: #dceaff;
  white-space: nowrap;
  font-size: 0.9rem;
}

.event-time-stack {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.event-age {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1;
  white-space: nowrap;
}

.event-age-stale {
  color: #ffd166;
  font-weight: 700;
  animation: stale-blink 1.2s ease-in-out infinite;
}

@keyframes stale-blink {
  0%, 100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

.feed-header {
  margin-bottom: 12px;
}

.feed-summary {
  margin: 0;
  color: var(--muted);
  max-width: 34ch;
  text-align: right;
  font-size: 0.88rem;
}

.events-list {
  display: grid;
  gap: 8px;
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 6px;
}

.log-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.terminal-tabs {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.terminal-tab {
  border: 1px solid rgba(141, 255, 181, 0.2);
  background: rgba(9, 21, 18, 0.9);
  color: #5f856d;
  border-radius: 999px;
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
}

.terminal-tab.active {
  color: #8dffb5;
  border-color: rgba(141, 255, 181, 0.4);
  box-shadow: inset 0 0 0 1px rgba(141, 255, 181, 0.1);
}

.terminal-shell {
  min-height: 320px;
  max-height: 420px;
  overflow: auto;
  border-radius: 22px;
  border: 1px solid rgba(106, 255, 181, 0.2);
  background:
    linear-gradient(180deg, rgba(8, 16, 13, 0.96), rgba(5, 9, 8, 0.98)),
    repeating-linear-gradient(
      180deg,
      rgba(141, 255, 181, 0.02) 0,
      rgba(141, 255, 181, 0.02) 24px,
      rgba(0, 0, 0, 0.03) 24px,
      rgba(0, 0, 0, 0.03) 48px
    );
  box-shadow: inset 0 0 0 1px rgba(141, 255, 181, 0.04);
  padding: 18px 18px 22px;
  font-family: "Liberation Mono", "DejaVu Sans Mono", monospace;
  color: #8dffb5;
  white-space: pre-wrap;
  line-height: 1.6;
}

.terminal-shell::before {
  content: "mikko@trailer-live:~$ tail -f";
  display: block;
  margin-bottom: 14px;
  color: #5f856d;
}

.terminal-line {
  display: block;
  word-break: break-word;
}

.terminal-line.error-line {
  color: #ff9f8f;
}

.terminal-line.warn-line {
  color: #ffe493;
}


.events-list::-webkit-scrollbar {
  width: 10px;
}

.events-list::-webkit-scrollbar-track {
  background: rgba(115, 170, 255, 0.08);
  border-radius: 999px;
}

.events-list::-webkit-scrollbar-thumb {
  background: rgba(155, 188, 255, 0.34);
  border-radius: 999px;
}

.event-card {
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.event-card:hover,
.event-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(155, 188, 255, 0.28);
  background: rgba(13, 31, 66, 0.96);
  outline: none;
}

.event-title {
  font-size: clamp(1rem, 1.45vw, 1.2rem);
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.event-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-shell.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 9, 22, 0.72);
  backdrop-filter: blur(10px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  padding: 24px;
  border-radius: 28px;
  border: 1px solid rgba(150, 186, 255, 0.2);
  background: rgba(8, 21, 48, 0.95);
  box-shadow: var(--shadow);
}

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

.ghost-button {
  border: 1px solid rgba(163, 195, 255, 0.22);
  background: rgba(115, 170, 255, 0.08);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 14px;
  font: inherit;
  cursor: pointer;
}

.map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(240px, 0.7fr);
  gap: 18px;
  margin-top: 20px;
}

.osm-map {
  min-height: 420px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(167, 198, 255, 0.14);
}

.offline-map-panel {
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(31, 75, 150, 0.28), rgba(10, 22, 48, 0.9)),
    radial-gradient(circle at top left, rgba(255, 209, 102, 0.18), transparent 26%);
}

.offline-map-copy {
  width: min(100%, 460px);
  display: grid;
  gap: 14px;
}

.offline-map-copy strong {
  font-size: 1.3rem;
}

.map-caption {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.zone-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.zone-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(167, 198, 255, 0.18);
  background: rgba(12, 28, 61, 0.82);
  color: var(--text);
  font-size: 0.88rem;
}

.zone-chip-active {
  border-color: rgba(255, 209, 102, 0.48);
  background: rgba(255, 209, 102, 0.18);
  color: #ffe7a6;
}

.map-sidebar {
  display: grid;
  gap: 12px;
}

.map-data {
  padding: 16px;
  border-radius: 18px;
  background: rgba(10, 22, 48, 0.76);
  border: 1px solid rgba(169, 198, 255, 0.12);
}

.map-data strong {
  display: block;
  margin-top: 8px;
  font-size: 1.08rem;
  line-height: 1.4;
}

@media (max-width: 860px) {
  .compact-header,
  .feed-header,
  .event-title-row,
  .modal-header,
  .map-grid {
    flex-direction: column;
    align-items: stretch;
  }

  .map-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .timestamp-pill {
    width: fit-content;
  }

  .event-time-stack {
    justify-items: start;
  }

  .app-shell {
    width: min(100% - 20px, 1180px);
    margin-top: 10px;
  }

  .events-list {
    max-height: none;
  }
}
