:root {
  --bg: #faf6f2;
  --card: #ffffff;
  --ink: #2c211a;
  --ink-2: #5b5148;
  --ink-3: #9a8e84;
  --line: #e8dbcf;
  --line-2: #f5ece4;
  --accent: #c94a08;
  --accent-soft: #fdece0;
  --good: #0b7a56;
  --good-soft: #e7f5ee;
  --warn: #a16207;
  --warn-soft: #fdf3dd;
  --bad: #c0392b;
  --bad-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(44, 33, 26, .05), 0 8px 24px -12px rgba(44, 33, 26, .12);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ------------------------------- 布局 ------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: #2a1810;
  color: #d9cfc6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px 16px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(140deg, #e2611a, #a83f0b);
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
  letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { color: #fff; font-size: 14px; font-weight: 600; }
.brand-text span { font-size: 10px; color: #a89c92; letter-spacing: .3px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  font-size: 13.5px; color: #d8c8b8;
  cursor: pointer; transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, .05); color: #efe2d5; }
.nav-item.active { background: rgba(226, 97, 26, .2); color: #fff; font-weight: 500; }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; background: #e2611a; border-radius: 0 3px 3px 0;
}
.nav-item i { width: 16px; height: 16px; display: block; flex: 0 0 16px; opacity: .85; }
.nav-item.active i { opacity: 1; }
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #c0392b; color: #fff;
  font-size: 10.5px; font-weight: 600; line-height: 18px; text-align: center;
  flex: 0 0 auto;
}

.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; }
.month-picker { display: flex; flex-direction: column; gap: 5px; padding: 0 4px; }
.month-picker label { font-size: 10.5px; color: #a89c92; letter-spacing: .4px; text-transform: uppercase; }
.month-picker input {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  color: #efe2d5; border-radius: 8px; padding: 7px 9px; font-size: 13px;
  color-scheme: dark;
}
.month-picker input:focus { outline: none; border-color: #e2611a; }
.hint { font-size: 10.5px; color: #8b7d72; padding: 12px 4px 0; line-height: 1.5; }

.main { flex: 1; min-width: 0; padding: 28px 32px 56px; }
.view { max-width: 1240px; margin: 0 auto; }

/* ------------------------------- 通用 ------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-head h1 { font-size: 21px; font-weight: 650; letter-spacing: -.3px; }
.page-head p { color: var(--ink-2); font-size: 12.5px; margin-top: 3px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-head .sub { font-size: 12px; color: var(--ink-3); }
.card-body { padding: 16px 18px; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* 3 张 KPI 一排；手机端退成 2 列，避免三张卡各占一屏 */
.kg3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mt { margin-top: 16px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #e0d2c4; background: #fdf9f5; }
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #a83f0b; border-color: #a83f0b; }
.btn-danger { color: var(--bad); border-color: #f3c9c5; background: #fff; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  background: var(--line-2); color: var(--ink-2);
}
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--accent-soft); color: var(--accent); }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.muted { color: var(--ink-3); }

/* KPI */
.kpi { padding: 16px 18px; }
.kpi-label { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.6px; margin-top: 6px; line-height: 1.15; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 4px; letter-spacing: 0; }
.kpi-foot { font-size: 11.5px; color: var(--ink-3); margin-top: 7px; display: flex; gap: 8px; align-items: center; }

/* 进度条 */
.bar { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width .4s; }
.bar.good > span { background: var(--good); }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--bad); }

/* 表格 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-weight: 500; font-size: 11.5px; color: var(--ink-3);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
  text-transform: uppercase; letter-spacing: .3px;
}
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; }
/* 需要换行的长文本单元格自己加 .wrap（事由、备注等） */
.tbl td.wrap, .tbl td .wrap { white-space: normal; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #fdf9f5; }
.tbl .r { text-align: right; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.field > label .req { color: var(--bad); }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; font-size: 13px; transition: border .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 74, 8, .1); }
textarea.input { resize: vertical; min-height: 62px; }
.field .tip { font-size: 11px; color: var(--ink-3); }
.form-row { display: grid; gap: 12px; }

/* 提示块 */
.note {
  padding: 11px 14px; border-radius: 10px; font-size: 12.5px;
  background: var(--accent-soft); color: #a83f0b; border: 1px solid #f6d3b8;
  display: flex; gap: 8px; align-items: flex-start; line-height: 1.5;
}
.note.warn { background: var(--warn-soft); color: #8a5108; border-color: #f6e0bb; }
.note.bad { background: var(--bad-soft); color: #93271f; border-color: #f6cfcb; }
.note.good { background: var(--good-soft); color: #075a41; border-color: #c9e8db; }

/* 空态 */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); font-size: 13px; }

/* 时间线 */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 10px; padding: 9px 0; font-size: 12.5px; }
.tl-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); margin-top: 7px; flex: 0 0 7px; }
.tl-dot.alert { background: var(--bad); }
.tl-dot.budget { background: var(--accent); }
.tl-dot.calibrate { background: #7c3aed; }
.tl-dot.expense { background: var(--good); }
.tl-time { color: var(--ink-3); font-size: 11px; margin-top: 1px; }

/* Toast */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 999; }
.toast {
  background: #2c211a; color: #fff; padding: 11px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  display: flex; gap: 8px; align-items: center; max-width: 380px;
  animation: slideIn .22s ease;
}
.toast.bad { background: #a8342a; }
.toast.good { background: #0b6f52; }
.toast.warn { background: #8a5108; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* Modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(42, 24, 16, .42);
  display: none; align-items: center; justify-content: center; z-index: 900; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 86vh; overflow: auto; box-shadow: 0 24px 60px rgba(42, 24, 16, .25);
  animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
.modal-head { padding: 20px 22px 0; }
.modal-head h3 { font-size: 16px; font-weight: 620; }
.modal-head p { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* 图表 */
.chart-wrap { position: relative; width: 100%; }
svg .grid-line { stroke: var(--line-2); stroke-width: 1; }
svg .axis-text { fill: var(--ink-3); font-size: 10px; font-family: var(--mono); }
svg .bar-rect { transition: opacity .15s; }
svg .bar-rect:hover { opacity: .78; }

/* 分段控件 */
.seg { display: inline-flex; background: var(--line-2); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button {
  border: none; background: transparent; padding: 5px 12px; border-radius: 7px;
  font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.07); font-weight: 500; }

/* 预算卡片 */
.bud-card { padding: 15px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.bud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.bud-name { font-weight: 550; font-size: 13.5px; }
.bud-amounts { font-size: 12px; color: var(--ink-2); margin-top: 8px; display: flex; justify-content: space-between; }
.bud-pct { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 响应式 */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 860px) {
  .sidebar { width: 64px; flex: 0 0 64px; padding: 16px 8px; }
  .brand-text, .nav-item span, .hint, .month-picker label { display: none; }
  .nav-item { justify-content: center; padding: 10px 0; }
  .month-picker input { padding: 6px 2px; font-size: 11px; }
  .main { padding: 18px 14px 40px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
}

/* ============================ 身份与项目切换 ============================ */

.scope-box {
  margin: 0 4px 14px;
  padding: 10px 11px;
  background: #3b2416;
  border: 1px solid #4a2e1c;
  border-radius: 10px;
}
.scope-box label {
  display: block;
  font-size: 11px;
  letter-spacing: .6px;
  color: #a89c92;
  margin-bottom: 6px;
}
.scope-box select {
  width: 100%;
  background: #2a1810;
  color: #efe2d5;
  border: 1px solid #4a2e1c;
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.scope-box select:focus { border-color: #e2611a; }
.scope-meta {
  margin-top: 7px;
  font-size: 11px;
  color: #a89c92;
  line-height: 1.5;
}
.scope-meta b { color: #f0a878; font-weight: 600; }

.user-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  margin-top: 10px;
  background: #3b2416;
  border: 1px solid #4a2e1c;
  border-radius: 10px;
}
.user-avatar {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 8px;
  background: linear-gradient(140deg, #e2611a, #a83f0b);
  color: #fff; font-size: 13px; font-weight: 600;
  display: grid; place-items: center;
}
.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; font-size: 12.5px; color: #efe2d5; font-weight: 600; }
.user-info span { display: block; font-size: 10.5px; color: #a89c92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-out {
  background: none; border: none; color: #a89c92; cursor: pointer; padding: 3px;
  display: grid; place-items: center; border-radius: 5px;
}
.user-out:hover { color: #efe2d5; background: #4a2e1c; }

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

.auth-gate {
  position: fixed; inset: 0; z-index: 900;
  background: radial-gradient(1200px 600px at 20% -10%, #4a2a15 0%, #2a1810 55%, #1a0f08 100%);
  display: grid; place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 760px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.auth-head {
  padding: 26px 30px 20px;
  background: linear-gradient(135deg, #2a1810, #4a2a15);
  color: #fff;
}
.auth-head .brand-mark.lg {
  width: 42px; height: 42px; border-radius: 11px; font-size: 15px;
  margin-bottom: 12px;
}
.auth-head h1 { font-size: 20px; font-weight: 650; letter-spacing: .2px; }
.auth-head p { font-size: 12.5px; color: #c9b3a2; margin-top: 4px; }
.auth-body { padding: 22px 30px 26px; }
.auth-label { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; letter-spacing: .3px; }
.auth-users {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 16px;
}
.auth-user {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  transition: .15s;
  text-align: left;
}
.auth-user:hover { border-color: #f2c9a8; background: #fdf6ef; }
.auth-user.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(201, 74, 8, .1); }
.auth-user .user-avatar { width: 28px; height: 28px; flex: 0 0 28px; font-size: 12px; }
.auth-user > span:last-child { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.auth-user .au-name { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-user .au-role { display: block; font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-code { display: flex; gap: 10px; }
.auth-code input {
  flex: 1;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  letter-spacing: 3px;
  font-family: var(--mono);
  outline: none;
}
.auth-code input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 74, 8, .1); }
.auth-code .btn { padding: 10px 26px; }
.auth-tip { font-size: 11.5px; color: var(--ink-3); margin-top: 11px; }
.auth-tip.bad { color: var(--bad); }

.auth-qr {
  display: flex; align-items: center; gap: 14px;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.auth-qr .qr-code { flex: 0 0 auto; width: 86px; height: 86px; }
.auth-qr .qr-code svg { width: 86px; height: 86px; display: block; }
.auth-qr .qr-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.auth-qr .qr-text strong { font-size: 12.5px; font-weight: 600; }
.auth-qr .qr-text span { font-size: 11px; color: var(--ink-3); }
.auth-qr .qr-text code {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  background: var(--accent-soft); padding: 2px 7px; border-radius: 5px;
  align-self: flex-start; margin-top: 2px;
}

/* ============================== 沙盘推演 ============================== */

.plan-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  padding: 14px 16px;
  background: linear-gradient(180deg, #fdf6ef, #fff);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
}
.plan-field { display: flex; flex-direction: column; gap: 5px; }
.plan-field label { font-size: 11px; color: var(--ink-3); letter-spacing: .3px; }
.plan-field input, .plan-field select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: #fff;
  min-width: 108px;
}
.plan-field input:focus, .plan-field select:focus { border-color: var(--accent); }
.plan-field.wide input { min-width: 150px; }

.advice-item {
  display: flex; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line-2);
}
.advice-item:last-child { border-bottom: none; }
.advice-badge {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  height: fit-content;
  white-space: nowrap;
}
.advice-badge.up { background: var(--good-soft); color: var(--good); }
.advice-badge.down { background: var(--warn-soft); color: var(--warn); }
.advice-badge.keep { background: #f7efe8; color: var(--ink-2); }
.advice-main { flex: 1; min-width: 0; }
.advice-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.advice-reason { font-size: 12px; color: var(--ink-2); line-height: 1.6; }
.advice-amount { flex: 0 0 auto; text-align: right; font-family: var(--mono); font-size: 13px; }

.assume-list { font-size: 12px; color: var(--ink-2); line-height: 1.85; padding-left: 16px; }
.assume-list li { margin-bottom: 2px; }

.day-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 3px;
  margin-top: 10px;
}
.day-cell {
  border-radius: 5px;
  padding: 4px 1px;
  text-align: center;
  font-size: 9px;
  line-height: 1.35;
  font-family: var(--mono);
  border: 1px solid transparent;
}
.day-cell b { display: block; font-size: 10px; font-weight: 600; }
.day-cell.pos { background: var(--good-soft); color: #0a6b4c; }
.day-cell.neg { background: var(--bad-soft); color: #a8342a; }

/* ============================== 权限配置 ============================== */

.perm-matrix { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.perm-matrix th, .perm-matrix td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line-2); }
.perm-matrix th { font-size: 11px; color: var(--ink-3); font-weight: 500; letter-spacing: .3px; }
.perm-matrix td.c { text-align: center; }
.perm-yes { color: var(--good); font-weight: 600; }
.perm-no { color: #d9cfc6; }

.role-chip {
  display: inline-flex; align-items: center;
  font-size: 11px; padding: 2px 8px; border-radius: 5px;
  background: #f5ece4; color: var(--ink-2);
  font-weight: 550;
}
.role-chip.owner { background: #3b2416; color: #f7e8db; }
.role-chip.finance { background: #f7e0cc; color: #a83f0b; }
.role-chip.pm { background: var(--accent-soft); color: var(--accent); }
.role-chip.member { background: #f5ece4; color: var(--ink-2); }

/* KPI 栅格：4 列 / 3 列自适应 */
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1280px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .g3, .g4 { grid-template-columns: 1fr; }
}

/* ====================== 手机端（≤860px）====================== */
/* 侧栏改为顶部工具条：品牌+账期 / 项目 / 横向滑动导航 */

@media (max-width: 860px) {
  .app { display: block; min-height: 100vh; }

  .sidebar {
    position: sticky; top: 0; z-index: 400;
    width: 100%; height: auto; flex: none;
    display: flex; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 6px; padding: 8px 10px 0; border-bottom: 1px solid #3d2415;
    box-shadow: 0 8px 20px -12px rgba(8, 13, 23, .6);
  }

  /* 品牌 —— 压缩成一行 */
  .brand { order: 1; flex: 1 1 0; padding: 0; gap: 7px; min-width: 0; }
  .brand-text { min-width: 0; }
  .brand-text strong { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-mark { width: 26px; height: 26px; border-radius: 7px; font-size: 10px; }
  .brand-text span { display: none; }

  /* 账期 + 用户 —— 右上角 */
  .sidebar-foot {
    order: 2; flex: 0 0 auto;
    display: flex; align-items: center; gap: 6px;
    border: none; padding: 0;
  }
  .month-picker { flex-direction: row; align-items: center; gap: 0; padding: 0; }
  .month-picker label { display: none; }
  .month-picker input {
    flex: 0 0 128px; width: 128px;
    padding: 4px 6px; font-size: 11.5px; border-radius: 7px;
  }
  .user-card { margin: 0; padding: 0; background: none; border: none; }
  .user-info { display: none; }
  .user-avatar { width: 26px; height: 26px; flex: 0 0 26px; font-size: 11px; border-radius: 7px; }
  .user-out { padding: 2px; }

  /* 项目选择 —— 整行 */
  .scope-box {
    order: 3; flex: 1 1 100%; margin: 0; padding: 5px 9px;
    display: flex; align-items: center; gap: 8px; border-radius: 8px;
  }
  .scope-box label { margin: 0; flex: 0 0 auto; font-size: 10px; letter-spacing: .3px; }
  .scope-box select { flex: 1; min-width: 0; padding: 5px 8px; font-size: 12.5px; }
  .scope-meta { display: none; }

  /* 导航 —— 横向滑动，恢复文字 */
  .nav {
    order: 4; flex: 1 1 100%;
    flex-direction: row; gap: 4px;
    overflow-x: auto; overflow-y: hidden;
    padding: 1px 0 7px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item {
    flex: 0 0 auto; gap: 6px; white-space: nowrap;
    padding: 7px 11px; font-size: 12.5px; border-radius: 8px;
  }
  .nav-item span { display: inline; }
  .nav-item i { width: 14px; height: 14px; flex: 0 0 14px; }
  .nav-item.active::before { display: none; }

  /* 内容区 */
  .main { padding: 14px 12px 48px; }
  .view { max-width: 100%; }

  .page-head { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 16px; }
  .page-head h1 { font-size: 18px; }
  .page-head p { font-size: 12px; }
  .head-actions { gap: 6px; }

  .card { border-radius: 12px; }
  .card-head { padding: 14px 14px 0; flex-direction: column; align-items: flex-start; gap: 3px; }
  .card-body { padding: 14px; }
  .grid { gap: 10px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  /* KPI 保留两列，避免每个指标独占一屏 */
  .g4, .kg3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 12px; }
  .kpi-label { font-size: 11.5px; }
  .kpi-value { font-size: 20px; margin-top: 4px; letter-spacing: -.3px; }
  .kpi-value small { font-size: 11px; }
  .kpi-foot { font-size: 10.5px; gap: 4px; margin-top: 5px; flex-wrap: wrap; line-height: 1.45; }
  .mt { margin-top: 12px; }

  /* 表格：容器内横向滚动，不撑破页面 */
  .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.tbl { min-width: max-content; }
  .tbl th, .tbl td { padding: 9px 8px; font-size: 12.5px; }

  /* 输入框 ≥16px，避免 iOS 聚焦自动放大 */
  .input, select.input, textarea.input, .auth-code input, .plan-field input, .plan-field select { font-size: 16px; }

  /* 登录页：卡片可滚动，内容超出屏高时不被裁切 */
  .auth-gate { display: flex; align-items: flex-start; overflow-y: auto; padding: 14px; }
  .auth-card { margin: auto; max-width: 100%; border-radius: 14px; }
  .auth-head { padding: 20px 18px 16px; }
  .auth-head .brand-mark.lg { width: 36px; height: 36px; margin-bottom: 10px; font-size: 13px; }
  .auth-head h1 { font-size: 17px; }
  .auth-head p { font-size: 11.5px; }
  .auth-body { padding: 16px 18px 20px; }
  .auth-users { grid-template-columns: 1fr; max-height: 44vh; gap: 6px; }
  .auth-code .btn { padding: 10px 18px; flex: 0 0 auto; }
  .auth-qr { display: none !important; }

  /* 弹窗 */
  .modal-mask { padding: 12px; align-items: flex-start; padding-top: 5vh; }
  .modal { max-width: 100%; max-height: 88vh; border-radius: 14px; }
  .modal-head { padding: 16px 16px 0; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 0 16px 16px; }

  /* 提示条不挡底部操作 */
  .toast-wrap { left: 12px; right: 12px; bottom: 14px; align-items: stretch; }

  /* 沙盘/推演等密集布局 */
  .plan-bar { gap: 10px; padding: 12px; }
  .plan-field input, .plan-field select { min-width: 0; width: 100%; }
  .plan-field { flex: 1 1 46%; }
}

/* 超小屏微调 */
@media (max-width: 400px) {
  .brand-text strong { font-size: 12px; }
  .month-picker input { width: 96px; font-size: 11.5px; }
  .nav-item { padding: 6px 9px; font-size: 12px; }
  .main { padding: 12px 10px 44px; }
  .auth-body { padding: 14px 14px 18px; }
}

.daily-params {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 12px;
}
.daily-params strong { font-size: 15px; }
.daily-params button { margin-left: auto; }
.daily-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.daily-metrics .kpi { min-width: 0; padding: 12px 14px; }
.daily-metrics .kpi-value { font-size: clamp(16px, 1.65vw, 24px); overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .daily-metrics { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

.modal.modal-wide {
  width: min(92vw, 1800px);
  max-width: 100%;
  max-height: 92vh;
}
.modal-wide .tbl thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
