/* ============ Rack panel design system ============ */
:root {
  --bg: #050b16;
  --surface: linear-gradient(160deg, rgba(22, 40, 66, .66), rgba(10, 21, 38, .72));
  --surface-solid: #0c192c;
  --line: rgba(126, 168, 220, .15);
  --line-strong: rgba(126, 176, 235, .3);
  --text: #eaf2fc;
  --muted: #8ba3c0;
  --faint: #64799a;
  --cyan: #3ee6d2;
  --blue: #5aa8ff;
  --green: #4ade9c;
  --red: #ff7185;
  --amber: #ffbf62;
  --violet: #9d8cff;
  --grad: linear-gradient(135deg, var(--cyan), var(--blue));
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 14px 44px rgba(2, 8, 20, .48);
  --glow-cyan: 0 0 22px rgba(62, 230, 210, .35);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { scrollbar-color: #27405e transparent; }

body {
  margin: 0;
  min-width: 320px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 88% -12%, rgba(56, 110, 195, .17), transparent 62%),
    radial-gradient(820px 520px at -12% 112%, rgba(46, 200, 190, .1), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

/* faint engineering grid over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(110, 160, 220, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 160, 220, .05) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 25%, transparent 78%);
  mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 25%, transparent 78%);
}

.bg-scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; }
.b1 { width: 480px; height: 480px; right: -140px; top: -180px; background: rgba(52, 108, 200, .34); animation: drift 22s ease-in-out infinite alternate; }
.b2 { width: 420px; height: 420px; left: -160px; bottom: -200px; background: rgba(43, 196, 180, .22); animation: drift 26s ease-in-out infinite alternate-reverse; }
.b3 { width: 300px; height: 300px; left: 38%; top: 42%; background: rgba(122, 96, 220, .13); animation: drift 30s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(60px, 40px, 0) scale(1.12); } }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid rgba(128, 187, 255, .75);
  outline-offset: 2px;
  border-radius: 6px;
}
h1, h2, p { margin: 0; }
.muted, .panel p, small { color: var(--muted); line-height: 1.55; }
.num, .metric-card strong, td.number { font-variant-numeric: tabular-nums; }

.eyebrow {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--cyan);
  font-weight: 700;
}

/* ============ buttons ============ */
.primary, .secondary, .quiet, .text-button, .icon-button {
  border: 0;
  border-radius: var(--radius-sm);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, filter .16s ease, color .16s ease, border-color .16s ease;
}
.primary {
  background: var(--grad);
  color: #04101e;
  padding: 10px 18px;
  font-weight: 750;
  box-shadow: 0 6px 22px rgba(62, 190, 230, .28), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.primary:hover { transform: translateY(-1px); filter: brightness(1.07); box-shadow: 0 10px 28px rgba(62, 190, 230, .38), inset 0 1px 0 rgba(255, 255, 255, .28); }
.primary:active { transform: translateY(0); }
.wide { width: 100%; padding: 12px; }
.secondary {
  background: rgba(28, 56, 92, .45);
  color: #dcecff;
  border: 1px solid rgba(90, 140, 195, .35);
  padding: 9px 14px;
  font-weight: 650;
  backdrop-filter: blur(6px);
}
.secondary:hover { background: rgba(40, 78, 122, .6); border-color: rgba(110, 165, 225, .5); transform: translateY(-1px); }
.quiet, .text-button { background: transparent; color: var(--muted); padding: 7px 10px; border-radius: 8px; }
.quiet:hover, .text-button:hover { color: var(--text); background: rgba(255, 255, 255, .07); }

/* ============ login ============ */
.login-view {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  place-items: center;
  align-content: center;
  gap: 22px;
  padding: 24px;
}
.login-card {
  width: min(100%, 440px);
  padding: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(170, 205, 255, .1);
  animation: rise .55s cubic-bezier(.2, .9, .25, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(22px) scale(.985); } to { opacity: 1; transform: none; } }
.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 17px;
  color: #07111f;
  background: var(--grad);
  font-weight: 900;
  letter-spacing: -.06em;
  margin-bottom: 27px;
  box-shadow: var(--glow-cyan), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.login-card h1 { font-size: 29px; margin: 7px 0 12px; letter-spacing: .01em; }
.login-card > .muted { color: #a9bdd4; }
.stack { display: grid; gap: 17px; margin-top: 27px; }
.stack label { display: grid; gap: 8px; color: #c3d6ea; font-weight: 600; }
.stack input {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(6, 15, 28, .75);
  color: var(--text);
  padding: 12px 14px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.stack input:focus { border-color: rgba(94, 176, 255, .65); box-shadow: 0 0 0 3px rgba(74, 148, 235, .18); outline: none; }
.form-error {
  border-left: 3px solid var(--red);
  background: rgba(255, 113, 133, .09);
  padding: 9px 12px;
  border-radius: 6px;
  color: #ffd0d8;
  margin: 0;
}
.login-features { display: flex; gap: 18px; list-style: none; margin: 26px 0 0; padding: 18px 0 0; border-top: 1px solid var(--line); }
.login-features li { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.fi { width: 15px; height: 15px; border-radius: 5px; display: inline-block; background: rgba(62, 230, 210, .16); position: relative; }
.fi::after { content: ""; position: absolute; inset: 4px; border-radius: 3px; background: var(--cyan); }
.fi-shield::after { border-radius: 3px 3px 5px 5px; }
.fi-bolt { background: rgba(90, 168, 255, .16); } .fi-bolt::after { background: var(--blue); clip-path: polygon(60% 0, 20% 55%, 48% 55%, 38% 100%, 82% 42%, 54% 42%); }
.fi-chart { background: rgba(154, 140, 255, .16); } .fi-chart::after { background: var(--violet); clip-path: polygon(0 100%, 0 55%, 30% 70%, 62% 22%, 100% 40%, 100% 100%); }
.login-foot { color: var(--faint); font-size: 12px; }

/* ============ app frame ============ */
.app-view { position: relative; z-index: 1; min-height: 100vh; }
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 18, 33, .82);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.wordmark { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 760; text-decoration: none; letter-spacing: .02em; }
.wordmark-badge {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--grad); color: #07111f;
  font-size: 12px; font-weight: 900; letter-spacing: -.04em;
  box-shadow: 0 0 14px rgba(62, 230, 210, .35);
}
.wordmark-text { font-size: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.history-link { text-decoration: none; white-space: nowrap; }
.session-chip { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(18, 36, 60, .5); }
.session-avatar { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--grad); color: #07111f; font-size: 12px; font-weight: 800; font-style: normal; }
.session-user { color: #bdd1e8; font-size: 13px; }

.app-shell { display: grid; grid-template-columns: 284px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar {
  border-right: 1px solid var(--line);
  padding: 23px 15px;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow: auto;
  background: rgba(8, 18, 33, .5);
  backdrop-filter: blur(8px);
}
.side-head, .page-title-row, .panel-head, .filters, .header-tools { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.side-head h2 { font-size: 18px; margin-top: 4px; }
.icon-button { width: 34px; height: 34px; background: rgba(30, 66, 105, .7); color: var(--cyan); font-size: 24px; line-height: 1; border: 1px solid rgba(90, 150, 210, .3); }
.icon-button:hover { background: rgba(38, 86, 136, .85); box-shadow: 0 0 14px rgba(62, 230, 210, .25); transform: translateY(-1px); }
.selection-actions { display: flex; align-items: center; margin: 18px 0 10px; }
.selection-count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.link-list { display: grid; gap: 7px; }
.link-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  min-width: 0;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
  animation: rowIn .3s ease both;
}
@keyframes rowIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.link-row:hover { background: rgba(38, 70, 110, .28); }
.link-row.no-anim { animation: none; }
.link-row:has(input:checked) { background: rgba(28, 84, 122, .32); border-color: rgba(72, 140, 190, .45); box-shadow: inset 0 0 18px rgba(46, 140, 190, .08); }
.link-row input { accent-color: var(--cyan); width: 16px; height: 16px; flex: 0 0 auto; margin-top: 3px; }
.link-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.link-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.link-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.link-sub { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.link-sub .dot { margin-right: 0; }
.link-meta { display: flex; gap: 5px; align-items: center; flex: 0 0 auto; }
.badge { font-size: 10px; padding: 2px 6px; border-radius: 5px; color: #a8c2dc; background: rgba(52, 96, 146, .35); letter-spacing: .03em; }
.badge.off { color: #ffc0c9; background: rgba(150, 48, 70, .4); }
.legacy { color: var(--amber); font-size: 12px; }
.link-manage { border: 0; border-radius: 7px; background: transparent; color: #8eacc8; width: 26px; height: 26px; font-weight: 800; flex: 0 0 auto; }
.link-manage:hover { background: rgba(255, 255, 255, .1); color: var(--text); }
.sidebar-foot { color: var(--muted); font-size: 12px; margin-top: 19px; padding: 14px 8px 0; border-top: 1px solid var(--line); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; background: var(--faint); flex: 0 0 auto; }
.dot.online { background: var(--green); box-shadow: 0 0 9px var(--green); animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ============ content ============ */
.content { padding: 35px clamp(18px, 4vw, 54px) 60px; max-width: 1500px; width: 100%; margin: auto; }
.page-title-row h1 { font-size: clamp(25px, 3vw, 34px); letter-spacing: .01em; margin-top: 3px; font-weight: 800; }
.header-tools { flex-wrap: wrap; }
.refresh-status { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

#dashboardBody > * { animation: rise .45s cubic-bezier(.2, .9, .25, 1) both; }
#dashboardBody > *:nth-child(2) { animation-delay: .04s; }
#dashboardBody > *:nth-child(3) { animation-delay: .08s; }
#dashboardBody > *:nth-child(4) { animation-delay: .12s; }
#dashboardBody > *:nth-child(5) { animation-delay: .16s; }
#dashboardBody > *:nth-child(6) { animation-delay: .2s; }
#dashboardBody > *:nth-child(7) { animation-delay: .24s; }

.empty-selection {
  padding: 30px;
  border: 1px dashed rgba(90, 140, 190, .45);
  border-radius: 14px;
  display: grid;
  gap: 5px;
  color: var(--muted);
  background: rgba(14, 34, 54, .4);
}
.empty-selection strong { color: var(--text); font-size: 17px; }

.filters { margin-bottom: 18px; }
.filters > span { font-weight: 650; color: #c7d9ea; }
.segmented { display: flex; background: rgba(6, 15, 28, .8); border: 1px solid var(--line-strong); padding: 3px; border-radius: 11px; gap: 2px; }
.segmented button { border: 0; border-radius: 8px; background: transparent; color: var(--muted); padding: 6px 12px; font-weight: 600; transition: background .16s ease, color .16s ease; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--grad); color: #051423; box-shadow: 0 2px 10px rgba(62, 190, 230, .3); }

/* metric cards */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.metric-card, .panel, .quota-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(170, 205, 255, .07);
}
.metric-card { padding: 18px; position: relative; overflow: hidden; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.metric-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: var(--grad); opacity: 0; transition: opacity .18s ease; }
.metric-card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 18px 50px rgba(2, 8, 20, .6), inset 0 1px 0 rgba(170, 205, 255, .1); }
.metric-card:hover::before { opacity: 1; }
.metric-card header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric-card header span { color: var(--muted); font-size: 12px; }
.metric-icon { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.mi-cyan { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.mi-blue { background: var(--blue); box-shadow: 0 0 10px var(--blue); }
.mi-green { background: var(--green); box-shadow: 0 0 10px var(--green); animation: pulse 2.2s ease-in-out infinite; }
.mi-violet { background: var(--violet); box-shadow: 0 0 10px var(--violet); }
.metric-card strong {
  display: block;
  font-size: clamp(21px, 2.2vw, 30px);
  letter-spacing: -.01em;
  margin: 9px 0 2px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff, #c4ddf5);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.metric-extra { color: var(--faint); font-size: 11px; min-height: 17px; }
.metric-card small { font-size: 11px; display: block; margin-top: 6px; }
.spark { display: block; width: 100%; height: 34px; margin-top: 8px; overflow: visible; }
.spark path.line { fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spark path.fill { opacity: .16; stroke: none; }

/* quota */
.quota-card { margin-top: 13px; padding: 17px 20px; }
.quota-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.quota-head h2 { font-size: 14px; color: #c7d9ea; }
.quota-text { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.quota-text b { color: var(--cyan); font-weight: 750; }
.quota-track { margin-top: 11px; height: 10px; border-radius: 999px; background: rgba(10, 24, 42, .9); border: 1px solid var(--line); overflow: hidden; position: relative; }
.quota-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad); box-shadow: 0 0 14px rgba(62, 230, 210, .45); transition: width .7s cubic-bezier(.2, .9, .25, 1), background .3s ease; }
.quota-fill.warn { background: linear-gradient(90deg, var(--amber), #ff9a62); box-shadow: 0 0 14px rgba(255, 191, 98, .4); }
.quota-fill.over { background: linear-gradient(90deg, var(--red), #ff5470); box-shadow: 0 0 14px rgba(255, 113, 133, .45); }
.quota-hint { margin-top: 8px; font-size: 11px; color: var(--faint); }

/* panels */
.panel { padding: 20px; }
.panel h2 { font-size: 16px; }
.chart-card { margin-top: 13px; }
.panel-head { align-items: flex-start; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.legend .up { background: var(--cyan); box-shadow: 0 0 7px var(--cyan); }
.legend .down { background: var(--blue); box-shadow: 0 0 7px var(--blue); }

.trend-chart { position: relative; height: 280px; margin-top: 14px; }
.trend-chart svg { display: block; width: 100%; height: 100%; overflow: hidden; }
.chart-grid { stroke: rgba(120, 165, 220, .16); stroke-width: 1; }
.chart-grid.zero { stroke: rgba(120, 165, 220, .3); }
.chart-label { fill: #7e96b4; font-size: 10px; }
.chart-line { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { stroke: none; }
.chart-focus { fill: #fff; stroke-width: 2; }
.chart-cross { stroke: rgba(190, 215, 245, .5); stroke-width: 1; stroke-dasharray: 3 3; }
.trend-overlay { fill: transparent; cursor: crosshair; }
.trend-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  pointer-events: none;
  min-width: 148px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(8, 18, 33, .92);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity .12s ease;
}
.trend-tooltip.on { opacity: 1; }
.trend-tooltip .tt-time { color: var(--muted); font-size: 11px; margin-bottom: 5px; font-variant-numeric: tabular-nums; }
.trend-tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.trend-tooltip .tt-row b { font-weight: 700; }
.tt-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }

.lower-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 13px; }

/* protocols */
.protocol-rows { display: flex; align-items: center; gap: 22px; margin-top: 16px; }
.protocol-donut { position: relative; width: 148px; height: 148px; flex: 0 0 auto; }
.protocol-donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-track { fill: none; stroke: rgba(120, 165, 220, .12); stroke-width: 14; }
.donut-seg { fill: none; stroke-width: 14; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.donut-center span { color: var(--faint); font-size: 11px; }
.protocol-list { flex: 1; display: grid; gap: 14px; min-width: 0; }
.protocol-row { display: grid; gap: 6px; }
.protocol-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.protocol-name { font-weight: 700; display: flex; align-items: center; gap: 7px; }
.protocol-name i { width: 8px; height: 8px; border-radius: 50%; }
.protocol-pct { color: var(--text); font-weight: 750; font-variant-numeric: tabular-nums; }
.protocol-traffic { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: rgba(16, 34, 56, .9); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: var(--grad); border-radius: inherit; transition: width .6s ease; }

/* collection */
.collection-rows { display: grid; gap: 10px; margin-top: 16px; }
.collection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(10, 23, 40, .5);
}
.collection-id { display: flex; align-items: center; gap: 9px; }
.status { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; letter-spacing: .04em; }
.status.ok { color: #8ff2c6; background: rgba(74, 222, 156, .13); }
.status.fail { color: #ffb3be; background: rgba(255, 113, 133, .13); }
.status.wait { color: #ffe0ae; background: rgba(255, 191, 98, .13); }
.collection-detail { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }

/* sources */
.sources-panel { margin-top: 13px; }
.sources-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.sources-filters { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.sources-filters input, .sources-filters select, .dialog select {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(6, 15, 28, .75);
  color: var(--text);
  padding: 8px 11px;
  font-size: 13px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.sources-filters input { min-width: 200px; flex: 0 1 240px; }
.sources-filters input:focus, .sources-filters select:focus { border-color: rgba(94, 176, 255, .65); box-shadow: 0 0 0 3px rgba(74, 148, 235, .15); outline: none; }
.source-count { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; margin-top: 12px; max-height: 460px; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
thead th { position: sticky; top: 0; z-index: 1; background: #0d1c31; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid rgba(90, 130, 180, .12); white-space: nowrap; }
th { color: #8ca8c4; font-weight: 600; font-size: 12px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sort-ind::after { content: " ↓"; color: var(--cyan); }
th.sort-ind.asc::after { content: " ↑"; }
td { color: #d4e5f5; font-size: 13px; }
td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: rgba(56, 100, 150, .14); }
.empty-table { text-align: center; color: var(--muted); padding: 26px; }

/* notice */
.notice { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(12, 28, 46, .45); color: var(--muted); font-size: 12px; }
.notice summary { cursor: pointer; padding: 10px 14px; color: #9db4cd; font-weight: 600; list-style: none; }
.notice summary::before { content: "ⓘ "; color: var(--cyan); }
.notice summary::-webkit-details-marker { display: none; }
.notice[open] summary { border-bottom: 1px solid var(--line); }
.notice p { padding: 11px 14px; line-height: 1.6; }

/* ============ dialogs ============ */
.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 9, 19, .66);
  backdrop-filter: blur(7px);
  animation: fadeIn .18s ease;
}
.dialog-layer[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  width: min(100%, 620px);
  max-height: min(780px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(18, 34, 56, .97), rgba(9, 19, 35, .97));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(170, 205, 255, .1);
  padding: 26px;
  animation: dialogIn .22s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes dialogIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.dialog h2 { font-size: 20px; }
.dialog-close { border: 0; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; width: 34px; height: 34px; border-radius: 8px; }
.dialog-close:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
.dialog form { display: grid; gap: 16px; }
.dialog label { display: grid; gap: 7px; color: #c5d8eb; font-weight: 600; }
.dialog input { border: 1px solid var(--line-strong); border-radius: 10px; background: rgba(6, 15, 28, .8); color: var(--text); padding: 10px 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 5px; flex-wrap: wrap; }

.share-list { display: grid; gap: 13px; }
.share-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; background: rgba(10, 23, 40, .5); }
.share-title { font-weight: 700; margin-bottom: 8px; font-size: 13px; }
.share-url { display: flex; gap: 7px; }
.share-url input { min-width: 0; flex: 1; font-size: 12px; color: #b9d2ea; font-variant-numeric: tabular-nums; }
.share-url button { flex: 0 0 auto; padding: 7px 12px; }
.qr-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 18px; }
.qr-card { padding: 12px 10px; text-align: center; background: rgba(255, 255, 255, .045); border: 1px solid var(--line); border-radius: 12px; }
.qr-card strong { font-size: 12px; }
.qr-card img { display: block; width: 118px; height: 118px; max-width: 100%; margin: 9px auto 0; background: #fff; border-radius: 10px; padding: 6px; }
.share-note { color: var(--muted); font-size: 12px; line-height: 1.5; }
.share-head-extra { display: flex; gap: 8px; align-items: center; }

/* toast */
.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  max-width: min(90vw, 520px);
  padding: 12px 16px;
  border: 1px solid rgba(90, 150, 210, .4);
  border-radius: 12px;
  background: rgba(16, 40, 66, .95);
  backdrop-filter: blur(10px);
  color: #e5f6ff;
  box-shadow: var(--shadow);
  animation: toastIn .25s cubic-bezier(.2, .9, .3, 1.15) both;
  font-size: 13px;
}
.toast.error { background: rgba(74, 24, 38, .95); border-color: rgba(255, 113, 133, .45); color: #ffdde3; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #27405e; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #35577d; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ============ responsive ============ */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: relative; top: 0; height: auto; min-width: 0; border-right: 0; border-bottom: 1px solid var(--line); padding: 16px 17px; }
  .link-list { display: flex; overflow: auto; padding-bottom: 3px; }
  .link-row { min-width: 200px; }
  .sidebar-foot { display: none; }
  .content { padding-top: 26px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .protocol-rows { flex-direction: column; align-items: stretch; }
  .protocol-donut { margin: 0 auto; }
  .qr-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .topbar { padding: 12px 16px; height: auto; min-height: 64px; flex-wrap: wrap; gap: 10px; }
  .topbar-actions { margin-left: auto; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
  .session-user { max-width: 105px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .content { padding: 22px 14px 40px; }
  .page-title-row { align-items: flex-start; flex-direction: column; }
  .header-tools { width: 100%; }
  .filters { align-items: flex-start; flex-direction: column; }
  .segmented { width: 100%; justify-content: space-between; }
  .segmented button { padding: 6px 9px; }
  .metrics { gap: 9px; }
  .metric-card { padding: 14px; }
  .lower-grid { grid-template-columns: 1fr; }
  .panel { padding: 15px; }
  .trend-chart { height: 220px; }
  .dialog { padding: 18px; }
  .share-url { flex-wrap: wrap; }
  .share-url input { width: 100%; flex-basis: 100%; }
  .sources-filters input { min-width: 0; flex: 1 1 100%; }
  .link-list { display: grid; grid-template-columns: minmax(0, 1fr); max-height: 230px; overflow: auto; }
  .link-row { min-width: 0; }
}
