@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700&display=swap");

:root {
  --canvas: #f3f1ec;
  --surface: #faf9f6;
  --surface-raised: #ffffff;
  --sidebar: #171c1b;
  --sidebar-soft: #222826;
  --ink: #1b201f;
  --muted: #727976;
  --faint: #a5aaa7;
  --line: #e2dfd8;
  --line-strong: #d4d0c7;
  --accent: #d95d39;
  --accent-deep: #a93f24;
  --accent-soft: #f8e7e1;
  --rescue: #b74a31;
  --police: #3e6680;
  --police-soft: #e6eef2;
  --green: #557463;
  --green-soft: #e8efea;
  --shadow: 0 16px 44px rgba(31, 35, 33, 0.07);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 0%, rgba(255,255,255,.8), transparent 32rem),
    var(--canvas);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
  padding: 30px 18px 20px;
  color: #f5f5f1; background: var(--sidebar);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  color: #fff; background: var(--accent); border-radius: 10px;
  box-shadow: 0 7px 18px rgba(217,93,57,.25);
}
.brand-mark svg { width: 23px; stroke: none; fill: currentColor; }
.brand-name { font-family: "Manrope", sans-serif; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.brand-kicker { margin-top: 1px; color: #89918e; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }

.primary-nav { display: grid; gap: 5px; padding-bottom: 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.nav-item, .feed-item {
  width: 100%; border: 0; cursor: pointer; text-align: left; color: #aeb5b2; background: transparent;
}
.nav-item {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px;
  min-height: 43px; padding: 0 11px; border-radius: 9px; font-size: 13px; font-weight: 600;
}
.nav-item:hover, .nav-item.active { color: #fff; background: var(--sidebar-soft); }
.nav-icon svg { width: 19px; height: 19px; }
.nav-count { min-width: 24px; padding: 2px 7px; border-radius: 10px; color: #8f9794; background: rgba(255,255,255,.05); font-size: 10px; text-align: center; }
.nav-count.accent { color: #ffad94; background: rgba(217,93,57,.14); }
.sidebar-section { min-height: 0; display: flex; flex-direction: column; flex: 1; padding-top: 22px; }
.section-heading {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 8px 10px; color: #737d79; font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
}
.icon-button {
  width: 27px; height: 27px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 7px; color: #8d9692; background: transparent; cursor: pointer;
}
.icon-button:hover { color: #fff; background: rgba(255,255,255,.07); }
.icon-button svg { width: 16px; }
.feed-list { overflow: auto; scrollbar-width: thin; scrollbar-color: #39403e transparent; }
.feed-group { margin-bottom: 15px; }
.feed-group-label { padding: 6px 10px; color: #69716e; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.feed-item {
  display: grid; grid-template-columns: 7px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  min-height: 37px; padding: 6px 10px; border-radius: 8px; font-size: 12px;
}
.feed-item:hover, .feed-item.active { color: #fff; background: rgba(255,255,255,.055); }
.feed-source-dot { width: 6px; height: 6px; border-radius: 50%; background: #53605c; }
.feed-source-dot.rescue { background: #bd6048; }
.feed-source-dot.police { background: #66859a; }
.feed-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-unread { color: #89918e; font-size: 10px; font-variant-numeric: tabular-nums; }
.feed-item.active .feed-unread { color: #fff; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; padding: 14px 9px 0; border-top: 1px solid rgba(255,255,255,.08); color: #737d79; font-size: 10px; }
.connection-dot { width: 7px; height: 7px; border: 1px solid #76817d; border-radius: 50%; }
.connection-dot.online { border: 0; background: #6c9a7e; box-shadow: 0 0 0 3px rgba(108,154,126,.12); }
.connection-dot.error { border: 0; background: var(--accent); }

.main { min-width: 0; padding: 45px clamp(28px, 4vw, 68px) 64px; }
.topbar { display: flex; justify-content: space-between; gap: 30px; align-items: flex-end; max-width: 1280px; margin: 0 auto 32px; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .15em; }
h1, h2, h3 { font-family: "Manrope", sans-serif; }
h1 { margin: 0; font-size: clamp(30px, 3.2vw, 44px); line-height: 1.08; letter-spacing: -.045em; }
.view-description { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 15px; }
.last-update { color: var(--muted); font-size: 11px; white-space: nowrap; }
.button {
  min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 9px; background: transparent; cursor: pointer; font-size: 12px; font-weight: 600;
}
.button svg { width: 16px; }
.manage-top { display: none; width: 40px; padding: 0; }
.button:hover { border-color: #b7b2a9; background: rgba(255,255,255,.5); }
.button:disabled { cursor: wait; opacity: .58; }
.button.primary { color: #fff; border-color: var(--accent); background: var(--accent); }
.button.primary:hover { background: var(--accent-deep); }

.summary-grid { max-width: 1280px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; margin: 0 auto 20px; }
.summary-card { min-height: 132px; padding: 22px 23px; border: 1px solid var(--line); border-radius: 12px; background: rgba(250,249,246,.8); }
.summary-card.highlight { border-color: #ebc9bd; background: linear-gradient(145deg, #fffaf7, #f8ebe5); }
.summary-label { color: var(--muted); font-size: 11px; font-weight: 600; }
.summary-value { margin: 8px 0 3px; font-family: "Manrope", sans-serif; font-size: 33px; font-weight: 700; line-height: 1; letter-spacing: -.04em; }
.summary-caption { display: flex; align-items: center; gap: 7px; color: var(--faint); font-size: 10px; }
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(217,93,57,.12); }

.stream-panel { max-width: 1280px; margin: auto; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.stream-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.filter-tabs { display: flex; gap: 3px; padding: 3px; border-radius: 8px; background: #eeece7; }
.filter-tab { padding: 6px 13px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; font-weight: 600; }
.filter-tab:hover { color: var(--ink); }
.filter-tab.active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(30,35,33,.09); }
.toolbar-actions { display: flex; align-items: center; gap: 14px; }
.search-field { width: min(220px, 24vw); display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--faint); background: #fff; }
.search-field:focus-within { border-color: #b9b4ab; box-shadow: 0 0 0 3px rgba(62,102,128,.08); }
.search-field svg { width: 15px; flex: 0 0 auto; }
.search-field input { width: 100%; height: 34px; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 11px; }
.search-field input::placeholder { color: #a8aca9; }
.text-button { padding: 0; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; font-weight: 600; white-space: nowrap; }
.text-button:hover { color: var(--ink); }
.stream-header { display: flex; justify-content: space-between; align-items: center; padding: 21px 24px 15px; }
.stream-header h2 { display: inline; margin: 0 9px 0 0; font-size: 15px; letter-spacing: -.02em; }
.stream-header > div > span { color: var(--faint); font-size: 10px; }
.auto-refresh { display: flex; align-items: center; gap: 7px; color: var(--faint); font-size: 10px; }
.auto-refresh select { padding: 5px 22px 5px 8px; border: 1px solid var(--line); border-radius: 7px; outline: 0; color: var(--muted); background: #fff; font-size: 10px; }
.status { display: none; margin: 0 24px 12px; padding: 9px 11px; border-radius: 7px; color: #8a4d3c; background: var(--accent-soft); font-size: 10px; }
.status.visible { display: block; }
.items { padding: 0 24px 15px; }
.item {
  position: relative; display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 15px;
  padding: 17px 4px; border-top: 1px solid var(--line); cursor: pointer;
  transition: background .15s ease;
}
.item:first-child { border-top: 0; }
.item:hover { margin: 0 -10px; padding-right: 14px; padding-left: 14px; border-radius: 8px; background: #f5f3ef; }
.item-indicator { width: 7px; height: 7px; margin-top: 6px; border: 1px solid #c9cbc8; border-radius: 50%; }
.item.unread .item-indicator { border: 0; background: var(--accent); box-shadow: 0 0 0 3px rgba(217,93,57,.11); }
.item-content { min-width: 0; }
.item-title-line { display: flex; align-items: center; gap: 8px; }
.item-title { margin: 0; overflow: hidden; color: #343a38; font-family: "Manrope", sans-serif; font-size: 13px; font-weight: 600; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.item.unread .item-title { color: var(--ink); font-weight: 700; }
.type-badge { flex: 0 0 auto; padding: 2px 6px; border-radius: 4px; font-size: 8px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.type-badge.fire { color: #a33e27; background: #f6dfd8; }
.type-badge.pollution { color: #806323; background: #f3ead1; }
.type-badge.inspection { color: #426279; background: #e3edf2; }
.type-badge.info, .type-badge.other { color: #5d6b63; background: #e8ece9; }
.item-meta { display: flex; align-items: center; gap: 7px; min-width: 0; margin-top: 5px; color: var(--faint); font-size: 10px; }
.source-pill { color: var(--police); font-weight: 600; }
.source-pill.rescue { color: var(--rescue); }
.meta-separator { color: #d1d2cf; }
.station { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-time { padding: 3px 0 0 20px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.open-icon { display: inline-block; width: 12px; margin-left: 6px; color: var(--faint); vertical-align: -2px; }
.empty-state { display: grid; justify-items: center; padding: 62px 20px 72px; color: var(--muted); text-align: center; }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 15px; border: 1px solid var(--line); border-radius: 50%; color: var(--faint); background: #fff; }
.empty-icon svg { width: 19px; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-size: 14px; }
.empty-state p { max-width: 330px; margin: 0; font-size: 11px; line-height: 1.6; }
.loading-row { display: grid; grid-template-columns: 8px 1fr; gap: 15px; padding: 19px 4px; border-top: 1px solid var(--line); }
.loading-row > span { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: #e7e4de; }
.loading-row b, .loading-row i { display: block; border-radius: 4px; background: linear-gradient(90deg, #ece9e3, #f6f4f0, #ece9e3); background-size: 200%; animation: shimmer 1.5s infinite; }
.loading-row b { width: 52%; height: 11px; }
.loading-row i { width: 31%; height: 8px; margin-top: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.dialog { width: min(900px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); padding: 0; border: 0; border-radius: 15px; color: var(--ink); background: var(--surface); box-shadow: 0 30px 80px rgba(20,25,23,.25); }
.dialog::backdrop { background: rgba(18,23,21,.6); backdrop-filter: blur(3px); }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; padding: 25px 28px 20px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 22px; letter-spacing: -.035em; }
.dialog-header p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.dialog-close { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.dialog-close svg { width: 16px; }
.dialog-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .8fr); gap: 24px; padding: 24px 28px 28px; }
.dialog-section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dialog h3 { margin: 0; font-size: 13px; }
.dialog-section-heading span { color: var(--faint); font-size: 10px; }
.manage-list { max-height: 430px; overflow: auto; padding-right: 5px; }
.manage-group-label { margin: 15px 0 7px; color: var(--faint); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.manage-group-label:first-child { margin-top: 0; }
.manage-row { display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 7px 8px; border-top: 1px solid var(--line); }
.manage-row-name { min-width: 0; flex: 1; font-size: 11px; font-weight: 500; }
.source-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--police); background: var(--police-soft); font-size: 9px; font-weight: 700; }
.source-icon.rescue { color: var(--rescue); background: var(--accent-soft); }
.switch { position: relative; width: 34px; height: 20px; flex: 0 0 auto; padding: 0; border: 0; border-radius: 10px; background: #d7d7d2; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.15); transition: transform .15s; }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(14px); }
.remove-feed { padding: 3px; border: 0; color: #b7b7b2; background: transparent; cursor: pointer; }
.remove-feed:hover { color: var(--accent); }
.remove-feed svg { width: 14px; }
.add-feed { align-self: start; display: grid; gap: 15px; padding: 18px; border: 1px solid var(--line); border-radius: 11px; background: #f5f3ee; }
.add-feed p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.add-feed label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 600; }
.add-feed input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; outline: 0; color: var(--ink); background: #fff; font-size: 11px; }
.add-feed input:focus { border-color: #9d9a92; }
.form-error { min-height: 13px; color: var(--accent-deep); font-size: 10px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar { padding: 26px 12px 18px; }
  .brand { justify-content: center; padding: 0 0 25px; }
  .brand > div:last-child, .nav-item > span:nth-child(2), .nav-count, .section-heading > span, .feed-name, .feed-unread, .sidebar-footer span:last-child { display: none; }
  .primary-nav { justify-items: center; }
  .nav-item { width: 44px; grid-template-columns: 1fr; justify-items: center; padding: 0; }
  .section-heading { justify-content: center; padding-left: 0; padding-right: 0; }
  .feed-item { width: 40px; grid-template-columns: 1fr; justify-items: center; margin: auto; padding: 7px; }
  .feed-group-label { display: none; }
  .sidebar-footer { justify-content: center; }
  .main { padding-left: 25px; padding-right: 25px; }
  .toolbar-actions .text-button { display: none; }
}
@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 12px 16px; }
  .brand { justify-content: flex-start; padding: 0; }
  .brand-mark { width: 34px; height: 34px; }
  .brand > div:last-child { display: block; }
  .brand-kicker { display: none; }
  .primary-nav { grid-template-columns: repeat(2, 42px); gap: 4px; margin-left: auto; padding: 0; border: 0; }
  .sidebar-section, .sidebar-footer { display: none; }
  .main { padding: 28px 14px 40px; }
  .topbar { align-items: flex-start; margin-bottom: 22px; }
  .view-description, .last-update { display: none; }
  h1 { font-size: 29px; }
  .button.secondary span { display: none; }
  .button.secondary { width: 40px; padding: 0; }
  .manage-top { display: inline-flex; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card { min-height: 105px; padding: 17px; }
  .summary-card:last-child { display: none; }
  .summary-value { font-size: 27px; }
  .stream-toolbar { align-items: stretch; flex-direction: column; padding: 13px; }
  .toolbar-actions, .search-field { width: 100%; }
  .stream-header { padding: 18px 15px 12px; }
  .items { padding: 0 15px 10px; }
  .item { grid-template-columns: 7px minmax(0, 1fr); gap: 11px; padding: 15px 2px; }
  .item-time { grid-column: 2; padding: 0; margin-top: -6px; }
  .item-title { white-space: normal; }
  .dialog-body { grid-template-columns: 1fr; }
}
