/* XSFiNE 云管理 — 视觉系统 v2
   与产品壳层同一语言：中性灰阶、发丝线分层、无阴影无渐变，墨色为主按钮，蓝色只用于可交互。
   CSP 为 style-src 'self'：全部由类驱动，不使用内联样式。
   主题：默认跟随系统；html[data-theme] 手动覆盖。 */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --side: #f7f7f8;
  --surface: #f7f7f8;
  --surface-2: #f1f1f2;
  --hover: rgb(0 0 0 / 0.045);
  --active: rgb(0 0 0 / 0.075);
  --line: rgb(0 0 0 / 0.08);
  --line-strong: rgb(0 0 0 / 0.16);
  --ink: #141414;
  --ink-2: #565656;
  --ink-3: #8f8f8f;
  --accent: #1e96eb;
  --accent-soft: rgb(30 150 235 / 0.1);
  --on-ink: #ffffff;
  --ok: #1d8a5a;
  --warn: #b27316;
  --bad: #cf3b32;
  --info: #1e86d6;
  --ok-soft: rgb(29 138 90 / 0.1);
  --warn-soft: rgb(178 115 22 / 0.11);
  --bad-soft: rgb(207 59 50 / 0.09);
  --info-soft: rgb(30 134 214 / 0.1);
  --code-bg: #f3f3f4;
  --scrim: rgb(10 10 12 / 0.38);
  --pop-shadow: 0 10px 34px rgb(0 0 0 / 0.12), 0 0 0 0.5px rgb(0 0 0 / 0.06);
  --chart-0: #1e96eb;
  --chart-1: #2fa37a;
  --chart-2: #d9912b;
  --chart-3: #d6453d;
  --radius: 10px;
  --radius-s: 7px;
  --font:
    13.5px/1.55 -apple-system, 'SF Pro Text', 'PingFang SC', 'Microsoft YaHei',
    'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #141414;
    --side: #1c1c1c;
    --surface: #1c1c1c;
    --surface-2: #262626;
    --hover: rgb(255 255 255 / 0.06);
    --active: rgb(255 255 255 / 0.1);
    --line: rgb(255 255 255 / 0.09);
    --line-strong: rgb(255 255 255 / 0.18);
    --ink: #ececec;
    --ink-2: #b0b0b0;
    --ink-3: #7d7d7d;
    --accent: #4aaef5;
    --accent-soft: rgb(74 174 245 / 0.14);
    --on-ink: #141414;
    --ok: #4cc38a;
    --warn: #e3a94d;
    --bad: #ff7168;
    --info: #5ab4f7;
    --ok-soft: rgb(76 195 138 / 0.13);
    --warn-soft: rgb(227 169 77 / 0.14);
    --bad-soft: rgb(255 113 104 / 0.13);
    --info-soft: rgb(90 180 247 / 0.14);
    --code-bg: #0e0e0e;
    --scrim: rgb(0 0 0 / 0.55);
    --pop-shadow: 0 10px 34px rgb(0 0 0 / 0.5), 0 0 0 0.5px rgb(255 255 255 / 0.08);
    --chart-0: #4aaef5;
    --chart-1: #45c895;
    --chart-2: #eba84a;
    --chart-3: #ff7168;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #141414;
  --side: #1c1c1c;
  --surface: #1c1c1c;
  --surface-2: #262626;
  --hover: rgb(255 255 255 / 0.06);
  --active: rgb(255 255 255 / 0.1);
  --line: rgb(255 255 255 / 0.09);
  --line-strong: rgb(255 255 255 / 0.18);
  --ink: #ececec;
  --ink-2: #b0b0b0;
  --ink-3: #7d7d7d;
  --accent: #4aaef5;
  --accent-soft: rgb(74 174 245 / 0.14);
  --on-ink: #141414;
  --ok: #4cc38a;
  --warn: #e3a94d;
  --bad: #ff7168;
  --info: #5ab4f7;
  --ok-soft: rgb(76 195 138 / 0.13);
  --warn-soft: rgb(227 169 77 / 0.14);
  --bad-soft: rgb(255 113 104 / 0.13);
  --info-soft: rgb(90 180 247 / 0.14);
  --code-bg: #0e0e0e;
  --scrim: rgb(0 0 0 / 0.55);
  --pop-shadow: 0 10px 34px rgb(0 0 0 / 0.5), 0 0 0 0.5px rgb(255 255 255 / 0.08);
  --chart-0: #4aaef5;
  --chart-1: #45c895;
  --chart-2: #eba84a;
  --chart-3: #ff7168;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
}
code {
  font-family: var(--mono);
  font-size: 0.9em;
}
a {
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.icon-svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ================= 外壳 ================= */

body.authed #app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 224px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--side);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 52px;
  padding: 0 18px;
}
.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 700;
  font-size: 10.5px;
  display: grid;
  place-items: center;
  letter-spacing: 0.3px;
}
.brand-name {
  font-weight: 600;
  font-size: 13.5px;
}
.side-nav {
  flex: 1;
  padding: 4px 10px 16px;
  overflow-y: auto;
}
.nav-group-title {
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 16px 10px 5px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 31px;
  padding: 0 10px;
  border-radius: var(--radius-s);
  color: var(--ink-2);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.nav-link:hover {
  background: var(--hover);
  color: var(--ink);
}
.nav-link.active {
  background: var(--active);
  color: var(--ink);
  font-weight: 560;
}
.nav-icon {
  display: inline-flex;
  color: var(--ink-3);
}
.nav-link.active .nav-icon {
  color: var(--ink);
}
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* 顶栏：左面包屑 / 中搜索 / 右状态与账户 */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink-3);
  white-space: nowrap;
}
#view-title {
  color: var(--ink);
  font-weight: 560;
}
.crumb-group::after {
  content: '/';
  margin-left: 8px;
  color: var(--line-strong);
}
.search-trigger {
  flex: 0 1 380px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink-3);
  cursor: pointer;
  text-align: left;
}
.search-trigger:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}
.search-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
kbd {
  font: 11px var(--mono);
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-3);
  background: var(--bg);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--ink);
}
.menu-btn,
.nav-mask {
  display: none;
}
.alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.alert-chip::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
}
.alert-chip:hover {
  background: var(--hover);
}
.alert-chip.ok::before {
  background: var(--ok);
}
.alert-chip.warn::before {
  background: var(--warn);
}
.account {
  position: relative;
}
.avatar {
  width: 28px;
  height: 28px;
  margin-left: 4px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: var(--ink);
  color: var(--on-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
}
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  padding: 6px;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--pop-shadow);
  z-index: 60;
}
.menu-head {
  padding: 8px 10px 9px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.menu-head strong {
  display: block;
  font-weight: 560;
}
.menu-head span {
  color: var(--ink-3);
  font-size: 12px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover {
  background: var(--hover);
}
.menu-item .icon-svg {
  color: var(--ink-3);
}

#view {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 32px 56px;
}

/* ================= 页面骨架 ================= */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h2 {
  font-size: 21px;
  font-weight: 620;
  letter-spacing: -0.012em;
}
.page-desc {
  margin-top: 3px;
  color: var(--ink-3);
  max-width: 64ch;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.page-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.page-note {
  color: var(--ink-3);
  font-size: 12.5px;
}
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

/* 面板：所有“块”共用的扁平容器 —— 发丝线边框，无阴影 */
.card,
.panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.card {
  padding: 16px 18px 18px;
  overflow: hidden;
}
/* 卡片里的表格贴边铺满，与列表面板一致 */
.card > table.data {
  margin: 0 -18px;
  width: calc(100% + 36px);
}
.card > table.data:last-child {
  margin-bottom: -18px;
}
.card > .pagination {
  margin: 0 -18px -18px;
  border-top: 1px solid var(--line);
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}
.card-sub {
  color: var(--ink-3);
  font-size: 12.5px;
}
.panel {
  overflow: hidden;
}
.panel-body {
  overflow-x: auto;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.toolbar form {
  display: contents;
}
.toolbar .spacer {
  flex: 1;
}
.panel-foot {
  border-top: 1px solid var(--line);
}

/* 指标条：一整条分栏，而不是一排独立卡片 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat {
  background: var(--bg);
  padding: 14px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-label {
  color: var(--ink-3);
  font-size: 12.5px;
}
.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.stat-hint {
  color: var(--ink-3);
  font-size: 12px;
}
.stat.ok .stat-value {
  color: var(--ok);
}
.stat.warn .stat-value {
  color: var(--warn);
}
.stat.bad .stat-value {
  color: var(--bad);
}
.spark {
  width: 100%;
  height: 32px;
  margin-top: 8px;
}

/* ================= 图表 ================= */

.chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}
.chart-axis {
  fill: var(--ink-3);
  font-size: 11px;
}
.chart-axis.end {
  text-anchor: end;
}
.chart-axis.start {
  text-anchor: start;
}
.chart-axis.mid {
  text-anchor: middle;
}
.chart-bar.s0,
.chart-area.s0,
.chart-dot.s0 {
  fill: var(--chart-0);
}
.chart-bar.s1,
.chart-area.s1,
.chart-dot.s1 {
  fill: var(--chart-1);
}
.chart-bar.s2,
.chart-area.s2,
.chart-dot.s2 {
  fill: var(--chart-2);
}
.chart-bar.s3,
.chart-area.s3,
.chart-dot.s3 {
  fill: var(--chart-3);
}
.chart-area {
  fill-opacity: 0.12;
}
.chart-line {
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart-line.s0 {
  stroke: var(--chart-0);
}
.chart-line.s1 {
  stroke: var(--chart-1);
}
.chart-line.s2 {
  stroke: var(--chart-2);
}
.chart-line.s3 {
  stroke: var(--chart-3);
}
.chart-bar:hover {
  opacity: 0.75;
}
.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  color: var(--ink-2);
  font-size: 12.5px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}
.legend-dot.s0 {
  background: var(--chart-0);
}
.legend-dot.s1 {
  background: var(--chart-1);
}
.legend-dot.s2 {
  background: var(--chart-2);
}
.legend-dot.s3 {
  background: var(--chart-3);
}
.meter {
  width: 100%;
  height: 6px;
  display: block;
}
.meter-track {
  fill: var(--surface-2);
}
.meter-fill {
  fill: var(--ok);
}
.meter.warn .meter-fill {
  fill: var(--warn);
}
.meter.bad .meter-fill {
  fill: var(--bad);
}

/* ================= 待办 / 健康 ================= */

.attention {
  display: flex;
  flex-direction: column;
  margin: -6px -8px -8px;
}
.attention-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 8px;
  border-radius: var(--radius-s);
  text-decoration: none;
  color: inherit;
}
a.attention-item:hover {
  background: var(--hover);
}
.attention-count {
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  color: var(--ink-2);
}
.attention-item.warn .attention-count {
  background: var(--warn-soft);
  color: var(--warn);
}
.attention-item.bad .attention-count {
  background: var(--bad-soft);
  color: var(--bad);
}
.attention-item.ok .attention-count {
  background: var(--ok-soft);
  color: var(--ok);
}
.attention-text {
  flex: 1;
  min-width: 0;
}
.attention-hint {
  color: var(--ink-3);
  font-size: 12px;
}
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.health-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg);
}
.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
  background: var(--ink-3);
}
.health-item.ok .health-dot {
  background: var(--ok);
}
.health-item.warn .health-dot {
  background: var(--warn);
}
.health-item.bad .health-dot {
  background: var(--bad);
}
.health-label {
  font-weight: 560;
}
.health-detail {
  color: var(--ink-2);
  font-size: 12.5px;
  word-break: break-word;
}

/* ================= 选项卡 / 分段控件 ================= */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  background: transparent;
  padding: 8px 12px;
  color: var(--ink-3);
  display: inline-flex;
  gap: 7px;
  align-items: center;
  font: inherit;
  cursor: pointer;
}
.tab:hover {
  color: var(--ink);
}
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
  font-weight: 560;
}
.tab-badge {
  font-size: 11.5px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius-s);
  background: var(--surface-2);
}
.segmented button {
  height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.segmented button.active {
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 0 0 0.5px var(--line-strong);
}

/* ================= 表格 ================= */

table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-3);
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface);
}
table.data td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  word-break: break-word;
}
table.data tbody tr:last-child td {
  border-bottom: 0;
}
table.data tbody tr.clickable {
  cursor: pointer;
}
table.data tbody tr.clickable:hover {
  background: var(--hover);
}
table.data td.mono,
code.id,
code.cmd,
code.err-code {
  font-family: var(--mono);
  font-size: 12.5px;
}
code.id {
  color: var(--ink-2);
  cursor: copy;
}
code.id.block {
  display: block;
  word-break: break-all;
  background: var(--code-bg);
  padding: 8px 10px;
  border-radius: var(--radius-s);
}
code.err-code {
  color: var(--bad);
}
td.empty {
  text-align: center;
  color: var(--ink-3);
  padding: 36px 16px;
}
.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  color: var(--ink-3);
  font-size: 12.5px;
}
.pager-buttons {
  display: flex;
  gap: 6px;
}
.panel > .pagination {
  border-top: 1px solid var(--line);
}
.panel > .toolbar:last-child {
  border-bottom: 0;
}

/* 状态：圆点 + 文字，不用彩色药丸 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--ink-2);
}
.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
}
.badge.ok::before {
  background: var(--ok);
}
.badge.warn::before {
  background: var(--warn);
}
.badge.bad::before {
  background: var(--bad);
}
.badge.info::before {
  background: var(--info);
}
.badge.muted {
  color: var(--ink-3);
}

/* ================= 按钮 / 表单 ================= */

button {
  font: inherit;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover {
  background: var(--hover);
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}
.btn.primary:hover {
  opacity: 0.86;
  background: var(--ink);
}
.btn.danger {
  color: var(--bad);
  border-color: rgb(207 59 50 / 0.35);
}
.btn.danger:hover {
  background: var(--bad-soft);
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}
.btn.ghost:hover {
  background: var(--hover);
  color: var(--ink);
}
.btn.sm,
.row-actions .btn {
  height: 26px;
  padding: 0 9px;
  font-size: 12.5px;
}
.btn.icon {
  width: 30px;
  padding: 0;
}
.btn.block {
  width: 100%;
  height: 36px;
}
.field {
  display: block;
  margin-bottom: 14px;
}
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 560;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.field-hint {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
}
input,
textarea,
select {
  font: inherit;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--bg);
  color: var(--ink);
}
textarea {
  height: auto;
  min-height: 80px;
  padding: 8px 10px;
  resize: vertical;
}
input:focus,
textarea:focus,
select:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder,
textarea::placeholder {
  color: var(--ink-3);
}
input[type='checkbox'] {
  width: 15px;
  height: 15px;
  padding: 0;
  accent-color: var(--ink);
}
.toolbar input:not([type='checkbox']),
.toolbar select {
  width: auto;
  min-width: 150px;
  flex: 0 1 220px;
}
.toolbar input[type='search'],
.toolbar input.search {
  flex: 1 1 240px;
  max-width: 340px;
}
.page-actions select {
  width: auto;
}
.check-item,
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.check-row input {
  margin-top: 3px;
}
.check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}
.check-hint {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.form-info {
  min-height: 18px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.form-info.ok {
  color: var(--ok);
}
.form-info.err {
  color: var(--bad);
}
.form-summary {
  padding: 9px 12px;
  margin-bottom: 14px;
  border-radius: var(--radius-s);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12.5px;
}
.form-summary.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.form-summary.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 32px;
}
.settings-form .field {
  margin: 0;
  min-width: 0;
}
.settings-form .form-info,
.settings-form .form-actions {
  grid-column: 1 / -1;
  margin-top: 0;
}
.modal .settings-form {
  grid-template-columns: minmax(0, 1fr);
}
.auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}
.secret-box {
  margin-bottom: 14px;
}
.secret-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
code.secret {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  background: var(--code-bg);
  word-break: break-all;
  white-space: pre-wrap;
  font-size: 12.5px;
  user-select: all;
}

/* ================= 提示 / 空态 ================= */

.banner {
  padding: 9px 12px;
  border-radius: var(--radius-s);
  font-size: 12.5px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.banner.info {
  background: var(--info-soft);
  color: var(--info);
}
.banner.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.banner.err {
  background: var(--bad-soft);
  color: var(--bad);
}
.banner.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 56px 0;
  color: var(--ink-3);
}
.loading i {
  width: 15px;
  height: 15px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.empty-state {
  text-align: center;
  padding: 48px 0;
  color: var(--ink-3);
}
.empty-title {
  font-weight: 560;
  color: var(--ink-2);
}

/* ================= 弹窗 / 命令面板 / 抽屉 ================= */

dialog.modal,
dialog.palette {
  border: 0;
  border-radius: 14px;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--pop-shadow);
  width: min(540px, 92vw);
  max-height: 90vh;
}
dialog.modal::backdrop,
dialog.palette::backdrop {
  background: var(--scrim);
}
.modal-card {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}
.modal-head h3 {
  font-size: 15px;
  font-weight: 600;
}
.modal-body {
  padding: 14px 20px 20px;
  overflow-y: auto;
}
dialog.palette {
  width: min(600px, 94vw);
  margin-top: 12vh;
}
.palette-input {
  height: 52px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0 18px;
  font-size: 15px;
}
.palette-input:focus {
  box-shadow: none;
}
.palette-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
}
.palette-group {
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 10px 10px 4px;
}
.palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.palette-row.active,
.palette-row:hover {
  background: var(--active);
}
.palette-sub {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 12.5px;
}
.palette-empty {
  padding: 28px;
  text-align: center;
  color: var(--ink-3);
}

.drawer-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
.drawer-wrap.open {
  pointer-events: auto;
}
.drawer-mask {
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.2s;
}
.drawer-wrap.open .drawer-mask {
  background: var(--scrim);
}
.drawer {
  position: absolute;
  inset: 0 0 0 auto;
  width: min(580px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: var(--pop-shadow);
  transform: translateX(28px);
  opacity: 0;
  transition: transform 0.24s var(--ease), opacity 0.2s;
}
.drawer-wrap.open .drawer {
  transform: none;
  opacity: 1;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 52px;
  padding: 0 14px 0 20px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h3 {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 28px;
}
.drawer-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
/* 抽屉里的操作条固定在内容最上方，紧挨标题 */
.action-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

dl.kv {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 9px 16px;
  margin: 0 0 8px;
}
dl.kv dt {
  color: var(--ink-3);
}
dl.kv dd {
  margin: 0;
  word-break: break-all;
}
pre.json {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-s);
  background: var(--code-bg);
  font: 12px/1.6 var(--mono);
  overflow: auto;
  max-height: 60vh;
  white-space: pre-wrap;
  word-break: break-all;
}
.section-title {
  margin: 22px 0 10px;
  font-size: 12px;
  font-weight: 560;
  color: var(--ink-3);
}
.drawer-body table.data th,
.drawer-body table.data td,
.modal-body table.data th,
.modal-body table.data td {
  padding-left: 10px;
  padding-right: 10px;
}
ol.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}
li.step {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
li.step:last-child {
  border-bottom: 0;
}
.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
  background: var(--ink-3);
}
li.step.succeeded .step-dot {
  background: var(--ok);
}
li.step.failed .step-dot {
  background: var(--bad);
}
li.step.running .step-dot,
li.step.pending .step-dot {
  background: var(--info);
}
li.step.reconciling .step-dot {
  background: var(--warn);
}
.step-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.step-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--ink-3);
  font-size: 12.5px;
}

/* 日志 */
.log-list {
  display: flex;
  flex-direction: column;
  font: 12.5px/1.55 var(--mono);
}
.log-line {
  display: grid;
  grid-template-columns: 150px 52px minmax(0, 1fr);
  gap: 12px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--line);
}
.log-line:last-child {
  border-bottom: 0;
}
.log-time {
  color: var(--ink-3);
}
.log-msg {
  white-space: pre-wrap;
  word-break: break-word;
}
.log-level.error {
  color: var(--bad);
}
.log-level.warn {
  color: var(--warn);
}

.notice-preview {
  padding: 9px 12px;
  border-radius: var(--radius-s);
  font-size: 13px;
}
.notice-preview.info {
  background: var(--info-soft);
  color: var(--info);
}
.notice-preview.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.notice-preview.critical {
  background: var(--bad-soft);
  color: var(--bad);
}

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 36px);
}
.toast {
  padding: 10px 14px;
  border-radius: var(--radius-s);
  background: var(--ink);
  color: var(--on-ink);
  box-shadow: var(--pop-shadow);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show {
  opacity: 1;
  transform: none;
}
.toast.err {
  background: var(--bad);
  color: #fff;
}
.time {
  color: var(--ink-2);
  white-space: nowrap;
}

/* ================= 登录 ================= */

body.guest {
  background: var(--surface);
}
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-box {
  width: min(380px, 100%);
  padding: 32px 30px 26px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.login-logo {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: 18px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 11px;
  font-weight: 700;
}
.login-title {
  font-size: 19px;
  font-weight: 620;
  margin-bottom: 20px;
}
.login-note {
  margin-top: 16px;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.6;
}

/* ================= 响应式 ================= */

@media (max-width: 1100px) {
  .two-col {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 860px) {
  body.authed #app {
    flex-direction: column;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(272px, 84vw);
    transform: translateX(-100%);
    transition: transform 0.24s var(--ease);
  }
  body.nav-open .sidebar {
    transform: none;
    box-shadow: var(--pop-shadow);
  }
  body.nav-open .nav-mask {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--scrim);
    z-index: 30;
  }
  .menu-btn {
    display: inline-grid;
  }
  .topbar {
    padding: 0 10px;
    gap: 6px;
  }
  .crumb-group,
  .search-text,
  .search-trigger kbd,
  .hide-narrow {
    display: none;
  }
  .search-trigger {
    flex: 0 0 32px;
    width: 32px;
    padding: 0;
    justify-content: center;
    margin: 0 0 0 auto;
    border-color: transparent;
    background: transparent;
  }
  #view {
    padding: 20px 14px 40px;
  }
  .settings-form,
  .check-list {
    grid-template-columns: minmax(0, 1fr);
  }
  .page-actions {
    width: 100%;
  }
}
/* 窄屏：表格改为“卡片行”，不出现横向滚动。 */
@media (max-width: 720px) {
  .panel-body {
    overflow-x: visible;
  }
  table.data,
  table.data tbody,
  table.data tr,
  table.data td {
    display: block;
    width: 100%;
  }
  table.data thead {
    display: none;
  }
  table.data tbody tr {
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
  }
  table.data tbody tr:last-child {
    border-bottom: 0;
  }
  table.data td {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 14px;
    border-bottom: 0;
    text-align: right;
  }
  table.data td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--ink-3);
    font-size: 12px;
    text-align: left;
  }
  table.data td[colspan]::before {
    content: none;
  }
  table.data td .row-actions {
    justify-content: flex-end;
  }
  .toolbar input:not([type='checkbox']),
  .toolbar select,
  .toolbar input[type='search'] {
    flex: 1 1 100%;
    max-width: none;
  }
  dl.kv {
    grid-template-columns: 88px 1fr;
  }
  .log-line {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* 区块标题行：左侧标题，右侧该区块自己的控件（如趋势范围） */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}
.section-head h3 {
  font-size: 13px;
  font-weight: 600;
}
