:root {
  --blue: #3370ff;
  --blue-soft: #e8f0ff;
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e5e6eb;
  --text: #1f2329;
  --muted: #646a73;
  --muted-2: #8f959e;
  --green: #0f9f6e;
  --green-soft: #e8f8f1;
  --orange: #d97008;
  --orange-soft: #fff3df;
  --red: #d83931;
  --red-soft: #fff0ed;
  --shadow: 0 8px 24px rgba(31, 35, 41, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  position: fixed;
  inset: 0 auto 0 0;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  padding: 10px 8px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.brand-logo {
  width: 166px;
  height: auto;
  object-fit: contain;
}
.brand-name { font-weight: 700; line-height: 1.25; }
.nav { display: grid; gap: 4px; }
.nav button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.nav button.active { color: var(--blue); background: var(--blue-soft); font-weight: 700; }
.main {
  flex: 1;
  min-width: 0;
  margin-left: 232px;
  padding: 22px max(32px, calc((100vw - 232px - 1320px) / 2 + 32px)) 40px;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
h1, h2, h3 { margin: 0; }
.topbar h1 { font-size: 24px; }
.topbar p, .drawer-head p, .empty p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.data-stamp { color: var(--muted); font-size: 13px; }
.primary-btn, .secondary-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
}
.primary-btn { background: var(--blue); color: #fff; }
.primary-btn:disabled { cursor: not-allowed; background: #a8c0ff; }
.secondary-btn { background: #fff; color: var(--text); border-color: var(--line); }
.wide { width: 100%; margin-top: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.filters {
  display: flex !important;
  position: relative;
  z-index: 10;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 12px 14px;
  margin-bottom: 16px;
  overflow: visible;
  width: 100%;
}
.filter-field, .form-row { display: grid; gap: 5px; }
.filters > .filter-field {
  flex: 1 1 0 !important;
  width: 0;
  min-width: 0 !important;
  max-width: none;
  align-self: center;
}
label, .input-label { color: var(--muted); font-size: 12px; line-height: 1.25; }
select, input, textarea {
  width: 100%;
  border: 1px solid #dfe3e8;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
  font-size: 13px;
}
select, input { height: 32px; padding: 6px 10px; }
.filters select,
.filters input {
  width: 100%;
  min-width: 0;
}
select:focus, input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(51, 112, 255, 0.12); }
.date-range-field {
  position: relative;
  min-width: 0;
}
.date-range-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  width: 260px;
  padding: 12px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.date-range-row { display: grid; gap: 5px; }
.date-range-actions { display: flex; justify-content: flex-end; gap: 8px; }
.content { display: grid; gap: 16px; }
.dashboard-section { display: grid; gap: 12px; }
.section-title { display: flex; align-items: baseline; gap: 16px; }
.section-title strong { color: var(--blue); font-size: 17px; }
.section-title span { color: var(--muted); font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 12px; }
.metric-grid-five { grid-template-columns: repeat(5, minmax(150px, 1fr)); }
.tracking-metrics-grid { grid-template-columns: repeat(5, minmax(150px, 1fr)); }
.metric {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-height: 116px;
  padding: 18px;
}
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 10px; color: var(--text); font-size: 23px; font-weight: 800; }
.metric-extra { margin-top: 8px; color: var(--muted); font-size: 12px; }
.home-metrics { align-items: stretch; justify-content: center; }
.metric-blue,
.metric-green,
.metric-orange,
.metric-violet { border-top: 0; }
.metric-blue .metric-value,
.metric-green .metric-value,
.metric-orange .metric-value,
.metric-violet .metric-value { color: var(--text); }
.metric-icon {
  display: none;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
}
.metric-green .metric-icon { background: var(--green-soft); color: var(--green); }
.metric-orange .metric-icon { background: var(--orange-soft); color: var(--orange); }
.metric-violet .metric-icon { background: #f1edff; color: #7c3aed; }
.section-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel { padding: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel h3 { font-size: 16px; }
.panel-note { margin: -4px 0 12px; color: var(--muted-2); font-size: 12px; }
.top-panel-plays { border-top: 3px solid var(--blue); }
.top-panel-sales { border-top: 3px solid var(--green); }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; min-width: 900px; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.data-table.compact { min-width: 620px; }
.data-table th, .data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  vertical-align: middle;
}
.data-table th { color: #4b5563; background: #f8fafc; font-weight: 600; user-select: none; }
.data-table td { background: #fff; }
.data-table th.sortable { cursor: pointer; }
.data-table tr:last-child td { border-bottom: 0; }
.script-summary-panel .table-wrap { max-height: 540px; overflow: auto; }
.script-summary-panel .data-table thead th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 #e5e7eb; }
.script-summary-table { min-width: 1120px; }
.data-table tr.is-top-script td { background: #f8fbff; }
.data-table tr.is-top-script td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.script-name { margin-left: 8px; font-weight: 700; }
.progress-cell { display: flex; align-items: center; justify-content: center; gap: 8px; }
.progress-track { width: 72px; height: 8px; overflow: hidden; border-radius: 999px; background: #eef2f7; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.progress-cell strong { min-width: 42px; color: var(--green); font-size: 12px; }
.tracking-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 4px;
}
.tracking-chart-block {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.tracking-chart-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.15;
  font-weight: 700;
}
.tracking-chart {
  position: relative;
  min-width: 0;
  padding: 16px 18px 12px;
}
.tracking-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 28px;
  margin-bottom: 6px;
}
.tracking-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}
.tracking-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.tracking-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.legend-produced { background: var(--blue); }
.legend-published { background: #9bbcff; }
.legend-published-line {
  height: 3px !important;
  border-radius: 999px !important;
  background: var(--green);
}
.legend-plays {
  height: 3px !important;
  border-radius: 999px !important;
  background: var(--text);
}
.tracking-note {
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}
.tracking-chart-svg {
  display: block;
  width: 100%;
  height: 320px;
}
.tracking-grid-line {
  stroke: #e8edf5;
  stroke-width: 1;
}
.tracking-axis-title,
.tracking-axis-label {
  fill: var(--muted);
  font-size: 23px;
  font-weight: 650;
}
.tracking-axis-title { font-size: 21px; }
.tracking-date-label {
  fill: #4b5563;
  font-size: 23px;
  font-weight: 700;
}
.tracking-bar-produced { fill: var(--blue); }
.tracking-bar-published { fill: #9bbcff; }
.tracking-bar-produced,
.tracking-bar-published,
.tracking-line-point,
.tracking-published-point {
  cursor: default;
}
.tracking-published-line {
  fill: none;
  stroke: var(--green);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  stroke-dasharray: 8 6;
}
.tracking-line {
  fill: none;
  stroke: var(--text);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.2;
}
.tracking-line-point {
  fill: #fff;
  stroke: var(--text);
  stroke-width: 3.2;
}
.tracking-published-point {
  fill: #fff;
  stroke: var(--green);
  stroke-width: 3;
}
.tracking-tooltip {
  position: absolute;
  z-index: 5;
  max-width: 220px;
  pointer-events: none;
  border-radius: 6px;
  background: rgba(31, 35, 41, 0.94);
  color: #fff;
  padding: 7px 9px;
  box-shadow: 0 8px 20px rgba(31, 35, 41, 0.18);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.4;
  white-space: nowrap;
}
.tracking-panel .data-table { min-width: 1120px; }
.overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.overview-card { padding: 16px 18px; }
.overview-rates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.overview-rate-label { color: var(--muted); font-size: 13px; }
.overview-rate-item strong { display: block; margin-top: 10px; font-size: 20px; }
.overview-bar { height: 8px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #e9edf3; }
.overview-bar span { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.overview-rate-tail { margin-top: 6px; color: var(--muted); font-size: 12px; text-align: right; }
.block-title { margin: 0; font-size: 18px; font-weight: 900; color: var(--text); }
.video-overview-section { gap: 10px; }
.video-overview-grid {
  display: grid;
  grid-template-columns: minmax(220px, 4fr) minmax(180px, 3fr) minmax(420px, 5fr);
  gap: 16px;
}
.video-overview-card { padding: 22px 24px; }
.video-overview-card span { color: var(--muted); font-size: 13px; font-weight: 600; }
.video-overview-card strong {
  display: block;
  margin-top: 12px;
  color: var(--text);
  font-size: 22px;
  line-height: 1.1;
  font-weight: 850;
}
.video-overview-card p {
  margin: 12px 0 0;
  color: var(--text);
  font-size: 13px;
}
.average-basis {
  display: grid;
  gap: 5px;
  line-height: 1.35;
}
.average-basis span {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.video-overview-card em {
  display: block;
  margin-top: 10px;
  color: var(--text);
  font-style: normal;
  font-size: 13px;
  font-weight: 800;
}
.video-overview-card h3 { margin: 0 0 22px; font-size: 15px; font-weight: 850; color: var(--text); }
.distribution {
  display: grid;
  align-content: center;
  min-height: 172px;
}
.distribution-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(116px, 1fr);
  align-items: center;
  gap: 18px;
}
.distribution-list { min-width: 0; }
.distribution-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 12px;
  min-height: 36px;
  padding: 7px 0;
}
.distribution-row + .distribution-row {
  border-top: 1px solid var(--line);
}
.distribution-row span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}
.distribution-row strong {
  margin: 0;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  font-weight: 850;
  text-align: right;
}
.distribution-row em {
  margin: 0;
  min-width: 44px;
  color: #53627c;
  font-style: normal;
  font-size: 13px;
  font-weight: 750;
  text-align: right;
}
.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
}
.dot-attached { background: var(--blue); }
.dot-unattached { background: #9bbcff; }
.dot-hidden { background: #d8dde6; }
.donut-wrap { display: grid; place-items: center; min-width: 0; }
.donut-chart {
  position: relative;
  display: grid;
  place-items: center;
  width: 116px;
  aspect-ratio: 1;
  border-radius: 50%;
}
.donut-hole {
  display: grid;
  place-items: center;
  align-content: center;
  width: 72px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(229, 230, 235, 0.9);
}
.donut-hole strong {
  margin: 0;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  font-weight: 900;
}
.overview-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.overview-stats-five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.overview-stats div { border-radius: 8px; background: #f8fafc; padding: 16px 12px; text-align: center; }
.overview-stats span { display: block; color: var(--muted); font-size: 12px; }
.overview-stats strong { display: block; margin-top: 8px; color: var(--text); font-size: 20px; }
.overview-stats em { display: block; margin-top: 4px; color: var(--text); font-style: normal; font-size: 12px; font-weight: 800; }
.stat-progress { height: 6px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: #e8edf5; }
.stat-progress i { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.stat-progress.empty { background: transparent; }
.top-rank-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.top-rank-card { padding: 16px; min-height: 194px; }
.top-rank-card.top-rank-blue,
.top-rank-card.top-rank-green,
.top-rank-card.top-rank-orange { border-top: 0; }
.top-rank-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.top-rank-head h3 { font-size: 14px; }
.top-rank-head span { color: var(--blue); font-size: 12px; font-weight: 800; }
.top-rank-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 72px; align-items: center; gap: 10px; padding: 7px 0; }
.top-rank-row.has-play { grid-template-columns: 24px minmax(0, 1fr) 28px 72px; }
.top-rank-index {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
}
.top-rank-index.blue { color: var(--blue); background: var(--blue-soft); }
.top-rank-index.green { color: var(--green); background: var(--green-soft); }
.top-rank-index.orange { color: var(--orange); background: var(--orange-soft); }
.top-rank-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 13px; font-weight: 700; }
.top-rank-play,
.top-rank-play-placeholder {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}
.top-rank-play {
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 10px;
  font-weight: 900;
  text-decoration: none;
}
.top-rank-play:hover {
  color: #fff;
  background: var(--blue);
  text-decoration: none;
}
.top-rank-row strong { color: var(--text); font-size: 13px; text-align: right; }
.top-rank-empty {
  display: grid;
  place-items: center;
  height: 118px;
  color: var(--muted-2);
  background: #fafbfc;
  border: 1px dashed #edf1f5;
  border-radius: 8px;
  font-size: 13px;
}
.top-rank-card.top-rank-green:has(.top-rank-empty) { box-shadow: none; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.tag-blue { color: var(--blue); background: var(--blue-soft); }
.tag-green { color: var(--green); background: var(--green-soft); }
.tag-orange { color: var(--orange); background: var(--orange-soft); }
.tag-red { color: var(--red); background: var(--red-soft); }
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; color: var(--muted); font-size: 12px; }
.pagination-actions { display: flex; align-items: center; gap: 8px; }
.pagination-size { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.pagination-size select { width: 70px; height: 28px; padding: 4px 8px; font-size: 12px; }
.pagination-btn { height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); cursor: pointer; font-size: 12px; }
.pagination-btn:disabled { cursor: not-allowed; color: var(--muted-2); background: #f5f6f8; }
.empty { padding: 44px 24px; text-align: center; }
.drawer-mask { position: fixed; inset: 0; background: rgba(31, 35, 41, 0.32); opacity: 0; pointer-events: none; transition: opacity 0.18s ease; }
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; gap: 16px; padding: 22px 22px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 20px; }
.icon-btn { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }
.drawer-section { padding: 18px 22px; display: grid; gap: 12px; }
.hidden { display: none; }
.wide-input { height: 40px; }
textarea { min-height: 300px; resize: vertical; padding: 12px; line-height: 1.5; }
.drawer-actions { display: flex; justify-content: flex-end; gap: 10px; }
.preview-result { display: grid; gap: 10px; }
.preview-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfbfc; }
.preview-list { margin: 8px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.7; font-size: 13px; }
.inline-error { color: var(--red); font-size: 13px; min-height: 18px; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tracking-metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-grid { grid-template-columns: 1fr; }
  .metric-grid-five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid, .top-rank-grid { grid-template-columns: 1fr; }
  .overview-rates { grid-template-columns: 1fr; }
  .video-overview-grid { grid-template-columns: 1fr; }
  .tracking-chart-grid { grid-template-columns: 1fr; }
  .tracking-chart-head { align-items: flex-start; flex-direction: column; }
  .tracking-legend { flex-wrap: wrap; }
  .distribution-layout { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: 100%; height: auto; }
  .app-shell, .topbar, .top-actions { display: block; }
  .main { margin-left: 0; padding: 16px; }
  .metric-grid { grid-template-columns: 1fr; }
  .tracking-metrics-grid { grid-template-columns: 1fr; }
  .distribution-layout { grid-template-columns: 1fr; }
  .donut-chart { width: 116px; }
}
