/* ============================================================
   iStats 控制台
   轻量数据产品风格：浅色中性底 + 单主色，信息密度优先
   ============================================================ */

:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --border: #E6E8EE;
  --border-strong: #D6DAE3;
  --text: #14161A;
  --text-2: #4A5160;
  --muted: #7A8291;
  --faint: #9AA1AE;

  --primary: #3B5BDB;
  --primary-hover: #2F4AC4;
  --primary-soft: #EEF1FD;

  --web: #3B5BDB;
  --green: #0CA678;
  --green-soft: #E6F7F1;
  --red: #E03131;
  --red-soft: #FDECEC;
  --amber: #E8890C;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .03);
  --shadow-2: 0 8px 24px rgba(16, 24, 40, .08), 0 2px 6px rgba(16, 24, 40, .04);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* hidden 属性只在 UA 样式里是 display:none，任何类选择器里的 display
   （.login-mask / .shell / .view 等）都会覆盖它，导致 JS 切换 hidden 无效。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, dl, dd, dt, figure { margin: 0; }
button { font-family: inherit; font-size: inherit; color: inherit; }

svg { display: block; }
[data-icon] svg { display: block; }

.num, .tbl td.num, .kpi__value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ---------------------------------------------------- 品牌 */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 18px;
}

.brand__mark { color: var(--primary); flex: none; }

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.brand__text strong {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.brand__text em {
  font-style: normal;
  font-size: 11px;
  color: var(--faint);
  letter-spacing: .02em;
}

/* ---------------------------------------------------- 登录（左品牌 + 右表单分屏） */
.login-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(420px, 44%) 1fr;
  height: 100%;
}

/* 左：品牌叙事区 */
.login-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 44px 52px 34px;
  color: #fff;
  background: linear-gradient(160deg, #10173A 0%, #1A2450 48%, #24347E 100%);
}
/* 点阵纹理 + 顶部光晕 */
.login-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}
.login-hero::after {
  content: '';
  position: absolute;
  top: -180px;
  right: -120px;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(110, 139, 255, .38) 0%, transparent 65%);
  pointer-events: none;
}
.login-hero > * { position: relative; z-index: 1; }

.brand--hero { padding: 0; }
.brand--hero .brand__mark { color: #6E8BFF; }
.brand--hero .brand__text strong { font-size: 19px; color: #fff; }
.brand--hero .brand__text em { color: rgba(226, 232, 255, .55); }

.login-hero__title {
  margin: 40px 0 12px;
  font-size: 32px;
  line-height: 1.32;
  font-weight: 700;
  letter-spacing: -.02em;
}
.login-hero__sub {
  max-width: 42ch;
  font-size: 13.5px;
  line-height: 1.75;
  color: rgba(226, 232, 255, .72);
}

.login-hero__feats {
  list-style: none;
  margin: 26px 0 0;
  padding: 0;
  display: grid;
  gap: 13px;
}
.login-hero__feats li {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13px;
  color: rgba(226, 232, 255, .85);
}
.login-hero__ico {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(143, 166, 255, .16);
  border: 1px solid rgba(143, 166, 255, .24);
  color: #9FB2FF;
}

/* 装饰数据图形：玻璃拟态指标条 + 生长动画柱状图 */
.login-hero__viz { margin-top: auto; padding-top: 28px; }
.viz-chips { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.viz-chip {
  padding: 9px 14px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .13);
  font-size: 11.5px;
  color: rgba(226, 232, 255, .6);
  display: grid;
  gap: 2px;
}
.viz-chip b {
  font-size: 15px;
  font-weight: 650;
  color: #fff;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.viz-chip .up, .viz-chip .down {
  font-style: normal;
  font-size: 10.5px;
  font-weight: 500;
  color: #4ADE80;
}
.viz-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 86px;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
}
.viz-bars i {
  flex: 1;
  height: var(--h, 40%);
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, rgba(110, 139, 255, .9), rgba(59, 91, 219, .55));
  animation: vizBarIn .7s cubic-bezier(.2, .7, .3, 1) both;
}
.viz-bars i.is-now { background: linear-gradient(180deg, #9FB2FF, #5B78F0); }
@keyframes vizBarIn {
  from { height: 6%; opacity: .35; }
}
.login-hero__foot {
  margin-top: 18px;
  font-size: 11.5px;
  letter-spacing: .04em;
  color: rgba(226, 232, 255, .4);
}

/* 右：表单区 */
.login-panel {
  display: grid;
  place-items: center;
  padding: 40px 24px;
  overflow-y: auto;
  background:
    radial-gradient(800px 420px at 88% -6%, #EEF1FD 0%, transparent 60%),
    radial-gradient(620px 400px at 8% 106%, #E9F8F3 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow:
    0 24px 64px rgba(23, 26, 33, .10),
    0 4px 12px rgba(23, 26, 33, .05);
  padding: 34px 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.login-card__title {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
}

.login-card__hint {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: -8px;
}

.login-card__error {
  color: var(--red);
  font-size: 12.5px;
  background: var(--red-soft);
  border-radius: 6px;
  padding: 7px 10px;
}

.login-card__foot {
  text-align: center;
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 2px;
}

/* 移动端：品牌区收起，卡片内展示品牌；表单卡片铺满 */
.brand--card { display: none; padding: 0 0 2px; }
@media (max-width: 920px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .brand--card { display: flex; }
  .login-panel { padding: 24px 16px; }
}

/* 登录卡片内的控件精修：更高的输入框、渐变主按钮、验证码 GIF 对齐 */
.login-card .field input,
.login-card .captcha-row input { height: 40px; border-radius: 9px; }
.login-card .captcha-img { height: 40px; width: 118px; border-radius: 9px; }
.login-card .btn--primary {
  height: 42px;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(180deg, #4666E3, var(--primary));
  box-shadow: 0 6px 16px rgba(59, 91, 219, .28);
  transition: background .15s, box-shadow .15s, transform .1s;
}
.login-card .btn--primary:hover {
  background: linear-gradient(180deg, #3D5BD6, var(--primary-hover));
  box-shadow: 0 8px 20px rgba(59, 91, 219, .34);
}
.login-card .btn--primary:active { transform: translateY(1px); box-shadow: 0 3px 10px rgba(59, 91, 219, .28); }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > span {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}
.field input {
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 11px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, .12);
}

/* 验证码：输入框和 GIF 并排，图片整体是一个按钮（点哪里都能换） */
.captcha-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.captcha-row input { flex: 1; min-width: 0; }

.captcha-img {
  flex: none;
  width: 112px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #F3F4F8;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
  transition: border-color .15s;
}
.captcha-img:hover { border-color: var(--primary); }
.captcha-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* 还没拿到图时显示的占位文字，拿到后由 JS 加 is-ready 隐藏 */
.captcha-img em {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 11.5px;
  color: var(--faint);
}
.captcha-img.is-ready em { display: none; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  margin-left: 6px;
  font-size: 11.5px;
  color: var(--primary);
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* 自助注册后的空态：没有任何可见应用 */
.empty-state {
  max-width: 520px;
  margin: 48px auto;
  padding: 40px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-state__mark { color: var(--faint); }
.empty-state__title { font-size: 16px; font-weight: 650; }
.empty-state__text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}
.empty-state__text strong { color: var(--text); font-weight: 600; }
.empty-state__text code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.empty-state__actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  background: transparent;
}
.btn:active { transform: translateY(.5px); }

.btn--primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(59, 91, 219, .25);
}
.btn--primary:hover { background: var(--primary-hover); }

.btn--ghost {
  border-color: var(--border-strong);
  color: var(--text-2);
  background: var(--surface);
}
.btn--ghost:hover { border-color: var(--faint); color: var(--text); }

.btn--block { width: 100%; height: 38px; }
.btn--sm { height: 30px; font-size: 12.5px; padding: 0 10px; }

.btn svg { width: 15px; height: 15px; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------------------------------------------------- 骨架 */

.shell {
  display: grid;
  grid-template-columns: 236px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.nav {
  flex: 1;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav__label {
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 16px 10px 6px;
  font-weight: 600;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background .12s, color .12s;
}
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item svg { width: 16px; height: 16px; color: var(--faint); flex: none; }
.nav__item:hover svg { color: var(--text-2); }

.nav__item.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 550;
}
.nav__item.is-active svg { color: var(--primary); }
.nav__item.is-active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--primary);
}

.sidebar__foot {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
}
.who {
  display: flex;
  align-items: center;
  gap: 8px;
}
.who__avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex: none;
  text-transform: uppercase;
}
.who__name {
  font-size: 12.5px;
  color: var(--text-2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------- 主区 */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(245, 246, 248, .86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex: none;
  flex-wrap: wrap;
  /* backdrop-filter 形成的堆叠上下文要显式高于内容区，
   * 否则应用下拉菜单（fixed，本上下文内）会被 .content 的卡片盖住 */
  z-index: 10;
}

.topbar__title {
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -.015em;
}
.topbar__sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px 0 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
}
.select svg { width: 15px; height: 15px; color: var(--faint); flex: none; }
.select select {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  cursor: pointer;
  max-width: 180px;
  padding-right: 2px;
}
.select--sm { height: 30px; }

/* 顶栏左侧：标题 + 日期段同行 */
.topbar__left {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  min-width: 0;
}
.topbar__head { min-width: 0; }

/* 应用切换：自定义下拉（触发器 + fixed 菜单 + 搜索） */
.app-switch { position: relative; }
.app-switch__trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  max-width: 280px;
  transition: border-color .12s, box-shadow .12s;
}
.app-switch__trigger:hover { border-color: var(--faint); }
.app-switch__trigger:focus-visible,
.app-switch.is-open .app-switch__trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.app-switch__trigger svg { width: 15px; height: 15px; color: var(--faint); flex: none; }
.app-switch__name {
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-switch__mine {
  flex: none;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 1px 7px;
}
.app-switch__chev { color: var(--faint); flex: none; transition: transform .18s; }
.app-switch.is-open .app-switch__chev { transform: rotate(180deg); }

.app-switch__menu {
  /* fixed 定位脱离顶栏布局，坐标由 JS 按触发器实时计算、右对齐触发器 */
  position: fixed;
  z-index: 95;
  min-width: 250px;
  max-width: 300px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  display: grid;
  gap: 4px;
  overflow-y: auto;
  animation: platMenuIn .14s ease-out;
}
.app-switch__search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.app-switch__search:focus-within { border-color: var(--primary); background: var(--surface); }
.app-switch__search svg { width: 13px; height: 13px; color: var(--faint); flex: none; }
.app-switch__search input {
  flex: 1;
  min-width: 0;
  height: 30px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  outline: none;
}
.app-switch__search input::placeholder { color: var(--faint); }
.app-switch__list { display: grid; gap: 2px; }
.app-switch__opt {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.app-switch__opt:hover { background: var(--surface-2); }
.app-switch__opt-icon svg { width: 14px; height: 14px; color: var(--faint); flex: none; }
.app-switch__opt-text { flex: 1; min-width: 0; }
.app-switch__opt-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-switch__opt-text small {
  display: block;
  font-size: 11px;
  color: var(--faint);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-switch__opt .app-switch__check {
  color: var(--primary);
  opacity: 0;
  flex: none;
  margin-left: auto;
}
.app-switch__opt.is-active { background: var(--primary-soft); }
.app-switch__opt.is-active .app-switch__check { opacity: 1; }
.app-switch__opt.is-active .app-switch__opt-icon svg { color: var(--primary); }
.app-switch__empty {
  padding: 14px 10px;
  font-size: 12px;
  color: var(--faint);
  text-align: center;
}

.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.seg__btn {
  border: 0;
  background: transparent;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.seg__btn svg { width: 13px; height: 13px; }
.seg__btn:hover { color: var(--text-2); }
.seg__btn.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 550;
}
.seg--sm .seg__btn { height: 24px; font-size: 12px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 40px;
  min-height: 0;
  scroll-behavior: smooth;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise .22s ease-out;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------- 卡片 & 栅格 */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 16px 18px 18px;
  min-width: 0;
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card__title {
  font-size: 13.5px;
  font-weight: 620;
  letter-spacing: -.005em;
}
.card__sub {
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 2px;
}

.card--empty {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--faint);
  font-size: 13px;
}
.card--list { display: flex; flex-direction: column; min-height: 0; }

.grid { display: grid; gap: 16px; }
.grid--2-1 { grid-template-columns: minmax(0, 1.9fr) minmax(260px, 1fr); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--aside { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }

.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.note {
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.6;
  margin-top: 12px;
  padding: 9px 11px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ---------------------------------------------------- KPI */

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.kpis--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 15px;
  box-shadow: var(--shadow-1);
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.kpi__label {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.kpi__label svg { width: 13px; height: 13px; color: var(--faint); }

.kpi__value {
  font-size: 25px;
  font-weight: 620;
  letter-spacing: -.03em;
  line-height: 1.2;
  margin-top: 8px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.kpi__unit {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0;
}

.kpi__foot {
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--faint);
}
.kpi__spark {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 78px;
  height: 34px;
  opacity: .5;
  pointer-events: none;
}

/* ---------------------------------------------------- 表格 */

.table-wrap { overflow: auto; margin: 0 -4px; }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.tbl th {
  text-align: left;
  font-weight: 550;
  font-size: 11px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--surface-2);
  color: var(--text-2);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }

.tbl td.num, .tbl th.num { text-align: right; }
.tbl td.num { color: var(--text); font-weight: 500; }

.tbl .name {
  color: var(--text);
  font-weight: 500;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: -.01em;
}

.tbl .ell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* 单元格两行式：主文 + 次要说明 */
.cell-strong { color: var(--text); font-weight: 550; }
.cell-sub { color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.tbl tbody tr.is-active-app { background: var(--primary-soft); }
.tbl tbody tr.is-active-app:hover { background: var(--primary-soft); }
.mono { font-family: var(--mono); font-size: 11.5px; letter-spacing: -.01em; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 550;
  letter-spacing: .01em;
  background: var(--surface-2);
  color: var(--faint);
  border: 1px solid var(--border);
  margin-left: 6px;
  vertical-align: middle;
}
.tag--auto { background: var(--surface-2); color: var(--faint); }

.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.bar-cell__track {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
  min-width: 40px;
}
.bar-cell__fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  opacity: .8;
}

.empty-row {
  text-align: center;
  color: var(--faint);
  padding: 28px 0 !important;
  font-size: 12.5px;
}

/* ---------------------------------------------------- 图表 */

.chart { position: relative; width: 100%; height: 232px; }
.chart--sm { height: 150px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }

.chart .axis-text {
  font-size: 10px;
  fill: var(--faint);
  font-family: var(--font);
}
.chart .grid-line { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.chart .hit { fill: transparent; cursor: crosshair; }

/* ---------------------------------------------------- 端分布 */

.split { display: flex; flex-direction: column; gap: 10px; }

.split__row { display: flex; flex-direction: column; gap: 5px; }
.split__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
}
.split__label { display: flex; align-items: center; gap: 7px; color: var(--text-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.split__val { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }
.split__val span { color: var(--faint); font-weight: 400; margin-left: 5px; font-size: 11.5px; }

.split__track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}
.split__fill { height: 100%; border-radius: 4px; transition: width .35s ease; }

.facts { display: flex; flex-direction: column; gap: 9px; }
.facts > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
}
.facts dt { color: var(--muted); }
.facts dd {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.facts--kv dt { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.facts--kv dd { font-family: var(--mono); font-size: 12px; word-break: break-all; text-align: right; }

/* ---------------------------------------------------- 事件列表 */

.search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-bottom: 10px;
}
.search svg { width: 14px; height: 14px; color: var(--faint); flex: none; }
.search input {
  border: 0;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  width: 100%;
}
.search input::placeholder { color: var(--faint); }

.event-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  max-height: 560px;
  margin: 0 -6px;
}

.event-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .1s;
}
.event-item:hover { background: var(--surface-2); }
.event-item.is-active { background: var(--primary-soft); }
.event-item.is-active .event-item__name { color: var(--primary); font-weight: 550; }

.event-item__name {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-item__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.event-item__remark {
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-item__count {
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  flex: none;
}

/* 事件详情卡里的备注块：展示态一行 + 铅笔；编辑态 textarea */
.event-remark { margin-top: 10px; max-width: 520px; }
.event-remark__row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}
.event-remark__text {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-remark__text.is-empty { color: var(--faint); }
.event-remark__edit {
  flex: none;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  border-radius: 5px;
  color: var(--faint);
  cursor: pointer;
  transition: background .1s, color .1s;
}
.event-remark__edit:hover { background: var(--primary-soft); color: var(--primary); }
.event-remark__editor textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  resize: vertical;
  min-height: 64px;
}
.event-remark__editor textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft, rgba(59,91,219,.12));
}
.event-remark__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
.event-remark__count {
  margin-right: auto;
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* 详情头 */
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
/* 左列（名称/类型/备注）：给足基础宽度，备注 textarea 才不会被指标列挤成一窄条 */
.detail-head > div:first-child {
  flex: 1 1 360px;
  min-width: 0;
}
.detail-name {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.detail-metrics {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}
.detail-metric { display: flex; flex-direction: column; gap: 2px; }
.detail-metric__label { font-size: 11px; color: var(--faint); }
.detail-metric__value {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

/* 属性分布 */
.prop-group { padding: 12px 0; border-bottom: 1px solid var(--border); }
.prop-group:last-child { border-bottom: 0; padding-bottom: 0; }
.prop-group__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.prop-group__key {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}
.prop-group__total { font-size: 11px; color: var(--faint); }
.prop-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 56px;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  font-size: 12px;
}
.prop-row__val {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prop-row__count {
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* ---------------------------------------------------- 漏斗 */

.funnel-builder { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.funnel-step {
  display: flex;
  align-items: center;
  gap: 10px;
}
.funnel-step__idx {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex: none;
}
.funnel-step__select {
  flex: 1;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  min-width: 0;
}
.funnel-step__select:focus { border-color: var(--primary); }

.funnel-remove {
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  flex: none;
}
.funnel-remove:hover { background: var(--red-soft); color: var(--red); }
.funnel-remove svg { width: 14px; height: 14px; }

.funnel-chart { display: flex; flex-direction: column; gap: 16px; padding-top: 4px; }

.funnel-row { display: flex; flex-direction: column; gap: 7px; }
.funnel-row__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
}
.funnel-row__name { font-family: var(--mono); color: var(--text); font-weight: 500; }
.funnel-row__nums { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.funnel-row__nums b { color: var(--text); font-weight: 600; font-size: 13px; }

.funnel-bar {
  height: 30px;
  border-radius: 6px;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}
.funnel-bar__fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--primary) 0%, #5C7CFA 100%);
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 54px;
  transition: width .45s cubic-bezier(.4, 0, .2, 1);
}

/* ---------------------------------------------------- 留存热力 */

.heat {
  border-collapse: separate;
  border-spacing: 2px;
  font-size: 11.5px;
  width: 100%;
}
.heat th {
  font-size: 10.5px;
  font-weight: 550;
  color: var(--faint);
  padding: 0 4px 6px;
  text-align: center;
  white-space: nowrap;
}
.heat th:first-child, .heat td:first-child {
  text-align: left;
  padding-left: 2px;
  white-space: nowrap;
}
.heat td {
  text-align: center;
  padding: 7px 4px;
  border-radius: 5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  min-width: 46px;
}
.heat td.heat--empty { background: transparent; color: var(--faint); }
.heat .heat__cohort { color: var(--text-2); font-family: var(--mono); font-size: 11.5px; background: transparent; }
.heat .heat__size { color: var(--faint); font-size: 11px; }
.heat td.heat--cell { font-weight: 500; }

/* ---------------------------------------------------- 实时 */

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--green);
  background: var(--green-soft);
  padding: 3px 8px;
  border-radius: 20px;
}
.live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 1.6s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

.stream__props {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* ---------------------------------------------------- 代码块 */

.code {
  margin: 0;
  padding: 14px 16px;
  background: #15181F;
  color: #D7DCE5;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}
.code .c { color: #6B7688; }
.code .s { color: #8FD9A8; }
.code .k { color: #A9B8FF; }

/* ---------------------------------------------------- Toast / tooltip */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(8px);
  background: #1D2129;
  color: #fff;
  font-size: 12.5px;
  padding: 9px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transition: opacity .18s, transform .18s;
  z-index: 100;
  pointer-events: none;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

.tooltip {
  position: fixed;
  z-index: 70;
  background: #1D2129;
  color: #fff;
  font-size: 11.5px;
  padding: 7px 9px;
  border-radius: 6px;
  pointer-events: none;
  box-shadow: var(--shadow-2);
  line-height: 1.55;
  white-space: nowrap;
}
.tooltip b { font-weight: 600; }
.tooltip .tooltip__row { display: flex; gap: 8px; justify-content: space-between; }
.tooltip .tooltip__key { color: #A9AEB8; }

/* ---------------------------------------------------- 阈值告警 */

.alert-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
}
.alert-banner .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--faint);
}
.alert-banner--ok { border-color: #CFEFE4; background: var(--green-soft); color: #0B7A5A; }
.alert-banner--ok .dot { background: var(--green); }
.alert-banner--warn { border-color: #F5E0BE; background: #FDF6EA; color: #96601A; }
.alert-banner--warn .dot { background: var(--amber); }
.alert-banner code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: rgba(0, 0, 0, .05);
  padding: 1px 5px;
  border-radius: 4px;
}
/* 文案主体：flex:1 + min-width:0 让它可以正常收缩换行。
   横幅是 flex 容器，裸文本节点会成为匿名 flex 项、被压到 min-content
   宽度导致中文一字一行竖排——所以文案必须包在这个 span 里。 */
.alert-banner__msg {
  flex: 1;
  min-width: 0;
  line-height: 1.7;
}
.alert-banner__msg code { white-space: nowrap; }
/* 右侧巡检间隔/状态：不参与收缩 */
.alert-banner__when {
  flex: none;
  opacity: .8;
  white-space: nowrap;
}
.alert-banner__note {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid currentColor;
  opacity: .75;
}

.card__actions { display: flex; align-items: center; gap: 8px; }

.alert-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 16px;
  margin-bottom: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
}
.field--wide { grid-column: 1 / -1; }
.field select {
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 9px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, .12);
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.alert-form__err {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--red);
  background: var(--red-soft);
  border-radius: 6px;
  padding: 7px 10px;
}

/* 启用开关 */
.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 19px;
  flex: none;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute;
  inset: 0;
  background: #D6DAE3;
  border-radius: 999px;
  transition: background .15s;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .2);
  transition: transform .15s;
}
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(15px); }

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.link-btn {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--primary);
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 2px; }
.link-btn--danger { color: var(--red); }
.link-btn[disabled] { color: var(--faint); cursor: not-allowed; text-decoration: none; }

.tag--ok     { background: var(--green-soft); color: #0B7A5A; border-color: #CFEFE4; }
.tag--sent   { background: var(--green-soft); color: #0B7A5A; border-color: #CFEFE4; }
.tag--dry    { background: #FDF6EA; color: #96601A; border-color: #F5E0BE; }
.tag--fail   { background: var(--red-soft); color: var(--red); border-color: #F8D5D5; }
.tag--idle   { background: var(--surface-2); color: var(--faint); border-color: var(--border); }

/* ---------------------------------------------------- 异常监控 */

.err-type {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  letter-spacing: -.01em;
  word-break: break-all;
}
.err-msg {
  margin-top: 2px;
  max-width: 420px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}
.err-msg--one {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.err-msg--one:empty::before { content: "(无消息)"; }

.tbl tbody tr.err-row { cursor: pointer; }
.tbl tbody tr.err-row.is-open { background: var(--primary-soft); }
.tbl tbody tr.err-row.is-open td { border-bottom-color: transparent; }
.tbl tbody tr.err-stack-row:hover { background: transparent; }
.err-stack-row > td { padding: 0 8px 14px !important; }

.err-stack {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #0F1420;
  color: #C6D0E2;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 340px;
  overflow: auto;
}

@media (max-width: 1080px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------- 响应式 */

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .grid--2-1 { grid-template-columns: minmax(0, 1fr); }
  .grid--2 { grid-template-columns: minmax(0, 1fr); }
  .grid--aside { grid-template-columns: minmax(0, 1fr); }
  .event-list { max-height: 240px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kpis, .kpis--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding: 12px 14px; }
  .topbar__left { gap: 12px; }
  .app-switch__trigger { max-width: 200px; }
  .content { padding: 14px; }
}

/* ============================================================
   账号与授权
   ============================================================ */

.who__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.25;
}
.who__role {
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.role-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
}
.role-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.role-card__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.role-card__name {
  font-size: 13.5px;
  font-weight: 600;
}
.role-card__code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  margin-left: auto;
}
.role-card__desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}

.inline-form {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
}
.inline-form__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.acc-list { display: flex; flex-direction: column; gap: 8px; }

.acc-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.acc-row.is-disabled { opacity: .6; }

.acc-row__main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}
.acc-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  flex: none;
  text-transform: uppercase;
}
.acc-id {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.acc-id strong { font-size: 13.5px; font-weight: 600; }
.acc-id em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acc-badge {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}
.acc-badge--on { background: var(--green-soft); color: var(--green); border-color: #CFEFE4; }
.acc-badge--off { background: var(--red-soft); color: var(--red); border-color: #F8D7D7; }
.acc-badge--super { background: var(--primary-soft); color: var(--primary); border-color: #DDE3FB; }

.acc-scope {
  font-size: 12px;
  color: var(--muted);
  flex: none;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-actions { display: flex; gap: 6px; flex: none; }
.acc-actions button {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}
.acc-actions button:hover { border-color: var(--border-strong); color: var(--text); }
.acc-actions button[data-act="delete"]:hover { color: var(--red); border-color: #F5C2C2; }

.acc-panel {
  border-top: 1px dashed var(--border);
  background: var(--surface-2);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.acc-panel__hint { font-size: 12px; color: var(--muted); }

.grant-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
}
.grant-item__app {
  min-width: 130px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grant-item__id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}
.grant-chks { display: flex; align-items: center; gap: 12px; flex: 1; }
.grant-chk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  color: var(--text-2);
  user-select: none;
}
.grant-chk input { margin: 0; cursor: pointer; }
.grant-chk--write { color: var(--primary); font-weight: 500; }
.grant-item.is-off .grant-chks { opacity: .45; }

@media (max-width: 900px) {
  .role-cards { grid-template-columns: 1fr; }
  .acc-row__main { flex-wrap: wrap; }
  .acc-scope { max-width: 100%; }
}

/* 只读角色：开关整体降透明度，让人一眼看出点不动 */
.switch input:disabled + i,
.switch input:disabled ~ i { opacity: .45; }
.switch:has(input:disabled) { cursor: not-allowed; }

.acc-role {
  height: 26px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  padding: 0 4px;
  font-family: inherit;
  cursor: pointer;
}
.acc-role:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------- 告警表单：字段条件与渠道 */

.field__hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}
.field input:disabled {
  background: var(--surface-2, #F7F8FA);
  color: var(--muted);
  cursor: not-allowed;
}

/* 字段条件的小标签，跟事件名并列显示在规则表格里 */
.cond-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--primary-soft, #EEF1FC);
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

/* 通知渠道多选 */
.chk-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chk:hover { border-color: var(--primary); }
.chk input { margin: 0; cursor: pointer; }
.chk em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}
.chk--off {
  background: var(--surface-2, #F7F8FA);
  color: var(--muted);
  cursor: not-allowed;
}
.chk--off:hover { border-color: var(--border-strong); }
.chk--off input { cursor: not-allowed; }

/* 规则表格里的渠道标签 */
.ch-tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* 横幅里的补充说明：正常态横幅是绿色底，这行用中性色，别抢主信息 */
.alert-banner__note {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid currentColor;
  opacity: .75;
}

/* ============================================================
   应用表单 / 接入信息：整页视图（非弹层）
   这两个 section 是 body 直接子元素、排在外壳（100vh 的 .shell）之后；
   必须用 fixed 全屏覆盖，否则内容落在「第二屏」，要滚过整个外壳才看得到。
   ============================================================ */
.view[data-view="app-form"],
.view[data-view="app-detail"] {
  position: fixed;
  inset: 0;
  z-index: 60;          /* 高于外壳内容，低于 toast(100) */
  background: var(--bg);
  overflow-y: auto;
  padding: 20px 16px 28px;
}

.page-panel {
  /* 父级 .view 是 flex column：交叉轴 auto margin 会禁用 stretch，
     必须显式 width:100% 才能撑满到 max-width，否则卡片塌成内容宽度 */
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
}

.page-back {
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* 新建 / 编辑应用弹窗：入口在顶栏右上角。遮罩 z=90，toast(100) 在其上不会被遮 */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(23, 26, 33, .45);
}
.modal-mask[hidden] { display: none; }  /* 类里的 display:flex 会压过 hidden 的 UA 规则 */
.modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(23, 26, 33, .25);
  padding: 18px 18px 16px;
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.modal__title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal__close {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.modal__close:hover { color: var(--text); background: var(--bg); }
.modal .field { margin-bottom: 12px; }
.modal__note { margin-top: 2px; }

/* ---- 应用弹窗：平台服务自定义下拉（图标 + 说明 + 选中态） ---- */
.plat-select { position: relative; }
.plat-select__trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 44px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, box-shadow .15s;
}
.plat-select__trigger:hover { border-color: var(--faint); }
.plat-select__trigger:focus-visible,
.plat-select.is-open .plat-select__trigger {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.plat-select__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.plat-select__text strong { font-size: 13.5px; font-weight: 600; color: var(--text); }
.plat-select__text small { font-size: 11.5px; color: var(--faint); }
.plat-select__chev { color: var(--faint); flex: none; transition: transform .18s; }
.plat-select.is-open .plat-select__chev { transform: rotate(180deg); }

.plat-icon {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.plat-icon svg { display: block; }
.plat-icon--web         { background: var(--primary-soft); color: var(--web); }
.plat-icon--flutter     { background: #E3FAFC; color: #0C8599; }
.plat-icon--server      { background: #F3F0FF; color: #7048E8; }
.plat-icon--miniprogram { background: var(--green-soft); color: var(--green); }
.plat-icon--other       { background: #F1F3F5; color: var(--faint); }

.plat-select__menu {
  /* fixed 定位脱离弹窗的 overflow 裁剪，坐标由 JS 按触发器实时计算 */
  position: fixed;
  z-index: 95;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  display: grid;
  gap: 2px;
  overflow-y: auto;
  animation: platMenuIn .14s ease-out;
}
@keyframes platMenuIn {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.plat-select__opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.plat-select__opt:hover { background: var(--surface-2); }
.plat-select__opt .plat-select__check {
  color: var(--primary);
  opacity: 0;
  flex: none;
  margin-left: auto;
}
.plat-select__opt.is-active { background: var(--primary-soft); }
.plat-select__opt.is-active .plat-select__check { opacity: 1; }

/* 表单控件：field 里除了 input，还要接住 select / textarea */
.field .req { color: #E03131; font-style: normal; margin-left: 2px; }
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  box-sizing: border-box;
}
.field select { height: 38px; padding: 0 11px; }
.field textarea { resize: vertical; min-height: 66px; }
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, .12);
}
.page-panel .field { margin-bottom: 12px; }

/* 接入信息里的凭证块 */
.cred-list { display: grid; gap: 8px; margin: 0; }
.cred-list > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2, #F7F8FA);
  border: 1px solid var(--border, #E4E7EF);
  border-radius: var(--radius-sm);
}
.cred-list dt {
  flex: none;
  width: 72px;
  font-size: 12px;
  color: var(--text-2);
}
.cred-list dd {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  word-break: break-all;
}
.cred-list dd.plain { font-family: inherit; }
.cred-copy { flex: none; }
.cred-note { margin: 10px 0 0; }
.cred-guide-title {
  margin: 18px 0 8px;
  font-size: 13.5px;
  font-weight: 600;
}

/* ============================================================
   账号列表：搜索工具栏 + 分页条
   ============================================================ */
.acc-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.acc-toolbar input[type="search"] {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.acc-toolbar input[type="search"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, .12);
}
.acc-toolbar select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.acc-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-2);
}
.acc-pager__info { white-space: nowrap; }
.acc-pager select {
  padding: 3px 8px;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.acc-pager button[disabled] { opacity: .4; cursor: not-allowed; }
