/* navdash — conventional admin layout: dark side menu, white header, cards and tables */
/* colours: light by default; dark when picked with the toggle in the header (cookie nd_theme),
   or when the device is set to dark and nothing was picked */
:root {
  color-scheme: light;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #e8e8e8;
  --split: #f0f0f0;
  --head: #fafafa;
  --text: #1f1f1f;
  --text-2: #595959;
  --muted: #8c8c8c;
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --primary-dark: #0958d9;
  --primary-bg: #e6f4ff;
  --primary-border: #91caff;
  --success: #52c41a;
  --success-text: #389e0d;
  --success-bg: #f6ffed;
  --success-border: #b7eb8f;
  --warning-text: #d48806;
  --warning-bg: #fffbe6;
  --warning-border: #ffe58f;
  --error: #ff4d4f;
  --error-text: #cf1322;
  --error-bg: #fff2f0;
  --error-border: #ffccc7;
  --side-bg: #001529;
  --side-sub: #000c17;
  --side-line: rgba(255, 255, 255, .08);
  --side-text: rgba(255, 255, 255, .68);
  --side-on: #1677ff;
  --bar: #1677ff;
  --bar-end: #0958d9;
  --c0: #1677ff;      /* route 1 of a brand */
  --c1: #eb6834;      /* route 2 */
  --c2: #1baf7a;      /* route 3 */
  --c-line: #595959;  /* went to platform */
  --link: #1677ff;
  --link-hover: #4096ff;
  --control-bg: #ffffff;
  --control-border: #d9d9d9;
  --row-hover: #fafafa;
  --head-hover: #f0f0f0;
  --btn-hover: rgba(0, 0, 0, .05);
  --tag-bg: #fafafa;
  --tag-border: #d9d9d9;
  --idle: #d9d9d9;
  --k-other: #bfbfbf;
  --k-cs: #722ed1;
  --k-download: #fa8c16;
  --box-shadow: 0 6px 16px rgba(0, 0, 0, .06);
  --radius: 8px;
  --radius-sm: 6px;
  --side-w: 216px;
  --heat-1: #f0f6ff;
  --heat-2: #dceafe;
  --heat-3: #bfd9fd;
  --heat-4: #94c0fb;
  --heat-5: #66a3f7;
}
/* dark: chart colours are the same three hues stepped for the dark surface (checked for colour-blind separation and contrast) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --heat-1: #14213a;
  --heat-2: #182c4f;
  --heat-3: #1d3a68;
  --heat-4: #234a85;
  --heat-5: #2b5ba3;
  --bg: #141414;
  --surface: #1f1f1f;
  --border: #424242;
  --split: #303030;
  --head: #262626;
  --text: #dcdcdc;
  --text-2: #b0b0b0;
  --muted: #8c8c8c;
  --primary: #1668dc;
  --primary-hover: #3c89e8;
  --primary-dark: #1554ad;
  --primary-bg: #111a2c;
  --primary-border: #15325b;
  --link: #4096ff;
  --link-hover: #69b1ff;
  --success: #49aa19;
  --success-text: #49aa19;
  --success-bg: #162312;
  --success-border: #274916;
  --warning-text: #d89614;
  --warning-bg: #2b2111;
  --warning-border: #594214;
  --error: #dc4446;
  --error-text: #ff7875;
  --error-bg: #2c1618;
  --error-border: #5b2526;
  --side-bg: #1a1a1a;
  --side-sub: #111111;
  --side-line: #2a2a2a;
  --side-text: rgba(255, 255, 255, .62);
  --side-on: #1668dc;
  --bar: #3c89e8;
  --bar-end: #65a9f3;
  --c0: #3987e5;
  --c1: #d95926;
  --c2: #199e70;
  --c-line: #a6a6a6;
  --control-bg: #141414;
  --control-border: #424242;
  --row-hover: #262626;
  --head-hover: #303030;
  --btn-hover: rgba(255, 255, 255, .08);
  --tag-bg: #262626;
  --tag-border: #424242;
  --idle: #595959;
  --k-other: #737373;
  --k-cs: #9254de;
  --k-download: #d87a16;
  --box-shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --heat-1: #14213a;
    --heat-2: #182c4f;
    --heat-3: #1d3a68;
    --heat-4: #234a85;
    --heat-5: #2b5ba3;
    --bg: #141414;
    --surface: #1f1f1f;
    --border: #424242;
    --split: #303030;
    --head: #262626;
    --text: #dcdcdc;
    --text-2: #b0b0b0;
    --muted: #8c8c8c;
    --primary: #1668dc;
    --primary-hover: #3c89e8;
    --primary-dark: #1554ad;
    --primary-bg: #111a2c;
    --primary-border: #15325b;
    --link: #4096ff;
    --link-hover: #69b1ff;
    --success: #49aa19;
    --success-text: #49aa19;
    --success-bg: #162312;
    --success-border: #274916;
    --warning-text: #d89614;
    --warning-bg: #2b2111;
    --warning-border: #594214;
    --error: #dc4446;
    --error-text: #ff7875;
    --error-bg: #2c1618;
    --error-border: #5b2526;
    --side-bg: #1a1a1a;
    --side-sub: #111111;
    --side-line: #2a2a2a;
    --side-text: rgba(255, 255, 255, .62);
    --side-on: #1668dc;
    --bar: #3c89e8;
    --bar-end: #65a9f3;
    --c0: #3987e5;
    --c1: #d95926;
    --c2: #199e70;
    --c-line: #a6a6a6;
    --control-bg: #141414;
    --control-border: #424242;
    --row-hover: #262626;
    --head-hover: #303030;
    --btn-hover: rgba(255, 255, 255, .08);
    --tag-bg: #262626;
    --tag-border: #424242;
    --idle: #595959;
    --k-other: #737373;
    --k-cs: #9254de;
    --k-download: #d87a16;
    --box-shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5715 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--text); }
h1 { font-size: 20px; line-height: 28px; }
h2 { font-size: 16px; line-height: 24px; }
h3 { font-size: 14px; line-height: 22px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.inline { display: inline; margin: 0; }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

/* ---- frame: side menu + main column */
body.app { display: flex; min-height: 100vh; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.sider { width: var(--side-w); flex: 0 0 var(--side-w); background: var(--side-bg); color: var(--side-text); z-index: 30; transition: width .2s, flex-basis .2s; }
.sider-in { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 18px; color: #fff; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; flex: 0 0 auto; }
.logo:hover { color: #fff; }
.logo-mark { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 7px; background: var(--side-on); display: inline-flex; align-items: center; justify-content: center; }
.logo-mark .ico { width: 17px; height: 17px; stroke: #fff; stroke-width: 2.2; }
.menu { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 0 12px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .2) transparent; }
.mg-title { display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 0 16px 0 18px; background: none; border: 0; color: var(--side-text);
  font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
.mg-title:hover, .mg.active > .mg-title { color: #fff; }
.mg-title .mt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-title .arrow { width: 14px; height: 14px; opacity: .65; transition: transform .2s; }
.mg.open > .mg-title .arrow { transform: rotate(180deg); }
.badge { flex: 0 0 30px; height: 22px; border-radius: 5px; background: rgba(255, 255, 255, .1); color: #fff; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; letter-spacing: .2px; white-space: nowrap; }
.mg.active .badge { background: var(--side-on); }
.mg-title .gi { width: 18px; height: 18px; margin: 0 6px; }
.mg-items { display: none; background: var(--side-sub); padding: 4px 0; }
.mg.open > .mg-items { display: block; }
.fly-head { display: none; }
.mi { display: flex; align-items: center; gap: 10px; height: 40px; margin: 2px 8px; padding: 0 12px 0 34px; border-radius: 6px; color: var(--side-text); white-space: nowrap; }
.mi:hover { color: #fff; background: rgba(255, 255, 255, .04); }
.mi.on, .mi.on:hover { background: var(--side-on); color: #fff; }
.mi .ico { width: 16px; height: 16px; }
.menu-sep { height: 1px; background: var(--side-line); margin: 8px 16px; }
.fold-btn { display: flex; align-items: center; gap: 10px; height: 44px; flex: 0 0 44px; padding: 0 22px; border: 0; border-top: 1px solid var(--side-line);
  background: none; color: var(--side-text); cursor: pointer; font: inherit; white-space: nowrap; overflow: hidden; }
.fold-btn:hover { color: #fff; }
.fold-btn .ico { width: 18px; height: 18px; transition: transform .2s; }
.sider-mask { display: none; }

/* folded: a 64px icon bar; each group opens its pages as a flyout on hover */
@media (min-width: 861px) {
  body.folded .sider { width: 64px; flex-basis: 64px; }
  body.folded .sider .mt, body.folded .mg-title .arrow { display: none; }
  body.folded .menu { overflow: visible; }
  body.folded .mg { position: relative; }
  body.folded .mg-title { justify-content: center; padding: 0; }
  body.folded .mg > .mg-items, body.folded .mg.open > .mg-items { display: none; position: absolute; left: 64px; top: 0; min-width: 184px; padding: 4px 0 6px;
    background: var(--side-bg); border-radius: 0 8px 8px 0; box-shadow: 4px 6px 16px rgba(0, 0, 0, .28); z-index: 40; }
  body.folded .mg:hover > .mg-items, body.folded .mg.open:hover > .mg-items,
  body.folded .mg:focus-within > .mg-items, body.folded .mg.open:focus-within > .mg-items { display: block; }
  body.folded .mg-items .mt { display: inline; }
  body.folded .fly-head { display: block; padding: 8px 16px 6px; color: rgba(255, 255, 255, .45); font-size: 12px; white-space: nowrap; }
  body.folded .mi { padding: 0 12px; }
  body.folded .fold-btn { justify-content: center; padding: 0; }
  body.folded .fold-btn .ico { transform: rotate(180deg); }
}

/* ---- header: breadcrumb, clock, theme, language, account, log out */
.header { position: sticky; top: 0; z-index: 20; height: 56px; flex: 0 0 56px; display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--split); }
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--link); }
.crumb .sep { color: var(--control-border); }
.crumb .cur { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.hd-right { margin-left: auto; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.hd-btn { height: 32px; min-width: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none;
  border-radius: 6px; color: var(--text-2); cursor: pointer; font: inherit; }
.hd-btn:hover { background: var(--btn-hover); color: var(--text); }
.hd-btn .ico { width: 18px; height: 18px; }
.hd-text { font-size: 13px; font-weight: 600; }
.menu-btn { display: none; margin-left: -8px; }
.hd-clock { color: var(--text-2); font-variant-numeric: tabular-nums; padding: 0 12px 0 0; margin-right: 4px; border-right: 1px solid var(--split); cursor: default; }
.hd-clock-l { color: var(--muted); margin-right: 6px; font-size: 12px; }
.hd-user { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; border-radius: 6px; color: var(--text); }
.hd-user:hover, .hd-user.on { background: var(--btn-hover); color: var(--text); }
.avatar { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; }
.avatar.sm { width: 22px; height: 22px; flex-basis: 22px; font-size: 11px; margin-right: 8px; vertical-align: middle; position: relative; top: -1px; }
.avatar.lg { width: 48px; height: 48px; flex-basis: 48px; font-size: 20px; }
.theme-btn svg { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: none; }
}

/* ---- page */
.wrap { width: 100%; max-width: 1440px; margin: 0 auto; padding: 20px 24px 24px; flex: 1; }
.pagehead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 16px; }
.pagehead h1 { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.pagehead:has(+ .ph-desc) { margin-bottom: 6px; }
.ph-brand { font-size: 12px; font-weight: 600; line-height: 20px; padding: 0 8px; border-radius: 4px; color: var(--link); background: var(--primary-bg); border: 1px solid var(--primary-border); }
.ph-desc { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0 20px; }

/* ---- filters */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.seg { display: inline-flex; }
.seg a { height: 32px; line-height: 30px; padding: 0 14px; color: var(--text); background: var(--control-bg); border: 1px solid var(--control-border); margin-left: -1px; white-space: nowrap; }
.seg a:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.seg a:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.seg a:hover { color: var(--link); position: relative; z-index: 1; }
.seg a.on { color: var(--link); border-color: var(--link); position: relative; z-index: 2; }
.range { display: inline-flex; align-items: center; height: 32px; background: var(--control-bg); border: 1px solid var(--control-border); border-radius: var(--radius-sm); padding: 0 4px 0 8px; }
.range:focus-within { border-color: var(--link-hover); }
.range input { border: 0; font: inherit; color: var(--text); background: transparent; padding: 0 2px; height: 30px; width: 128px; outline: none; }
.range .sep { color: var(--muted); padding: 0 4px; }
.btn-ghost { height: 32px; padding: 0 14px; border: 1px solid var(--control-border); border-radius: var(--radius-sm); background: var(--control-bg); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; }
.btn-ghost:hover { color: var(--link); border-color: var(--link); }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; white-space: nowrap; }
.check:hover { color: var(--text); }
.check .box { width: 16px; height: 16px; border: 1px solid var(--control-border); border-radius: 4px; background: var(--control-bg); display: inline-block; position: relative; }
.check.on .box { background: var(--primary); border-color: var(--primary); }
.check.on .box::after { content: ""; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* ---- cards */
.card { background: var(--surface); border-radius: var(--radius); margin-bottom: 16px; border: 1px solid var(--split); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 10px 20px; border-bottom: 1px solid var(--split); }
.card-head h2 { font-size: 16px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 4px; }
.card-count { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 4px; }
.card-meta { color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 16px; }
.card-meta b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.card-body { padding: 16px 20px; }
.card-desc { padding: 12px 20px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--split); }
.card-foot { padding: 10px 20px; border-top: 1px solid var(--split); text-align: right; }
.card-foot.left { text-align: left; }
.toolbar { padding: 16px 20px; border-bottom: 1px solid var(--split); background: var(--head); }
.toolbar .form-help { margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
.grid2 > .card { margin-bottom: 0; }
.grid2.account { max-width: 1040px; }
.split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.split > .card { margin-bottom: 0; }
.empty { color: var(--muted); padding: 28px 20px; text-align: center; }

/* ---- statistic tiles */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--split); border-radius: var(--radius); padding: 16px 20px; }
.stat-label { color: var(--muted); }
.stat-label[title] { cursor: help; }
.stat-value { font-size: 28px; line-height: 38px; font-weight: 600; margin-top: 4px; color: var(--text); }
.stat-sub { color: var(--muted); margin-top: 2px; font-size: 13px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); vertical-align: middle; margin-right: 8px; position: relative; top: -2px; }
.dot.idle { background: var(--idle); }

/* ---- route card: funnel + top domains */
.route-body { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.route-body > div { padding: 16px 20px 18px; min-width: 0; }
.route-body > div + div { border-left: 1px solid var(--split); }
.sub-title { display: flex; justify-content: space-between; align-items: baseline; color: var(--text-2); font-weight: 600; margin-bottom: 8px; }
.sub-title a { font-weight: 400; }
.funnel { display: grid; grid-template-columns: max-content minmax(60px, 1fr) max-content; column-gap: 16px; row-gap: 6px; align-items: center; }
.funnel .f-name { white-space: nowrap; padding: 6px 0; }
.funnel .f-name a { color: var(--link); }
.funnel .f-name a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }
.funnel .f-track { display: flex; align-items: center; gap: 10px; min-width: 0; }
.funnel .f-bar { height: 14px; background: var(--bar); border-radius: 0 4px 4px 0; flex: 0 0 auto; width: 0; min-width: 2px; }
.funnel .f-plat .f-bar { background: var(--bar-end); }
.funnel .f-val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.funnel .f-rate { color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.funnel .f-rate b { color: var(--text); font-weight: 500; }
.funnel .f-line { grid-column: 1 / -1; border-top: 1px dashed var(--split); height: 0; margin: 2px 0; }
.funnel .f-track[title] { cursor: default; }

/* ---- tabs */
.tabs { display: flex; gap: 32px; border-bottom: 1px solid var(--split); margin: -4px 0 16px; overflow-x: auto; }
.tabs a { padding: 10px 0; color: var(--text); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--link); }
.tabs a.on { color: var(--link); border-bottom-color: var(--link); font-weight: 500; }

/* ---- tables */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 10px 16px; border-bottom: 1px solid var(--split); text-align: left; vertical-align: middle; }
.tbl th { background: var(--head); color: var(--text); font-weight: 600; white-space: nowrap; }
.tbl tbody tr:hover td { background: var(--row-hover); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .w { white-space: nowrap; }
.tbl.compact th, .tbl.compact td { padding: 8px 12px; }
.tbl tr.dim td { color: var(--muted); }
.tbl tr.group td { background: var(--head); color: var(--text-2); font-weight: 600; padding-top: 8px; padding-bottom: 8px; }
.tbl.sortable th { cursor: pointer; user-select: none; }
.tbl.sortable th:hover { background: var(--head-hover); }
.tbl.sortable th.sorted-asc::after, .tbl.sortable th.sorted-desc::after { color: var(--link); font-size: 10px; margin-left: 4px; }
.tbl.sortable th.sorted-asc::after { content: "▲"; }
.tbl.sortable th.sorted-desc::after { content: "▼"; }
.card > .tbl-wrap:first-child .tbl th:first-child, .card > .tbl:first-child th:first-child { border-top-left-radius: var(--radius); }
.card > .tbl-wrap:first-child .tbl th:last-child, .card > .tbl:first-child th:last-child { border-top-right-radius: var(--radius); }
.tbl td.share { width: 40%; min-width: 80px; }
.tbl.areas td { padding-top: 7px; padding-bottom: 7px; }
.tbl.areas td.share { width: 34%; }
.tbl.matrix th { vertical-align: bottom; }
.tbl.matrix th .small { font-weight: 400; }
.tbl.matrix td { padding-top: 7px; padding-bottom: 7px; }
.tbl.matrix td.heat { font-weight: 500; }
.tbl.matrix td.h1 { background: var(--heat-1); }
.tbl.matrix td.h2 { background: var(--heat-2); }
.tbl.matrix td.h3 { background: var(--heat-3); }
.tbl.matrix td.h4 { background: var(--heat-4); }
.tbl.matrix td.h5 { background: var(--heat-5); }
.matrix-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; text-align: left; }
.meter { display: block; height: 8px; }
.meter span { display: block; height: 100%; width: 0; min-width: 2px; background: var(--bar); border-radius: 0 4px 4px 0; }
.pid { color: var(--muted); font-size: 12px; margin-left: 6px; font-weight: 400; }
.rate { color: var(--muted); font-size: 12px; margin-left: 6px; }
.actions { white-space: nowrap; text-align: right; }
.actions form + form { margin-left: 6px; }

/* ---- tags */
.tag { display: inline-block; padding: 0 7px; font-size: 12px; line-height: 20px; border-radius: 4px; border: 1px solid var(--tag-border); background: var(--tag-bg); color: var(--text-2); white-space: nowrap; font-weight: 400; }
.tag.ok { color: var(--success-text); background: var(--success-bg); border-color: var(--success-border); }
.tag.warn { color: var(--warning-text); background: var(--warning-bg); border-color: var(--warning-border); }
.tag.err { color: var(--error-text); background: var(--error-bg); border-color: var(--error-border); white-space: normal; }
.tag.blue { color: var(--link); background: var(--primary-bg); border-color: var(--primary-border); }
.kind { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text-2); }
.kind::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--k-other); }
.k-line::before, .k-register::before, .k-promo::before, .k-agent::before { background: var(--success); }
.k-nav::before { background: var(--link); }
.k-cs::before { background: var(--k-cs); }
.k-download::before { background: var(--k-download); }

/* ---- messages */
.alert, .notice { padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; }
.alert { background: var(--error-bg); border-color: var(--error-border); color: var(--error-text); }
.notice { background: var(--primary-bg); border-color: var(--primary-border); color: var(--text); }
.notice.ok { background: var(--success-bg); border-color: var(--success-border); }
.notice p { margin: 0 0 8px; }
input.copy { width: 100%; font-family: SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; padding: 6px 10px; border: 1px solid var(--control-border); border-radius: var(--radius-sm); background: var(--control-bg); color: var(--text); }

/* ---- buttons and forms */
.btn { height: 32px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--primary); color: #fff;
  border: 1px solid var(--primary); border-radius: var(--radius-sm); cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn .ico { width: 15px; height: 15px; stroke-width: 2.2; }
.btn.block { width: 100%; height: 40px; font-size: 15px; }
.btn-sm { height: 24px; padding: 0 8px; font-size: 13px; border: 1px solid var(--control-border); border-radius: 4px; background: var(--control-bg); color: var(--text); cursor: pointer; font-family: inherit; white-space: nowrap; }
.btn-sm:hover { color: var(--link); border-color: var(--link); }
a.btn-sm { display: inline-flex; align-items: center; }
.btn-sm.danger { color: var(--error-text); }
.btn-sm.danger:hover { border-color: var(--error); }
.form { display: flex; flex-direction: column; gap: 16px; }
.form label, .form-row label { display: flex; flex-direction: column; gap: 6px; color: var(--text); }
.form label small { color: var(--muted); font-size: 12px; }
.form input, .form select, .form-row input, .form-row select { height: 32px; padding: 4px 11px; border: 1px solid var(--control-border); border-radius: var(--radius-sm); font: inherit; color: var(--text); background: var(--control-bg); }
.form input:focus, .form select:focus, .form-row input:focus, .form-row select:focus, .range input:focus { outline: none; border-color: var(--link-hover); box-shadow: 0 0 0 2px rgba(5, 145, 255, .1); }
.form input:disabled, .form select:disabled { background: var(--head); color: var(--muted); cursor: not-allowed; }
.form .form-help { margin-top: -4px; }
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.form-row input { width: 200px; }
.form-row label.grow { flex: 1 1 220px; max-width: 420px; }
.form-row label.grow input { width: 100%; }
.form-row input.mono-in { font-family: SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.form-help { color: var(--muted); font-size: 13px; margin-top: 12px; }
.mine { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--split); }
.search { display: flex; align-items: center; gap: 8px; }
.search-box { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--control-border); border-radius: var(--radius-sm); background: var(--control-bg); }
.search-box:focus-within { border-color: var(--link-hover); }
.search-box .ico { width: 14px; height: 14px; color: var(--muted); }
.search-box input { border: 0; outline: none; background: transparent; font: inherit; color: var(--text); width: 210px; height: 30px; }

/* ---- account, users */
.pagehead h1 .avatar { width: 28px; height: 28px; flex-basis: 28px; font-size: 13px; }
.pagehead h1 .pid { margin-left: -4px; }
.profile { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.profile-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 28px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---- login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--split); padding: 32px 32px 24px; box-shadow: var(--box-shadow); }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box .login-sub { color: var(--muted); margin-bottom: 24px; }
.login-box .form input { height: 40px; }
.login-lang { margin-top: 20px; display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--control-border); }
.login-lang a, .login-lang .theme-btn { color: var(--text-2); }
.login-lang .theme-btn { padding: 2px 4px; height: auto; min-width: 0; }
.login-lang a:hover, .login-lang a.on, .login-lang .theme-btn:hover { color: var(--link); background: none; }

/* ---- chart */
.chartbox { position: relative; height: 340px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-2); margin-bottom: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; }
.legend i.c0 { background: var(--c0); }
.legend i.c1 { background: var(--c1); }
.legend i.c2 { background: var(--c2); }
.legend i.c-line { background: var(--c-line); }

/* ---- narrower screens */
@media (max-width: 1280px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .route-body { grid-template-columns: minmax(0, 1fr); }
  .route-body > div + div { border-left: 0; border-top: 1px solid var(--split); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
/* phones and small tablets: the menu becomes a drawer opened with the ☰ button */
@media (max-width: 860px) {
  body.app { display: block; }
  .sider { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; transform: translateX(-100%); transition: transform .2s; }
  .sider-in { position: static; height: 100%; }
  body.drawer .sider { transform: none; box-shadow: 0 0 28px rgba(0, 0, 0, .35); }
  body.drawer .sider-mask { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 25; }
  body.drawer { overflow: hidden; }
  .fold-btn { display: none; }
  .menu-btn { display: inline-flex; }
  .header { padding: 0 12px; gap: 8px; height: 52px; }
  .hd-clock { display: none; }
  .wrap { padding: 14px 12px 24px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 24px; line-height: 32px; }
  .card-head { padding: 10px 14px; flex-wrap: wrap; }
  .card-meta { white-space: normal; flex-wrap: wrap; gap: 4px 12px; }
  .card-body, .route-body > div, .toolbar { padding: 12px 14px; }
  .tbl th, .tbl td { padding: 8px 10px; white-space: nowrap; }
  .pagehead { align-items: flex-start; }
  .pagehead h1 { flex-basis: 100%; }
  .range input { width: 118px; }
  .tabs { gap: 20px; }
  .search, .search-box { width: 100%; }
  .search-box input { width: 100%; min-width: 0; }
  .form-row input, .form-row label, .form-row label.grow { width: 100%; max-width: none; flex-basis: 100%; }
}
@media (max-width: 520px) {
  .hd-user .uname { display: none; }
  .crumb { font-size: 13px; }
  .funnel { grid-template-columns: max-content minmax(0, 1fr); column-gap: 12px; row-gap: 0; }
  .funnel .f-rate { grid-column: 2; text-align: left; font-size: 12px; margin: -4px 0 6px; white-space: normal; }
  .funnel .f-rate:empty { display: none; }
  .seg a { padding: 0 10px; }
}

/* ---- Matomo sites table (Matomo 报表 page) */
.tbl.msites td.in { padding-left: 32px; }
.tbl.msites tr.group td.n { font-weight: 600; color: var(--text-2); }
.tbl.msites tfoot td { background: var(--head); font-weight: 600; border-top: 1px solid var(--split); border-bottom: 0; }
.tbl.msites th.go, .tbl.msites td.go { width: 1%; white-space: nowrap; text-align: right; }
.tbl.msites td.go a { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.tbl.msites td.go .ico { width: 13px; height: 13px; }
sup.mark { color: var(--warning-text); font-size: 11px; margin-left: 1px; }
.tbl td.n[title] { cursor: help; }
.seg.sm a { height: 28px; line-height: 26px; padding: 0 12px; font-size: 13px; }
.card-meta .seg { margin-left: 4px; }
@media (max-width: 860px) {
  .tbl.msites td.in { padding-left: 20px; }
}

/* ---- 跳板 (IP relays) */
.tabs .tab-n { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 10px; background: var(--tag-bg); border: 1px solid var(--tag-border);
  color: var(--muted); font-size: 12px; line-height: 18px; text-align: center; font-weight: 400; }
.tabs a.on .tab-n { color: var(--link); border-color: var(--primary-border); background: var(--primary-bg); }
.tb-rule { color: var(--muted); font-size: 13px; margin: -6px 0 16px; }
.tbl tr.sel > td { background: var(--primary-bg); }
.tbl .warn-n { color: var(--warning-text); font-weight: 600; }
.tbl a.warn-n:hover { color: var(--warning-text); text-decoration: underline; text-underline-offset: 3px; }
.tb-foot { margin: -4px 0 16px; }
.search a.btn-ghost { margin-left: 4px; }
a.btn-ghost { display: inline-flex; align-items: center; }
section.card[id] { scroll-margin-top: 72px; }
/* two-line cells: the value, and a smaller grey line under it */
.tbl .l2 { color: var(--muted); font-size: 12px; line-height: 18px; margin-top: 1px; }
.tbl .l2.in { display: inline; margin: 0 0 0 4px; }
.tbl .ell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono-s { font-family: SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; }
.tbl.tb-list th, .tbl.tb-list td, .tbl.tb-lines th, .tbl.tb-lines td { padding-left: 12px; padding-right: 12px; }
.tbl.tb-list th:first-child, .tbl.tb-list td:first-child, .tbl.tb-lines th:first-child, .tbl.tb-lines td:first-child { padding-left: 20px; }
.tbl.tb-list th:last-child, .tbl.tb-list td:last-child, .tbl.tb-lines th:last-child, .tbl.tb-lines td:last-child { padding-right: 20px; }
.tbl.tb-list td { padding-top: 8px; padding-bottom: 8px; }
.tbl tr[data-href] { cursor: pointer; }
.dot.after { width: 6px; height: 6px; margin: 0 0 0 6px; top: -1px; }
.tbl.bars td.lbl { max-width: 0; width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* one visitor IP */
.ph-ip { font-variant-numeric: tabular-nums; }
.pagehead h1 .tag { font-size: 12px; }
.ph-online { display: inline-flex; align-items: center; font-size: 13px; font-weight: 400; color: var(--success-text); }
.ph-online .dot { margin-right: 6px; top: 0; }
.ph-actions { display: flex; align-items: center; gap: 8px; }
.kv dd > div + div { margin-top: 2px; }
.ua-list { list-style: none; margin: 0; padding: 0; }
.ua-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--split); }
.ua-list li:last-child { border-bottom: 0; }
.ua-list code { font-family: SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; line-height: 1.6; color: var(--text-2); word-break: break-all; }
.ua-list .small { white-space: nowrap; }
@media (max-width: 1400px) {
  .tbl .ell { max-width: 160px; }
  .tbl.tb-list th, .tbl.tb-list td, .tbl.tb-lines th, .tbl.tb-lines td { padding-left: 9px; padding-right: 9px; }
  .tbl.tb-list th:first-child, .tbl.tb-list td:first-child, .tbl.tb-lines th:first-child, .tbl.tb-lines td:first-child { padding-left: 16px; }
  .tbl.tb-list th:last-child, .tbl.tb-list td:last-child, .tbl.tb-lines th:last-child, .tbl.tb-lines td:last-child { padding-right: 16px; }
}
@media (max-width: 860px) {
  .tbl.tb-list th:first-child, .tbl.tb-list td:first-child, .tbl.tb-lines th:first-child, .tbl.tb-lines td:first-child { padding-left: 14px; }
  .ph-actions { width: 100%; }
  .ua-list li { padding: 10px 14px; flex-direction: column; gap: 2px; }
}
