/* Ivyea Surveillance 看板样式。零构建：没有预处理器、没有打包，改完刷新即可。
   图表用的两个分类色（--pv / --uv）跑过配色六项检查（亮度带 / 色度 / 色盲可分辨 /
   常视可分辨 / 对比度），明暗两种模式全部 PASS —— 不要随手改。 */

:root {
  color-scheme: dark light;
  --bg: #0f1011;
  --panel: #17181a;
  --panel-2: #1d1f21;
  --line: #2a2d30;
  --t1: #e9eaec;
  --t2: #a4a9ae;
  --t3: #70767c;
  --pv: #16a34a;      /* 浏览量 */
  --uv: #3b82f6;      /* 访客数 */
  --up: #22c55e;
  --down: #ef4444;
  --amber: #d97706;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f6f5;
    --panel: #ffffff;
    --panel-2: #fafaf9;
    --line: #e3e3e1;
    --t1: #1a1c1e;
    --t2: #55595e;
    --t3: #8b9096;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--t1);
  font: 13px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ── 登录页 ─────────────────────────────────────────────── */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: min(340px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 30px 26px; text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}
.login-mark { font-size: 30px; color: var(--pv); line-height: 1; }
.login-card h1 { margin: 12px 0 2px; font-size: 19px; letter-spacing: .02em; }
.login-card .muted { margin: 0 0 20px; color: var(--t3); font-size: 12px; }
.login-card input, .login-card button {
  width: 100%; padding: 10px 12px; border-radius: 8px; font-size: 13px; font-family: inherit;
}
.login-card input {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--t1); margin-bottom: 10px;
}
.login-card input:focus { outline: 2px solid color-mix(in srgb, var(--pv) 55%, transparent); outline-offset: 1px; }
.login-card button {
  border: 0; background: var(--pv); color: #fff; font-weight: 600; cursor: pointer;
  transition: filter .15s ease;
}
.login-card button:hover:not(:disabled) { filter: brightness(1.1); }
.login-card button:disabled { opacity: .6; cursor: default; }
.login-err { margin-top: 12px; color: var(--down); font-size: 12px; }

/* ── 布局 ───────────────────────────────────────────────── */
.wrap { max-width: 1220px; margin: 0 auto; padding: 18px 18px 60px; }

header.top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 650; }
.brand i { color: var(--pv); font-style: normal; font-size: 17px; }
.brand small { color: var(--t3); font-weight: 400; font-size: 11px; }
.grow { flex: 1; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button {
  border: 0; background: transparent; color: var(--t2); font: inherit; font-size: 12px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--t1); background: color-mix(in srgb, var(--pv) 9%, transparent); }
.seg button[aria-pressed="true"] { color: var(--pv); background: color-mix(in srgb, var(--pv) 14%, transparent); font-weight: 600; }

.check { display: inline-flex; align-items: center; gap: 6px; color: var(--t3); font-size: 12px; cursor: pointer; }
.check input { accent-color: var(--pv); }
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--t2); font: inherit;
  font-size: 12px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.btn:hover { color: var(--t1); border-color: color-mix(in srgb, var(--pv) 45%, var(--line)); }

/* ── 筛选 chips ─────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 4px 4px 4px 10px;
  border-radius: 999px; background: color-mix(in srgb, var(--pv) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--pv) 35%, var(--line)); color: var(--t1);
}
.chip button {
  border: 0; background: transparent; color: var(--t3); font: inherit; font-size: 13px; line-height: 1;
  cursor: pointer; padding: 2px 5px; border-radius: 999px;
}
.chip button:hover { color: var(--down); background: color-mix(in srgb, var(--down) 15%, transparent); }
.chip-clear {
  border: 0; background: transparent; color: var(--t3); font: inherit; font-size: 11.5px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px; padding: 4px 2px;
}
.chip-clear:hover { color: var(--t1); }

/* ── 卡片 ───────────────────────────────────────────────── */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
}
.card > h2 {
  margin: 0 0 12px; font-size: 12px; font-weight: 600; color: var(--t2);
  letter-spacing: .04em; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card > h2 span.sub { font-weight: 400; color: var(--t3); font-size: 11px; letter-spacing: 0; }
.card h3 { margin: 14px 0 7px; font-size: 11px; font-weight: 600; color: var(--t3); letter-spacing: .03em; }
.card h3:first-of-type { margin-top: 0; }

.grid { display: grid; gap: 12px; margin-bottom: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ── KPI ────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi.live { border-left: 3px solid var(--pv); }
.kpi .k-label { font-size: 11px; color: var(--t3); margin-bottom: 5px; }
.kpi .k-val { font-size: 25px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .k-val small { font-size: 12px; font-weight: 500; color: var(--t3); margin-left: 2px; }
.kpi .k-delta { font-size: 11px; color: var(--t3); margin-top: 4px; }
.k-up { color: var(--up); }
.k-down { color: var(--down); }
.dot-live {
  width: 7px; height: 7px; border-radius: 50%; background: var(--pv);
  display: inline-block; margin-right: 7px; vertical-align: middle;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .3 } }

/* ── 趋势图 ─────────────────────────────────────────────── */
.chart { position: relative; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--t2); margin-bottom: 4px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.legend b { color: var(--t1); margin-left: 6px; font-variant-numeric: tabular-nums; }
.chart svg { display: block; width: 100%; overflow: visible; }
.tip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3); white-space: nowrap; transform: translateX(-50%);
}
.tip .tip-t { color: var(--t3); font-size: 11px; margin-bottom: 3px; }
.tip .tip-r { display: flex; align-items: center; gap: 7px; line-height: 1.7; }
.tip .tip-r b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ── 热力图 ─────────────────────────────────────────────── */
/* 格子高度写死而不是 aspect-ratio：容器一宽 aspect-ratio 会把格子撑成 45px 的
   大色块，整张图变成一面绿墙，读不出时段差异。 */
.heat { display: grid; grid-template-columns: 30px repeat(24, 1fr); gap: 2px; align-items: center; max-width: 700px; }
.heat .lab { font-size: 10px; color: var(--t3); text-align: right; padding-right: 5px; }
.heat .cell { height: 17px; border-radius: 3px; background: var(--panel-2); }
.heat-x { display: grid; grid-template-columns: 30px repeat(24, 1fr); gap: 2px; margin-top: 4px; max-width: 700px; }
.heat-x span { font-size: 9px; color: var(--t3); text-align: center; }
.heat-legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--t3); margin-top: 10px; }
.heat-legend i { width: 15px; height: 10px; border-radius: 2px; display: inline-block; }

/* ── 排行条 ─────────────────────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: 2px; }
.bar { position: relative; display: flex; align-items: center; gap: 9px; padding: 6px 9px; border-radius: 6px; font-size: 12px; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--pv) 17%, transparent); border-radius: 6px; transition: width .35s ease; }
.bar .nm { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.bar .sb { position: relative; color: var(--t3); font-size: 10.5px; white-space: nowrap; }
.bar .vl { position: relative; margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar .vl em { font-style: normal; color: var(--t3); font-weight: 400; }
.bar:hover .fill { background: color-mix(in srgb, var(--pv) 28%, transparent); }
.bar.clickable { cursor: pointer; }
.bar.clickable:focus-visible { outline: 2px solid var(--pv); outline-offset: -2px; }

/* ── 实时流 / 表格 ──────────────────────────────────────── */
.live { display: flex; flex-direction: column; gap: 2px; max-height: 330px; overflow-y: auto; }
.live-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; font-size: 12px; }
.live-row:nth-child(odd) { background: color-mix(in srgb, var(--t1) 4%, transparent); }
.live-row .tm { color: var(--t3); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.live-row .pt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-row .pt span { color: var(--t3); }
.live-row .mt { color: var(--t3); font-size: 11px; white-space: nowrap; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; color: var(--t3); font-size: 11px; font-weight: 500; padding: 5px 7px; border-bottom: 1px solid var(--line); }
td { padding: 7px; color: var(--t2); border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
tr:last-child td { border-bottom: 0; }
td b { color: var(--t1); font-variant-numeric: tabular-nums; }

/* 渠道表列多，窄屏必须让**表格自己**横向滚动，不能让 body 横滚。 */
.tbl-scroll { overflow-x: auto; }
.tbl-scroll table { min-width: 560px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: color-mix(in srgb, var(--pv) 8%, transparent); }
td .tag { color: var(--t3); font-size: 10.5px; margin-left: 7px; }
td.good { color: var(--up); font-weight: 600; }

/* ── 排除我自己 ─────────────────────────────────────────── */
.ign { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.ign-row {
  display: flex; align-items: center; gap: 10px; font-size: 12px; padding: 6px 8px; border-radius: 6px;
}
.ign-row:nth-child(odd) { background: color-mix(in srgb, var(--t1) 4%, transparent); }
.ign-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ign-row a { color: var(--pv); text-decoration: none; white-space: nowrap; font-size: 11.5px; }
.ign-row a:hover { text-decoration: underline; }
.ign-row a.off { color: var(--t3); }

.empty { color: var(--t3); font-size: 12px; text-align: center; padding: 18px 4px; }
.note { color: var(--t3); font-size: 11.5px; line-height: 1.75; }
.note code { font-family: var(--mono); font-size: 10.5px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.warn { color: var(--amber); }
.err-bar { border-left: 3px solid var(--down); color: var(--down); font-size: 12px; }

@media (max-width: 640px) {
  .wrap { padding: 12px 12px 40px; }
  .kpi .k-val { font-size: 21px; }
  .live-row .mt { display: none; }
}
