/* ==========================================================================
   xP&A+ · 智能扩展财务规划与分析系统
   设计语言：账房仪表台（Ledger Control Room）
   —— 暖纸画布 + 深墨绿侧栏 + 黄铜刻线；数字用等宽表格数字，像读真实账页。
   ========================================================================== */

/* ------------------------------- 1. Tokens ------------------------------- */
:root {
  /* 纸与墨 */
  --paper: #f6f3ec;
  --paper-2: #fbf9f4;
  --paper-3: #efeade;
  --ink: #12211c;
  --ink-2: #2b3d35;
  --ink-3: #55665e;
  --ink-4: #8a988f;

  /* 线 */
  --line: #e2dacb;
  --line-2: #d2c8b4;
  --line-3: #bdb098;

  /* 色 */
  --brass: #9c6b34;
  --brass-2: #b5811f;
  --brass-soft: #dcc7a1;
  --brass-wash: #f3ead9;
  --green: #1c4b3c;
  --green-2: #2c6e52;
  --green-wash: #e4ece7;
  --red: #a8342a;
  --red-wash: #f7e7e4;
  --amber: #b5811f;
  --amber-wash: #f9efd9;

  /* 侧栏 */
  --rail: #101b17;
  --rail-2: #16241f;
  --rail-line: #26352e;
  --rail-ink: #e6ddc9;
  --rail-ink-2: #8e9a90;

  /* 字体 */
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", SimSun, Georgia, "Times New Roman", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  /* 尺度 */
  --r-sm: 3px;
  --r-md: 5px;
  --r-lg: 8px;
  --rail-w: 238px;
  --pad: 40px;
  --shadow-1: 0 1px 0 rgba(18, 33, 28, 0.04), 0 8px 24px -18px rgba(18, 33, 28, 0.35);
  --shadow-2: 0 24px 60px -28px rgba(18, 33, 28, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ------------------------------- 2. Base -------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 纸纹：极淡的网点 + 一条斜向微光，避免纯色平板感 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(18, 33, 28, 0.035) 1px, transparent 1px);
  background-size: 4px 4px;
  opacity: 0.5;
}

h1,
h2,
h3,
h4,
p,
figure {
  margin: 0;
}

a {
  color: var(--green);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

button {
  font: inherit;
  color: inherit;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 10px;
  border: 3px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--line-3);
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ------------------------------ 3. Boot --------------------------------- */
.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--rail);
}

.boot-inner {
  text-align: center;
  animation: boot-in 900ms var(--ease) both;
}

.boot-mark {
  font-family: var(--serif);
  font-size: 42px;
  letter-spacing: 0.04em;
  color: var(--rail-ink);
}

.boot-mark span {
  color: var(--brass-2);
}

.boot-line {
  width: 0;
  height: 1px;
  margin: 18px auto 14px;
  background: linear-gradient(90deg, transparent, var(--brass-2), transparent);
  animation: boot-line 1200ms 200ms var(--ease) both;
}

.boot-text {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--rail-ink-2);
}

@keyframes boot-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
@keyframes boot-line {
  to {
    width: 220px;
  }
}

/* ------------------------------ 4. Shell -------------------------------- */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---- 侧栏 ---- */
.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--rail);
  border-right: 1px solid #000;
  overflow: hidden;
}

/* 侧栏顶部黄铜刻线 */
.rail::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brass-2), transparent 70%);
  opacity: 0.85;
}

.brand {
  padding: 26px 22px 20px;
  border-bottom: 1px solid var(--rail-line);
}

.brand-mark {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--serif);
  font-size: 25px;
  letter-spacing: 0.02em;
  color: var(--rail-ink);
}

.brand-mark b {
  font-weight: 400;
  color: var(--brass-2);
}

.brand-sub {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--rail-ink-2);
  letter-spacing: 0.04em;
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 3px 8px;
  border: 1px solid var(--rail-line);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass-soft);
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 24px;
}

.nav-group {
  padding: 0 14px;
  margin-bottom: 18px;
}

.nav-group-title {
  padding: 0 8px 8px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #6b7a72;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--rail-ink-2);
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease);
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
}

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

.nav-item .idx {
  font-family: var(--mono);
  font-size: 10px;
  color: #5f6f66;
  min-width: 16px;
  transition: color 160ms var(--ease);
}

.nav-item .label {
  font-size: 13.5px;
  letter-spacing: 0.01em;
}

.nav-item .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 2px;
  background: rgba(181, 129, 31, 0.18);
  color: var(--brass-soft);
}

.nav-item.active {
  background: #1b2a23;
  color: #fff;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--brass-2);
}

.nav-item.active .idx {
  color: var(--brass-2);
}

.rail-foot {
  border-top: 1px solid var(--rail-line);
  padding: 14px 16px 16px;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
}

.who-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background: var(--brass-2);
  color: #101b17;
  font-family: var(--serif);
  font-size: 15px;
}

.who-meta {
  min-width: 0;
  flex: 1;
}

.who-name {
  font-size: 13px;
  color: var(--rail-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.who-role {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rail-ink-2);
}

.who-out {
  border: 0;
  background: none;
  color: #6b7a72;
  cursor: pointer;
  padding: 4px;
  border-radius: 2px;
}

.who-out:hover {
  color: var(--red);
  background: rgba(168, 52, 42, 0.12);
}

/* ---- 主区 ---- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 var(--pad);
  height: 58px;
  background: rgba(246, 243, 236, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-3);
  min-width: 0;
}

.crumb b {
  color: var(--ink);
  font-weight: 600;
}

.crumb .sep {
  color: var(--line-3);
}

.topbar-spacer {
  flex: 1;
}

.stamp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 4px 9px;
  border: 1px solid var(--line-2);
  border-radius: 2px;
  background: var(--paper-2);
  white-space: nowrap;
}

.stamp i {
  width: 5px;
  height: 5px;
  background: var(--green-2);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(44, 110, 82, 0.15);
}

.page {
  padding: 30px var(--pad) 72px;
  max-width: 1560px;
  width: 100%;
}

/* --------------------------- 5. Typography ------------------------------ */
.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
}

.page-title {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: 0.005em;
  font-weight: 600;
  color: var(--ink);
}

.page-desc {
  margin-top: 7px;
  font-size: 13px;
  color: var(--ink-3);
  max-width: 74ch;
}

.section-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--brass);
  letter-spacing: 0.14em;
}

.muted {
  color: var(--ink-3);
}

.dim {
  color: var(--ink-4);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.tiny {
  font-size: 11.5px;
}

.strong {
  font-weight: 600;
}

.nowrap {
  white-space: nowrap;
}

.right {
  text-align: right;
}

.center {
  text-align: center;
}

.pos {
  color: var(--green-2);
}

.neg {
  color: var(--red);
}

/* --------------------------- 6. Page header ----------------------------- */
.phead {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.phead::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 1px;
  background: var(--line);
  opacity: 0.45;
}

.phead-main {
  flex: 1;
  min-width: 0;
}

.phead-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

/* ------------------------------ 7. Buttons ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms var(--ease), border-color 140ms var(--ease), transform 120ms var(--ease),
    box-shadow 140ms var(--ease);
}

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

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--green);
  border-color: var(--green);
  color: #f4efe0;
}

.btn-primary:hover {
  background: #235847;
  border-color: #235847;
}

.btn-brass {
  background: var(--brass);
  border-color: var(--brass);
  color: #fff8ea;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.btn-brass:hover {
  background: #ab7a3f;
  border-color: #ab7a3f;
}

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

.btn-danger:hover {
  background: #b94136;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-3);
}

.btn-ghost:hover {
  background: var(--paper-3);
  border-color: transparent;
  color: var(--ink);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.btn svg {
  width: 14px;
  height: 14px;
}

/* ------------------------------- 8. Chips ------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 2px;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.chip .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.chip-muted {
  background: var(--paper-3);
  color: var(--ink-3);
  border-color: var(--line);
}
.chip-warn {
  background: var(--amber-wash);
  color: #8a6114;
  border-color: #e6cf9f;
}
.chip-danger {
  background: var(--red-wash);
  color: var(--red);
  border-color: #ecc9c3;
}
.chip-ok {
  background: var(--green-wash);
  color: var(--green);
  border-color: #c3d6cb;
}
.chip-info {
  background: #e9eef3;
  color: #3c5a72;
  border-color: #cfdae4;
}
.chip-brass {
  background: var(--brass-wash);
  color: var(--brass);
  border-color: #e3d0ab;
}

/* 风险等级：方点 + 短横，像账页上的批注 */
.level {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.level::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
}

.level-green::before {
  background: var(--green-2);
}
.level-amber::before {
  background: var(--amber);
}
.level-red::before {
  background: var(--red);
}
.level-green {
  color: var(--green-2);
}
.level-amber {
  color: #8a6114;
}
.level-red {
  color: var(--red);
}

/* ------------------------------- 9. Cards ------------------------------- */
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

/* 卡头双线：呼应账簿的分隔线 */
.card-head::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brass-2) 0 42px, var(--line) 42px 100%);
  opacity: 0.9;
}

.card-head h3 {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.card-head .sub {
  font-size: 12px;
  color: var(--ink-4);
}

.card-body {
  padding: 18px;
}

.card-body.tight {
  padding: 0;
}

.card-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-4);
}

/* -------------------------------- 10. KPI ------------------------------- */
.kpi-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(--r-md);
  overflow: hidden;
}

.kpi {
  background: var(--paper-2);
  padding: 16px 18px 15px;
  min-width: 0;
  position: relative;
}

.kpi-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-4);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-value {
  margin-top: 8px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.kpi-value .unit {
  font-size: 12px;
  color: var(--ink-4);
  margin-left: 4px;
  letter-spacing: 0;
}

.kpi-note {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-4);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi.accent::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--brass-2);
}

/* ------------------------------- 11. Table ------------------------------ */
.tbl-wrap {
  overflow-x: auto;
}

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

table.tbl th {
  text-align: left;
  padding: 9px 14px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
  border-bottom: 1px solid var(--line-2);
  background: var(--paper-3);
  white-space: nowrap;
}

table.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.tbl tbody tr {
  transition: background 120ms var(--ease);
}

table.tbl tbody tr:hover {
  background: #fff;
}

table.tbl tbody tr.clickable {
  cursor: pointer;
}

table.tbl tbody tr:last-child td {
  border-bottom: 0;
}

table.tbl td.num,
table.tbl th.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

table.tbl .code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-4);
  letter-spacing: 0.02em;
}

.row-title {
  font-weight: 600;
  color: var(--ink);
}

.row-sub {
  font-size: 11.5px;
  color: var(--ink-4);
  margin-top: 2px;
}

/* 表格脚注 */
.tbl-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-4);
}

/* -------------------------------- 12. Form ------------------------------ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.form-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  min-width: 0;
}

.field.span-2 {
  grid-column: span 2;
}

.field label {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 6px;
}

.field label .req {
  color: var(--red);
  margin-left: 2px;
}

.input,
.select,
.textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: #fff;
  font-size: 13px;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}

.textarea {
  height: auto;
  min-height: 76px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.55;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--line-3);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(156, 107, 52, 0.12);
}

.input.num {
  text-align: right;
}

.hint {
  margin-top: 5px;
  font-size: 11px;
  color: var(--ink-4);
}

.hint-danger {
  color: var(--red);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .track {
  width: 36px;
  height: 20px;
  border-radius: 20px;
  background: var(--line-2);
  position: relative;
  transition: background 160ms var(--ease);
  flex: none;
}

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

.switch input:checked + .track {
  background: var(--green-2);
}

.switch input:checked + .track::after {
  transform: translateX(16px);
}

/* ------------------------------- 13. Tabs ------------------------------- */
.tabs {
  display: flex;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.tab {
  position: relative;
  padding: 9px 0 11px;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-4);
  transition: color 140ms var(--ease);
}

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

.tab.active {
  color: var(--ink);
  font-weight: 600;
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--brass);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--paper-2);
}

.seg button {
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}

.seg button:last-child {
  border-right: 0;
}

.seg button:hover {
  background: #fff;
}

.seg button.active {
  background: var(--green);
  color: #f4efe0;
}

/* ------------------------------ 14. Timeline ---------------------------- */
.timeline {
  position: relative;
  padding-left: 22px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--line-2);
}

.tl-item {
  position: relative;
  padding-bottom: 18px;
}

.tl-item:last-child {
  padding-bottom: 0;
}

.tl-item::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--paper-2);
  border: 1.5px solid var(--line-3);
}

.tl-item.done::before {
  background: var(--green-2);
  border-color: var(--green-2);
}

.tl-item.active::before {
  background: var(--brass-2);
  border-color: var(--brass-2);
  box-shadow: 0 0 0 4px rgba(181, 129, 31, 0.15);
}

.tl-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
}

.tl-title {
  font-size: 13px;
  font-weight: 600;
}

.tl-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: 0.02em;
}

.tl-note {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
  padding: 7px 10px;
  background: var(--paper-3);
  border-left: 2px solid var(--line-2);
  border-radius: 0 2px 2px 0;
}

/* --------------------------- 15. Risk findings -------------------------- */
.finding {
  display: flex;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.finding:last-child {
  border-bottom: 0;
}

.finding::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 2px;
}

.finding.red::before {
  background: var(--red);
}
.finding.amber::before {
  background: var(--amber);
}
.finding.green::before {
  background: var(--green-2);
}

.finding-body {
  min-width: 0;
  flex: 1;
}

.finding-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.finding-title {
  font-size: 13px;
  font-weight: 600;
}

.finding-code {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
}

.finding-detail {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.finding-fix {
  margin-top: 6px;
  font-size: 12px;
  color: var(--brass);
  display: flex;
  gap: 6px;
}

.finding-fix::before {
  content: "→";
  flex: none;
}

.ack-note {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--green-wash);
  border-radius: 2px;
  font-size: 12px;
  color: var(--green);
}

/* ------------------------------ 16. Charts ------------------------------ */
.chart {
  width: 100%;
  display: block;
  overflow: visible;
}

.chart text {
  font-family: var(--mono);
  font-size: 9px;
  fill: var(--ink-4);
  letter-spacing: 0.02em;
}

.chart .grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.chart .axis-line {
  stroke: var(--line-2);
  stroke-width: 1;
}

.chart .bar {
  transition: opacity 140ms var(--ease);
}

.chart .bar:hover {
  opacity: 0.78;
}

.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-3);
}

.legend i {
  width: 8px;
  height: 8px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 1px;
}

/* 维度条：利润排行 */
.rank-row {
  display: grid;
  grid-template-columns: 22px minmax(88px, 1.1fr) minmax(0, 2.2fr) 96px 74px;
  gap: 12px;
  align-items: center;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

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

.rank-row:hover {
  background: #fff;
}

.rank-idx {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
}

.rank-track {
  height: 6px;
  background: var(--paper-3);
  border-radius: 1px;
  overflow: hidden;
  position: relative;
}

.rank-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--green-2));
  transition: width 600ms var(--ease);
}

.rank-fill.amber {
  background: linear-gradient(90deg, #a87418, var(--amber));
}

.rank-fill.red {
  background: linear-gradient(90deg, #8d2a21, var(--red));
}

/* 毛利热力格 */
.heat {
  display: grid;
  gap: 2px;
}

.heat-cell {
  padding: 7px 8px;
  font-family: var(--mono);
  font-size: 11px;
  border-radius: 1px;
  text-align: right;
  color: #fff;
}

/* --------------------------- 17. Drawer / Modal ------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(16, 27, 23, 0.42);
  backdrop-filter: blur(2px);
  opacity: 0;
  animation: fade-in 180ms var(--ease) forwards;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 91;
  width: min(560px, 92vw);
  background: var(--paper);
  border-left: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  transform: translateX(24px);
  opacity: 0;
  animation: drawer-in 260ms var(--ease) forwards;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
}

.drawer-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: var(--paper-2);
}

.modal {
  position: fixed;
  z-index: 91;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -48%);
  width: min(520px, 92vw);
  max-height: 86vh;
  overflow: auto;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  opacity: 0;
  animation: modal-in 220ms var(--ease) forwards;
}

.modal-head {
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  padding: 18px 22px;
}

.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@keyframes fade-in {
  to {
    opacity: 1;
  }
}
@keyframes drawer-in {
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes modal-in {
  to {
    transform: translate(-50%, -50%);
    opacity: 1;
  }
}

/* -------------------------------- 18. Toast ----------------------------- */
.toasts {
  position: fixed;
  z-index: 120;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  background: var(--rail);
  color: #f0e9d8;
  border-left: 3px solid var(--brass-2);
  border-radius: 2px;
  box-shadow: var(--shadow-2);
  font-size: 12.5px;
  line-height: 1.5;
  animation: toast-in 220ms var(--ease) both;
}

.toast.error {
  border-left-color: #e0645a;
}
.toast.success {
  border-left-color: #5fb98c;
}

.toast .close {
  background: none;
  border: 0;
  color: #8e9a90;
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* --------------------------- 19. Empty / loading ------------------------ */
.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-4);
}

.empty-mark {
  font-family: var(--serif);
  font-size: 30px;
  color: var(--line-3);
  margin-bottom: 8px;
}

.empty-title {
  font-size: 13.5px;
  color: var(--ink-3);
}

.empty-desc {
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink-4);
}

.skeleton {
  background: linear-gradient(90deg, var(--paper-3) 25%, #f8f5ee 37%, var(--paper-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 2px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

.sk-line {
  height: 12px;
  margin-bottom: 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  display: inline-block;
}

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

/* ------------------------------- 20. Login ------------------------------ */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  background: var(--paper);
}

.login-art {
  position: relative;
  background: var(--rail);
  overflow: hidden;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--rail-ink);
}

/* 账页横线 + 黄铜斜线 */
.login-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 43px,
    rgba(232, 220, 196, 0.055) 43px 44px
  );
}

.login-art::after {
  content: "";
  position: absolute;
  width: 820px;
  height: 820px;
  right: -320px;
  top: -260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(181, 129, 31, 0.22), transparent 62%);
  pointer-events: none;
}

.login-art > * {
  position: relative;
  z-index: 1;
}

.login-brand {
  font-family: var(--serif);
  font-size: 34px;
  letter-spacing: 0.02em;
}

.login-brand b {
  font-weight: 400;
  color: var(--brass-2);
}

.login-tagline {
  margin-top: 14px;
  max-width: 30ch;
  font-size: 14px;
  line-height: 1.75;
  color: var(--rail-ink-2);
}

.login-points {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 40px;
  max-width: 420px;
}

.login-point {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.login-point .n {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--brass-2);
  padding-top: 3px;
  letter-spacing: 0.12em;
}

.login-point .t {
  font-size: 13px;
  color: var(--rail-ink);
}

.login-point .d {
  font-size: 12px;
  color: var(--rail-ink-2);
  margin-top: 2px;
  line-height: 1.6;
}

.login-foot {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #5f6f66;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-box {
  width: 100%;
  max-width: 360px;
}

.login-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}

.login-sub {
  margin-top: 6px;
  margin-bottom: 26px;
  font-size: 13px;
  color: var(--ink-3);
}

.login-box .field {
  margin-bottom: 14px;
}

.login-error {
  margin-bottom: 14px;
  padding: 9px 12px;
  border-left: 2px solid var(--red);
  background: var(--red-wash);
  color: #8a2a22;
  font-size: 12.5px;
  border-radius: 0 2px 2px 0;
}

.demo-accounts {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--line-2);
}

.demo-title {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 10px;
}

.demo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.demo-btn {
  border: 1px solid var(--line-2);
  background: var(--paper-2);
  border-radius: 2px;
  padding: 4px 9px;
  font-size: 11.5px;
  cursor: pointer;
  color: var(--ink-2);
  transition: all 130ms var(--ease);
}

.demo-btn:hover {
  border-color: var(--brass);
  color: var(--brass);
  background: var(--brass-wash);
}

.demo-btn b {
  font-family: var(--mono);
  font-weight: 500;
}

/* --------------------------- 21. Layout helpers ------------------------- */
.grid {
  display: grid;
  gap: 18px;
}

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

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2-1 {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.grid-1-2 {
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wrap {
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 26px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 26px; }

.kv-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 18px;
  font-size: 12.5px;
}

.kv-list dt {
  color: var(--ink-4);
  white-space: nowrap;
}

.kv-list dd {
  margin: 0;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.kv-list dd.plain {
  font-family: var(--sans);
}

/* 决策卡：复核用的"一页纸" */
.verdict {
  padding: 16px 18px;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--brass);
  background: var(--paper-2);
  border-radius: 0 2px 2px 0;
}

.verdict.red {
  border-left-color: var(--red);
}
.verdict.amber {
  border-left-color: var(--amber);
}
.verdict.green {
  border-left-color: var(--green-2);
}

.verdict-title {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 6px;
}

.verdict-text {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink);
}

/* 价格阶梯 */
.price-ladder {
  display: flex;
  align-items: stretch;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.ladder-step {
  flex: 1;
  background: var(--paper-2);
  padding: 10px 12px;
  min-width: 0;
}

.ladder-step .lb {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.ladder-step .lv {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.ladder-step.floor .lv {
  color: var(--red);
}
.ladder-step.target .lv {
  color: var(--green-2);
}
.ladder-step.now {
  background: var(--brass-wash);
}
.ladder-step.now .lv {
  color: var(--brass);
  font-weight: 600;
}

/* 段进度 */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 4px 0 2px;
}

.step {
  flex: 1;
  position: relative;
  padding-top: 18px;
  font-size: 11.5px;
  color: var(--ink-4);
  text-align: center;
}

.step::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line-2);
}

.step::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 50%;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: var(--paper-2);
  border: 1.5px solid var(--line-3);
}

.step:first-child::before {
  left: 50%;
}
.step:last-child::before {
  right: 50%;
}

.step.done {
  color: var(--green);
}
.step.done::after {
  background: var(--green-2);
  border-color: var(--green-2);
}

.step.current {
  color: var(--brass);
  font-weight: 600;
}
.step.current::after {
  background: var(--brass-2);
  border-color: var(--brass-2);
  box-shadow: 0 0 0 3px rgba(181, 129, 31, 0.16);
}

.step.rejected {
  color: var(--red);
}
.step.rejected::after {
  background: var(--red);
  border-color: var(--red);
}

/* ------------------------- 22. Motion & responsive ---------------------- */
.reveal {
  animation: reveal 480ms var(--ease) both;
}

.reveal:nth-child(1) { animation-delay: 0ms; }
.reveal:nth-child(2) { animation-delay: 40ms; }
.reveal:nth-child(3) { animation-delay: 80ms; }
.reveal:nth-child(4) { animation-delay: 120ms; }
.reveal:nth-child(5) { animation-delay: 160ms; }
.reveal:nth-child(6) { animation-delay: 200ms; }

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

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

@media (max-width: 1180px) {
  :root {
    --pad: 26px;
    --rail-w: 208px;
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-2-1,
  .grid-1-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .rail {
    position: fixed;
    z-index: 80;
    left: 0;
    top: 0;
    width: 258px;
    transform: translateX(-100%);
    transition: transform 240ms var(--ease);
  }
  .shell.nav-open .rail {
    transform: translateX(0);
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }
  .login {
    grid-template-columns: 1fr;
  }
  .login-art {
    display: none;
  }
  .phead {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .form-grid,
  .form-grid.cols-3 {
    grid-template-columns: minmax(0, 1fr);
  }
  .field.span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 620px) {
  :root {
    --pad: 16px;
  }
  .page {
    padding-top: 20px;
  }
  .page-title {
    font-size: 24px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .rank-row {
    grid-template-columns: 18px minmax(70px, 1.2fr) minmax(0, 1.6fr) 78px;
  }
  .rank-row .rank-margin {
    display: none;
  }
  .topbar {
    height: 52px;
  }
  .stamp {
    display: none;
  }
}

/* 移动端菜单按钮 */
.nav-toggle {
  display: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-2);
  background: var(--paper-2);
  border-radius: 2px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@media (max-width: 900px) {
  .nav-toggle {
    display: inline-flex;
  }
}
