/* 武汉事业部预算预测系统 - 轻量商务蓝风格（浅色主题） */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2F5597;
  --primary-2: #4472C4;
  --primary-soft: #EDF2FA;
  --border: #D9DFE8;
  --text: #1F2733;
  --muted: #7A8699;
  --bg: #F4F6FA;
  --amber: #FFF7E6;
  --purple: #F3E8FF;
  --danger: #C0392B;
  --ok: #1E8449;
}
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
button { font-family: inherit; }
input, select { font-family: inherit; color: var(--text); }

/* ---------- 登录页 ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #2F5597 0%, #4472C4 55%, #6C8FD6 100%); }
.auth-card { width: 380px; max-width: 96vw; background: #fff; border-radius: 14px; padding: 30px 28px;
  box-shadow: 0 18px 50px rgba(20, 40, 90, .35); }
.auth-card h1 { font-size: 20px; color: var(--primary); text-align: center; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.auth-tabs { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 16px; }
.auth-tabs button { flex: 1; padding: 9px 0; border: 0; background: #fff; cursor: pointer; font-size: 14px; color: var(--muted); }
.auth-tabs button.on { background: var(--primary-2); color: #fff; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary-2); }
.auth-tip { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.6; }
.btn { border: 0; border-radius: 8px; cursor: pointer; padding: 9px 16px; font-size: 14px; background: #E8ECF4; color: var(--text); }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--primary-2); color: #fff; }
.btn.block { width: 100%; padding: 11px 0; font-size: 15px; }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.danger { background: #FDECEA; color: var(--danger); }
.btn.ok { background: #E8F6EE; color: var(--ok); }
.form-err { color: var(--danger); font-size: 12px; min-height: 16px; margin: 4px 0 8px; }

/* ---------- 主框架 ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 10px 18px; display: flex;
  align-items: center; gap: 14px; flex-wrap: wrap; position: sticky; top: 0; z-index: 50; }
.topbar .brand { font-size: 16px; font-weight: 700; color: var(--primary); }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.topbar .who b { color: var(--text); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--border); background: #fff; color: var(--muted); padding: 7px 16px; border-radius: 20px; cursor: pointer; font-size: 13px; }
.tabs button.on { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.content { padding: 14px 18px 40px; max-width: 1720px; margin: 0 auto; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .sp { flex: 1; }
.toolbar select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--muted); border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.save-state { font-size: 12px; color: var(--muted); }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- 表格 ---------- */
.table-box { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: auto; max-height: calc(100vh - 210px); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1560px; font-size: 13px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--border); padding: 0 8px; height: 32px; white-space: nowrap; }
table.grid thead th { position: sticky; top: 0; z-index: 5; background: var(--primary-2); color: #fff; font-weight: 600; text-align: right; }
table.grid thead th.tl { text-align: left; }
table.grid td.num, table.grid td.calc { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.code { color: var(--muted); font-family: Consolas, monospace; font-size: 12px; }
td.stick1, th.stick1 { position: sticky; left: 0; z-index: 3; background: #fff; }
th.stick1 { z-index: 6; }
td.stick2, th.stick2 { position: sticky; left: 90px; z-index: 3; background: #fff; text-align: left; min-width: 260px; }
th.stick2 { z-index: 6; }
tr.lv1 td { background: var(--primary-soft) !important; font-weight: 700; }
tr.lv1 td.stick1, tr.lv1 td.stick2 { background: var(--primary-soft) !important; }
tr.lv2 td.stick1, tr.lv2 td.stick2 { background: #FBFCFE; }
tr:hover td { background-color: #F2F6FF; }
tr.lv1:hover td { background-color: #E2EAF8 !important; }
.arrow { display: inline-block; width: 16px; cursor: pointer; color: var(--primary-2); user-select: none; text-align: center; }
.noarrow { display: inline-block; width: 16px; }
td.name-cell { overflow: hidden; text-overflow: ellipsis; }
.fill { width: 100%; height: 30px; border: 0; background: transparent; text-align: right; font-size: 13px; outline: none; }
.fill.note-in { text-align: left; }
.fill:focus { box-shadow: inset 0 0 0 2px var(--primary-2); background: #fff; }
/* 每月说明小输入框：数字下方第二行 */
.fill.note-mini { height: 22px; font-size: 11px; text-align: left; color: var(--muted); border-top: 1px dashed #d8dee8; }
.fill.note-mini:focus { color: var(--ink); background: #fff; }
/* ✎ 说明角标：置于左上角（数字右对齐不被遮挡）；有说明时高亮；悬停预览，点击弹出气泡编辑 */
td[data-fc] { position: relative; }
.note-dot {
  position: absolute; top: 2px; left: 3px; width: 16px; height: 16px;
  font-size: 10px; line-height: 16px; text-align: center; cursor: pointer;
  color: #C3CCDA; border-radius: 50%; user-select: none; z-index: 2;
}
.note-dot:hover { color: var(--primary-2); background: #E8EEF9; }
.note-dot.has { color: #fff; background: #E8A33D; font-weight: 700; }
.note-dot.has:hover { background: #D09230; }
/* 说明气泡 */
#note-pop {
  position: fixed; z-index: 999; width: 260px; background: #fff;
  border: 1px solid var(--primary-2); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(30,50,90,.18); padding: 10px;
}
#note-pop .np-title { font-size: 12px; font-weight: 600; color: var(--primary); margin-bottom: 6px; }
#note-pop .np-text {
  width: 100%; box-sizing: border-box; height: 64px; resize: none;
  border: 1px solid #d8dee8; border-radius: 6px; padding: 6px 8px;
  font-size: 12px; font-family: inherit; outline: none;
}
#note-pop .np-text:focus { border-color: var(--primary-2); }
#note-pop .np-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
#note-pop .np-hint { font-size: 10px; color: var(--muted); }
/* 父级科目"自动汇总"只读格 */
td.rollup-cell { background: #E8EEF9 !important; text-align: right; padding: 2px 8px; }
td.rollup-cell .rollup-num { font-size: 13px; font-weight: 600; color: #3B62A8; }
td.rollup-cell .rollup-tag { display: block; font-size: 10px; color: #8496B8; line-height: 12px; }
td.fillnum {}
td.fillmix { background: var(--purple) !important; }
td.filltext { background: #F5F5F7 !important; }
td.filltext .fill { color: var(--muted); font-style: italic; }
td.calc { background: #FAFBFC; color: #34455E; }
td.diff-on { background: var(--amber) !important; font-weight: 600; }
td .sub-ind { font-size: 10px; color: var(--muted); }
tr.exonly td.code { color: #B49CE8; }
tbody tr.hidden { display: none; }

/* KPI 卡 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 700; color: var(--primary); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .v.neg { color: var(--danger); }
.kpi .v.pos { color: #1E8E3E; }
/* 修改记录清单 */
.chg-sess { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: #fff; }
.chg-head { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; align-items: center; padding-bottom: 6px; border-bottom: 1px dashed var(--border); }
.chg-user { font-weight: 700; font-size: 13px; color: var(--primary); }
.chg-tbl { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.chg-tbl th { text-align: left; background: #F0F4FB; color: var(--primary); font-weight: 600; padding: 5px 8px; border: 1px solid var(--border); white-space: nowrap; }
.chg-tbl td { padding: 4px 8px; border: 1px solid var(--border); word-break: break-all; }
.chg-tbl .nowrap { white-space: nowrap; }
.kpi .s { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* 抽屉 */
.overlay { position: fixed; inset: 0; background: rgba(15, 30, 60, .35); z-index: 90; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(880px, 96vw); background: #fff; z-index: 91;
  box-shadow: -12px 0 40px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.drawer .d-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer .d-head h3 { font-size: 15px; color: var(--primary); }
.drawer .d-head .x { margin-left: auto; }
.drawer .d-body { overflow: auto; padding: 14px 18px; }
.drawer table.grid { min-width: 780px; }
.drawer td.stick1, .drawer td.stick2 { position: static; }

/* 列表卡片 */
.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.card h3 { font-size: 15px; color: var(--primary); margin-bottom: 10px; }
.card table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
.card table.list th, .card table.list td { border-bottom: 1px solid var(--border); padding: 8px 8px; text-align: left; }
.card table.list th { color: var(--muted); font-weight: 600; font-size: 12px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; }
.tag.admin { background: #FDEEE0; color: #B95D10; }
.tag.member { background: #E8F6EE; color: var(--ok); }
.tag.pending { background: #FFF7E6; color: #9A6B00; }
.tag.rejected { background: #FDECEA; color: var(--danger); }
.muted { color: var(--muted); }
.help h3 { margin: 14px 0 6px; color: var(--primary); font-size: 14px; }
.help p, .help li { font-size: 13px; line-height: 1.9; color: #3A4657; }
.help ul { padding-left: 20px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); background: rgba(30, 40, 60, .92);
  color: #fff; padding: 9px 20px; border-radius: 20px; font-size: 13px; z-index: 200; display: none; max-width: 80vw; }
#toast.err { background: rgba(160, 40, 30, .95); }

@media (max-width: 720px) {
  .content { padding: 10px 8px 40px; }
  .topbar { padding: 8px 10px; }
  .kpi .v { font-size: 16px; }
}
