:root {
  --bg: #eef4f8;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --line: rgba(36, 64, 96, 0.12);
  --text: #16304f;
  --muted: #5f738a;
  --emerald: #12805c;
  --blue: #1e5cb3;
  --amber: #ba6e12;
  --rose: #a73843;
  --shadow: 0 18px 40px rgba(23, 46, 72, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(81, 162, 255, 0.22), transparent 28%),
    radial-gradient(circle at top right, rgba(26, 181, 137, 0.18), transparent 24%),
    linear-gradient(180deg, #f7fbff 0%, var(--bg) 100%);
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px 18px 40px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 28px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(241, 248, 255, 0.9)),
    linear-gradient(120deg, rgba(18, 128, 92, 0.08), rgba(30, 92, 179, 0.08));
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.9);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--blue);
  font-weight: 800;
}

.hero h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.02;
}

.hero-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.hero-period {
  margin: 8px 0 0;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
}

.refresh-button,
.ghost-link {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, #1e5cb3, #12805c);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(30, 92, 179, 0.22);
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 6px 10px;
}

.period-toolbar {
  margin-top: 18px;
}

.period-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 6px;
  scrollbar-width: none;
}

.period-tabs::-webkit-scrollbar {
  display: none;
}

.period-tab {
  flex: 0 0 auto;
  border: 1px solid rgba(36, 64, 96, 0.14);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.period-tab:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(23, 46, 72, 0.08);
}

.period-tab.active {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, #1e5cb3, #12805c);
  box-shadow: 0 12px 24px rgba(30, 92, 179, 0.2);
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(22, 48, 79, 0.08);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.status-pill.ok {
  background: rgba(18, 128, 92, 0.14);
  color: var(--emerald);
}

.status-pill.warning {
  background: rgba(186, 110, 18, 0.14);
  color: var(--amber);
}

.status-pill.error {
  background: rgba(167, 56, 67, 0.14);
  color: var(--rose);
}

.status-text {
  color: var(--muted);
  font-size: 14px;
}

.alerts {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 14px;
}

.alert.warning {
  border-color: rgba(186, 110, 18, 0.25);
}

.alert.stale {
  border-color: rgba(186, 110, 18, 0.35);
  background: linear-gradient(135deg, rgba(255, 244, 214, 0.96), rgba(255, 250, 236, 0.96));
  color: #8c5608;
}

.alert.error {
  border-color: rgba(167, 56, 67, 0.25);
}

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

.card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.card::after {
  content: "";
  position: absolute;
  inset: auto -30px -38px auto;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  opacity: 0.14;
}

.card.emerald::after { background: var(--emerald); }
.card.blue::after { background: var(--blue); }
.card.amber::after { background: var(--amber); }
.card.rose::after { background: var(--rose); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-badge {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.card.emerald .card-badge { background: var(--emerald); }
.card.blue .card-badge { background: var(--blue); }
.card.amber .card-badge { background: var(--amber); }
.card.rose .card-badge { background: var(--rose); }

.card-value {
  margin: 18px 0 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1;
}

.card-label {
  color: var(--muted);
  font-size: 14px;
}

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

.stat-row,
.debt-row,
.highlight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stat-label,
.debt-meta,
.highlight-label {
  color: var(--muted);
  font-size: 14px;
}

.stat-value,
.debt-value,
.highlight-value {
  font-weight: 800;
}

.panel {
  margin-top: 18px;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 20px;
  font-family: "Space Grotesk", sans-serif;
}

.section-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.ghost-link {
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: none;
}

.highlights-grid,
.list-block,
.channels-list {
  display: grid;
  gap: 12px;
}

.highlight-card,
.debt-row,
.channel-card,
.empty-state {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
}

.highlight-card {
  display: grid;
  gap: 8px;
}

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

.debt-row {
  display: grid;
  gap: 6px;
}

.debt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.channel-card {
  display: grid;
  gap: 10px;
}

.channel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.channel-name {
  font-weight: 800;
}

.channel-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(36, 64, 96, 0.08);
  overflow: hidden;
}

.channel-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1e5cb3, #12805c);
}

.channel-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 840px) {
  .cards-grid,
  .split-layout,
  .channel-meta {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .refresh-button,
  .ghost-link {
    width: 100%;
    text-align: center;
  }
}
