/* =========================================================
   KissMe · Sky Ops — 后台样式
   设计基调：深色侧栏 + 浅色工作区 + 赤陶色强调
   信息密度优先：紧凑间距、清晰层级、稳定表格行高
   ========================================================= */

:root {
  --canvas: #eff3f2;
  --surface: #f8faf9;
  --surface-2: #ffffff;
  --surface-tint: #e7efec;
  --ink: #1b2421;
  --ink-soft: #4d5c57;
  --muted: #74847e;
  --line: #d8e1de;
  --line-soft: #e9f0ed;
  --rail: #18211f;
  --rail-2: #242f2c;
  --rail-line: #34433e;
  --rail-text: #e8f0ec;
  --rail-dim: #8ca098;
  --accent: #c85c3f;
  --accent-ink: #fff6f1;
  --accent-soft: rgba(200, 92, 63, 0.12);
  --amber: #b7791f;
  --amber-soft: rgba(183, 121, 31, 0.14);
  --danger: #bf4a42;
  --danger-soft: rgba(191, 74, 66, 0.13);
  --ok: #3e8c69;
  --ok-soft: rgba(62, 140, 105, 0.13);
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(24, 33, 31, 0.05);
  --shadow-md: 0 8px 24px rgba(24, 33, 31, 0.08);
  --shadow-lg: 0 24px 60px rgba(24, 33, 31, 0.18);
}

* { box-sizing: border-box; }

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

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.grow { flex: 1; min-width: 0; }

::selection { background: var(--accent); color: var(--accent-ink); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: #c2cfca;
  border: 2px solid transparent;
  border-radius: 99px;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #a9b8b3; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== 通用排版 ===================== */

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 21px; }
h2 { font-size: 14px; }
h3 { font-size: 13px; }

.kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.login-view {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background: var(--canvas);
  z-index: 60;
}

.login-rail {
  background: var(--rail);
  color: var(--rail-text);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-rail-meta { display: grid; gap: 6px; }
.login-kicker, .login-rail .kicker { color: var(--rail-dim); }
.login-session {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.login-stage {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 30px 28px;
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 14px;
}

.login-card h1 { font-size: 22px; }
.login-sub { margin: 0; color: var(--muted); font-size: 13px; }

.field { display: grid; gap: 6px; }
.field-label { font-size: 12px; color: var(--ink-soft); }

.field input,
.inline-form input,
.search,
.select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.inline-form input:focus,
.search:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface-2);
}

.login-actions { display: flex; gap: 10px; }
.login-error { color: var(--danger); font-size: 12px; min-height: 16px; }

/* ===================== 按钮 ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.08s;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-tint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover { background: #b5502f; border-color: #b5502f; }

.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-tint); }

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  color: var(--ink-soft);
}

.danger-ghost:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--ink);
  animation: spin 0.7s linear infinite;
}
.btn.primary.loading::after { color: var(--accent-ink); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== 骨架 / 空态 ===================== */

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--line-soft) 25%, #f3f7f5 50%, var(--line-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.empty {
  padding: 26px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.error-box {
  padding: 14px 16px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ===================== 布局骨架 ===================== */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}

.app.auth-hidden { display: none; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 18px 12px 14px;
  background: var(--rail);
  color: var(--rail-text);
  overflow: hidden;
}

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

.brand-sigil {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rail-line);
  border-radius: 10px;
  background: var(--rail-2);
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
}

.brand-name { font-size: 14px; font-weight: 600; letter-spacing: 0.01em; }
.brand-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--rail-dim);
  text-transform: uppercase;
}

.side-nav { display: grid; gap: 2px; }

.nav-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--rail-dim);
  padding: 6px 8px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--rail-dim);
  font-size: 13px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--rail-2); color: var(--rail-text); }

.nav-item.active {
  background: var(--rail-2);
  color: var(--rail-text);
  box-shadow: inset 2px 0 0 var(--accent);
}

.nav-index {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--rail-line);
  letter-spacing: 0.08em;
}

.nav-item.active .nav-index { color: var(--accent); }

.nav-text { flex: 1; }

.nav-badge {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px 8px 0;
  border-top: 1px solid var(--rail-line);
  display: grid;
  gap: 6px;
}

.bot-state {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--rail-dim);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rail-line);
  flex: none;
}
.status-dot.online { background: #4fbd8a; box-shadow: 0 0 0 3px rgba(79, 189, 138, 0.18); }
.status-dot.offline { background: #d0736b; box-shadow: 0 0 0 3px rgba(208, 115, 107, 0.16); }

.sidebar-time { font-family: var(--mono); font-size: 11px; color: var(--rail-dim); }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  background: rgba(248, 250, 249, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-context {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.crumb { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; color: var(--muted); }
.crumb-sep { color: var(--line); }

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

.local-note {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface-2);
}

.main { padding: 20px 22px 48px; }

.view { display: none; }
.view.active { display: block; animation: fade-in 0.18s ease-out; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.page-head h1 { margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 8px; }

/* ===================== 搜索框 ===================== */

.search-wrap { position: relative; display: flex; align-items: center; }

.search-wrap .search { padding-left: 30px; min-width: 220px; }

.search-icon {
  position: absolute;
  left: 11px;
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: 5px;
  height: 1.5px;
  background: var(--muted);
  transform: rotate(45deg);
}

.select { padding-left: 11px; min-width: 150px; }

/* ===================== 总览：状态条 ===================== */

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.pill strong { font-family: var(--mono); font-weight: 600; color: var(--ink); }

.pill.ok { border-color: rgba(62, 140, 105, 0.35); background: var(--ok-soft); color: var(--ok); }
.pill.ok strong { color: var(--ok); }
.pill.warn { border-color: rgba(183, 121, 31, 0.35); background: var(--amber-soft); color: var(--amber); }
.pill.warn strong { color: var(--amber); }
.pill.bad { border-color: rgba(191, 74, 66, 0.35); background: var(--danger-soft); color: var(--danger); }
.pill.bad strong { color: var(--danger); }

/* ===================== 指标卡 ===================== */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 2px;
  box-shadow: var(--shadow-sm);
}

.metric-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.metric-label { font-size: 11.5px; color: var(--muted); }

.metric.warn { border-color: rgba(183, 121, 31, 0.4); }
.metric.warn .metric-value { color: var(--amber); }
.metric.bad { border-color: rgba(191, 74, 66, 0.4); }
.metric.bad .metric-value { color: var(--danger); }

/* ===================== 面板 ===================== */

.panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}

.panel-head h2 { font-size: 13px; }

.panel-grid { display: grid; gap: 12px; }

.dashboard-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

#view-tasks .panel,
#view-owners .panel { margin-bottom: 12px; }

/* ===================== 列表 ===================== */

.list-box { display: grid; max-height: 320px; overflow: auto; }

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  min-height: 48px;
}

.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface); }

.list-title {
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 42ch;
}

.list-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 46ch;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10.5px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(62, 140, 105, 0.28); }
.badge.err { background: var(--danger-soft); color: var(--danger); border-color: rgba(191, 74, 66, 0.28); }
.badge.wait { background: var(--amber-soft); color: var(--amber); border-color: rgba(183, 121, 31, 0.28); }
.badge.flat { background: var(--surface-tint); color: var(--ink-soft); border-color: var(--line); }

/* ===================== 进度 ===================== */

.progress-box { padding: 12px 14px; display: grid; gap: 10px; max-height: 320px; overflow: auto; }

.progress-line { display: grid; gap: 5px; }

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.progress-label {
  font-size: 12px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-value { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.progress-track {
  height: 5px;
  border-radius: 99px;
  background: var(--line-soft);
  overflow: hidden;
}

.progress-track > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #e08a63);
  transition: width 0.4s ease;
}

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

.table-panel { display: flex; flex-direction: column; }

.table-scroll { overflow: auto; max-height: calc(100vh - 300px); }

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 9px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}

.data-table tbody tr:hover { background: var(--surface); }
.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table .col-action { width: 64px; }

.data-table .mono {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-soft);
}

.data-table .id-cell {
  font-family: var(--mono);
  font-size: 11.5px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.perms { display: flex; flex-wrap: wrap; gap: 3px; }

.perm-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  background: var(--surface-tint);
  color: #9aa9a4;
  border: 1px solid transparent;
  line-height: 1.6;
}

.perm-tag.on {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(200, 92, 63, 0.22);
}

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}

.pager { display: flex; align-items: center; gap: 6px; }

.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
}

.pager-size select {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 11.5px;
}

.pager-info {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  min-width: 58px;
  text-align: center;
}

/* ===================== 标签页 ===================== */

.tabbar {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab span {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--surface-tint);
  color: var(--ink-soft);
}

.tab:hover { color: var(--ink); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab.active span { background: var(--accent-soft); color: var(--accent); }

/* ===================== 任务卡 ===================== */

.task-groups { display: grid; gap: 16px; }

.task-group { display: grid; gap: 8px; }

.task-group-title {
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 2px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.task-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.task-card:hover { border-color: #c3d1cc; box-shadow: var(--shadow-sm); }

.task-name { font-size: 13px; font-weight: 500; }

.task-form { display: flex; gap: 6px; }
.task-form input { flex: 1; min-width: 0; }

.task-form input {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  outline: none;
  font-size: 12px;
}

.task-form input:focus { border-color: var(--accent); background: var(--surface-2); }

.task-form button {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
}

.task-form button:hover { background: #b5502f; }
.task-form button:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===================== 日志 ===================== */

.log-panel { display: flex; flex-direction: column; }

.log-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  flex-wrap: wrap;
}

.log-toolbar .search { padding: 6px 9px 6px 28px; font-size: 12px; }
.log-toolbar .search-icon { left: 10px; }

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  cursor: pointer;
}

.toggle-inline input { accent-color: var(--accent); }

.log-view {
  margin: 0;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  color: #2b3532;
  background: #fbfcfc;
  overflow: auto;
  height: calc(100vh - 260px);
  min-height: 320px;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-view mark {
  background: rgba(200, 92, 63, 0.22);
  color: inherit;
  border-radius: 2px;
}

/* ===================== 配置树 ===================== */

.config-hint {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
}

.config-tree { padding: 8px 14px 16px; }

.config-group { margin: 4px 0; }

.config-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px dashed transparent;
  font-size: 12px;
}

.config-row:hover { background: var(--surface); }

.config-key {
  flex: 0 0 210px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
}

.config-value {
  flex: 1;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
  word-break: break-all;
}

.config-value.masked { color: var(--muted); letter-spacing: 0.1em; }

.config-toggle {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  padding: 0 4px 0 0;
  width: 14px;
}

.config-children { padding-left: 16px; border-left: 1px solid var(--line-soft); margin-left: 4px; }

/* ===================== 内联表单 ===================== */

.inline-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.inline-form input { flex: 1; min-width: 0; }

/* ===================== 弹窗 ===================== */

.modal-host { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.modal-host:empty { display: none; }

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 28, 26, 0.45);
  backdrop-filter: blur(2px);
  animation: fade-in 0.15s ease-out;
}

.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modal-card.narrow { width: min(420px, 100%); }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-head h2 { font-size: 16px; margin-top: 2px; }
.modal-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  word-break: break-all;
}

.modal-body { padding: 16px 18px; overflow: auto; display: grid; gap: 16px; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.permission-section { display: grid; gap: 10px; }

.permission-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.permission-section-head h3 {
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.permission-grid { display: grid; gap: 2px; }

.permission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line-soft);
}

.permission-row:last-child { border-bottom: 0; }

.permission-info { display: grid; gap: 1px; }
.permission-name { font-size: 12.5px; }
.permission-note { font-size: 10.5px; color: var(--muted); }

.permission-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }

.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #ccd8d3;
  transition: background 0.16s;
  pointer-events: none;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.16s;
}

.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

.perm-expire {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.perm-days {
  width: 66px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 11.5px;
  outline: none;
}

.perm-days:focus { border-color: var(--accent); background: var(--surface-2); }

.perm-adjust { padding: 4px 9px; font-size: 11.5px; }

.chip-row { display: flex; gap: 4px; }

.chip {
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--ink-soft);
}

.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ===================== 确认框 ===================== */

.confirm-body { padding: 16px 18px; display: grid; gap: 6px; }
.confirm-title { font-size: 14px; font-weight: 500; }
.confirm-text { font-size: 12.5px; color: var(--muted); }

.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #a83f38; border-color: #a83f38; }

/* ===================== Toast ===================== */

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: grid;
  gap: 8px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  animation: toast-in 0.2s ease-out;
  pointer-events: auto;
}

.toast.err { border-left-color: var(--danger); color: var(--danger); }
.toast.warn { border-left-color: var(--amber); color: var(--amber); }

.toast.leaving { animation: toast-out 0.18s ease-in forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(12px); }
}

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

@media (max-width: 1180px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 960px) {
  .app { grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar { padding: 14px 8px; gap: 14px; align-items: center; }
  .brand-copy, .nav-label, .nav-text, .nav-badge, .sidebar-time { display: none; }
  .nav-item { justify-content: center; padding: 10px 0; }
  .nav-index { font-size: 11px; color: var(--rail-dim); }
  .bot-state { justify-content: center; }
  .sidebar-foot { padding-top: 8px; }
  .main { padding: 16px 14px 40px; }
  .topbar { padding: 0 14px; }
}

@media (max-width: 720px) {
  .login-view { grid-template-columns: minmax(0, 1fr); }
  .login-rail { display: none; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: space-between; flex-wrap: wrap; }
  .search-wrap .search { min-width: 0; width: 100%; }
  .search-wrap { flex: 1; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .local-note { display: none; }
  .table-scroll { max-height: none; }
  .log-view { height: 60vh; }
  .config-key { flex-basis: 130px; }
}

@media (max-width: 480px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-value { font-size: 19px; }
  .modal { padding: 12px; }
  .modal-card { max-height: calc(100vh - 24px); }
  .permission-row { flex-direction: column; align-items: flex-start; }
  .permission-control { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
