:root {
  color-scheme: light;
  --page: #f4f5f7;
  --surface: #ffffff;
  --text: #18212f;
  --muted: #697386;
  --line: #e1e5ea;
  --accent: #c8102e;
  --dark: #2c2c2c;
  --soft: #f8f9fa;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--text);
  background: var(--page);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; }
.dashboard-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 28px; }
.dashboard-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.brand { margin: 0 0 6px; color: var(--accent); font-size: 13px; font-weight: 700; }
h1 { margin: 0; font-size: clamp(26px, 4vw, 38px); line-height: 1.2; letter-spacing: -.03em; }
.muted, .panel-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 18px; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.admin-nav a { padding: 6px 10px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 12px; text-decoration: none; }
.admin-nav a:hover, .admin-nav a.active { border-color: var(--accent); color: var(--accent); }
.toolbar { display: grid; grid-template-columns: auto 148px 72px 72px; align-items: center; gap: 8px; }
.toolbar label { color: var(--muted); font-size: 12px; }
select, button { min-height: 38px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); }
select { padding: 0 30px 0 10px; }
button { padding: 0 14px; background: var(--dark); color: #fff; border-color: var(--dark); cursor: pointer; }
.secondary-button { background: var(--surface); color: var(--text); border-color: var(--line); }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid rgb(200 16 46 / 20%); outline-offset: 2px; }
.error-message { margin: 0 0 16px; padding: 12px 14px; border: 1px solid #efc8ce; border-radius: 6px; background: #fff6f7; color: #a51e35; font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric-grid article, .panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.metric-grid article { padding: 18px; }
.metric-grid span { display: block; color: var(--muted); font-size: 12px; }
.metric-grid strong { display: block; margin-top: 8px; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.operations-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.operations-grid article { min-width: 0; padding: 16px 18px; background: var(--surface); }
.operations-grid span, .operations-grid small { display: block; color: var(--muted); font-size: 11px; }
.operations-grid strong { display: block; margin: 8px 0 6px; font-size: 23px; line-height: 1; font-variant-numeric: tabular-nums; }
.panel { margin-top: 16px; overflow: hidden; }
.panel-heading { min-height: 70px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 15px; line-height: 22px; }
.panel-note { margin: 0; padding: 11px 18px 14px; color: var(--muted); font-size: 11px; line-height: 17px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
th, td { min-width: 88px; padding: 11px 18px; border-bottom: 1px solid var(--line); text-align: left; font-variant-numeric: tabular-nums; }
th { color: var(--muted); background: var(--soft); font-weight: 500; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
.empty-cell { padding: 28px 18px; color: var(--muted); text-align: center; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; }
.session-key, .trend-session { background: #475569; }
.click-key, .trend-click { background: var(--accent); }
.trend-chart { min-height: 210px; padding: 22px 18px 14px; display: flex; align-items: stretch; gap: 10px; overflow-x: auto; }
.trend-day { min-width: 46px; flex: 1 0 46px; display: grid; grid-template-rows: 160px auto; gap: 8px; }
.trend-bars { display: flex; align-items: end; justify-content: center; gap: 4px; border-bottom: 1px solid var(--line); }
.trend-bar { width: 12px; min-height: 2px; border-radius: 2px 2px 0 0; }
.trend-label { color: var(--muted); font-size: 10px; text-align: center; }
footer { padding: 22px 4px 0; color: var(--muted); font-size: 11px; text-align: center; }

.login-page { display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(100%, 400px); }
.login-card { padding: 32px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 14px 40px rgb(24 33 47 / 8%); }
.login-card h1 { font-size: 28px; }
.login-hint { margin: 9px 0 24px; color: var(--muted); font-size: 13px; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 7px; color: var(--text); font-size: 13px; font-weight: 600; }
.login-form input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); }
.login-form button { min-height: 44px; margin-top: 12px; }
.login-error { margin: 7px 0 0; }

@media (max-width: 720px) {
  .dashboard-shell { width: min(100% - 24px, 1180px); padding-top: 22px; }
  .dashboard-header { align-items: stretch; flex-direction: column; }
  .toolbar { grid-template-columns: 1fr 1fr 1fr; }
  .toolbar label { grid-column: 1 / -1; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .operations-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid article { padding: 14px; }
  .metric-grid strong { font-size: 24px; }
  .panel-heading { align-items: flex-start; }
  th, td { padding: 10px 14px; }
  .login-page { padding: 18px; }
  .login-card { padding: 26px 22px; }
}


.toolbar { flex-wrap: wrap; }
.toolbar input[type="date"] { min-width: 140px; }
.trend-bar { position: relative; }
.trend-value { position: absolute; top: -1.55rem; left: 50%; transform: translateX(-50%); color: #334155; font-size: 0.72rem; font-weight: 700; line-height: 1; white-space: nowrap; pointer-events: none; }

.custom-date-field[hidden] { display: none !important; }
