:root {
  --bg: #f7f8fa; --card: #fff; --line: #ececf0; --line-2: #e0e0e6;
  --text: #14161c; --muted: #6b7280; --primary: #2563eb; --primary-2: #3b82f6;
  --views: #c7d8fb; --visits: #2563eb; --good: #16a34a; --bad: #dc2626;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.err-text { color: var(--bad); font-size: 13px; margin-top: 8px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #f0f1f4; padding: 1px 5px; border-radius: 5px; font-size: 12px; }

/* 品牌 */
.brand { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-right: 6px; }
.brand .muted { font-weight: 600; }
.brand-lg { font-size: 24px; margin-bottom: 6px; }

/* 按钮 / 控件 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s; background: none; color: var(--text); white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4fd7; }
.btn-ghost { border-color: var(--line-2); background: #fff; color: var(--muted); min-width: 38px; }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; margin-top: 10px; }
.select { height: 38px; padding: 0 30px 0 12px; border: 1px solid var(--line-2); border-radius: 9px; background: #fff
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; -webkit-appearance: none; appearance: none; max-width: 240px; }
.select:focus, input:focus { outline: none; border-color: var(--primary); }
input { height: 40px; width: 100%; padding: 0 13px; border: 1px solid var(--line-2); border-radius: 9px; font-size: 15px; font-family: var(--font); }

/* 口令门 */
.gate { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; padding: 20px; }
.gate-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 34px 30px; width: 100%; max-width: 360px; text-align: center; }
.gate-card input { margin: 18px 0 4px; text-align: center; }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 22px; background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* 主体 */
.board { max-width: 1140px; margin: 0 auto; padding: 24px 22px 60px; }

/* 卡片行 */
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card .k { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.card .v { font-size: 27px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 4px; }
.card .d { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.card .d.up { color: var(--good); } .card .d.down { color: var(--bad); } .card .d.flat { color: var(--muted); }

/* 图表 */
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 18px 12px; margin-bottom: 16px; }
.chart-legend { display: flex; align-items: center; gap: 18px; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.lg-views i { background: var(--views); } .lg-visits i { background: var(--visits); }
.chart-range { margin-left: auto; font-weight: 500; }
.chart { width: 100%; height: 280px; display: block; }

/* 维度面板 */
.panels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.panel h3 { font-size: 14px; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.panel h3 .hint { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.rows { display: flex; flex-direction: column; gap: 2px; }
.row { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 7px; font-size: 13.5px; overflow: hidden; }
.row .bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--views); opacity: .55; border-radius: 7px; z-index: 0; transition: width .4s cubic-bezier(.16,1,.3,1); }
.row .lbl { position: relative; z-index: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.row .lbl .flag { margin-right: 7px; }
.row .num { position: relative; z-index: 1; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.row .num small { color: var(--muted); font-weight: 600; margin-left: 5px; }
.panel-empty { color: var(--muted); font-size: 13px; padding: 14px 4px; text-align: center; }

/* 空状态 */
.empty { text-align: center; padding: 80px 20px; }
.empty-emoji { font-size: 52px; } .empty h2 { margin: 14px 0 6px; } .empty .btn { margin-top: 18px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 40; display: none; place-items: center; background: rgba(16,24,40,.45); padding: 20px; }
.modal.open { display: grid; }
.modal-card { background: #fff; border-radius: var(--radius); box-shadow: 0 24px 70px rgba(0,0,0,.25); width: 100%; max-width: 440px; padding: 26px; position: relative; }
.modal-card h3 { margin-bottom: 18px; font-size: 18px; }
.modal-x { position: absolute; top: 16px; right: 18px; border: none; background: none; font-size: 16px; color: var(--muted); cursor: pointer; }
.fld { display: block; margin-bottom: 14px; } .fld span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.snippet { background: #14161c; color: #e6edf3; border-radius: 9px; padding: 14px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; margin: 10px 0; }

/* 吐司 */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #14161c; color: #fff; padding: 10px 18px; border-radius: 9px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: 0; transform: translateY(8px); transition: all .3s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #16a34a; } .toast.error { background: #dc2626; }

@media (max-width: 900px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .panels { grid-template-columns: 1fr; }
  .board { padding: 16px 14px 50px; }
  .brand .muted { display: none; }
  .select { max-width: 150px; }
}
