:root {
  --canvas: #f5f6f3;
  --surface: #fcfdf9;
  --surface-muted: #eef1ed;
  --ink: #18201e;
  --muted: #69736f;
  --line: #dde1dc;
  --accent: #246b5a;
  --accent-soft: #e3f0eb;
  --success: #247a52;
  --warning: #9a6419;
  --danger: #b9493c;
  --white: #fff;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--canvas); font: 450 13px/1.46 var(--sans); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(36, 107, 90, .22); }
[hidden] { display: none !important; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { width: min(1380px, calc(100% - 40px)); min-height: 72px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: var(--danger); background: #f7e8e5; border-radius: 8px; }
.brand-mark svg { width: 21px; fill: currentColor; }
.brand-mark .play { fill: var(--white); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; line-height: 18px; font-weight: 700; }
.brand small { color: var(--muted); font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.today-clock { display: flex; align-items: baseline; gap: 10px; padding-right: 16px; border-right: 1px solid var(--line); }
.today-clock span { color: var(--muted); font-size: 12px; }
.today-clock strong { font-variant-numeric: tabular-nums; font-size: 14px; }

.button { min-height: 36px; border: 1px solid transparent; border-radius: 6px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 650; font-size: 12px; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.button.primary { color: var(--white); background: var(--accent); }
.button.primary:hover { background: #1c594b; }
.button.secondary { color: var(--ink); background: var(--surface); border-color: var(--line); }
.button.secondary:hover { border-color: #aeb7b2; background: var(--surface-muted); }
.button:disabled { opacity: .58; cursor: wait; }
.button.loading svg { animation: spin .8s linear infinite; }

.shell { width: min(1380px, calc(100% - 40px)); margin: 0 auto; padding: 18px 0 36px; }
.runtime-strip { min-height: 40px; display: flex; align-items: center; gap: 20px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 11px; }
.runtime-strip b { color: var(--ink); font-weight: 650; }
.runtime-primary { display: flex; align-items: center; gap: 8px; color: var(--ink); margin-right: auto; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(36, 122, 82, .12); }
.view-tabs { margin: 18px 0; display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.view-tab { min-height: 32px; padding: 0 13px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 650; }
.view-tab.active { color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgba(24, 32, 30, .06); }
.notice { margin-bottom: 14px; padding: 10px 12px; border: 1px solid; border-radius: 6px; font-size: 12px; }
.notice.warning { color: #71470f; background: #fff8e8; border-color: #e8d2a7; }

.daily-ledger { display: grid; grid-template-columns: minmax(220px, 1.1fr) minmax(220px, .9fr) minmax(280px, 1.2fr) minmax(150px, .55fr); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.daily-ledger > div { min-height: 180px; padding: 24px; border-right: 1px solid var(--line); }
.daily-ledger > div:last-child { border-right: 0; }
.section-label { color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .04em; }
h1, h2, p { margin-top: 0; }
h1 { margin: 7px 0 8px; font-size: 28px; line-height: 34px; letter-spacing: -.025em; }
h2 { margin: 5px 0 0; font-size: 20px; line-height: 26px; letter-spacing: -.018em; }
.ledger-heading p, .period-head p { margin: 0; color: var(--muted); }
.channel-result { display: flex; flex-direction: column; }
.result-label { color: var(--muted); font-size: 12px; }
.result-value { display: flex; align-items: baseline; gap: 7px; margin: 7px 0 10px; }
.result-value strong { font-size: 32px; line-height: 38px; font-variant-numeric: tabular-nums; }
.result-value span { color: var(--muted); font-size: 15px; }
.progress, .mini-progress { overflow: hidden; background: var(--surface-muted); }
.progress { height: 5px; border-radius: 3px; }
.progress i, .mini-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease-out; }
.channel-result p { margin: auto 0 0; color: var(--muted); font-size: 12px; }
.channel-result p strong { color: var(--warning); }
.content-breakdown { display: grid; align-content: center; gap: 15px; }
.breakdown-row { display: grid; grid-template-columns: minmax(115px, auto) 36px 1fr; align-items: center; gap: 12px; }
.breakdown-row > span { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.breakdown-row > strong { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.type-icon { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.type-icon.video { background: var(--accent); }
.type-icon.short { background: #457b9d; border-radius: 50%; }
.type-icon.post { background: #8b6f47; transform: rotate(45deg); }
.mini-progress { height: 4px; border-radius: 2px; }
.ledger-total { display: flex; flex-direction: column; justify-content: center; }
.ledger-total > span { color: var(--muted); font-size: 12px; }
.ledger-total > strong { margin: 7px 0; font-size: 32px; line-height: 38px; font-variant-numeric: tabular-nums; }
.ledger-total p { margin: 0; color: var(--muted); font-size: 11px; }

.table-section, .report-table-section, .playlist-section { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.section-head { min-height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; }
.section-head.compact { min-height: 78px; }
.search-field { width: min(290px, 100%); height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 107, 90, .12); }
.search-field svg { width: 16px; flex: 0 0 auto; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.filters { padding: 0 20px 14px; display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); }
.filter { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: 11px; font-weight: 650; cursor: pointer; }
.filter span { margin-left: 4px; font-variant-numeric: tabular-nums; }
.filter:hover { color: var(--ink); border-color: #b6bdb9; }
.filter.active { color: var(--accent); border-color: #a9c9c0; background: var(--accent-soft); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.channel-table { min-width: 1120px; }
.report-table { min-width: 920px; }
th { padding: 10px 12px; color: var(--muted); background: var(--surface-muted); border-bottom: 1px solid var(--line); text-align: left; font-size: 11px; font-weight: 650; letter-spacing: .025em; white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f7f9f6; }
tr.row-quiet td { background: #fffaf0; }
tr.row-error td { background: #fff4f1; }
tr.row-quiet:hover td { background: #fff6e5; }
tr.row-error:hover td { background: #ffebe7; }
.number { text-align: right; }
.channel-cell { min-width: 190px; }
.channel-cell strong, .channel-cell small { display: block; }
.channel-cell strong { font-size: 13px; line-height: 18px; }
.channel-cell small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; border-radius: 999px; font-size: 10px; font-weight: 650; white-space: nowrap; }
.status-badge i { width: 6px; height: 6px; border-radius: 50%; }
.status-badge.posted { color: var(--success); background: #e8f4ed; }
.status-badge.posted i { background: var(--success); }
.status-badge.quiet { color: var(--warning); background: #fff1d8; }
.status-badge.quiet i { background: var(--warning); }
.status-badge.error { color: var(--danger); background: #f9e7e3; }
.status-badge.error i { background: var(--danger); }
.content-count { color: #3d4844; }
.subscriber { color: var(--muted); white-space: nowrap; }
.activity { width: min(330px, 28vw); min-width: 220px; }
.activity a, .activity > span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink); text-decoration: none; font-weight: 600; }
.activity a:hover { color: var(--accent); text-decoration: underline; }
.activity small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.icon-link { width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; }
.icon-link:hover { color: var(--accent); border-color: #a9c9c0; background: var(--accent-soft); }
.icon-link svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.loading-row td { height: 200px; text-align: center; color: var(--muted); }
.spinner { display: inline-block; width: 13px; height: 13px; margin-right: 7px; vertical-align: -2px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.empty { padding: 70px 20px; text-align: center; color: var(--muted); }

.period-head { min-height: 150px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.period-actions { display: flex; align-items: center; gap: 10px; }
.coverage { display: inline-flex; align-items: center; min-height: 30px; padding: 0 9px; border-radius: 999px; font-size: 10px; font-weight: 650; }
.coverage.complete { color: var(--success); background: #e8f4ed; }
.coverage.partial { color: var(--warning); background: #fff1d8; }
.report-table .total-cell { font-weight: 700; color: var(--accent); }
.view-metric strong, .view-metric small { display: block; }
.view-metric strong { font-size: 12px; }
.view-metric small { margin-top: 2px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.muted-cell { color: var(--muted); }
.data-note, .section-copy { margin: 0; color: var(--muted); font-size: 11px; }
.data-note { padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.playlist-section { padding-bottom: 14px; }
.count-chip { padding: 5px 9px; border-radius: 999px; color: var(--danger); background: #f9e7e3; font-size: 11px; }
.section-copy { padding: 0 20px 14px; }
.exception-list { margin: 0 14px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.exception-row { min-height: 58px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.exception-row:last-child { border-bottom: 0; }
.exception-row:hover { background: #fff8f6; }
.exception-row span { min-width: 0; }
.exception-row strong, .exception-row small { display: block; }
.exception-row strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.exception-row small { color: var(--muted); margin-top: 2px; }
.exception-row > b { flex: 0 0 auto; color: var(--danger); font-size: 10px; }
.empty-state { padding: 28px 14px; text-align: center; color: var(--muted); }
.empty-state.success { color: var(--success); background: #f4faf6; }

.operations { margin-top: 16px; display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.operations > div { min-height: 66px; padding: 13px 15px; border-right: 1px solid var(--line); }
.operations > div:last-child { border-right: 0; }
.operations span, .operations strong { display: block; }
.operations span { color: var(--muted); font-size: 10px; }
.operations strong { margin-top: 5px; font-size: 11px; line-height: 16px; font-weight: 650; }
.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; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1050px) {
  .daily-ledger { grid-template-columns: 1fr 1fr; }
  .daily-ledger > div:nth-child(2) { border-right: 0; }
  .daily-ledger > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .operations { grid-template-columns: repeat(3, 1fr); }
  .operations > div:nth-child(3) { border-right: 0; }
  .operations > div:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 720px) {
  .topbar-inner, .shell { width: calc(100% - 24px); }
  .today-clock { display: none; }
  .runtime-strip { gap: 8px 16px; flex-wrap: wrap; padding: 8px 0; }
  .runtime-primary { width: 100%; }
  .view-tabs { width: 100%; }
  .view-tab { flex: 1; }
  .daily-ledger { grid-template-columns: 1fr; }
  .daily-ledger > div { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .daily-ledger > div:last-child { border-bottom: 0; }
  .channel-result { min-height: 170px !important; }
  .ledger-total { min-height: 130px !important; }
  .section-head, .period-head { align-items: stretch; flex-direction: column; }
  .section-head { gap: 14px; }
  .search-field { width: 100%; }
  .period-actions { align-items: stretch; flex-direction: column; }
  .operations { grid-template-columns: 1fr 1fr; }
  .operations > div, .operations > div:nth-child(3) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .operations > div:nth-child(even) { border-right: 0; }
  .operations > div:last-child { border-bottom: 0; }
  .exception-row { align-items: flex-start; flex-direction: column; gap: 5px; }
}

@media (max-width: 430px) {
  .brand small { display: none; }
  .button.primary { padding: 0 11px; }
  .daily-ledger > div { padding: 20px; }
  h1 { font-size: 25px; }
  .operations { grid-template-columns: 1fr; }
  .operations > div, .operations > div:nth-child(3) { border-right: 0; }
}

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