:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #dfe4ec;
  --text: #182230;
  --body: #344054;
  --muted: #667085;
  --blue: #2563eb;
  --blue-soft: #edf3ff;
  --green: #14805e;
  --green-soft: #e8f7f1;
  --amber: #a15c00;
  --amber-soft: #fff4df;
  --red: #c9363e;
  --red-soft: #fdeced;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--body); font-size: 14px; letter-spacing: 0; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { min-height: 42px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--body); padding: 0 14px; font-weight: 750; cursor: pointer; }
button.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
button.danger { border-color: var(--red); background: var(--red); color: #fff; }
button:disabled { opacity: .55; cursor: wait; }
input, textarea { width: 100%; border: 1px solid #cfd6e2; border-radius: 7px; background: #fff; color: var(--text); padding: 11px 12px; outline: none; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
label { display: grid; gap: 7px; color: var(--body); font-size: 13px; font-weight: 700; }
h1, h2, p { margin: 0; }

.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: #fff; }
.login-form { width: min(100%, 390px); display: grid; gap: 18px; }
.login-form > img { width: 52px; height: 52px; object-fit: contain; }
.login-form h1 { color: var(--text); font-size: 24px; }
.login-form p { margin-top: 4px; color: var(--muted); }
.error { min-height: 18px; color: var(--red) !important; font-size: 12px; }

.mobile-app { min-height: 100dvh; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.app-header { position: sticky; top: 0; z-index: 20; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .97); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand-line { min-width: 0; display: flex; align-items: center; gap: 9px; }
.brand-line img { width: 34px; height: 34px; object-fit: contain; }
.brand-line div { min-width: 0; display: grid; }
.brand-line strong { color: var(--text); font-size: 15px; white-space: nowrap; }
.brand-line span { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; gap: 7px; }
.header-actions button { min-height: 36px; padding: 0 10px; font-size: 12px; }
.header-actions button.enabled { border-color: var(--green); background: var(--green-soft); color: var(--green); }

.status-band { padding: 16px; background: #fff; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-bottom: 1px solid var(--line); }
.status-band > div:not(.sync-state) { min-width: 0; display: flex; align-items: baseline; gap: 7px; }
.status-band strong { color: var(--text); font-size: 26px; }
.status-band span { color: var(--muted); font-size: 12px; }
.sync-state { grid-column: 1 / -1; color: var(--green); font-size: 12px; }

.tabs { position: sticky; top: calc(61px + env(safe-area-inset-top)); z-index: 15; display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fff; }
.tabs button { position: relative; border: 0; border-radius: 0; background: transparent; color: var(--muted); }
.tabs button.active { color: var(--blue); box-shadow: inset 0 -2px 0 var(--blue); }
.tab-badge { display: inline-grid; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 5px; place-items: center; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; }
.tab-badge:empty, .tab-badge[data-count="0"] { display: none; }

.view { display: none; }
.view.active { display: block; }
.range-switch { margin: 14px 12px 0; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; }
.range-switch button { min-height: 38px; border: 0; border-right: 1px solid var(--line); border-radius: 0; padding: 0 8px; color: var(--muted); font-size: 12px; }
.range-switch button:last-child { border-right: 0; }
.range-switch button.active { background: var(--blue-soft); color: var(--blue); }
.section-bar { padding: 16px 16px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-bar h2 { color: var(--text); font-size: 16px; }
.section-bar span { color: var(--muted); font-size: 12px; }
.record-list { padding: 0 12px 12px; display: grid; gap: 10px; }
.kpi-grid { padding: 0 12px 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { min-width: 0; min-height: 94px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 13px; display: grid; align-content: space-between; gap: 5px; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { color: var(--text); font-size: 24px; overflow-wrap: anywhere; }
.metric small { color: var(--muted); font-size: 11px; }
.platform-list { padding: 0 12px 6px; display: grid; gap: 8px; }
.platform-row { border-top: 1px solid var(--line); background: #fff; padding: 12px 4px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.platform-row:first-child { border-top: 0; }
.platform-row strong { color: var(--text); }
.platform-row b { color: var(--blue); font-size: 16px; }
.platform-row span { color: var(--muted); font-size: 11px; }
.rank-list, .video-rank-list { margin: 0 12px; border-top: 1px solid var(--line); background: #fff; }
.rank-row { min-width: 0; padding: 12px 4px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.rank-row .rank-index { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #f2f4f7; color: var(--muted); font-size: 11px; font-weight: 800; }
.rank-row:nth-child(-n+3) .rank-index { background: var(--blue-soft); color: var(--blue); }
.rank-copy { min-width: 0; display: grid; gap: 3px; }
.rank-copy strong { color: var(--text); overflow-wrap: anywhere; }
.rank-copy span { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.rank-value { min-width: 52px; text-align: right; display: grid; gap: 2px; }
.rank-value b { color: var(--text); font-size: 17px; }
.rank-value span { color: var(--muted); font-size: 10px; }
.video-rank { padding: 13px 4px; border-bottom: 1px solid var(--line); display: grid; gap: 9px; }
.video-rank-head { min-width: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.video-rank-head div { min-width: 0; display: grid; gap: 3px; }
.video-rank-head strong { color: var(--text); line-height: 1.45; overflow-wrap: anywhere; }
.video-rank-head span, .video-rank-meta span { color: var(--muted); font-size: 11px; }
.video-rank-head b { flex: 0 0 auto; color: var(--blue); font-size: 17px; }
.video-rank-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.video-rank-meta div { min-width: 0; display: grid; gap: 2px; }
.video-rank-meta strong { color: var(--body); font-size: 12px; overflow-wrap: anywhere; }
.record-card { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 14px; display: grid; gap: 12px; }
.record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.record-head > div { min-width: 0; }
.record-head h3 { margin: 0; color: var(--text); font-size: 16px; overflow-wrap: anywhere; }
.record-head p { margin-top: 4px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.badge { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 25px; border-radius: 999px; padding: 0 9px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 800; }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.danger { background: var(--red-soft); color: var(--red); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.detail-grid div { min-width: 0; display: grid; gap: 2px; }
.detail-grid span { color: var(--muted); font-size: 11px; }
.detail-grid strong, .detail-grid a { color: var(--body); font-size: 13px; overflow-wrap: anywhere; text-decoration: none; }
.record-note { padding: 10px; border-left: 3px solid var(--line); background: #f8fafc; color: var(--body); font-size: 12px; line-height: 1.6; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card-actions button[data-action="approve"] { border-color: var(--blue); background: var(--blue); color: #fff; }
.card-actions button[data-action="reject"], .card-actions button[data-action="suspend"], .card-actions button[data-action="delete-unactivated"] { color: var(--red); }
.empty-state { padding: 36px 20px; text-align: center; color: var(--muted); }

.search-row { padding: 14px 12px 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.search-row button { min-width: 68px; }
footer { padding: 24px 16px; }
footer button { width: 100%; color: var(--muted); }

dialog { width: min(calc(100% - 24px), 520px); max-height: calc(100dvh - 24px); border: 0; border-radius: 8px; padding: 0; color: var(--body); }
dialog::backdrop { background: rgba(16, 24, 40, .48); }
dialog form { padding: 18px; display: grid; gap: 15px; overflow-y: auto; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { color: var(--text); font-size: 18px; }
.dialog-head button { min-height: 34px; padding: 0 9px; }
.dialog-context { padding: 10px 12px; background: var(--blue-soft); color: var(--body); line-height: 1.55; font-size: 13px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog form > button.primary, dialog form > button.danger { width: 100%; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); width: min(calc(100% - 32px), 430px); transform: translate(-50%, 20px); border-radius: 7px; background: #182230; color: #fff; padding: 12px 14px; opacity: 0; pointer-events: none; transition: .18s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (min-width: 700px) {
  .mobile-app { width: 680px; margin: 0 auto; border-inline: 1px solid var(--line); background: var(--bg); }
}

@media (max-width: 370px) {
  .app-header { align-items: flex-start; }
  .header-actions { display: grid; }
  .header-actions button { min-height: 31px; }
  .detail-grid, .field-grid { grid-template-columns: 1fr; }
}
