:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --panel: #fbfaf6;
  --panel-raised: #ffffff;
  --text: #1f2421;
  --muted: #66716b;
  --line: #d7d2c8;
  --line-strong: #b9b2a6;
  --accent: #2f766d;
  --accent-strong: #174f49;
  --warn: #946423;
  --danger: #a33f45;
  --shadow: 0 1px 2px rgba(31, 36, 33, 0.05);
  font-family:
    "JetBrains Mono",
    "IBM Plex Mono",
    "Cascadia Code",
    "SFMono-Regular",
    ui-monospace,
    monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111412;
  --panel: #171b18;
  --panel-raised: #1c211e;
  --text: #edf0ea;
  --muted: #99a69e;
  --line: #2c342f;
  --line-strong: #425149;
  --accent: #7fc7b8;
  --accent-strong: #a7ddd1;
  --warn: #d8ad66;
  --danger: #e07f86;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  text-rendering: geometricPrecision;
}

a {
  color: inherit;
}

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

.topbar,
.workspace,
.site-footer {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0;
  text-decoration: none;
}

.theme-toggle,
.repo-link {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  box-shadow: none;
}

.theme-toggle {
  cursor: pointer;
}

.theme-toggle:hover,
.repo-link:hover {
  color: var(--accent-strong);
}

.icon,
.repo-link svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.repo-link svg {
  fill: currentColor;
  stroke: none;
}

.moon,
:root[data-theme="dark"] .sun {
  display: none;
}

:root[data-theme="dark"] .moon {
  display: block;
}

.workspace {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 34px 0 36px;
}

.dashboard-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 260px);
  gap: 18px;
  align-items: end;
}

.eyebrow,
.status-kicker {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 10px;
  font-size: clamp(1.9rem, 4vw, 3.6rem);
  line-height: 0.96;
  letter-spacing: 0;
  font-weight: 720;
}

.lede {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.35fr) repeat(4, minmax(130px, 1fr)) minmax(220px, auto);
  gap: 8px;
  align-items: end;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: end;
  justify-content: flex-end;
}

.filter-status {
  grid-column: 1 / -1;
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.module-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 2px;
}

.module-nav a {
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.74rem;
  text-decoration: none;
}

.module-nav a:hover,
.module-nav a[aria-current="page"] {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

.module-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field {
  display: grid;
  gap: 5px;
}

.field span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
}

select,
input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  padding: 0 10px;
}

input::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

select:focus,
input:focus,
.theme-toggle:focus-visible,
.repo-link:focus-visible,
.small-button:focus-visible,
.icon-text-button:focus-visible,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.state-banner {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
}

.warning-state {
  border-color: color-mix(in srgb, var(--warn) 55%, var(--line));
  color: var(--warn);
}

.error-state {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  color: var(--danger);
}

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

.dashboard-section {
  display: grid;
  align-content: start;
  min-height: 200px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, var(--bg));
}

.section-head h2 {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
}

.section-head span {
  color: var(--muted);
  font-size: 0.74rem;
}

.item-list {
  display: grid;
}

.item-card {
  display: grid;
  gap: 7px;
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
}

.item-card:hover {
  background: color-mix(in srgb, var(--accent) 5%, var(--panel-raised));
}

.item-card.is-read {
  opacity: 0.72;
}

.item-card.is-watched {
  background: color-mix(in srgb, var(--warn) 8%, var(--panel-raised));
}

.item-card.is-pinned {
  border-left-color: var(--warn);
}

.item-card:last-child {
  border-bottom: 0;
}

.item-topline,
.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  color: var(--muted);
  font-size: 0.68rem;
}

.item-topline a,
.source-row a {
  color: var(--accent-strong);
  text-decoration: none;
}

.item-topline a:hover,
.source-row a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.item-card h3 {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.35;
  font-weight: 680;
}

.item-card h3 a {
  text-decoration: none;
}

.item-card h3 a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.item-card p,
.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.item-meta span {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.inline-button {
  min-height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  cursor: pointer;
}

.inline-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.daily-summary {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.daily-summary div {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
}

.daily-summary strong {
  font-size: 1.2rem;
  line-height: 1;
}

.daily-summary span {
  color: var(--muted);
  font-size: 0.68rem;
}

.urgency-high {
  border-left: 3px solid var(--danger);
}

.urgency-normal {
  border-left: 3px solid var(--accent);
}

.urgency-low {
  border-left: 3px solid var(--line);
}

.empty-state {
  padding: 14px;
}

.module-view {
  display: grid;
  gap: 10px;
}

.module-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 170px);
  gap: 16px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  box-shadow: var(--shadow);
}

.module-head h2 {
  margin: 0 0 8px;
  font-size: clamp(1.25rem, 2.8vw, 2.1rem);
  line-height: 1.08;
}

.module-stat {
  display: grid;
  gap: 2px;
  justify-items: end;
  color: var(--muted);
}

.module-stat span {
  color: var(--text);
  font-size: 1.7rem;
  font-weight: 720;
  line-height: 1;
}

.module-stat p {
  margin: 0;
  font-size: 0.7rem;
  text-align: right;
}

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

.fact-card {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 142px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  box-shadow: var(--shadow);
}

.fact-card h3 {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.35;
}

.fact-card h3 a {
  text-decoration: none;
}

.fact-card h3 a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.fact-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.source-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.68rem;
}

.module-items {
  min-height: 160px;
}

.ops-section {
  display: grid;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

.ops-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.ops-table th,
.ops-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.ops-table th {
  color: var(--muted);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.ops-table tr:last-child td {
  border-bottom: 0;
}

.status-badge {
  display: inline-block;
  min-width: 72px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
}

.status-healthy {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--accent-strong);
}

.status-degraded {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  color: var(--danger);
}

.status-running {
  border-color: color-mix(in srgb, var(--warn) 55%, var(--line));
  color: var(--warn);
}

.status-disabled {
  border-color: var(--line);
  color: var(--muted);
}

.inline-admin,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.inline-admin input[type="number"] {
  width: 82px;
}

.inline-admin label {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  color: var(--muted);
}

.small-button {
  padding: 0 10px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.74rem;
  cursor: pointer;
}

.subtle-button,
.icon-text-button,
.preset-select {
  min-height: 30px;
  border-color: color-mix(in srgb, var(--line) 72%, transparent);
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
}

.subtle-button {
  padding: 0 8px;
}

.daily-tools {
  display: inline-flex;
  gap: 1px;
  min-height: 30px;
  padding: 1px;
  border: 1px solid color-mix(in srgb, var(--line) 62%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}

.icon-text-button {
  padding: 0 7px;
  border: 0;
  border-radius: 5px;
  font: inherit;
  cursor: pointer;
}

.preset-select {
  width: auto;
  max-width: 106px;
  padding: 0 22px 0 7px;
}

.subtle-button:hover,
.icon-text-button:hover,
.preset-select:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  color: var(--accent-strong);
}

.section-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.notification-form {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) minmax(120px, 0.7fr) minmax(140px, 0.8fr) minmax(220px, 1.4fr) minmax(180px, 1fr) auto auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.inline-check {
  display: inline-flex;
  min-height: 36px;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 0.72rem;
}

.url-cell {
  display: inline-block;
  max-width: 280px;
  overflow-wrap: anywhere;
}

.notification-log-wrap {
  border-top: 1px solid var(--line);
}

.small-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.config-textarea {
  min-height: 240px;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.74rem;
  line-height: 1.5;
  padding: 12px;
  resize: vertical;
}

.site-footer {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
}

.site-footer [data-version] {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .topbar,
  .workspace,
  .site-footer {
    width: min(100% - 24px, 1120px);
  }

  .workspace {
    padding-top: 24px;
  }

  .dashboard-head,
  .filters,
  .dashboard-grid,
  .daily-summary,
  .module-head,
  .fact-grid,
  .notification-form {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    align-items: stretch;
    justify-content: stretch;
  }

  .filter-actions .small-button,
  .daily-tools,
  .notification-form .small-button {
    width: 100%;
  }

  .daily-tools {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .preset-select {
    max-width: none;
  }

  .module-stat {
    justify-items: start;
  }

  .module-stat p {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
