:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Microsoft YaHei", sans-serif;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #fbfbfd;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --danger: #dc2626;
  --shadow-sm: 0 8px 24px rgba(15, 23, 42, .05);
  --shadow-md: 0 18px 48px rgba(15, 23, 42, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% -8%, rgba(0, 113, 227, .09), transparent 32rem),
    linear-gradient(180deg, #ffffff 0, var(--bg) 26rem);
  color: var(--text);
}

.app-frame {
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 24px 72px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 -6px 22px;
  padding: 14px 6px;
  background: rgba(247, 248, 251, .78);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(229, 229, 234, .75);
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.brand-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.header-actions a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  color: #303035;
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--line);
  text-decoration: none;
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}

main {
  padding: 14px 0 0;
}

h1 {
  margin: 0 0 10px;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin: 34px 0 14px;
  font-size: 22px;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

p {
  line-height: 1.65;
}

a {
  color: #06c;
}

a.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  white-space: nowrap;
}

a.button:hover,
button:hover {
  background: var(--blue-hover);
}

button[name="delete_channel_id"],
button.danger {
  background: var(--danger);
}

input,
select,
textarea {
  border: 1px solid #d2d2d7;
  border-radius: 12px;
  background: rgba(255,255,255,.96);
  padding: 10px 12px;
  color: var(--text);
  outline: none;
}

select[multiple] {
  border-radius: 14px;
  min-height: 118px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,113,227,.16);
}

label {
  color: #424245;
  font-size: 14px;
  font-weight: 700;
}

code,
pre {
  background: #eef2ff;
  border-radius: 12px;
}

code {
  padding: 2px 6px;
}

pre {
  padding: 14px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #ececf0;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 75px;
  z-index: 5;
  background: #fbfbfd;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

tr:hover td {
  background: #fafafa;
}

.panel {
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 22px;
  padding: 20px;
  margin: 14px 0;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.hero-subtitle,
.muted {
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.metric-card .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card .value {
  margin-top: 8px;
  font-size: 25px;
  font-weight: 850;
  letter-spacing: 0;
}

.metric-card .hint {
  margin-top: 5px;
  color: #86868b;
  font-size: 12px;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.group-card {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 14px;
}

.group-card strong {
  font-size: 18px;
}

.channel-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}

.channel-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: #f5f5f7;
  border: 2px solid var(--line);
  flex: 0 0 auto;
}

.channel-name {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.channel-name a {
  font-weight: 800;
  text-decoration: none;
  color: var(--text);
}

.channel-name a:hover {
  color: #06c;
}

.channel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.region-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.chart {
  height: 210px;
  padding: 16px 10px 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.chart-mixed {
  position: relative;
  overflow: hidden;
}

.bar-layer {
  position: absolute;
  inset: 18px 12px 0;
  display: flex;
  align-items: end;
  gap: 5px;
  z-index: 1;
}

.bar {
  flex: 1;
  min-width: 6px;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, rgba(0,113,227,.86), rgba(125,211,252,.72));
}

.chart svg {
  position: absolute;
  inset: 14px 12px 12px;
  z-index: 2;
  pointer-events: none;
}

.chart polyline {
  fill: none;
  stroke: #111827;
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
}

.alert-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.alert-item {
  border-radius: 14px;
  border: 1px solid #fed7aa;
  background: #fff8eb;
  color: #4d3511;
  padding: 10px 12px;
  font-weight: 700;
}

.alert-item.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.metric-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.metric-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: #f5f5f7;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.metric-tabs a.active {
  background: var(--blue);
  color: #fff;
}

.notice {
  background: #fff8eb;
  border: 1px solid #ffd89b;
  border-radius: 16px;
  padding: 12px 14px;
  color: #4d3511;
}

.ok {
  background: #eafaf0;
  border-color: #9be7b7;
  color: #163b22;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
}

.inline-form input {
  min-width: 170px;
}

.autosave-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 0 0 12px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f5f5f7;
  color: var(--muted);
  font-size: 13px;
}

.autosave-status.saving {
  background: #fff8eb;
  color: #6b4b12;
}

.autosave-status.saved {
  background: #eafaf0;
  color: #176333;
}

.autosave-status.error {
  background: #fff1f2;
  color: #b42318;
}

.qr-card {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 22px;
  align-items: center;
}

.qr-card img {
  width: 100%;
  max-width: 260px;
  border-radius: 18px;
  background: #fff;
  padding: 14px;
  border: 1px solid var(--line);
}

form[method="get"] {
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 1080px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .group-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-frame {
    padding: 14px 14px 48px;
  }

  .app-header,
  .topbar {
    display: block;
  }

  .header-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .qr-card {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.export-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin: 12px 0 18px;
}

.export-overview-card {
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow-sm);
}

.export-overview-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.export-overview-card strong {
  display: block;
  margin-top: 10px;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.export-history table {
  box-shadow: none;
}

.job-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  background: #f5f5f7;
  color: var(--muted);
}

.job-status-success {
  background: #eafaf0;
  color: #176333;
}

.job-status-running {
  background: #eaf3ff;
  color: #075ca8;
}

.job-status-failed {
  background: #fff1f2;
  color: #b42318;
}

@media (max-width: 900px) {
  .export-overview {
    grid-template-columns: 1fr 1fr;
  }
}


.range-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.trend-chip-row,
.channel-trend-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.channel-trend-stack {
  min-width: 190px;
}

.trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.trend-chip b {
  font-weight: 800;
}

.trend-chip em {
  font-style: normal;
  font-weight: 800;
}

.trend-up {
  color: #047857;
  background: #ecfdf5;
  border-color: #bbf7d0;
}

.trend-down {
  color: #b42318;
  background: #fff1f2;
  border-color: #fecdd3;
}

.trend-flat {
  color: #475569;
  background: #f8fafc;
}

.trend-info {
  color: #075985;
  background: #f0f9ff;
  border-color: #bae6fd;
}

.quiet-form {
  box-shadow: none !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
}

.channel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.button.secondary,
a.button.secondary {
  background: #6b7280;
}

.detail-data-table th,
.detail-data-table td {
  white-space: nowrap;
}

.custom-export-form {
  display: grid;
  gap: 16px;
}

.form-grid.compact {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(160px, 220px) minmax(260px, 1fr);
  gap: 14px;
  align-items: start;
}

.metric-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(248, 250, 252, .72);
}

.metric-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #eef0f4;
  font-size: 13px;
}

.weekly-overview-panel .chart {
  margin-top: 14px;
}

@media (max-width: 760px) {
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .channel-actions {
    justify-content: flex-start;
  }

  .channel-trend-stack {
    min-width: 0;
  }
}


.export-job-card {
  position: relative;
  overflow: hidden;
}

.export-job-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #0071e3, #12cdb5);
}

.export-job-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.export-job-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.export-job-grid > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfbfd;
}

.export-job-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.export-job-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.35;
}

@media (max-width: 900px) {
  .export-job-head {
    display: block;
  }
  .export-job-grid {
    grid-template-columns: 1fr 1fr;
  }
}


.channel-detail-hero {
  position: relative;
  overflow: hidden;
  border-color: rgba(0, 113, 227, .12);
  background:
    radial-gradient(circle at 8% 0%, rgba(0, 113, 227, .08), transparent 28%),
    linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,250,252,.92));
}

.channel-detail-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.06;
}

.detail-range-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.range-pill.active {
  background: #111827;
  color: #fff;
}

.detail-health-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.detail-health-chip,
.data-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #475569;
  white-space: nowrap;
}

.detail-health-chip.ok,
.data-status.status-ok {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: #047857;
}

.detail-health-chip.warn,
.data-status.status-warn {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.data-status.status-empty {
  border-color: #e5e7eb;
  background: #f1f5f9;
  color: #64748b;
}

.data-status.status-muted {
  border-color: #ddd6fe;
  background: #f5f3ff;
  color: #6d28d9;
}

.detail-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.detail-table-wrap table {
  margin: 0;
  border: 0;
  box-shadow: none;
}

.detail-table-wrap th:first-child,
.detail-table-wrap td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: inherit;
}

.detail-table-wrap th:first-child {
  z-index: 2;
}

.chart-mixed::after {
  content: "";
  position: absolute;
  inset: auto 12px 28px;
  height: 1px;
  background: #e5e7eb;
  z-index: 0;
}

@media (max-width: 720px) {
  .channel-detail-hero h1 {
    font-size: 30px;
  }

  .detail-range-actions,
  .detail-health-row {
    gap: 6px;
  }
}


.anchor-point {
  display: block;
  scroll-margin-top: 96px;
}

button:disabled,
button.is-loading {
  opacity: .72;
  cursor: progress;
  filter: saturate(.9);
}

button.is-loading::after {
  content: "";
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.55);
  border-top-color: #fff;
  animation: spin .75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.export-history,
.custom-export-panel {
  position: relative;
  overflow: hidden;
}

.export-history::before,
.custom-export-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, #0071e3, #34c759, transparent);
}

.detail-table-wrap,
.panel table {
  scrollbar-width: thin;
}

.panel > table,
.detail-table-wrap table {
  font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}


.export-command-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  margin: 18px 0 22px;
}

.export-command-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 18px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 22px;
  background: linear-gradient(180deg, #fff, #f8fafc);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .08);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.export-command-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .12);
  border-color: rgba(0, 113, 227, .22);
}

.export-command-card.primary {
  color: #fff;
  background: linear-gradient(145deg, #111827, #0f5fd7 58%, #0071e3);
}

.export-command-card span {
  width: 38px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 113, 227, .11);
  color: #0066cc;
  font-weight: 900;
  font-size: 12px;
}

.export-command-card.primary span {
  background: rgba(255,255,255,.18);
  color: #fff;
}

.export-command-card strong {
  font-size: 18px;
  letter-spacing: 0;
}

.export-command-card em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.5;
}

.export-command-card.primary em {
  color: rgba(255,255,255,.82);
}

.export-task-panel {
  scroll-margin-top: 92px;
}

.chart-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
}

.chart-heading-row h2 {
  margin: 0;
}

.channel-detail-export {
  display: flex;
  justify-content: flex-end;
}

.channel-detail-export button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
}

.chart-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin: 14px 0 12px;
}

.chart-summary-grid > div {
  padding: 12px 14px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 16px;
  background: #fbfbfd;
}

.chart-summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chart-summary-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
  color: var(--text);
}

.chart-summary-grid .trend-up { color: #047857; }
.chart-summary-grid .trend-down { color: #dc2626; }
.chart-summary-grid .trend-flat { color: #64748b; }

.chart-shell {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  grid-template-rows: minmax(260px, 34vh) auto;
  gap: 8px 12px;
  margin-top: 14px;
  padding: 12px 12px 10px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 22px;
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.chart-y-axis {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding: 7px 0 28px;
  color: #64748b;
  font-size: 12px;
  font-weight: 750;
}

.chart-enhanced {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  min-height: 260px;
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
}

.chart-grid-lines {
  position: absolute;
  inset: 8px 10px 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.chart-grid-lines i {
  display: block;
  border-top: 1px dashed #e5e7eb;
}

.chart-enhanced .bar-layer {
  position: absolute;
  inset: 12px 12px 28px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  z-index: 1;
}

.chart-enhanced .bar {
  flex: 1 1 4px;
  min-width: 3px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, rgba(0,113,227,.42), rgba(0,113,227,.12));
}

.chart-enhanced svg {
  position: absolute;
  inset: 8px 10px 28px;
  width: calc(100% - 20px);
  height: calc(100% - 36px);
  overflow: visible;
  z-index: 2;
}

.chart-enhanced polyline {
  fill: none;
  stroke: #0071e3;
  stroke-width: 2.1;
  vector-effect: non-scaling-stroke;
}

.chart-enhanced circle {
  fill: #fff;
  stroke: #0071e3;
  stroke-width: 1.9;
  vector-effect: non-scaling-stroke;
}

.chart-point-label {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 3;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(17, 24, 39, .9);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .18);
}

.chart-x-axis {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #64748b;
  font-size: 12px;
  font-weight: 750;
  padding: 0 6px;
}

@media (max-width: 1100px) {
  .export-command-grid,
  .chart-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .export-command-grid,
  .chart-summary-grid {
    grid-template-columns: 1fr;
  }

  .chart-heading-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-shell {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .chart-y-axis,
  .chart-x-axis {
    font-size: 11px;
  }
}


/* 2026-06 refined operations console */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #111113;
  --muted: #6b7280;
  --line: #e8e8ed;
  --blue: #0071e3;
  --ink: #0b0b0f;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .05);
  --shadow-md: 0 16px 54px rgba(16, 24, 40, .08);
}

body {
  background: linear-gradient(180deg, #fff 0, #f7f7f9 360px, #f5f5f7 100%);
  letter-spacing: 0;
}

.app-frame {
  max-width: 1440px;
  padding: 18px 28px 80px;
}

.app-header {
  margin: 0 0 26px;
  padding: 12px 16px;
  border: 1px solid rgba(17, 17, 19, .06);
  border-radius: 24px;
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 12px 36px rgba(17, 17, 19, .06);
}

.brand-block {
  display: grid;
  gap: 2px;
}

.brand {
  font-size: 19px;
  font-weight: 850;
  letter-spacing: 0;
}

.brand::before {
  content: "";
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 9px;
  border-radius: 50%;
  background: #111113;
  box-shadow: 15px 0 0 #0071e3;
}

.header-actions a {
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #3f3f46;
  font-size: 14px;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}

.header-actions a::before {
  content: attr(data-icon);
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f1f5f9;
  color: #111827;
  font-size: 11px;
  font-weight: 900;
}

.header-actions a:hover {
  background: #f5f5f7;
  color: #000;
  transform: translateY(-1px);
}

.hero-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: stretch;
  margin: 16px 0 24px;
  padding: clamp(26px, 4vw, 52px);
  border: 1px solid rgba(17, 17, 19, .06);
  border-radius: 32px;
  background: linear-gradient(145deg, #ffffff, #f7f8fb);
  box-shadow: var(--shadow-md);
}

.section-kicker {
  margin: 0 0 10px;
  color: #0071e3;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.hero-dashboard h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(40px, 6vw, 76px);
  line-height: .96;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.hero-dashboard .hero-subtitle {
  max-width: 760px;
  margin: 20px 0 0;
  color: #4b5563;
  font-size: 18px;
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.hero-status-card {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 220px;
  padding: 22px;
  border-radius: 26px;
  color: #fff;
  background: radial-gradient(circle at 0 0, rgba(255,255,255,.22), transparent 34%), linear-gradient(160deg, #111827, #030712);
}

.hero-status-card span {
  color: rgba(255,255,255,.68);
  font-size: 12px;
  font-weight: 850;
}

.hero-status-card strong {
  margin-top: 8px;
  font-size: 42px;
  line-height: 1;
}

.hero-status-card p {
  margin-bottom: 0;
  color: rgba(255,255,255,.78);
}

.panel,
form[method="get"] {
  border: 1px solid rgba(17, 17, 19, .07);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: 22px;
}

.section-heading-row,
.table-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.section-heading-row h2,
.table-title-row h3 {
  margin: 0;
}

.channel-management-shell {
  margin-top: 24px;
}

.management-summary-grid,
.export-overview {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.management-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(5, minmax(130px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin: 16px 0 20px;
  padding: 14px;
}

.management-toolbar label {
  font-size: 12px;
  color: #71717a;
}

.management-toolbar input,
.management-toolbar select,
.channel-table select {
  width: 100%;
  min-height: 40px;
  border-radius: 14px;
  font-size: 14px;
  background: #fff;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

a.button.secondary,
button.secondary {
  background: #f4f4f5;
  color: #111113;
  border: 1px solid #e4e4e7;
}

a.button.secondary:hover,
button.secondary:hover {
  background: #eaeaec;
}

.channel-table-panel {
  padding: 0;
  overflow: hidden;
}

.channel-table-panel .table-title-row {
  padding: 22px 22px 10px;
}

.table-scroll {
  overflow: auto;
  border-top: 1px solid var(--line);
}

.channel-table {
  min-width: 1320px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.channel-table th {
  top: 83px;
  background: rgba(250,250,252,.96);
  color: #71717a;
  font-size: 12px;
  text-transform: none;
  white-space: nowrap;
}

.channel-table td {
  padding: 11px 12px;
  font-size: 14px;
}

.channel-table tr:hover td {
  background: #fbfdff;
}

.channel-cell {
  min-width: 260px;
}

.channel-avatar {
  width: 42px;
  height: 42px;
  border-width: 2px;
  box-shadow: 0 0 0 4px #fff;
}

.channel-name a {
  font-weight: 850;
}

.number-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
  background: #f4f4f5;
  color: #3f3f46;
}

.status-unlocked { background: #ecfdf5; color: #047857; }
.status-reviewing { background: #eff6ff; color: #1d4ed8; }
.status-active { background: #fff7ed; color: #c2410c; }
.status-abandoned,
.status-abandoned-ypp { background: #fef2f2; color: #b91c1c; }

.subtle-danger {
  min-height: 34px;
  padding: 0 12px;
  box-shadow: none;
}

.export-command-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.export-command-card {
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
}

.chart-shell,
.chart-summary-grid > div {
  border-color: rgba(17, 17, 19, .07);
  box-shadow: var(--shadow-sm);
}

.permission-panel pre {
  max-height: 220px;
  background: #f8fafc;
}

@media (max-width: 1180px) {
  .hero-dashboard,
  .management-toolbar {
    grid-template-columns: 1fr;
  }
  .management-summary-grid,
  .export-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-frame {
    padding: 12px 14px 60px;
  }
  .app-header,
  .section-heading-row,
  .table-title-row {
    flex-direction: column;
  }
  .hero-dashboard {
    padding: 26px;
    border-radius: 26px;
  }
  .hero-dashboard h1 {
    font-size: 42px;
  }
  .management-summary-grid,
  .export-overview {
    grid-template-columns: 1fr;
  }
}


/* 2026-06-23: table stability and display bug fixes */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.brand::before {
  content: "";
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-right: 0;
  border-radius: 999px;
  background: radial-gradient(circle at 32% 34%, #111113 0 36%, transparent 37%),
    radial-gradient(circle at 68% 66%, #0071e3 0 38%, transparent 39%),
    #eef5ff;
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.12);
}

/* Keep sticky headers scoped to scrollable data tables only. */
table th {
  position: static;
  top: auto;
}

.table-scroll {
  max-height: min(72vh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
  position: relative;
}

.channel-table {
  border-collapse: separate;
  border-spacing: 0;
}

.channel-table th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 250, 252, 0.98);
  backdrop-filter: blur(18px);
  box-shadow: inset 0 -1px 0 var(--line);
}

.channel-table th:first-child,
.channel-table td:first-child {
  position: sticky;
  left: 0;
}

.channel-table th:first-child {
  z-index: 30;
  background: rgba(250, 250, 252, 0.98);
}

.channel-table td:first-child {
  z-index: 8;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.04);
}

.channel-table tbody tr:hover td:first-child {
  background: #fbfdff;
}

.channel-table .channel-cell {
  min-width: 280px;
}

.channel-table select {
  min-width: 108px;
}

.detail-table-wrap {
  max-height: min(70vh, 720px);
  overflow: auto;
  overscroll-behavior: contain;
  position: relative;
}

.detail-data-table {
  border-collapse: separate;
  border-spacing: 0;
}

.detail-data-table th {
  position: sticky;
  top: 0;
  z-index: 16;
  background: rgba(250, 250, 252, 0.98);
  backdrop-filter: blur(16px);
  box-shadow: inset 0 -1px 0 var(--line);
}

.detail-table-wrap th:first-child,
.detail-table-wrap td:first-child {
  position: sticky;
  left: 0;
}

.detail-table-wrap th:first-child {
  z-index: 24;
  background: rgba(250, 250, 252, 0.98);
}

.detail-table-wrap td:first-child {
  z-index: 6;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.04);
}


/* 2026-06-23: channel management full-page sticky header */
.channel-table-panel {
  overflow: visible;
}

.channel-table-panel .table-scroll {
  max-height: none;
  overflow-x: auto;
  overflow-y: visible;
}

.channel-table th {
  top: 72px;
}

.channel-table th:first-child {
  top: 72px;
}

.channel-table td:first-child {
  background: rgba(255, 255, 255, 0.985);
}

/* 2026-06-24: drama library release binding */
.compact-hero {
  grid-template-columns: minmax(0, 1fr) 260px;
}

.release-link-panel textarea {
  width: 100%;
  box-sizing: border-box;
}

.release-thumb {
  width: 96px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f4f4f5;
  display: block;
}

.release-table td:first-child,
.release-table th:first-child {
  min-width: 120px;
}

.duplicate-warning {
  border-color: #fecaca;
  background: #fff1f2;
  color: #7f1d1d;
}

.table-scroll.mini {
  max-height: 260px;
  margin-top: 12px;
}

@media (max-width: 760px) {
  .compact-hero {
    grid-template-columns: 1fr;
  }
  .release-thumb {
    width: 120px;
  }
}
.library-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

.action-card-form {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.action-card-form h3 {
  margin: 0;
}

.inline-bind-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(110px, .7fr) minmax(110px, .7fr) minmax(110px, .7fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 760px;
}

.inline-bind-form input {
  min-width: 0;
}

@media (max-width: 980px) {
  .library-action-grid {
    grid-template-columns: 1fr;
  }
  .inline-bind-form {
    grid-template-columns: 1fr;
    min-width: 280px;
  }
}
.library-search-form {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  max-width: 760px;
}

.library-search-form input {
  flex: 1;
  min-width: 220px;
}

.library-main-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.drama-result-list {
  display: grid;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.drama-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  background: #fff;
}

.drama-result-row:hover,
.drama-result-row.active {
  border-color: #0071e3;
  background: #f5faff;
}

.drama-result-row strong {
  grid-column: 1 / -1;
}

.drama-result-row span,
.drama-result-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.drama-detail-panel h2 {
  margin-top: 0;
}

.maintenance-tools {
  background: #fbfbfd;
}

@media (max-width: 980px) {
  .library-main-grid {
    grid-template-columns: 1fr;
  }
  .library-search-form {
    flex-direction: column;
  }
}

/* 2026-06-30: operator settings and compact channel table controls */
.operator-settings-panel {
  margin-top: 18px;
}

.operator-settings-form {
  display: grid;
  grid-template-columns: minmax(280px, 520px) auto;
  gap: 14px;
  align-items: end;
  padding: 0 22px 22px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.operator-settings-form textarea {
  min-height: 128px;
  resize: vertical;
  line-height: 1.7;
}

.channel-table td select {
  max-width: 138px;
}

@media (max-width: 720px) {
  .operator-settings-form {
    grid-template-columns: 1fr;
  }
}


/* Multi-user operations refresh */
.operator-overview-panel {
  margin: 24px 0;
}

.section-heading-row.compact {
  margin-bottom: 14px;
}

.channel-card-panel {
  overflow: visible;
}

.channel-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.channel-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.channel-card.issue-danger {
  border-color: #fecaca;
  box-shadow: 0 14px 36px rgba(220, 38, 38, .08);
}

.channel-card.issue-warning {
  border-color: #fed7aa;
}

.channel-card:target {
  outline: 3px solid rgba(0, 113, 227, .22);
  scroll-margin-top: 96px;
}

.channel-card-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.channel-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  background: #eef2ff;
  border: 1px solid var(--line);
}

.channel-card-title {
  min-width: 0;
}

.channel-card-title a {
  display: block;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-card-title span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.issue-pill {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.issue-ok { color: #047857; background: #d1fae5; }
.issue-warning { color: #b45309; background: #ffedd5; }
.issue-danger { color: #b91c1c; background: #fee2e2; }

.channel-card-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.channel-card-metrics div {
  background: var(--surface-soft);
  border: 1px solid #ececf0;
  border-radius: 10px;
  padding: 10px;
  min-width: 0;
}

.channel-card-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.channel-card-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.channel-card-tags,
.channel-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.soft-tag,
.read-only-value {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

.channel-card-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.channel-card-controls label {
  display: grid;
  gap: 6px;
}

.channel-card-controls select,
.channel-card-controls .read-only-value {
  width: 100%;
}

.channel-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-top: 1px solid #ececf0;
  padding-top: 12px;
}

.inline-form {
  display: inline-flex;
  margin: 0 6px 6px 0;
}

.admin-user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.notice.danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

@media (max-width: 760px) {
  .channel-card-grid {
    grid-template-columns: 1fr;
  }

  .channel-card-head {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .issue-pill {
    grid-column: 1 / -1;
    width: fit-content;
  }

  .channel-card-metrics,
  .channel-card-controls,
  .admin-user-form {
    grid-template-columns: 1fr 1fr;
  }

  .channel-card-foot {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .channel-card-metrics,
  .channel-card-controls,
  .admin-user-form {
    grid-template-columns: 1fr;
  }
}
