:root {
  --ink: #16302c;        /* 机房深墨绿：主色、标题 */
  --ink-2: #2d4a45;
  --paper: #f3f6f5;      /* 工作区底色 */
  --card: #ffffff;
  --line: #d9e1df;
  --muted: #66807b;
  --amber: #e0a100;      /* 机柜指示灯：强调、当前状态 */
  --mode-a: #1f6f6b;     /* 卡时租赁 */
  --mode-b: #d9931b;     /* 自营 token */
  --mode-c: #5b5f97;     /* 分成合作 */
  --pos: #2f8f5b;
  --neg: #b4381e;
  --radius-s: 4px;
  --radius-m: 8px;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); }
button, input, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-s);
  padding: 5px 12px; cursor: pointer;
}
button:hover { border-color: var(--ink-2); }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary:hover { background: var(--ink-2); }
button.link { border: 0; background: none; color: var(--muted); padding: 0; text-decoration: underline; }
button.danger { color: var(--neg); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
input, select {
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 4px 6px; background: #fff;
}
.num, td, .kpi .v { font-variant-numeric: tabular-nums; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 8px 16px; background: var(--ink); color: #e9f1ef;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; white-space: nowrap; }
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.topbar select { background: var(--ink-2); color: #fff; border-color: #3d5c56; max-width: 220px; }
.topbar button { background: transparent; color: #e9f1ef; border-color: #3d5c56; }
.topbar button:hover { border-color: var(--amber); }
.set-info { display: flex; align-items: center; gap: 8px; }
.dirty { color: var(--amber); font-size: 12px; }
.seg { display: flex; border: 1px solid #3d5c56; border-radius: var(--radius-s); overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 5px 10px; white-space: nowrap; }
.seg button + button { border-left: 1px solid #3d5c56; }
.seg button.on { background: var(--amber); color: var(--ink); }
.actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn { font-size: 18px; padding: 2px 8px; }
.only-mobile { display: none; }

.warn-bar { background: #fff4d6; color: #6b4b00; padding: 6px 16px; border-bottom: 1px solid #f0d58a; }

/* 主布局 */
.layout { display: grid; grid-template-columns: 330px 1fr; min-height: calc(100vh - 48px); }
.panel {
  background: var(--card); border-right: 1px solid var(--line); overflow-y: auto;
  height: calc(100vh - 48px); position: sticky; top: 48px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line); font-weight: 600;
}
.pgroup { border-bottom: 1px solid var(--line); }
.pgroup summary {
  cursor: pointer; padding: 8px 14px; font-weight: 600; list-style: none; display: flex; justify-content: space-between;
}
.pgroup summary::after { content: "+"; color: var(--muted); }
.pgroup[open] summary::after { content: "−"; }
.prow { display: grid; grid-template-columns: 1fr 112px; gap: 8px; align-items: center; padding: 3px 14px; }
.prow label { color: var(--ink-2); font-size: 13px; }
.prow .unit { color: var(--muted); font-size: 11px; margin-left: 2px; }
.prow .inp { display: flex; align-items: center; }
.prow input, .prow select { width: 100%; text-align: right; }
.prow .suffix { margin-left: 4px; color: var(--muted); font-size: 12px; width: 12px; }
.prow.changed label { color: var(--amber); }

.main { padding: 0 20px 40px; min-width: 0; }
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line); position: sticky; top: 48px; z-index: 10;
  background: var(--paper); padding-top: 10px; overflow-x: auto;
}
.tabs button { border: 0; background: none; border-bottom: 3px solid transparent; border-radius: 0; padding: 8px 14px; white-space: nowrap; }
.tabs button.active { border-bottom-color: var(--amber); font-weight: 600; }
.tab { display: none; padding-top: 16px; }
.tab.active { display: block; }

/* 总览 KPI：上面两个 IRR 为主角 */
.kpi-strip { display: grid; grid-template-columns: 1.3fr 1.3fr repeat(6, 1fr); gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 16px; }
.kpi { padding: 12px 14px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 20px; font-weight: 600; margin-top: 4px; }
.kpi.hero .v { font-size: 30px; letter-spacing: -0.5px; }
.kpi.hero { background: linear-gradient(0deg, #f8faf9, #fff); }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; margin-bottom: 16px; min-width: 0; }
.grid2 .box, .grid3 .box { margin-bottom: 0; }
.box h3 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 12px; margin: -4px 0 8px; }
.chart { height: 300px; }
.chart.tall { height: 420px; }
select.mini { font-size: 12px; padding: 1px 4px; }

/* 表格 */
.table-wrap { overflow: auto; max-width: 100%; }
.table-wrap.tall { max-height: calc(100vh - 170px); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #eef3f1; text-align: right; position: sticky; top: 0; z-index: 1; font-weight: 600; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: inherit; }
thead th:first-child { background: #eef3f1; z-index: 2; }
tbody tr { background: #fff; }
tbody tr:hover { background: #f7faf9; }
td { text-align: right; }
td.neg { color: var(--neg); }
tr.total td { font-weight: 600; border-top: 1px solid var(--ink-2); }
tr.sub td:first-child { padding-left: 20px; color: var(--ink-2); }
td.bad { color: var(--neg); font-weight: 600; }
td.ok { color: var(--pos); }
td input { width: 68px; text-align: right; }
td input.wide { width: 130px; text-align: left; }
td input.xwide { width: 170px; text-align: left; }
td input.src { width: 300px; text-align: left; }
.subtabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.subtabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.mode-a { color: var(--mode-a); } .mode-b { color: var(--mode-b); } .mode-c { color: var(--mode-c); }
.alloc-table td.ro { color: var(--muted); }

.custom-sens { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 10px; }
.custom-sens label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.custom-sens input { width: 220px; }
.choose { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; }
.choose label { font-size: 13px; }
.row-actions { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.row-actions input { min-width: 240px; }

dialog { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px 20px; min-width: 340px; }
dialog::backdrop { background: rgba(22, 48, 44, .35); }
dialog h3 { margin: 0 0 12px; }
dialog label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); }
dialog input { width: 100%; margin-top: 3px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 8px 16px; border-radius: var(--radius-s); z-index: 50;
}
.toast.err { background: var(--neg); }

@media (max-width: 1280px) {
  .kpi-strip { grid-template-columns: repeat(4, 1fr); }
  .kpi { border-bottom: 1px solid var(--line); }
  .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .only-mobile { display: inline-block; }
  .layout { grid-template-columns: 1fr; }
  .panel { position: fixed; left: 0; top: 48px; width: 320px; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 2px 0 10px rgba(0,0,0,.15); }
  .panel.open { transform: none; }
  .grid2 { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .actions { margin-left: 0; }
  .main { padding: 0 12px 40px; }
}
@media (prefers-reduced-motion: reduce) { .panel { transition: none; } }
