/* 策略超市 · 管理工作台（纯静态，无构建）
   色彩令牌沿用 UI还原规格：主色 #E8353F，页面底色 #F5F5F5 */

:root {
  --brand: #e8353f;
  --brand-dark: #c4262f;
  --brand-soft: #fdecee;
  --bg-page: #f5f5f5;
  --bg-card: #ffffff;
  --bg-side: #1d2029;
  --bg-side-hover: #2a2e3a;
  --text-main: #1f2430;
  --text-sub: #6b7280;
  --line: #e8e9ee;
  --ok: #0fa36b;
  --warn: #d98324;
  --danger: #d93025;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 35, 0.06), 0 8px 24px rgba(20, 24, 35, 0.04);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg-page);
  color: var(--text-main);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------------- 登录 ---------------- */
.login {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% 0%, #fff2f3 0%, rgba(255, 255, 255, 0) 60%),
    var(--bg-page);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px 24px;
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 24px;
}

.login-brand strong {
  font-size: 22px;
  letter-spacing: 1px;
}

.login-brand span {
  color: var(--text-sub);
  font-size: 13px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-sub);
  font-size: 13px;
}

.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  color: var(--text-main);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.textarea {
  min-height: 96px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  color: var(--text-main);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

.btn:hover { border-color: #c9ccd6; background: #fafafb; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn.primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn.ghost { background: transparent; }

.btn.sm { padding: 4px 10px; font-size: 13px; }

.btn.block { width: 100%; margin-top: 6px; }

.btn.link {
  padding: 0;
  color: var(--brand);
  background: none;
  border: none;
}

.hint { color: var(--text-sub); font-size: 13px; margin: 0 0 12px; }

.error {
  margin: 12px 0 0;
  padding: 8px 12px;
  color: #a3160f;
  background: #fdecea;
  border-radius: 8px;
  font-size: 13px;
}

.login-foot {
  margin: 18px 0 0;
  color: #9aa0ab;
  font-size: 12px;
  text-align: center;
}

/* ---------------- 骨架 ---------------- */
.shell {
  display: flex;
  min-height: 100%;
}

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  padding: 18px 12px;
  color: #cfd3dc;
  background: var(--bg-side);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.logo strong { color: #fff; font-size: 16px; letter-spacing: .5px; }

.badge {
  padding: 1px 8px;
  color: #fff;
  background: var(--brand);
  border-radius: 999px;
  font-size: 11px;
  line-height: 18px;
}

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

.nav a {
  padding: 9px 12px;
  color: #cfd3dc;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
}

.nav a:hover { background: var(--bg-side-hover); color: #fff; }

.nav a.active {
  color: #fff;
  background: var(--brand);
  font-weight: 600;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.titles h1 { margin: 0; font-size: 18px; font-weight: 600; }
.titles p { margin: 2px 0 0; color: var(--text-sub); font-size: 13px; }

.userbox { display: flex; align-items: center; gap: 12px; }
.user-meta { text-align: right; line-height: 1.3; }
.user-meta small { color: var(--text-sub); font-size: 11px; }

/* 系统管理员代管其他主体时的视角切换 */
.scope-switch { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.scope-switch .scope-tip { color: var(--text-sub); font-size: 12px; white-space: nowrap; }
.scope-switch .select { width: auto; min-width: 220px; padding: 6px 10px; font-size: 13px; }

.view { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }

/* ---------------- 卡片 / 表格 ---------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.card-desc { margin: -4px 0 12px; color: var(--text-sub); font-size: 13px; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.kpi {
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi span { color: var(--text-sub); font-size: 12px; }
.kpi strong { display: block; margin-top: 6px; font-size: 24px; font-weight: 600; letter-spacing: .5px; }
.kpi em { display: block; margin-top: 4px; color: var(--text-sub); font-style: normal; font-size: 12px; }

.table-wrap { overflow-x: auto; }

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th, .table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}

.table th {
  color: var(--text-sub);
  background: #fafafb;
  font-weight: 600;
  font-size: 12px;
}

.table tbody tr:hover { background: #fcfcfd; }
.table td.wrap { white-space: normal; min-width: 220px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { display: flex; gap: 6px; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
  background: #f0f1f5;
  color: #4b5262;
}

.tag.active, .tag.published, .tag.ok, .tag.sent, .tag.processed { background: #e7f7ef; color: var(--ok); }
.tag.draft, .tag.applied, .tag.received, .tag.pending { background: #fff4e5; color: var(--warn); }
.tag.disabled, .tag.failed, .tag.rejected, .tag.dropped { background: #fdecea; color: var(--danger); }

.empty, .loading {
  padding: 28px 12px;
  color: var(--text-sub);
  text-align: center;
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 14px;
  margin-bottom: 14px;
  background: #fafafb;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.form-grid .field { margin: 0; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .form-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  grid-column: 1 / -1;
}

.checkline { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 4px; }
.checkline label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-main); }

pre.code {
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  max-height: 420px;
  color: #e6e8ef;
  background: #171a21;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.secret {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: var(--brand-soft);
  border: 1px solid #f7c9cd;
  border-radius: 8px;
  font-size: 13px;
}

.secret code {
  display: block;
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: 360px;
  padding: 10px 14px;
  color: #fff;
  background: #2b3040;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(20, 24, 35, .24);
  font-size: 13px;
}

.toast.err { background: var(--danger); }

/* 分页条、键值详情、并排对比等公共小组件 */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.pager .actions {
  display: flex;
  gap: 8px;
}

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

.kv > span {
  display: block;
  color: var(--text-sub);
  font-size: 12px;
}

.kv > div {
  font-size: 13px;
  word-break: break-word;
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.sub-title {
  display: block;
  margin: 12px 0 6px;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
}

.wrap-text {
  white-space: normal;
  word-break: break-word;
}

.shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.shortcut {
  display: block;
  padding: 12px 14px;
  color: var(--text-main);
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}

.shortcut:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow);
}

.shortcut strong { display: block; font-size: 14px; }
.shortcut span { display: block; margin-top: 4px; color: var(--text-sub); font-size: 12px; }

@media (max-width: 860px) {
  .sidebar {
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    position: static;
    flex-direction: column;
  }
  .shell { flex-direction: column; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .view { padding: 14px; }
  .topbar { position: static; }
}
