:root {
  color-scheme: light;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #20283a;
  background: #f4f5fa;
  --navy: #19233b;
  --ink: #20283a;
  --muted: #606d83;
  --accent: #5045c7;
  --border: #dce1eb;
  --surface: #fff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.workspace { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow: auto; background: var(--navy); color: #e9edfa; padding: 25px 16px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 1.08rem; font-weight: 720; padding: 0 4px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: #6e62ed; color: white; font-weight: 750; }
.project-picker { margin: 31px 0 25px; padding: 0 4px; }
.project-picker label, .nav-group > p { color: #aeb9d5; font-size: .875rem; margin: 0 0 8px; }
.project-picker select { width: 100%; background-color: #263452; border-color: #445573; color: #fff; }
.nav-group { margin-bottom: 23px; }
.nav-group > p { padding-left: 9px; }
.nav-group a, .planned summary { display: block; color: #dce4f6; font-size: .9375rem; text-decoration: none; padding: 9px 11px; border-radius: 7px; margin: 2px 0; cursor: pointer; }
.nav-group a:hover, .planned summary:hover { background: #293958; }
.nav-group a[aria-current] { background: #3e3e79; color: #fff; font-weight: 650; box-shadow: inset 3px 0 #a69aff; }
.planned summary { display: list-item; }
.planned ul { list-style: none; margin: 0; padding: 5px 12px 4px 24px; color: #aeb9d5; font-size: .875rem; }
.planned li { margin: 0 0 8px; }
.work-area { min-width: 0; }
.topbar { min-height: 61px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px clamp(16px, 3vw, 42px); background: var(--surface); border-bottom: 1px solid var(--border); }
.breadcrumb { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: .9375rem; }
.breadcrumb strong { color: var(--ink); }
#report-zone { color: var(--muted); font-size: .875rem; text-align: right; }
main { min-width: 0; padding: 29px clamp(16px, 1.5vw, 28px) 52px; }
main[data-route="sync"], main[data-route="settings"], main[data-route="users"] {
  max-width: 1660px;
  margin-inline: auto;
  padding-inline: clamp(16px, 3vw, 42px);
}
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
h1 { margin: 0; font-size: clamp(1.68rem, 3vw, 2.22rem); line-height: 1.15; letter-spacing: -.02em; }
.page-heading p { color: var(--muted); font-size: .9375rem; margin: 9px 0 0; }
h2 { font-size: 1.08rem; margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
#date-panel { margin-bottom: 21px; }
form, .report-controls, .report-pager { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
label { display: grid; gap: 5px; color: #48566d; font-size: .875rem; }
select, input, button, textarea { font: inherit; padding: 8px 10px; border-radius: 7px; border: 1px solid #b7c1d4; background-color: var(--surface); color: var(--ink); }
select { appearance: none; padding-right: 30px; }
select { background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
button { color: white; border-color: var(--accent); background-color: var(--accent); cursor: pointer; font-size: .9rem; font-weight: 620; white-space: nowrap; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid #756af2; outline-offset: 3px; }
.date-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.date-presets button, .report-pager button, #ad-body td:last-child button { background: #f1f0ff; color: #4035a7; border-color: #dedbfb; }
#status, #ad-status, #analytics-status { color: var(--muted); font-size: .875rem; margin-bottom: 0; }
#ad-status { margin: 12px 0; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid #7869e4; border-radius: 11px; padding: 14px 15px; }
.metric strong { display: block; overflow-wrap: anywhere; font-size: clamp(1.2rem, 2.65vw, 2rem); letter-spacing: -.035em; font-variant-numeric: tabular-nums; margin: 5px 0; }
.metric span { display: block; font-size: .875rem; color: var(--muted); }
.report-panel { padding: 0; overflow: hidden; }
.panel-heading { padding: 15px 16px; }
.table-frame { background: #fff; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.report-panel .table-frame { border: 0; border-radius: 0; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; white-space: nowrap; }
th, td { padding: 11px 14px; text-align: right; font-size: .875rem; }
th { background: #eef0f8; color: #475471; }
th:first-child, td:first-child { text-align: left; }
td { border-top: 1px solid #e7ebf2; }
tbody tr:nth-child(even) { background: #fafaff; }
tfoot tr { background: #eef0f8; font-weight: 650; }
.report-pager { margin-top: 12px; align-items: center; }
#ad-body td:last-child button + button { margin-left: 6px; }
#ad-columns { display: grid; grid-template-columns: repeat(2, minmax(100px, 1fr)); gap: 5px; padding: 8px 0; }
#ad-columns label, #game-settings .check { display: flex; align-items: center; }
.report-controls summary { cursor: pointer; padding: 8px 0; font-size: .9rem; }
#game-settings form { display: grid; grid-template-columns: repeat(auto-fit, minmax(225px, 1fr)); align-items: start; margin-top: 12px; }
#game-settings fieldset { grid-column: 1 / -1; border: 1px solid var(--border); display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); }
#game-settings textarea, #game-settings input, #game-settings select { width: 100%; }
#game-settings input[type=checkbox] { width: auto; }
#runs { margin: 0; padding-left: 20px; }
#runs li { margin-bottom: 9px; overflow-wrap: anywhere; }
@media (max-width: 1000px) {
  .workspace { grid-template-columns: 196px minmax(0, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .workspace { display: block; }
  .sidebar { position: static; height: auto; padding: 14px 15px; }
  .project-picker { margin: 12px 0 8px; }
  #navigation { display: flex; overflow: auto; gap: 12px; }
  .nav-group { min-width: max-content; margin: 4px 0 0; }
  .nav-group a, .planned summary { padding-block: 6px; }
  .topbar { padding: 10px 15px; }
  main { padding-top: 20px; }
  .page-heading { align-items: start; }
}
#daily-coverage { margin: 6px 0 0; color: var(--muted); font-size: .875rem; }
#daily-panel th:first-child, #daily-panel td:first-child { position: sticky; left: 0; }
#daily-panel td:first-child { background: #fff; box-shadow: 1px 0 var(--border); }
#cohort-status, #cohort-sort-note { color: var(--muted); font-size: .875rem; margin: 12px 0; }
#cohort-table th:first-child, #cohort-table td:first-child { position: sticky; left: 0; }
#cohort-table td:first-child { background: #fff; box-shadow: 1px 0 var(--border); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
#session-name { color: var(--ink); font-size: .875rem; }
#logout, .secondary { background-color: var(--surface); border-color: var(--border); color: var(--accent); }
#user-form { margin: 16px 0; padding: 14px; background: #f4f5fb; border-radius: 8px; }
#user-form .check { display: flex; align-items: center; margin-bottom: 6px; }
#users-status, #login-status { font-size: .875rem; color: var(--muted); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: #19233b; }
.login-card { width: min(100%, 420px); margin: 0; padding: 32px; border-radius: 16px; background: var(--surface); }
.login-card h1 { margin: 16px 0 21px; font-size: 1.65rem; }
.login-card form { display: grid; align-items: stretch; gap: 14px; }
.login-card input { width: 100%; }
.login-card button { margin-top: 6px; }
.login-card #login-status { color: #942f44; min-height: 21px; margin-bottom: 0; }
@media (max-width: 540px) {
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
  .topbar-actions #report-zone { display: none; }
}
.country-picker { position: relative; z-index: 3; flex: 0 0 auto; max-width: 100%; }
.country-options { position: absolute; top: 100%; left: 0; width: min(310px, 80vw); padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px #19233b25; }
.country-choices { max-height: 245px; overflow: auto; margin: 8px 0; }
.country-choices label { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 8px; padding: 4px 0; }
.country-choices label span { overflow-wrap: anywhere; }
.country-options input[type="search"] { width: 100%; min-width: 0; }
.report-controls .country-picker-label {
  display: list-item;
  min-width: 132px;
  padding: 8px 12px;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}
#cohort-campaign-picker .country-picker-label { min-width: 166px; }
#cohort-campaign-picker .country-options { width: min(560px, calc(100vw - 520px)); }
@media (max-width: 900px) {
  .report-controls:has(.country-picker) { position: relative; }
  .country-picker { position: static; }
  #cohort-campaign-picker .country-options { width: min(560px, 100%); }
}
.sort-column { display: inline-flex; align-items: center; gap: 4px; padding: 0; background: transparent; color: inherit; border: 0; border-radius: 3px; font: inherit; font-weight: inherit; }
.sort-column span { color: var(--muted); font-size: .82rem; }
th[aria-sort] .sort-column, th[aria-sort] .sort-column span { color: var(--accent); }

.cohort-combined { font-weight: 650; }
.cohort-combined span { display: block; margin-top: 4px; color: var(--muted); font-size: .8rem; font-weight: 400; }

.report-scroll {
  max-height: max(min(52dvh, 22rem), var(--report-available-height, 62dvh));
  overscroll-behavior-y: contain;
}
.report-scroll thead th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px var(--border); }
#daily-panel .report-scroll thead th:first-child,
#cohort-table thead th:first-child { z-index: 3; }
#daily-panel .report-scroll td:first-child,
#cohort-table td:first-child { z-index: 1; }

td[data-profit-sign="1"] { color: #21724f; }
td[data-profit-sign="-1"] { color: #a23d50; }

.login-intro { color: var(--muted); margin: 0 0 20px; }
.login-card a { color: var(--accent); }
.privacy-card { width: min(100%, 720px); }
.privacy-card h2 { font-size: 1.1rem; margin-top: 22px; }
