:root {
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-pill: 999px;
  --blur-sm: 10px;
  --blur-md: 18px;
  --blur-lg: 28px;
  --blur-xl: 38px;
  --shadow-soft: 0 16px 48px rgba(15, 23, 42, .08);
  --shadow-float: 0 24px 64px rgba(15, 23, 42, .12);
  --content-max: 1240px;
  --side-width: 320px;
  --header-height: 72px;
  --hero-radius: 32px;
  --brand-light: #0071e3;
  --brand-dark: #2997ff;
  --light-bg-image: url("/assets/site-background.webp");
  --dark-bg-image: url("/assets/site-background.webp");

  --bg: #f5f5f7;
  --bg-elevated: rgba(255, 255, 255, .20);
  --bg-soft: rgba(255, 255, 255, .14);
  --bg-strong: rgba(255, 255, 255, .36);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --line: rgba(60, 60, 67, .12);
  --line-strong: rgba(60, 60, 67, .2);
  --brand: var(--brand-light);
  --brand-soft: rgba(0, 113, 227, .14);
  --success: #1f8a3b;
  --danger: #d70015;
  --warn: #c77c00;
}

/* 白天：减轻磨砂、背景更清晰、盈亏字更利落 */
html:not([data-theme="dark"]) .page-bg-image {
  opacity: .58;
}
html:not([data-theme="dark"]) .page-gradient {
  opacity: .28;
}
html:not([data-theme="dark"]) .glass-shell,
html:not([data-theme="dark"]) .glass-card,
html:not([data-theme="dark"]) .card {
  background: rgba(255, 255, 255, .28);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
}
html:not([data-theme="dark"]) #stat-cards .card,
html:not([data-theme="dark"]) #home-instances .inst-box,
html:not([data-theme="dark"]) #home-instances .inst-box-empty {
  background: rgba(255, 255, 255, .22);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .05);
}
html:not([data-theme="dark"]) .pos,
html:not([data-theme="dark"]) .card .v.pos,
html:not([data-theme="dark"]) .inst-float.pos,
html:not([data-theme="dark"]) .inst-eq .val.pos,
html:not([data-theme="dark"]) .inst-safe,
html:not([data-theme="dark"]) .pnl-cal-pnl.pos,
html:not([data-theme="dark"]) .pnl-cal-extra .pos {
  color: #167a34;
  text-shadow: none;
  -webkit-font-smoothing: antialiased;
}

html[data-theme="dark"] {
  --bg: #0b0b0f;
  --bg-elevated: rgba(28, 28, 30, .08);
  --bg-soft: rgba(44, 44, 46, .06);
  --bg-strong: rgba(28, 28, 30, .22);
  --text: #f5f5f7;
  --text-2: #c7c7cc;
  --text-3: #8e8e93;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .14);
  --brand: var(--brand-dark);
  --brand-soft: rgba(41, 151, 255, .12);
  --success: #30d158;
  --danger: #ff453a;
  --warn: #ff9f0a;
  --shadow-soft: 0 16px 48px rgba(0, 0, 0, .18);
  --shadow-float: 0 24px 64px rgba(0, 0, 0, .26);
}

html[data-theme="dark"] .glass-shell,
html[data-theme="dark"] .glass-card,
html[data-theme="dark"] .card {
  backdrop-filter: blur(36px) saturate(190%);
  -webkit-backdrop-filter: blur(36px) saturate(190%);
}

/* 总览统计卡 + 实例卡片：跟「今日已实现 / 本月」pill 一样透 */
html[data-theme="dark"] #stat-cards .card,
html[data-theme="dark"] #home-instances .inst-box,
html[data-theme="dark"] #home-instances .inst-box-empty {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "SF Pro Display", "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }
.hidden { display: none !important; }
.muted { color: var(--text-2); margin: 0; }

.page-bg {
  position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
  background: var(--bg);
}
body > :not(.page-bg) { position: relative; z-index: 1; }
body > .gate { position: fixed; inset: 0; z-index: 1000; }
body > .modal { position: fixed; inset: 0; z-index: 1200; }
.page-bg-image {
  position: absolute; inset: 0;
  background-image: var(--light-bg-image);
  background-position: center;
  background-size: cover;
  opacity: .37;
}
html[data-theme="dark"] .page-bg-image {
  background-image: var(--dark-bg-image);
  opacity: .25;
}
.page-gradient {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .65;
}
.page-gradient-a {
  width: 40vw; height: 40vw; left: -8vw; top: -12vw;
  background: rgba(10, 132, 255, .2);
}
.page-gradient-b {
  width: 36vw; height: 36vw; right: -8vw; top: 10vh;
  background: rgba(94, 92, 230, .14);
}

.glass-shell,
.glass-card {
  position: relative;
  background: var(--bg-elevated);
  backdrop-filter: blur(var(--blur-lg)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(160%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.glass-shell { border-radius: var(--hero-radius); }
.glass-card { border-radius: var(--radius-lg); }

.site-header-wrap,
.site-frame {
  width: min(calc(100% - 32px), var(--content-max));
  margin: 0 auto;
}
.site-header-wrap { margin-top: 16px; }
.site-frame { margin: 24px auto 32px; }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: var(--header-height); padding: 12px 16px;
}
.site-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), rgba(255, 255, 255, .94));
  color: #fff; font-weight: 800; font-size: 1.1rem; flex: none;
}
html[data-theme="dark"] .brand-mark {
  background: linear-gradient(135deg, var(--brand), rgba(255, 255, 255, .28));
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1rem; line-height: 1.2; }
.brand-text small {
  color: var(--text-3);
  margin-top: 4px;
  line-height: 1.35;
}
.site-nav { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: center; }
.nav-link {
  padding: 10px 14px; border-radius: var(--radius-pill); border: none;
  background: transparent; color: var(--text-2);
}
.nav-link:hover, .nav-link.is-active { background: var(--bg-soft); color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  padding: 0; background: var(--bg-soft); display: grid; place-items: center;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 18px; border-radius: var(--radius-pill);
  border: 1px solid transparent; font-weight: 700; transition: .25s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-soft); }
.btn-secondary { background: var(--bg-soft); border-color: var(--line); }
.btn.danger { color: var(--danger); border-color: rgba(255, 69, 58, .28); }

.content-grid {
  display: grid;
  grid-template-columns: var(--side-width) minmax(0, 1fr);
  gap: 24px;
}
.main-column, .side-column { min-width: 0; }
.side-column {
  display: grid; gap: 18px; align-self: start;
  position: sticky; top: 104px;
  max-height: calc(100vh - 120px);
  min-height: 0;
}
.sidebar-card {
  padding: 18px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100vh - 120px);
  max-height: calc(100vh - 120px);
  overflow: hidden;
}
.sidebar-card .section-head,
.sidebar-card .side-actions {
  flex: none;
}
.section-head {
  display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 16px;
}
.section-head h2 { margin: 0; font-size: 1.2rem; }
.section-head.compact h2 { font-size: 1rem; }
.section-head span { color: var(--text-3); font-size: .92rem; }
.side-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.side-actions .btn { width: 100%; }
.group-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.g-block {
  border: 1px solid var(--line); border-radius: var(--radius-md);
  overflow: hidden; background: var(--bg-soft);
  flex: 0 0 auto;
}
.g-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600;
  cursor: pointer; user-select: none; gap: 8px;
}
.g-head:hover { background: rgba(255,255,255,.04); }
.g-head-title {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  flex: 1;
}
.g-head-title .g-toggle {
  flex: 0 0 auto;
  width: 16px;
  color: var(--text-3);
  font-size: .75rem;
}
.g-head-title .g-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.g-head-title .g-count {
  flex: 0 0 auto;
  color: var(--text-3);
  font-size: .78rem;
  font-weight: 500;
}
.g-head-actions { display: flex; align-items: center; flex: 0 0 auto; }
.g-head button { border: none; background: none; color: var(--text-3); padding: 2px 6px; border-radius: 8px; }
.g-body {
  max-height: min(280px, 38vh);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.g-block.collapsed .g-body { display: none; }
.g-block.collapsed .g-head { border-bottom: none; }
.inst-item { padding: 11px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.inst-item:hover, .inst-item.active { background: var(--brand-soft); }
.inst-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.inst-item .name {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inst-item .inst-rename {
  flex: 0 0 auto;
  border: none;
  background: none;
  color: var(--text-3);
  padding: 2px 6px;
  border-radius: 8px;
  cursor: pointer;
  opacity: .55;
}
.inst-item:hover .inst-rename,
.inst-item.active .inst-rename { opacity: 1; }
.inst-item .inst-rename:hover { color: var(--brand); background: rgba(255,255,255,.06); }
.inst-item .sub { color: var(--text-3); font-size: .82rem; margin-top: 2px; }
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; background: var(--text-3); vertical-align: middle;
}
.dot.on { background: var(--success); box-shadow: 0 0 0 3px rgba(48, 209, 88, .22); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 159, 10, .22); }

.hero-home {
  display: grid; grid-template-columns: 1.2fr .9fr; gap: 22px;
  padding: 26px; min-height: 200px; margin-bottom: 22px;
}
.hero-copy { display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.hero-copy h1 { margin: 0; font-size: clamp(1.8rem, 3.2vw, 3rem); line-height: 1.05; letter-spacing: -.04em; }
.hero-subtitle { margin: 0; max-width: 60ch; color: var(--text-2); font-size: 1.02rem; }
.hero-panel { display: grid; gap: 12px; }
.hero-stat {
  padding: 16px; border-radius: var(--radius-md);
  background: var(--bg-soft); border: 1px solid var(--line);
}
.hero-stat .label { display: block; color: var(--text-3); font-size: .9rem; margin-bottom: 6px; }
.hero-stat strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.hero-stat strong.pos { color: var(--success); }
.hero-stat strong.neg { color: var(--danger); }

.chip-row, .meta-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.meta-pill, .chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font-size: .9rem;
}
.meta-pill.accent { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.meta-pill b { font-weight: 700; }

.stack { display: grid; gap: 18px; }
.panel { padding: 22px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 14px;
}
.card {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(var(--blur-lg)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(160%);
}
.card .k { color: var(--text-3); font-size: .9rem; margin-bottom: 6px; }
.card .v { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .v.pos, .pos { color: var(--success); }
.card .v.neg, .neg { color: var(--danger); }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
.trade-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.trade-filter-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.trade-filter-field > span {
  color: var(--text-3);
  font-size: .92rem;
  font-weight: 600;
}
.trade-filter-field select,
.trade-filter-field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-strong);
  color: var(--text);
  font-size: 1rem;
}
.trade-filter-field select:disabled {
  opacity: .55;
}
@media (max-width: 720px) {
  .trade-filter-grid { grid-template-columns: 1fr; }
}

.trade-filters { display: grid; gap: 14px; margin-bottom: 16px; }
.filter-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.filter-lab {
  padding-top: 10px;
  color: var(--text-3);
  font-size: .92rem;
  font-weight: 600;
}
.trade-filters .chip-row { gap: 8px; }
.trade-filters .chip {
  cursor: pointer;
  min-height: 40px;
  font-weight: 600;
  color: var(--text-2);
}
.trade-filters .chip:hover { border-color: var(--brand); color: var(--text); }
.trade-filters .chip.is-active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--text);
}
.trade-filters .chip.is-disabled {
  opacity: .45;
  pointer-events: none;
}

.toolbar, .inst-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.cal-toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin: 16px 0 12px;
}
.cal-toolbar select { min-width: 160px; }
.pnl-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.pnl-cal-head {
  text-align: center;
  color: var(--text-3);
  font-size: .85rem;
  font-weight: 600;
  padding: 6px 0;
}
.pnl-cal-cell {
  min-height: 96px;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
button.pnl-cal-cell {
  font: inherit;
}
.pnl-cal-cell.is-day:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}
.pnl-cal-cell.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
  background: color-mix(in srgb, var(--brand) 10%, var(--bg-soft));
}
.pnl-cal-cell.empty {
  background: transparent;
  border-color: transparent;
  min-height: 0;
  cursor: default;
  pointer-events: none;
}
.pnl-cal-cell.today {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand-soft);
}
.day-trades-panel {
  margin-top: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.day-trades-table {
  margin-top: 10px;
  min-height: 240px;
  max-height: min(48vh, 520px);
  overflow: auto;
}
.day-trades-table th,
.day-trades-table td {
  white-space: nowrap;
  padding: 10px 12px;
}
.pnl-cal-day {
  font-size: .82rem;
  color: var(--text-3);
  font-weight: 600;
}
.pnl-cal-pnl {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  word-break: break-all;
}
.pnl-cal-pnl.muted { color: var(--text-3); font-weight: 500; font-size: .9rem; }
.pnl-cal-trades {
  margin-top: auto;
  font-size: .75rem;
  color: var(--text-3);
}
.pnl-cal-extra {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.pnl-cal-extra .pos { color: var(--success); }
.pnl-cal-extra .neg { color: var(--danger); }
.inst-head { justify-content: space-between; margin-bottom: 14px; }
.inst-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
.inst-edit-grid label {
  display: grid;
  gap: 6px;
  font-size: .85rem;
  color: var(--text-3);
  font-weight: 600;
}
.inst-edit-grid input,
.inst-edit-grid select {
  width: 100%;
  min-width: 0;
  border-radius: var(--radius-md);
}
.inst-edit-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.inst-edit-actions .muted { font-size: .82rem; font-weight: 400; }

html[data-theme="dark"] { color-scheme: dark; }
html:not([data-theme="dark"]) { color-scheme: light; }

input, select {
  background: var(--bg-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 10px 14px;
  min-width: 120px;
  outline: none;
  color: var(--text);
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
select option,
select optgroup {
  background-color: #1c1c1e;
  color: #f5f5f7;
}
html:not([data-theme="dark"]) select option,
html:not([data-theme="dark"]) select optgroup {
  background-color: #ffffff;
  color: #1d1d1f;
}

/* 自定义下拉：跟玻璃卡片一致，避免系统弹层发灰 */
.ui-select {
  position: relative;
  width: 100%;
  min-width: 120px;
}
.ui-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-strong);
  color: var(--text);
  text-align: left;
}
.ui-select-trigger:hover,
.ui-select.is-open .ui-select-trigger {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.ui-select-trigger .caret {
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-3);
  flex: none;
}
.ui-select.is-open .ui-select-trigger .caret {
  transform: rotate(180deg);
}
.ui-select-menu {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  display: none;
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: rgba(28, 28, 30, .92);
  backdrop-filter: blur(var(--blur-md)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(160%);
  box-shadow: var(--shadow-float);
}
html:not([data-theme="dark"]) .ui-select-menu {
  background: rgba(255, 255, 255, .94);
}
.ui-select.is-open .ui-select-menu { display: grid; gap: 2px; }
.ui-select-option {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  width: 100%;
}
.ui-select-option:hover,
.ui-select-option.is-active {
  background: var(--brand-soft);
  color: var(--brand);
}
.modal-card .ui-select,
.inst-edit-grid .ui-select,
.toolbar .ui-select,
.cal-toolbar .ui-select {
  width: 100%;
}
.toolbar .ui-select { width: auto; min-width: 160px; }
.cal-toolbar .ui-select { min-width: 160px; }

.table-wrap { overflow: auto; max-height: 420px; }
#trades-table.table-wrap {
  margin-top: 16px;
  min-height: 640px;
  max-height: min(78vh, 920px);
}
#trades-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
#trades-table th,
#trades-table td {
  padding: 12px 14px;
  white-space: nowrap;
}
#trades-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--bg-strong) 92%, transparent);
  backdrop-filter: blur(8px);
}

#alerts-table.table-wrap {
  margin-top: 12px;
  min-height: 560px;
  max-height: min(78vh, 920px);
  max-width: 100%;
  overflow: auto;
}
#alerts-table table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.92rem;
}
#alerts-table th,
#alerts-table td {
  padding: 12px 12px;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
}
#alerts-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--bg-strong) 92%, transparent);
  backdrop-filter: blur(8px);
}
#alerts-table th:nth-child(1),
#alerts-table td:nth-child(1) { width: 148px; white-space: nowrap; }
#alerts-table th:nth-child(2),
#alerts-table td:nth-child(2) { width: 64px; }
#alerts-table th:nth-child(3),
#alerts-table td:nth-child(3) { width: 96px; }
#alerts-table th:nth-child(4),
#alerts-table td:nth-child(4) { width: 120px; word-break: break-all; }
#alerts-table th:nth-child(5),
#alerts-table td:nth-child(5) { width: auto; }
#alerts-table th:nth-child(6),
#alerts-table td:nth-child(6) { width: 72px; white-space: nowrap; }
#alerts-table .alert-msg {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.badge-soft,
.badge-warn {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}
.badge-soft {
  background: var(--bg-soft);
  color: var(--text-3);
  border: 1px solid var(--line);
}
.badge-warn {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
}
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.pager .btn { min-height: 36px; padding: 0 14px; }
.pager .btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
}
.pager-info {
  color: var(--text-3);
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
}

.group-nav,
.g-body,
.table-wrap {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.group-nav:hover,
.g-body:hover,
.table-wrap:hover {
  scrollbar-color: rgba(255, 255, 255, .28) transparent;
}
html:not([data-theme="dark"]) .group-nav:hover,
html:not([data-theme="dark"]) .g-body:hover,
html:not([data-theme="dark"]) .table-wrap:hover {
  scrollbar-color: rgba(60, 60, 67, .32) transparent;
}
.group-nav::-webkit-scrollbar,
.g-body::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.group-nav::-webkit-scrollbar-track,
.g-body::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}
.group-nav::-webkit-scrollbar-thumb,
.g-body::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
.group-nav:hover::-webkit-scrollbar-thumb,
.g-body:hover::-webkit-scrollbar-thumb,
.table-wrap:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .2);
  background-clip: padding-box;
}
.group-nav:hover::-webkit-scrollbar-thumb:hover,
.g-body:hover::-webkit-scrollbar-thumb:hover,
.table-wrap:hover::-webkit-scrollbar-thumb:hover {
  background: var(--brand);
  background-clip: padding-box;
}
html:not([data-theme="dark"]) .group-nav:hover::-webkit-scrollbar-thumb,
html:not([data-theme="dark"]) .g-body:hover::-webkit-scrollbar-thumb,
html:not([data-theme="dark"]) .table-wrap:hover::-webkit-scrollbar-thumb {
  background: rgba(60, 60, 67, .28);
  background-clip: padding-box;
}
html:not([data-theme="dark"]) .group-nav:hover::-webkit-scrollbar-thumb:hover,
html:not([data-theme="dark"]) .g-body:hover::-webkit-scrollbar-thumb:hover,
html:not([data-theme="dark"]) .table-wrap:hover::-webkit-scrollbar-thumb:hover {
  background: var(--brand);
  background-clip: padding-box;
}
.group-nav::-webkit-scrollbar-corner,
.g-body::-webkit-scrollbar-corner,
.table-wrap::-webkit-scrollbar-corner {
  background: transparent;
}
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--line); text-align: left; padding: 10px 8px; white-space: nowrap; }
th { color: var(--text-3); font-weight: 600; }
.meta { color: var(--text-2); }

.secret-box {
  background: var(--bg-soft);
  border: 1px dashed var(--brand);
  border-radius: var(--radius-md);
  padding: 14px; word-break: break-all; white-space: pre-wrap; font-size: .92rem;
}

.gate {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
}
.gate-backdrop {
  position: absolute; inset: 0;
  background: rgba(11, 11, 15, .45);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.gate-modal {
  position: relative; width: min(420px, 92vw); padding: 28px 24px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-float);
}
.gate-modal h1 { margin: 0; font-size: 1.8rem; letter-spacing: -.04em; }
.gate-modal label { font-size: .86rem; color: var(--text-3); }
.gate-modal input, .gate-modal .btn { width: 100%; }
.error { color: var(--danger); min-height: 1.2em; }

.modal {
  position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); backdrop-filter: blur(10px); }
.modal-card {
  position: relative; width: min(480px, 94vw); padding: 22px; z-index: 1;
  box-shadow: var(--shadow-float);
  overflow: visible;
}
.modal-card label { display: block; margin: 12px 0 6px; color: var(--text-3); font-size: .86rem; }
.modal-card input, .modal-card select { width: 100%; }
.modal-card .ui-select { z-index: 2; }
.modal-card .ui-select.is-open { z-index: 6; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.inst-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.inst-head-bar {
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  margin-bottom: 14px;
}
.inst-head-bar h2 { display: none; }
.filter-chips {
  flex: none;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.filter-chips .chip {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  backdrop-filter: blur(var(--blur-sm)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(140%);
  color: var(--text-2);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  transition: .2s ease;
}
.filter-chips .chip-label {
  cursor: default;
  color: var(--text);
  font-weight: 700;
  background: var(--bg-strong);
}
.filter-chips .chip-label:hover {
  color: var(--text);
  border-color: var(--line);
}
.filter-chips .chip.is-active {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand);
}
.filter-chips .chip:hover {
  color: var(--text);
  border-color: var(--line-strong);
}
.inst-box {
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
  display: flex;
  flex-direction: column;
}
.inst-box:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-float);
}
.inst-box-body {
  padding: 16px 16px 12px;
  display: grid;
  gap: 8px;
}
.inst-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.inst-box-title {
  min-width: 0;
  font-weight: 700;
  font-size: 1.02rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inst-box-title .gid {
  color: var(--text-3);
  font-weight: 600;
  margin-right: 6px;
}
.badge-online,
.badge-offline {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  font-size: .78rem;
  font-weight: 700;
}
.badge-online {
  background: rgba(48, 209, 88, .16);
  color: var(--success);
  border-color: rgba(48, 209, 88, .28);
}
.badge-offline {
  background: var(--bg-soft);
  color: var(--text-3);
}
.inst-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: .92rem;
}
.inst-row .lab { color: var(--text); opacity: .72; font-weight: 600; }
.inst-row .val {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.inst-float {
  margin: 2px 0;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  text-align: center;
  padding: 16px 10px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.inst-float.pos { color: var(--success); }
.inst-float.neg { color: var(--danger); }
.inst-eq .val.pos { color: var(--success); }
.inst-eq .val.neg { color: var(--danger); }
.inst-stats {
  margin: 0;
  padding: 4px 16px 8px;
  border: none;
  background: transparent;
  display: grid;
  gap: 6px;
}
.inst-stats .val { color: var(--text); }
.inst-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 14px;
  font-size: .9rem;
  border: none;
}
.inst-safe {
  color: var(--success);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.inst-unsafe {
  color: var(--warn);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.inst-dd { color: var(--text); opacity: .7; }

html:not([data-theme="dark"]) .inst-row .lab,
html:not([data-theme="dark"]) .inst-dd,
html:not([data-theme="dark"]) .inst-box-title .gid {
  color: #3a3a3c;
  opacity: 1;
}
html:not([data-theme="dark"]) .inst-row .val,
html:not([data-theme="dark"]) .inst-stats .val {
  color: #1d1d1f;
}
.inst-dd b {
  color: var(--danger);
  font-weight: 700;
  margin-left: 4px;
}
.inst-box-empty {
  grid-column: 1 / -1;
  padding: 28px;
  text-align: center;
  color: var(--text-2);
}
.notify-form { display: grid; gap: 18px; }
.notify-block {
  display: grid; gap: 10px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
.notify-block h3 { margin: 0 0 4px; font-size: 1rem; }
.notify-preview {
  margin: 8px 0 0;
  padding: 14px 16px;
  max-width: 640px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  color: var(--text);
}
.check-row {
  display: flex; align-items: center; gap: 10px;
  color: var(--text);
  cursor: pointer;
}
.check-row input { width: 16px; height: 16px; }
.empty-state {
  padding: 36px 32px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
  box-sizing: border-box;
  max-width: 100%;
}
.empty-state h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.empty-state p {
  margin: 0;
  max-width: 42em;
  color: var(--text-2);
  line-height: 1.65;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.instances-grid {
  margin-top: 0;
  align-items: start;
}
.instances-grid .main-column {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.instances-grid .side-column {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.instances-grid .sidebar-card {
  overflow: hidden;
}
.instances-grid .section-head span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

@media (max-width: 1120px) {
  .content-grid { grid-template-columns: 1fr; }
  .side-column {
    position: static;
    max-height: none;
  }
  .sidebar-card {
    height: auto;
    max-height: min(70vh, 640px);
  }
  .g-body { max-height: min(220px, 32vh); }
}
@media (max-width: 900px) {
  .hero-home { grid-template-columns: 1fr; }
  .site-nav {
    display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 4px;
    order: 3; flex: 0 0 100%;
  }
  .site-header { flex-wrap: wrap; }
  .grid-2, .inst-grid { grid-template-columns: 1fr; }
  .inst-edit-grid { grid-template-columns: 1fr; }
  .pnl-cal-cell { min-height: 64px; padding: 8px 6px; }
  .pnl-cal-pnl { font-size: .85rem; }
  .site-header-wrap, .site-frame { width: min(calc(100% - 20px), var(--content-max)); }
}
