:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --navy: #0f172a;
  --navy-2: #1e293b;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e8edf3;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --ok: #0f766e;
  --warn: #b45309;
  --err: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
button, input, select { font: inherit; }
.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100%;
}
.side {
  background: var(--navy);
  color: #cbd5e1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.brand { padding: 4px 8px 18px; }
.brand b { display: block; color: #fff; font-size: 15px; }
.brand span { font-size: 12px; color: #94a3b8; }
.side button.nav {
  text-align: left;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.side button.nav:hover { background: rgba(37, 99, 235, 0.16); color: #fff; }
.side button.nav.on { background: rgba(37, 99, 235, 0.22); color: #fff; font-weight: 600; }
.side .foot { margin-top: auto; padding: 12px 8px 4px; font-size: 12px; color: #64748b; line-height: 1.5; }

.main { min-width: 0; }
.top {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.crumb strong { display: block; font-size: 14px; }
.crumb span { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions a, .top-actions button.link {
  color: var(--muted); background: none; border: 0; cursor: pointer; font-size: 13px;
}
.top-actions a:hover, .top-actions button.link:hover { color: var(--text); }

.content { padding: 20px 24px 48px; }
#view-overview, #view-catalog { max-width: 1180px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.page-head h1 { margin: 0 0 4px; font-size: 20px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }

.btn {
  background: var(--primary); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.btn:hover { background: var(--primary-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: #334155; border: 1px solid #cbd5e1; }
.btn.ghost:hover { background: #f8fafc; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.danger { background: var(--err); }
.btn.danger:hover { background: #b91c1c; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: 1fr 1fr; } }
@media (max-width: 980px) { .app { grid-template-columns: 1fr; } .side { flex-direction: row; flex-wrap: wrap; } }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px; box-shadow: var(--shadow);
}
.kpi span { font-size: 12px; color: var(--muted); }
.kpi strong { display: block; margin: 8px 0 6px; font-size: 22px; color: var(--primary-2); }
.kpi small { color: #94a3b8; font-size: 12px; line-height: 1.4; }
.kpi.warn strong { color: var(--warn); }
.conclusion { margin: 12px 0 0; font-size: 13px; color: #334155; background: #f8fafc; border-radius: 8px; padding: 10px 12px; }

.grid-2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
@media (max-width: 900px) { .grid-2, .split { grid-template-columns: 1fr; } }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 14px; }
.bar { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.bar .track { flex: 1; height: 8px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--primary); }
.attn { list-style: none; margin: 0; padding: 0; }
.attn li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid #f1f5f9; font-size: 13px; }
.attn button { border: 0; background: none; color: var(--primary); cursor: pointer; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input, .toolbar select {
  height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: #fff;
}
.toolbar input { min-width: 220px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #f8fafc; }
tr.row { cursor: pointer; }
tr.row:hover td { background: #f8fbff; }
tr.row.active td { background: #eff6ff; }

.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; margin: 0 4px 4px 0; border: 1px solid transparent; }
.chip.on { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.chip.off { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.chip.warn { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.chip.mute { color: #475569; background: #f1f5f9; border-color: #e2e8f0; }
.chip.ok { color: #0f766e; background: #f0fdfa; border-color: #99f6e4; }

.split { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; align-items: start; }
.tenants-workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  min-height: calc(100vh - 168px);
}
.tenant-rail {
  display: flex;
  flex-direction: column;
  padding: 12px;
  min-height: 0;
  max-height: calc(100vh - 168px);
  position: sticky;
  top: 76px;
}
.rail-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.rail-toolbar input, .rail-toolbar select { min-width: 0; width: 100%; }
.tenant-rail-list { overflow: auto; min-height: 0; flex: 1; }
.tenant-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 10px 10px;
  cursor: pointer;
  color: inherit;
}
.tenant-item:hover { background: #f8fbff; }
.tenant-item.active { background: #eff6ff; }
.tenant-item-main { min-width: 0; }
.tenant-item-main b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenant-item .hint { margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenant-item .chip { margin: 0; flex-shrink: 0; }
.tenant-workspace { min-width: 0; padding: 18px 20px 22px; }
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.detail-head-main { min-width: 0; }
.detail-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-title-row h3 { margin: 0; font-size: 18px; }
.detail-head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.tabs {
  display: flex;
  gap: 4px;
  margin: 16px 0 0;
  border-bottom: 1px solid var(--line);
}
.tab {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.tab-count {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 99px;
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  align-items: center;
  justify-content: center;
}
.tab.on .tab-count { background: #dbeafe; color: #1d4ed8; }
.tab-panel { padding-top: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.panel-actions { display: flex; gap: 8px; margin-top: 12px; }
.acct-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.acc-form { margin-top: 12px; padding: 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; }
.empty { color: var(--muted); padding: 28px 8px; text-align: center; font-size: 13px; line-height: 1.6; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
input, select { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; line-height: 1.5; }
.mods { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 6px; }
.mods label { display: flex; gap: 6px; align-items: center; color: var(--text); margin: 0; font-size: 13px; }
.mods label.inc { color: var(--muted); }
.mods input:disabled { accent-color: var(--primary); }
.plans { display: grid; grid-template-columns: 1fr; gap: 8px; }
.plans-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.plan { border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; background: #fff; }
.plan:hover { border-color: #93c5fd; }
.plan.sel { border-color: var(--primary); background: #eff6ff; }
.plan b { display: block; margin-bottom: 4px; font-size: 13px; }
.plan span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.acct { display: flex; justify-content: space-between; gap: 8px; padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.acct .ops { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.status.off { color: var(--err); font-size: 12px; }
.danger-zone { margin-top: 28px; padding-top: 14px; border-top: 1px dashed #fecaca; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.domains { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }

.health { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 14px 0 0; }
.health div { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.health b { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.health strong { font-size: 14px; }
@media (max-width: 1100px) {
  .tenants-workspace { grid-template-columns: 1fr; min-height: 0; }
  .tenant-rail { position: static; max-height: 320px; }
  .form-grid, .plans-3, .health { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .form-grid, .plans-3, .health { grid-template-columns: 1fr; }
  .detail-head { flex-direction: column; }
}

#releaseKick { z-index: 60; }
.kick-box { max-width: 420px; }
.kick-box h3 { margin: 0 0 8px; font-size: 18px; }
.kick-box p { margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: #334155; }

.toast {
  position: fixed; right: 16px; bottom: 16px; max-width: 360px; padding: 12px 14px; border-radius: 10px;
  background: #fff; border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(15,23,42,.12); z-index: 50; font-size: 13px;
}
.toast.ok { border-color: #99f6e4; }
.toast.err { border-color: #fecaca; }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.28); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow: auto; }
.modal { width: min(720px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.steps { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 0 0 16px; color: var(--muted); font-size: 12px; }
.steps .on { color: var(--primary); font-weight: 600; }
.catalog { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .catalog { grid-template-columns: 1fr; } }
.value-list { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: #334155; line-height: 1.55; }
.not-list { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.mod-list { margin: 12px 0 0; padding: 0; list-style: none; }
.mod-list li { padding: 8px 0; border-top: 1px solid #f1f5f9; font-size: 13px; }
.mod-list small { display: block; color: var(--muted); }
.done-box { background: #f8fafc; border-radius: 10px; padding: 14px; font-size: 13px; line-height: 1.6; }
.done-box p { margin: 0 0 8px; }
.done-box p:last-child { margin-bottom: 0; }
.catalog-script { margin-bottom: 16px; overflow-x: auto; }
.catalog-script h2 { margin: 16px 0 10px; }
.catalog-script h2:first-child { margin-top: 0; }
.script-table { margin: 0 0 12px; }
.script-table th, .script-table td { vertical-align: top; }
.script-table td:first-child { font-weight: 600; white-space: nowrap; width: 88px; }
.callout {
  border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.6; color: #334155;
}
.callout b { display: block; margin-bottom: 4px; }
.callout.warn { background: #fffbeb; border: 1px solid #fde68a; }
.callout.info { background: #eff6ff; border: 1px solid #bfdbfe; }
.handoff { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.handoff h3 { margin: 0 0 6px; font-size: 16px; }
.handoff .lead { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.handoff-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-top: 1px solid #e8edf3; font-size: 13px;
}
.handoff-row span { color: var(--muted); min-width: 72px; }
.handoff-row strong { flex: 1; word-break: break-all; font-size: 14px; }
.handoff-row button { flex-shrink: 0; }
.handoff-note { margin: 12px 0 0; font-size: 13px; line-height: 1.6; color: #334155; }
.handoff-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
