:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #64748b;
  --line: #d9e0ea;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #0f766e;
  --red: #b42318;
  --amber: #b45309;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 18px;
  background: #111827;
  color: #eef2ff;
}

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

.brand-link {
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
}

.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.22));
}

.brand-logo-tile {
  fill: #ffffff;
  stroke: #cbd5e1;
  stroke-width: 2;
}

.brand-logo-grid {
  fill: none;
  stroke: #e5edf7;
  stroke-width: 1.2;
}

.brand-logo-green,
.brand-logo-blue,
.brand-logo-smile {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-logo-green {
  stroke: #1b988f;
  stroke-width: 3.4;
}

.brand-logo-blue {
  stroke: #0073e6;
  stroke-width: 3.8;
}

.brand-logo-eye {
  fill: #111827;
}

.brand-logo-smile {
  stroke: #111827;
  stroke-width: 1.8;
}

.brand strong,
.brand > div span {
  display: block;
}

.brand > div span {
  color: #a8b3c7;
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 12px;
  background: transparent;
  color: #cbd5e1;
  font: inherit;
  text-align: left;
  text-decoration: none;
}

.nav-button.active,
.nav-button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.sidebar-status {
  margin-top: auto;
  display: grid;
  gap: 9px;
  color: #a8b3c7;
  font-size: 12px;
  line-height: 1.35;
}

.main {
  min-width: 0;
}

.page {
  display: none;
  padding: 26px;
}

.page.active {
  display: block;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 15px;
  line-height: 1.3;
  margin-bottom: 14px;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

.topbar p:empty {
  display: none;
}

.content-page {
  max-width: 980px;
  margin-bottom: 20px;
  color: var(--ink);
}

.content-page h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.content-page p {
  color: var(--muted);
  line-height: 1.6;
}

.content-page a {
  color: var(--blue);
}

.content-page ul {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.manual-row,
.field-row,
.feed-card-header,
.feed-card-meta,
.subscription-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.link-button {
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.primary-button {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.secondary-button:hover,
.link-button:hover {
  border-color: #aab7c9;
}

.danger-button {
  border-color: #fecaca;
  color: var(--red);
}

.danger-button:hover {
  background: #fff1f2;
}

.link-button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}

.panel,
.feed-card,
.empty-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

.feed-list {
  display: grid;
  gap: 18px;
  max-width: 980px;
}

.feed-card {
  padding: 16px;
}

.feed-date-divider {
  display: grid;
  grid-template-columns: minmax(24px, 1fr) auto minmax(24px, 1fr);
  gap: 12px;
  align-items: center;
  margin: 2px 0 -2px;
  color: #7b8798;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}

.feed-date-divider::before,
.feed-date-divider::after {
  content: "";
  height: 1px;
  background: #d8e0ea;
}

.feed-date-divider span {
  white-space: nowrap;
}

.feed-card-header {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.feed-card-title {
  min-width: 0;
}

.feed-card-title h2 {
  margin: 0 0 5px;
  font-size: 18px;
}

.feed-card-title p,
.feed-card-meta {
  color: var(--muted);
  font-size: 12px;
}

.feed-card-meta {
  flex-wrap: wrap;
  margin-top: 10px;
}

.graph-data {
  margin: 0 0 12px;
}

.graph-data dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.graph-data dl > div,
.graph-data-status {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.graph-data dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.graph-data dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.graph-data-status {
  display: grid;
  min-height: 56px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border-radius: 8px;
  background: #eef6ff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 650;
}

.latest {
  text-align: right;
  white-space: nowrap;
}

.latest-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.latest strong {
  font-size: 24px;
  line-height: 1.05;
}

.latest span {
  color: var(--muted);
  font-size: 12px;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 8px;
  background: #ecfdf3;
  color: var(--green) !important;
  font-weight: 750;
}

.view-latest {
  display: block;
  margin-top: 5px;
  color: var(--ink) !important;
  font-weight: 650;
}

.graph-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.graph-control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.graph-control select {
  width: auto;
  min-width: 82px;
  min-height: 32px;
  padding: 4px 8px;
  font-size: 12px;
}

.graph-control select[data-feed-unit] {
  min-width: 170px;
}

.graph-save-button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.graph-frame {
  width: 100%;
  border: 1px solid #edf1f7;
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.local-chart {
  position: relative;
  background: #eaf3fb;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
}

.chart-background {
  fill: #ffffff;
}

.chart-grid-line {
  stroke: #c8c8c8;
  stroke-width: 1.5;
}

.chart-axis {
  stroke: #111827;
  stroke-width: 1.8;
}

.chart-x-tick {
  stroke: #cbd5e1;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: #1473d8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-x-label,
.chart-y-label {
  fill: #444444;
  font-size: 13px;
  font-weight: 500;
}

.chart-hover-line {
  opacity: 0;
  pointer-events: none;
  stroke: #111827;
  stroke-width: 1.5;
}

.chart-hover-point {
  opacity: 0;
  pointer-events: none;
  fill: #ffffff;
  stroke: #1473d8;
  stroke-width: 2;
}

.local-chart.has-hover-point:hover .chart-hover-line,
.local-chart.has-hover-point:hover .chart-hover-point {
  opacity: 1;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  transform: translate(10px, -100%);
  padding: 7px 9px;
  border: 1px solid rgba(37, 99, 235, 0.55);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
}

.chart-tooltip.left {
  transform: translate(calc(-100% - 10px), -100%);
}

.graph-status {
  display: grid;
  aspect-ratio: 920 / 500;
  min-height: 0;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.error-card,
.empty-card {
  padding: 18px;
}

.error-card {
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
  color: var(--red);
}

.empty-card {
  color: var(--muted);
  box-shadow: none;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(420px, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 16px;
  box-shadow: none;
}

.panel.wide {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 7px;
  width: 100%;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.field-row {
  margin-top: 12px;
  align-items: end;
}

.manual-row {
  align-items: stretch;
}

.csv-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hidden-file-input {
  display: none;
}

.manual-row {
  margin-top: 10px;
}

.manual-row button {
  min-width: 92px;
}

.result-list,
.subscription-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.result-item,
.subscription-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.result-item strong,
.subscription-title-field span {
  display: block;
  margin-bottom: 5px;
}

.result-item p,
.subscription-title-field p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.subscription-title-field {
  display: grid;
  gap: 6px;
}

.subscription-title-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.subscription-item {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 130px auto;
  gap: 12px;
  align-items: center;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #101827;
  color: #ffffff;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
  }

  .nav {
    grid-auto-flow: column;
    margin-left: auto;
  }

  .sidebar-status {
    display: none;
  }

  .settings-grid,
  .subscription-item {
    grid-template-columns: 1fr;
  }

  .graph-data dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
  }

  .latest {
    text-align: left;
  }

  .latest-row {
    justify-content: flex-start;
  }

}
