:root {
  --ink: #10231f;
  --muted: #64736f;
  --paper: #f3f5ef;
  --panel: #ffffff;
  --line: #dfe5dc;
  --green: #0f8f68;
  --green-dark: #08654b;
  --lime: #b9e45b;
  --orange: #f2a65a;
  --red: #d75b50;
  --shadow: 0 18px 50px rgba(20, 46, 39, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); 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; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 34px; padding: 30px 22px; color: #edf8f2; background: #10231f; }
.brand { display: flex; gap: 13px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.22); border-radius: 13px; color: var(--lime); background: rgba(255,255,255,.06); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 19px; letter-spacing: .14em; }
.brand small { margin-top: 2px; color: #adc0b9; font-size: 12px; }
nav { display: grid; gap: 8px; }
.nav-item { display: flex; gap: 12px; align-items: center; padding: 12px 13px; border-radius: 11px; color: #adc0b9; text-decoration: none; font-size: 14px; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.08); }
.nav-item.active span { color: var(--lime); }
.source-card { margin-top: auto; padding: 18px; border: 1px solid rgba(255,255,255,.12); border-radius: 15px; background: rgba(255,255,255,.05); }
.source-card strong { display: block; margin: 7px 0; font-size: 14px; }
.source-card p { margin: 0; color: #a6bab3; font-size: 12px; line-height: 1.55; }
.sidebar-foot { color: #95aba4; font-size: 12px; }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 999px; background: var(--lime); box-shadow: 0 0 0 5px rgba(185,228,91,.1); }

main { min-width: 0; padding: 32px clamp(24px, 4vw, 58px) 24px; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: clamp(30px, 4vw, 44px); }
h2 { font-size: 19px; }
.top-actions { display: flex; gap: 12px; align-items: center; }
.freshness { color: var(--muted); font-size: 12px; }
.ghost-button, .primary-button { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 700; }
.ghost-button { color: var(--ink); background: white; box-shadow: 0 5px 20px rgba(30,50,44,.06); }
.primary-button { align-self: end; color: white; background: var(--green); }
.ghost-button:hover, .primary-button:hover { transform: translateY(-1px); }

.filter-panel { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)) auto; gap: 14px; margin: 28px 0 18px; padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.72); }
.filter-panel label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.filter-panel input, .filter-panel select { min-width: 0; width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; outline: none; }
.filter-panel input:focus, .filter-panel select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(15,143,104,.1); }

.status-banner { margin-bottom: 18px; padding: 13px 15px; border: 1px solid #ecd5a8; border-radius: 12px; color: #754e1c; background: #fff8e8; font-size: 13px; }
.status-banner.error { border-color: #efc1bd; color: #842f29; background: #fff0ef; }
.hidden { display: none; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; }
.metric-card { min-width: 0; padding: 19px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 10px 28px rgba(23,49,42,.04); }
.metric-card.accent { color: white; border-color: transparent; background: linear-gradient(135deg, #0b7456, #13a578); }
.metric-card span, .metric-card small { display: block; }
.metric-card span { color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-card.accent span, .metric-card.accent small { color: rgba(255,255,255,.72); }
.metric-card strong { display: block; overflow: hidden; margin: 12px 0 8px; font-size: clamp(23px, 3vw, 32px); letter-spacing: -.04em; text-overflow: ellipsis; }
.metric-card small { color: #88948f; font-size: 10px; }

.split-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(250px, .8fr); gap: 16px; margin-top: 16px; }
.panel { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; gap: 6px; align-items: center; }
.legend i { width: 9px; height: 9px; border-radius: 3px; }
.legend i.revenue { background: var(--green); }
.legend i.spend { background: var(--orange); }
.chart-wrap { min-height: 320px; padding: 20px; }
#trendChart { width: 100%; height: 300px; overflow: visible; }
.pulse-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); }
.pulse-list div { padding: 22px; background: white; }
.pulse-list span, .pulse-list strong { display: block; }
.pulse-list span { color: var(--muted); font-size: 11px; }
.pulse-list strong { margin-top: 8px; font-size: 20px; }

.table-panel, .quality-panel { margin-top: 16px; overflow: hidden; }
.row-count { padding: 7px 10px; border-radius: 999px; color: var(--green-dark); background: #e9f6ef; font-size: 11px; font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 1160px; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-size: 12px; }
th { color: var(--muted); background: #fafbf8; font-size: 10px; letter-spacing: .04em; }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; text-align: left; background: inherit; }
tbody tr { background: white; }
tbody tr:hover { background: #f7faf6; }
.channel-name strong, .channel-name small { display: block; }
.channel-name small { margin-top: 4px; color: var(--muted); }
.positive { color: var(--green-dark); font-weight: 800; }
.negative { color: var(--red); font-weight: 800; }
.status-pill { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status-pill.good { color: #08714f; background: #e3f6ed; }
.status-pill.watch { color: #8a5b17; background: #fff3d8; }
.status-pill.loss { color: #963b33; background: #ffebe8; }
.empty { padding: 34px; color: var(--muted); text-align: center; }

.quality-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 14px; padding: 20px; }
.health-card { padding: 16px; border: 1px solid var(--line); border-radius: 13px; }
.health-card header { display: flex; justify-content: space-between; gap: 10px; }
.health-card strong { font-size: 13px; text-transform: uppercase; }
.health-card p { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
footer { padding: 28px 4px 0; color: #81908b; font-size: 10px; text-align: center; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 18px; }
  .sidebar nav, .source-card, .sidebar-foot { display: none; }
  main { padding: 22px 14px; }
  .topbar { align-items: flex-start; }
  .freshness { display: none; }
  .filter-panel { grid-template-columns: 1fr 1fr; }
  .filter-panel label:nth-child(3), .filter-panel .primary-button { grid-column: 1 / -1; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card:last-child { grid-column: 1 / -1; }
  .panel-head { padding: 18px; }
  .legend { display: none; }
  .quality-grid { grid-template-columns: 1fr; }
}
