:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1f2421;
  --muted: #66706a;
  --line: #dfe4dd;
  --water: #1976a2;
  --heat: #bd4b31;
  --electricity: #9a6b00;
  --gas: #4f6bb3;
  --elevator: #6d5a8d;
  --unknown: #617065;
  --shadow: 0 12px 30px rgba(35, 42, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

.shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.toolbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 260px;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #ffffff 0 20%, transparent 21%),
    conic-gradient(from 20deg, var(--water), var(--heat), var(--electricity), var(--elevator), var(--water));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
  font-weight: 750;
}

.brand p,
.feed-head p,
.event-text,
.source,
.filters span {
  color: var(--muted);
}

.brand p {
  margin-top: 3px;
  font-size: 13px;
}

.filters {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.filters label {
  display: grid;
  gap: 4px;
}

.filters span {
  font-size: 12px;
}

select,
button {
  height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
}

select {
  min-width: 128px;
  padding: 0 34px 0 10px;
}

button {
  width: 42px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.toggle {
  height: 38px;
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
}

.toggle input {
  width: 16px;
  height: 16px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
}

.map {
  min-height: calc(100vh - 77px);
  background: #e9eee7;
}

.feed {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.feed-head h2 {
  font-size: 18px;
}

.feed-head p {
  margin-top: 4px;
  font-size: 13px;
}

.counter {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: #eef2ed;
  color: var(--muted);
  font-size: 12px;
}

.events {
  overflow: auto;
  padding: 10px;
}

.event {
  padding: 13px;
  border-bottom: 1px solid var(--line);
}

.event:last-child {
  border-bottom: 0;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 190px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge.water { background: var(--water); }
.badge.heat { background: var(--heat); }
.badge.electricity { background: var(--electricity); }
.badge.gas { background: var(--gas); }
.badge.elevator { background: var(--elevator); }
.badge.unknown { background: var(--unknown); }

time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.event h3 {
  font-size: 15px;
  line-height: 1.25;
  margin-bottom: 7px;
}

.event-text {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
}

.source {
  display: inline-block;
  margin-top: 9px;
  font-size: 13px;
}

.leaflet-popup-content {
  min-width: 220px;
  max-width: 300px;
}

.popup-title {
  margin: 0 0 6px;
  font-weight: 750;
}

.popup-text {
  margin: 0;
  color: #4d5650;
  line-height: 1.35;
}

@media (max-width: 900px) {
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    min-width: 0;
  }

  .filters {
    justify-content: stretch;
  }

  .filters label,
  .toggle {
    flex: 1 1 150px;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 52vh 48vh;
  }

  .map {
    min-height: 52vh;
  }

  .feed {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
