/* ============ 基础 ============ */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --ink-2: #56616d;
  --ink-3: #8d97a3;
  --line: #e6eaef;
  --line-2: #eff2f5;
  --brand: #e2634a;
  --brand-dark: #c94f36;
  --brand-soft: #fdf0ed;
  --sidebar: #182029;
  --sidebar-2: #212b36;
  --sidebar-ink: #aeb9c4;
  --green: #1f9d63;
  --green-soft: #e9f7f0;
  --blue: #2f6fed;
  --blue-soft: #ecf2fe;
  --amber: #b8791a;
  --amber-soft: #fdf4e4;
  --red: #d9433b;
  --red-soft: #fdeceb;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(23, 32, 42, .06);
  --shadow: 0 8px 24px rgba(23, 32, 42, .08);
  --shadow-lg: 0 24px 60px rgba(23, 32, 42, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

/* hidden 属性必须真的隐藏：抽屉/弹层用 display:flex 时不会被 UA 样式覆盖 */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd6de; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b5bec8; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 布局 ============ */
.app {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  gap: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 6px 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--brand), #f08a5d);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 6px 16px rgba(226, 99, 74, .35);
}

.brand-mark svg { width: 21px; height: 21px; }

.brand-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: .3px; }
.brand-text span { font-size: 11px; color: #7d8894; letter-spacing: .2px; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--sidebar-ink);
  font-size: 13.5px;
  text-align: left;
  transition: background .16s, color .16s;
  position: relative;
}

.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--sidebar-2); color: #fff; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.nav-badge {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  background: var(--brand);
  color: #fff;
  border-radius: 20px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conn { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #cfd8e0; }
.conn .dot { width: 7px; height: 7px; border-radius: 50%; background: #f0a93c; box-shadow: 0 0 0 3px rgba(240, 169, 60, .16); }
.conn.ok .dot { background: #35c07e; box-shadow: 0 0 0 3px rgba(53, 192, 126, .16); }
.conn.err .dot { background: var(--red); box-shadow: 0 0 0 3px rgba(217, 67, 59, .16); }
.foot-note { font-size: 11px; color: #6d7883; line-height: 1.5; }

/* ============ 主区 ============ */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 26px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar-title h1 { margin: 0; font-size: 19px; letter-spacing: -.2px; }

.menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  place-items: center;
  color: var(--ink-2);
}
.menu-btn svg { width: 18px; height: 18px; }.topbar-title p { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-3); }

.topbar-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  transition: all .15s;
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: #d3dae1; background: #fbfcfd; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(226, 99, 74, .26);
}
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { background: #fff; }
.btn.danger { color: var(--red); border-color: #f3c9c6; background: #fff; }
.btn.danger:hover { background: var(--red-soft); }
.btn.tiny { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.scroller {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px 26px 40px;
}
.view { max-width: 1680px; }

/* ============ KPI ============ */
/* 成员账号的范围提示 */
.scope-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 9px 13px;
  border: 1px solid #f4dcd4;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12.5px;
  line-height: 1.5;
}
.scope-bar svg { width: 16px; height: 16px; flex: none; }

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  position: relative;
  overflow: hidden;
}

.kpi .kpi-label { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi .kpi-value { font-size: 24px; font-weight: 650; letter-spacing: -.6px; line-height: 1; }
.kpi .kpi-sub { font-size: 11.5px; color: var(--ink-3); }
.kpi .kpi-value small { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-left: 4px; letter-spacing: 0; }
.kpi.accent { background: linear-gradient(160deg, #fff8f6, #fff); border-color: #f6ddd6; }
.kpi.accent .kpi-value { color: var(--brand-dark); }
.kpi.danger .kpi-value { color: var(--red); }
.kpi.good .kpi-value { color: var(--green); }

/* ============ 面板 ============ */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel.pad { padding: 20px 22px; border-radius: var(--radius); }
.panel-title { margin: 0 0 6px; font-size: 15px; }
.panel-sub { margin: 0 0 16px; font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }

/* ============ 工具条 ============ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.search {
  position: relative;
  flex: 1 1 240px;
  max-width: 340px;
}

.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--ink-3);
}

.search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 33px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  outline: none;
  transition: all .15s;
}

.search input:focus { border-color: #cbd4dd; background: #fff; box-shadow: 0 0 0 3px rgba(226, 99, 74, .09); }

.sort-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}
.sort-pick > svg { width: 15px; height: 15px; color: var(--ink-3); flex: 0 0 auto; }
.sort-pick select { height: 34px; }
@media (max-width: 900px) {
  .sort-pick { margin-left: 0; flex: 1 1 100%; }
  .sort-pick select { flex: 1 1 auto; }
}

.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

select, .filters select {
  height: 34px;
  padding: 0 26px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%238d97a3' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 8px center;
  background-size: 12px;
  appearance: none;
  outline: none;
  font-size: 13px;
  color: var(--ink-2);
  max-width: 150px;
}

select:focus { border-color: #cbd4dd; background-color: #fff; }
#fMonth { max-width: 168px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  font-size: 13px;
  color: var(--ink-2);
  transition: all .15s;
}

.chip svg { width: 14px; height: 14px; }
.chip:hover { border-color: #d3dae1; }
.chip[data-on="1"] { background: var(--brand-soft); border-color: #f3cec5; color: var(--brand-dark); font-weight: 500; }

.link-btn {
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 4px 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--brand-dark); }

/* ============ 表格 ============ */
.table-wrap { overflow: auto; max-height: max(260px, calc(100dvh - 372px)); }

table.grid {
  width: 100%;
  min-width: 1960px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafb;
  color: var(--ink-2);
  font-weight: 550;
  font-size: 12.5px;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}

table.grid thead th[data-sort] { cursor: pointer; }
table.grid thead th[data-sort]:hover { color: var(--brand-dark); }
table.grid thead th.sorted::after {
  content: "";
  display: inline-block;
  margin-left: 4px;
  border: 4px solid transparent;
  border-top-color: var(--brand);
  transform: translateY(2px);
}
table.grid thead th.sorted.asc::after { border-top-color: transparent; border-bottom-color: var(--brand); transform: translateY(-2px); }

table.grid tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-2);
  color: var(--ink);
  white-space: nowrap;
  vertical-align: middle;
}

table.grid tbody tr { transition: background .12s; cursor: pointer; }
table.grid tbody tr:hover td { background: #fbfcfd; }

/* 带底色标签的列不能被压窄，否则「未量房」会被裁成「未量」 */
table.grid th[data-col="measure_status"], table.grid td[data-col="measure_status"],
table.grid th[data-col="sign_status"], table.grid td[data-col="sign_status"],
table.grid th[data-col="refund_status"], table.grid td[data-col="refund_status"] { min-width: 96px; }
table.grid th[data-col="source"], table.grid td[data-col="source"] { min-width: 100px; }
table.grid th[data-col="house_type"], table.grid td[data-col="house_type"],
table.grid th[data-col="reno_type"], table.grid td[data-col="reno_type"] { min-width: 86px; }
table.grid tbody tr.is-overdue td.col-date { color: var(--red); font-weight: 600; }
table.grid tbody tr.is-overdue .due-cell { color: var(--red); font-weight: 600; }

.col-date, .col-no {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}
.col-date { left: 40px; }
.col-no { left: calc(40px + var(--col-date-w, 98px)); }
table.grid thead .col-date, table.grid thead .col-no { z-index: 4; background: #f8fafb; }
table.grid tbody tr:hover .col-date, table.grid tbody tr:hover .col-no { background: #fbfcfd; }
.col-date { min-width: 98px; width: 98px; }
.col-no { min-width: 84px; width: 84px; box-shadow: 1px 0 0 var(--line); }

/* 勾选列（左冻结） */
.col-check {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 40px;
  min-width: 40px;
  padding: 10px 4px 10px 12px !important;
  background: #fff;
}
table.grid thead .col-check { z-index: 5; background: #f8fafb; }
table.grid tbody tr:hover .col-check { background: #fbfcfd; }
.col-check input {
  width: 15px; height: 15px; margin: 0; vertical-align: middle;
  accent-color: var(--brand); cursor: pointer;
}
table.grid thead .col-check input { cursor: pointer; }
table.grid tbody tr.is-picked td { background: #fdf2ee; }
table.grid tbody tr.is-picked .col-check,
table.grid tbody tr.is-picked .col-date,
table.grid tbody tr.is-picked .col-no,
table.grid tbody tr.is-picked .col-act { background: #fdf2ee; }
table.grid tbody tr.is-picked:hover td { background: #fbeae4; }
table.grid tbody tr.is-picked:hover .col-check,
table.grid tbody tr.is-picked:hover .col-date,
table.grid tbody tr.is-picked:hover .col-no,
table.grid tbody tr.is-picked:hover .col-act { background: #fbeae4; }
.th-custom { color: var(--ink-2); }
.th-custom-cell { color: var(--ink-2); max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.col-addr { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.col-note { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.col-act { position: sticky; right: 0; background: #fff; z-index: 2; box-shadow: -1px 0 0 var(--line); }
table.grid thead .col-act { z-index: 4; background: #f8fafb; }
table.grid tbody tr:hover .col-act { background: #fbfcfd; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 550; }
.cell-muted { color: var(--ink-3); }
.cell-phone { font-variant-numeric: tabular-nums; letter-spacing: .2px; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: #f1f3f5;
  color: var(--ink-2);
  white-space: nowrap;
}

.tag.a { background: var(--red-soft); color: #c0392b; }
.tag.b { background: var(--amber-soft); color: var(--amber); }
.tag.c { background: var(--blue-soft); color: var(--blue); }
.tag.d { background: #f1f3f5; color: #6b7683; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.gray { background: #f1f3f5; color: #77828e; }
.tag.teal { background: #e8f6f5; color: #0e8a80; }
.tag.outline { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }

.row-act {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.row-act button {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 3px 6px;
  border-radius: 6px;
}
.row-act button:hover { background: var(--brand-soft); color: var(--brand-dark); }

.empty {
  padding: 70px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13.5px;
  line-height: 1.9;
}
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 6px; }

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-3);
}

.pager-btns { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pager-btns span { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.pager select { height: 30px; font-size: 12.5px; }

/* ============ 提醒视图 ============ */
.remind-head {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 14px;
}

.remind-summary { display: flex; gap: 26px; flex-wrap: wrap; }
.remind-summary .rs-item { display: flex; flex-direction: column; gap: 3px; }
.remind-summary .rs-num { font-size: 20px; font-weight: 650; letter-spacing: -.4px; }
.remind-summary .rs-num.warn { color: var(--red); }
.remind-summary .rs-label { font-size: 12px; color: var(--ink-3); }
.remind-actions { margin-left: auto; display: flex; gap: 9px; }

.remind-groups { display: flex; flex-direction: column; gap: 14px; }

.rgroup { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rgroup-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-2);
  background: #fcfdfd;
}
.rgroup-head h3 { margin: 0; font-size: 14px; }
.rgroup-head .count { font-size: 12px; color: var(--ink-3); }

.rlist { display: flex; flex-direction: column; }
.ritem {
  display: grid;
  grid-template-columns: 120px 1fr 130px 96px auto;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}
.ritem:last-child { border-bottom: 0; }
.ritem:hover { background: #fbfcfd; }
.ritem .r-time { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12.5px; }
.ritem .r-time.late { color: var(--red); font-weight: 600; }
.ritem .r-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ritem .r-main strong { font-size: 13.5px; font-weight: 550; }
.ritem .r-main span { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ritem .r-meta { display: flex; gap: 5px; flex-wrap: wrap; }
.ritem .r-actions { display: flex; gap: 6px; justify-content: flex-end; }

.rgroup-empty { padding: 26px 18px; color: var(--ink-3); font-size: 13px; text-align: center; }

/* ============ 导入导出 ============ */
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

.dropzone {
  border: 1.5px dashed #d7dee5;
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .16s;
  background: #fbfcfd;
}
.dropzone:hover, .dropzone.hot { border-color: var(--brand); background: var(--brand-soft); }
.dropzone svg { width: 30px; height: 30px; color: var(--ink-3); }
.dropzone.hot svg { color: var(--brand-dark); }
.dropzone strong { font-size: 13.5px; font-weight: 550; }
.dropzone span { font-size: 12px; color: var(--ink-3); }

.row-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }

.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.switch-line.big { margin: 14px 0; }
.switch-line input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}

.import-result {
  margin-top: 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  overflow: hidden;
  font-size: 12.5px;
}
.import-result .ir-head { padding: 11px 14px; background: #f8fafb; border-bottom: 1px solid var(--line); font-weight: 550; }
.import-result .ir-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.ir-line { display: flex; gap: 8px; color: var(--ink-2); }
.ir-line .ok { color: var(--green); font-weight: 600; }
.ir-line .err { color: var(--red); font-weight: 600; }

.export-list { display: flex; flex-direction: column; gap: 9px; }

.export-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-align: left;
  transition: all .15s;
}
.export-row:hover { border-color: #d5dce3; background: #fbfcfd; }
.export-row div { display: flex; flex-direction: column; gap: 3px; }
.export-row strong { font-size: 13.5px; font-weight: 550; }
.export-row span { font-size: 12px; color: var(--ink-3); }
.export-row svg { width: 17px; height: 17px; margin-left: auto; color: var(--ink-3); }

.tip-box {
  margin-top: 16px;
  padding: 13px 15px;
  background: #f8fafb;
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.75;
}
.tip-box strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 12.5px; }
.tip-box p { margin: 0; }
.tip-box b { color: var(--ink); }

.preview {
  margin: 0;
  padding: 16px;
  background: #17202a;
  color: #dbe3ea;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 380px;
  overflow: auto;
}

/* ============ 抽屉 ============ */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 42, .38);
  backdrop-filter: blur(1.5px);
  z-index: 40;
  animation: fade .18s ease;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(620px, 94vw);
  background: var(--panel);
  z-index: 41;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideIn .22s cubic-bezier(.22, .8, .3, 1);
}

@keyframes fade { from { opacity: 0; } }
@keyframes slideIn { from { transform: translateX(28px); opacity: .6; } }

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-head p { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-3); }

.icon-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--ink-3);
}
.icon-btn:hover { background: #f2f4f6; color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 24px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.block { grid-column: 1 / -1; }
.field.span2 { grid-column: span 2; }
.field-label { font-size: 12px; color: var(--ink-3); font-weight: 500; }

/* 每日三个推送时段 */
.slot-row { display: flex; gap: 8px; }
.slot {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 10px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfd;
}
.slot > span { font-size: 12px; color: var(--ink-3); flex: 0 0 auto; }
.slot > input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 13px;
  outline: none;
  color: var(--ink);
}
.slot:focus-within { border-color: #cbd4dd; background: #fff; box-shadow: 0 0 0 3px rgba(226, 99, 74, .09); }
@media (max-width: 520px) {
  .slot-row { flex-wrap: wrap; }
  .slot { flex: 1 1 100%; }
}

/* 个人企业微信：四参数两列排布 */
.app-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  margin: 2px 0 14px;
}
@media (max-width: 900px) {
  .app-grid { grid-template-columns: 1fr; }
}

.field input, .field select, .field textarea {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfd;
  outline: none;
  transition: all .15s;
  font-size: 13.5px;
}

.field textarea { height: auto; padding: 10px 11px; resize: vertical; line-height: 1.7; }
.field select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%238d97a3' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 12px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #cbd4dd;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(226, 99, 74, .09);
}

.quick-follow { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.quick-row { display: flex; gap: 8px; margin-top: 7px; }
.quick-row select { flex: 0 0 120px; }
.quick-row input {
  flex: 1;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfd;
  outline: none;
  font-size: 13.5px;
}
.quick-row input:focus { border-color: #cbd4dd; background: #fff; }

.drawer-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: #fcfdfd;
}
.drawer-foot .spacer { flex: 1; }

/* ============ Toast ============ */
.toast-wrap {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: #17202a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn .2s ease;
  max-width: 80vw;
}
.toast.ok { background: #1c8f5e; }
.toast.err { background: #c9403a; }
.toast.warn { background: #b8791a; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ============ 登录 ============ */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  background:
    radial-gradient(900px 520px at 12% 8%, rgba(226, 99, 74, .16), transparent 60%),
    radial-gradient(760px 480px at 88% 92%, rgba(47, 111, 237, .14), transparent 62%),
    #f4f6f8;
}

.auth-card {
  width: min(468px, 100%);
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 30px 28px 26px;
  animation: authIn .26s cubic-bezier(.22, .8, .3, 1);
}
@keyframes authIn { from { transform: translateY(10px); opacity: 0; } }

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-mark {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; flex: none;
}
.auth-brand .brand-mark svg { width: 22px; height: 22px; }
.auth-brand strong { display: block; font-size: 16px; }
.auth-brand span { font-size: 12.5px; color: var(--ink-3); }

.auth-card h2 { margin: 0 0 6px; font-size: 19px; letter-spacing: -.2px; }
.auth-card > p { margin: 0 0 20px; font-size: 13px; color: var(--ink-2); line-height: 1.7; }

.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-form .field input { background: #fbfcfd; }
.auth-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }

.btn-wecom {
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: #1a7af8;
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  box-shadow: 0 6px 18px rgba(26, 122, 248, .26);
  transition: all .15s;
  text-decoration: none;
}
.btn-wecom:hover { background: #0f6ae4; transform: translateY(-1px); }
.btn-wecom:disabled { opacity: .6; cursor: default; transform: none; }
.btn-wecom svg { width: 19px; height: 19px; }

.auth-hint {
  margin-top: 18px;
  padding: 13px 15px;
  border-radius: 11px;
  background: #f7f9fb;
  border: 1px solid var(--line-2);
  font-size: 12.3px;
  color: var(--ink-2);
  line-height: 1.8;
}
.auth-hint strong { color: var(--ink); display: block; margin-bottom: 4px; font-size: 12.5px; }
.auth-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #eef1f4;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
  word-break: break-all;
}
.auth-error {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--red-soft);
  color: #a5322c;
  font-size: 12.5px;
  line-height: 1.7;
}
.auth-steps { margin: 0; padding-left: 17px; font-size: 12.3px; color: var(--ink-2); line-height: 1.95; }
.auth-steps b { color: var(--ink); }

/* ============ 顶栏用户 ============ */
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 6px 5px 5px;
  border-radius: 30px;
  border: 1px solid var(--line);
  background: #fff;
  margin-left: 4px;
  max-width: 200px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; flex: none;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-meta strong {
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 96px;
}
.user-meta span { font-size: 10.5px; color: var(--ink-3); }
.user-chip .icon-btn { width: 26px; height: 26px; margin-left: 2px; }
.user-chip .icon-btn svg { width: 15px; height: 15px; }

/* ============ 成员管理 ============ */
.member-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.member-table th {
  text-align: left; font-weight: 500; color: var(--ink-3);
  font-size: 11.5px; padding: 0 10px 8px; border-bottom: 1px solid var(--line);
}
.member-table td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.member-table tr:last-child td { border-bottom: 0; }
.member-table .m-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-dark); display: grid; place-items: center;
  font-size: 11px; font-weight: 600; overflow: hidden;
}
.member-table .m-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-table select {
  height: 30px; border: 1px solid var(--line); border-radius: 7px;
  background: #fbfcfd; padding: 0 8px; font-size: 12.5px; outline: none;
}
.member-empty { padding: 16px 0; color: var(--ink-3); font-size: 12.5px; }

/* ---- 账号管理 ---- */
.acc-new {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 92px 104px;
  gap: 8px;
  margin-bottom: 14px;
}
.acc-new input, .acc-new select {
  height: 34px; border: 1px solid var(--line); border-radius: 8px;
  background: #fbfcfd; padding: 0 10px; font-size: 12.5px; outline: none;
  font-family: inherit;
}
.acc-new input:focus, .acc-new select:focus { border-color: var(--brand); background: #fff; }
.acc-new .btn { height: 34px; justify-content: center; }
.acc-name { display: flex; align-items: center; gap: 9px; }
.acc-name > div { display: flex; flex-direction: column; line-height: 1.35; }
.acc-name small { font-size: 11px; }
.acc-ok { color: #2f9e6e; }
.acc-off td { opacity: .55; }
#accountBox { overflow-x: auto; }
.acc-table { min-width: 520px; }
.acc-table td, .acc-table th { white-space: nowrap; }
.acc-table td:first-child { white-space: normal; }
.member-table .row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }

/* ---- 批量操作条 ---- */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin: 0 0 10px;
  border: 1px solid #f2cfc5;
  background: #fdf3ef;
  border-radius: 10px;
}
.batch-count { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.batch-count b { color: var(--brand-dark); font-size: 15px; }
.batch-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

/* ---- 字段自定义 ---- */
.section-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: .04em;
  margin: 16px 0 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.req-mark { color: var(--red); font-weight: 700; }

@media (max-width: 1100px) {
  .acc-new { grid-template-columns: 1fr 1fr; }
  .acc-new .btn { grid-column: 1 / -1; }
}

/* ============ 响应式 ============ */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols-2 { grid-template-columns: 1fr; }
}

@media (max-width: 1000px) {
  /* 手机端改成整页原生滚动：
     内层 flex 滚动容器在 iOS / 企微 / 微信内置 webview 里经常滑不动，
     所以这里解除固定高度，让 body 自己滚 */
  .app { grid-template-columns: 1fr; height: auto; min-height: 100dvh; overflow: visible; }
  .main { min-height: 0; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 228px;
    transform: translateX(-100%);
    transition: transform .22s;
    z-index: 50;
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { flex-wrap: wrap; }
  .topbar-actions { width: 100%; margin-left: 0; }
  .scroller {
    flex: 0 1 auto;
    min-height: 0;
    overflow: visible;
    padding: 16px;
  }
  /* 表格容器不再限制高度，交给整页滚动；横向仍可滑动 */
  .table-wrap { max-height: none; }
  .ritem { grid-template-columns: 1fr; gap: 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span2 { grid-column: span 1; }
  .field.block { grid-column: auto; }
}

/* ---- 侧栏：账号客户 ---- */
.side-team {
  margin-top: 0;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.side-team-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 11px 7px;
  font-size: 11px;
  letter-spacing: .06em;
  color: #78848f;
}
.side-team-head em { font-style: normal; font-size: 10.5px; color: #5f6b76; }
.side-team-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  max-height: 216px;
  padding-right: 2px;
}
.side-team-list::-webkit-scrollbar { width: 6px; }
.side-team-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 4px; }
.team-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-ink);
  font-size: 12.5px;
  text-align: left;
  transition: background .14s, color .14s;
}
.team-item:hover { background: var(--sidebar-2); color: #fff; }
.team-item.active { background: rgba(226, 99, 74, .18); color: #fff; }
.team-item.active .team-count { background: var(--brand); color: #fff; }
.team-avatar {
  width: 20px; height: 20px;
  flex: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #dde5ec;
  display: grid;
  place-items: center;
  font-size: 10.5px;
}
.team-avatar.ghost { background: rgba(255, 255, 255, .05); color: #8b969f; }
.team-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-count {
  font-style: normal;
  font-size: 11px;
  min-width: 20px;
  height: 17px;
  line-height: 17px;
  padding: 0 6px;
  border-radius: 999px;
  text-align: center;
  background: rgba(255, 255, 255, .08);
  color: #c6d0d8;
}

/* ============ 字段管理 ============ */
.fm-overview {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.fm-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  flex: 1 1 520px;
  min-width: 0;
}
.fm-stat {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 13px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  transition: box-shadow .16s, transform .16s;
}
.fm-stat:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.fm-stat::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--brand), #f0a08f);
  opacity: .85;
}
.fm-stat-k { font-size: 12px; color: var(--ink-3); }
.fm-stat b {
  font-size: 23px; line-height: 1.15; font-weight: 650; letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}
.fm-stat small { font-size: 11.5px; color: var(--ink-3); }

.fm-search {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 1 260px;
  min-width: 200px;
  padding: 0 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.fm-search:focus-within { border-color: #cbd4dd; box-shadow: 0 0 0 3px rgba(226, 99, 74, .09); }
.fm-search svg { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.fm-search input {
  border: 0; outline: none; background: none;
  width: 100%; min-width: 0; min-height: 46px;
  font-size: 13px;
}
.fm-search input::-webkit-search-cancel-button { cursor: pointer; }

.fm-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.fm-head .panel-title { display: flex; align-items: center; gap: 8px; }
.fm-head .panel-sub { margin-bottom: 0; }
.fm-count {
  font-style: normal;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border: 1px solid #f6ddd6;
  border-radius: 999px;
  padding: 1px 9px;
}
.fm-note { font-size: 12.5px; color: var(--ink-3); line-height: 1.7; margin: 12px 0 10px; }
.fm-empty { padding: 30px 16px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* ---- 新建字段卡片：从左侧滑入 / 滑出 ---- */
.nf-card {
  margin-top: 14px;
  padding: 15px 16px 13px;
  background: linear-gradient(180deg, #fdfefe, #f9fbfc);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  opacity: 0;
  transform: translateX(-32px);
  transition: transform .26s cubic-bezier(.22, .8, .3, 1), opacity .2s ease;
}
.nf-card.is-in { opacity: 1; transform: none; }
.nf-card[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .nf-card { transition: none; transform: none; }
}
.nf-grid { display: grid; grid-template-columns: 1.1fr 148px 1.7fr; gap: 10px; }
.nf-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.nf-item > span { font-size: 11.5px; color: var(--ink-3); }
.nf-item input, .nf-item select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  font-size: 12.5px;
  outline: none;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.nf-item input:focus, .nf-item select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(226, 99, 74, .1);
}
.nf-foot { display: flex; align-items: center; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.nf-foot .ck-line input { width: 15px; height: 15px; }
.nf-spacer { flex: 1 1 auto; }

/* ---- 字段表 ---- */
.field-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
/* 列少，限宽后视觉更紧凑，也避免名称列被拉得过宽 */
#builtinBox .field-table-wrap { max-width: 760px; }
#fieldBox .field-table-wrap { max-width: 840px; }
.field-table { min-width: 0; width: 100%; border-collapse: collapse; table-layout: fixed; }
.field-table th:last-child, .field-table td:last-child { text-align: center; padding-right: 14px; }
.field-table th {
  background: #f8fafb;
  padding: 9px 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: .03em;
  border-bottom: 1px solid var(--line);
}
.field-table td { padding: 9px 14px; border-bottom: 1px solid var(--line-2); }
.field-table tbody tr:last-child td { border-bottom: 0; }
.field-table tbody tr { transition: background .13s; }
.field-table tbody tr:hover { background: #fcfdfd; }
.field-table td, .field-table th { white-space: nowrap; }
.field-table .fm-td-name { min-width: 210px; white-space: normal; }
.fm-ops { text-align: right; }
.fm-dash { color: #d9dfe5; font-size: 12px; }

.fm-name-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fm-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
  padding: 3px 7px 3px 4px;
  margin-left: -4px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink);
  text-align: left;
  transition: background .13s, border-color .13s, color .13s;
}
.fm-name:hover { background: var(--brand-soft); border-color: #f6ddd6; color: var(--brand-dark); }
.fm-name .fm-label { overflow: hidden; text-overflow: ellipsis; }
.fm-pen {
  width: 13px; height: 13px;
  flex: none;
  color: var(--brand-dark);
  opacity: 0;
  transition: opacity .13s;
}
.fm-name:hover .fm-pen { opacity: .85; }

.fm-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: #b9c4cf; }
.fm-dot.t-txt { background: #93a6b7; }
.fm-dot.t-num { background: #5b8def; }
.fm-dot.t-dt { background: #7c6ce0; }
.fm-dot.t-sel { background: #2fa37a; }

.fm-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 15px;
  font-size: 11.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fm-sub code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  color: var(--ink-3);
  background: #f4f6f8;
  border-radius: 4px;
  padding: 1px 5px;
}
.fm-opts {
  align-self: flex-start;
  max-width: 100%;
  margin-left: 11px;
  padding: 1px 5px;
  border: 0;
  border-radius: 4px;
  background: none;
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fm-opts:hover { background: #f1f3f5; color: var(--brand-dark); }

.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 23px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #f4f6f8;
  color: var(--ink-2);
  font-size: 11.5px;
  white-space: nowrap;
}
.type-chip.is-edit { background: #fff; border-color: var(--line); }
.type-chip.is-edit:hover { border-color: #f0c8bd; background: var(--brand-soft); color: var(--brand-dark); }
.type-chip .fm-caret { width: 12px; height: 12px; opacity: .55; }
.type-chip.is-locked { background: #f7f8fa; border: 1px dashed #e2e7ec; color: var(--ink-3); }
.type-chip .fm-lock { width: 12px; height: 12px; opacity: .55; }

/* 拖拽排序：鼠标整行都能拖，手机按住行首 ⋮⋮ 拖 */
.fm-grip-cell { padding-right: 0 !important; padding-left: 10px !important; }
.fm-grip { display: inline-flex; color: #c9d1d9; cursor: grab; touch-action: none; }
.fm-grip svg { width: 17px; height: 17px; }
.field-table tbody tr:hover .fm-grip { color: var(--ink-3); }
.fm-custom tbody tr[data-row^="c:"] { cursor: grab; }
.fm-custom tbody tr[data-row^="c:"] td { transition: background .12s; }
.fm-custom tbody tr.is-dragging {
  position: relative;
  z-index: 3;
  cursor: grabbing;
  background: #fff;
  box-shadow: 0 10px 26px rgba(23, 32, 42, .16), 0 0 0 1px rgba(226, 99, 74, .28);
}
.fm-custom tbody tr.is-dragging td { background: #fffdfc; }
.field-table tbody tr.drop-before td { box-shadow: inset 0 2px 0 var(--brand); }
.field-table tbody tr.drop-after td { box-shadow: inset 0 -2px 0 var(--brand); }
body.row-dragging { cursor: grabbing; }
body.row-dragging * { cursor: grabbing !important; }
body.row-dragging .fm-custom tbody tr:not(.is-dragging) td { background: #fafcfd; }

/* 开关 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 12px;
  color: var(--ink-3);
}
.switch i {
  position: relative;
  width: 33px; height: 19px;
  flex: none;
  border-radius: 999px;
  background: #dfe4e9;
  transition: background .16s;
}
.switch i::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(23, 32, 42, .28);
  transition: transform .16s;
}
.switch em { font-style: normal; }
.switch:hover i { filter: brightness(.97); }
.switch.on { color: var(--brand-dark); font-weight: 500; }
.switch.on i { background: var(--brand); }
.switch.on i::after { transform: translateX(14px); }

/* 就地编辑 */
.fm-inline {
  width: 100%;
  min-width: 140px;
  height: 29px;
  padding: 0 8px;
  border: 1px solid var(--brand);
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
  outline: none;
  box-shadow: 0 0 0 3px rgba(226, 99, 74, .13);
}
.fm-inline.is-select { min-width: 106px; }
.fm-editing { padding: 3px 0; }
.fm-saving { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-3); }
.fm-saving i {
  width: 12px; height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.field-order { display: flex; gap: 4px; }
.icon-mini {
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .13s;
}
.icon-mini:hover:not(:disabled) { border-color: #d3dae1; background: #fbfcfd; }
.icon-mini:disabled { opacity: .3; cursor: not-allowed; }
.icon-mini svg { width: 14px; height: 14px; }
.icon-mini.danger:hover { border-color: #f3c9c6; background: var(--red-soft); color: var(--red); }

.ck-line { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.ck-line input { accent-color: var(--brand); }

@media (max-width: 1100px) {
  .fm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nf-grid { grid-template-columns: 1fr 1fr; }
  .nf-wide { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .fm-overview { flex-direction: column; }
  /* 列方向布局时 flex-basis 会变成高度，必须取消，否则统计卡被拉成方块 */
  .fm-stats { flex: none; }
  .fm-search { flex: 0 0 auto; min-height: 42px; }
  .fm-search input { min-height: 42px; }
  .fm-stat b { font-size: 20px; }
  .nf-grid { grid-template-columns: 1fr; }
  .nf-wide { grid-column: auto; }
  .fm-foot { gap: 10px; }
  /* 窄屏保留最小宽度，靠容器横向滚动 */
  .field-table { min-width: 600px; }
}
@media (max-width: 640px) {
  .fm-head { flex-direction: column; align-items: stretch; }
  .fm-head .btn { align-self: flex-start; }
  .field-table td, .field-table th { padding: 8px 10px; }
}

/* ============ 选项配色 ============ */
.fm-tone-cell { text-align: center; }
.tone-entry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 30px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.tone-entry svg { width: 15px; height: 15px; }
.tone-entry em {
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  color: var(--brand-dark);
}
.tone-entry:hover { border-color: #f0c8bd; background: var(--brand-soft); color: var(--brand-dark); }
.tone-entry.has {
  border-color: #f2cfc6;
  background: linear-gradient(135deg, #fdf1ed, #fdeae4);
  color: var(--brand-dark);
}

body.tone-open { overflow: hidden; }

.tone-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(23, 32, 42, .42);
  backdrop-filter: blur(1.5px);
  animation: fade .16s ease;
}

.tone-panel {
  width: min(640px, 100%);
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: toneIn .2s cubic-bezier(.22, .8, .3, 1);
}
@keyframes toneIn {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.tone-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line-2);
}
.tone-title {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tone-title em {
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 2px 9px;
}
.tone-sub { margin: 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }

.tone-body {
  padding: 6px 20px 12px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.tone-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 10px 0 6px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-3);
}
.tone-legend > span:first-child {
  flex: 0 0 auto;
  white-space: nowrap;
  border: 1px dashed #cdd5de;
  border-radius: 999px;
  padding: 1px 8px;
  background: #fbfcfd;
}
.tone-legend-tip { flex: 1 1 200px; min-width: 0; }

.tone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  transition: background .12s;
}
.tone-row:hover { background: #fafbfc; }
.tone-row + .tone-row { border-top: 1px solid var(--line-2); }

.tone-pill {
  flex: 0 0 auto;
  min-width: 74px;
  max-width: 168px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tone-fixed {
  font-style: normal;
  font-size: 10.5px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}

.tone-sw {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tone-dot {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(23, 32, 42, .1);
  background: var(--dot-bg, #f1f3f6);
  cursor: pointer;
  position: relative;
  transition: transform .1s, box-shadow .12s;
  flex: 0 0 auto;
}
.tone-dot::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--dot-ink, #8d97a3);
}
.tone-dot:hover { transform: scale(1.12); }
.tone-dot.on {
  box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--dot-ink, #8d97a3);
}
.tone-dot.is-auto {
  background: #fff;
  border: 1px dashed #c3ccd6;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  --dot-ink: transparent;
}
.tone-dot.is-auto::after { display: none; }
.tone-dot.is-auto svg { width: 12px; height: 12px; }
.tone-dot.is-auto:hover { border-color: var(--ink-3); color: var(--ink-2); }
.tone-dot.is-auto.on { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #b6c0cb; }

.tone-empty {
  padding: 26px 4px 30px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
}

.tone-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line-2);
  background: #fcfdfe;
}

/* 选项编辑 */
.tone-sec {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 12px 2px 6px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 3px;
}
.tone-sec-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}
.tone-sec-title em {
  font-style: normal;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  background: #f1f3f6;
  border-radius: 999px;
  padding: 1px 7px;
}
.tone-sec-note { font-size: 11px; color: var(--ink-3); margin-left: auto; }
#toneResetOpts { font-size: 11.5px; }

.tone-pill.is-edit {
  border: 1px dashed rgba(23, 32, 42, .2);
  cursor: text;
  font-family: inherit;
}
.tone-pill.is-edit:hover { border-color: var(--brand); }
.tone-edit {
  flex: 0 0 auto;
  width: 128px;
  height: 28px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  padding: 0 11px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  color: var(--ink);
}
.tone-del {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.tone-del:hover { background: var(--red-soft); border-color: #f3c9c6; color: var(--red); }

.tone-add { display: flex; align-items: center; gap: 8px; padding: 10px 2px 4px; }
.tone-add input {
  flex: 1 1 auto;
  min-width: 0;
  height: 32px;
  border: 1px dashed #d3dae1;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12.5px;
  font-family: inherit;
  background: #fbfcfd;
  outline: none;
}
.tone-add input:focus { border-style: solid; border-color: var(--brand); background: #fff; }

.tone-tip { font-size: 11px; color: var(--ink-3); line-height: 1.7; padding: 10px 2px 4px; }

@media (max-width: 640px) {
  .tone-mask { padding: 0; align-items: flex-end; }
  .tone-panel { width: 100%; max-height: 88vh; border-radius: 16px 16px 0 0; }
  .tone-head { padding: 16px 16px 12px; }
  .tone-body { padding: 4px 12px 10px; }
  .tone-row { flex-wrap: wrap; gap: 8px; padding: 9px 6px; }
  .tone-pill { min-width: 0; }
  .tone-sw { margin-left: 0; width: 100%; justify-content: flex-start; }
  .tone-foot { padding: 10px 16px 14px; }
}

/* ============ 施工工期表 ============ */
.plan-toolbar .filters { margin-left: auto; }
.plan-toolbar #btnPlanNew { flex: none; }

.plan-list { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; }

.plan-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  transition: border-color .14s, box-shadow .14s;
}
.plan-card:hover { border-color: #d9e0e7; box-shadow: var(--shadow-sm); }
.plan-card-main { flex: 1 1 auto; min-width: 0; }
.plan-card-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plan-card-top strong { font-size: 14.5px; }
.plan-card-addr {
  font-size: 12.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 48%;
}
.plan-card-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 7px; font-size: 12px; color: var(--ink-2); }
.plan-card-meta .plan-remain { color: var(--brand-dark); font-weight: 500; }
.plan-bar { height: 6px; border-radius: 4px; background: #eef2f6; margin: 9px 0 6px; overflow: hidden; }
.plan-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #2f6fed, #5b8ef7); }
.plan-card-sub { font-size: 12px; color: var(--ink-3); }
.plan-card-ops { flex: none; display: flex; gap: 6px; }

/* ---------- 编辑弹层 ---------- */
.plan-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 26px 20px;
  overflow: auto;
  background: rgba(23, 32, 42, .42);
  backdrop-filter: blur(2px);
  animation: fade .16s ease;
}

.plan-sheet {
  width: min(1180px, 100%);
  max-height: calc(100vh - 52px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: planIn .2s cubic-bezier(.22, .8, .3, 1);
}
@keyframes planIn { from { transform: translateY(14px); opacity: .5; } }

.plan-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line-2);
  flex: none;
}
.plan-title { margin: 0; font-size: 17px; letter-spacing: -.2px; }
.plan-head-sub { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }
.plan-head-ops { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }

.plan-body { padding: 16px 22px 8px; overflow: auto; flex: 1 1 auto; }

.plan-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  padding: 10px 13px;
  margin-bottom: 14px;
  background: #f8fafb;
  border: 1px solid var(--line-2);
  border-radius: 10px;
}
.meta-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.meta-item strong { color: var(--ink); font-weight: 500; }

.plan-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin-bottom: 14px; }
.plan-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-3); }
.plan-field input, .plan-field select {
  height: 34px;
  border: 1px solid #dde3e9;
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  font-size: 13px;
  outline: none;
  max-width: 200px;
}
.plan-field input:focus, .plan-field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(226, 99, 74, .1); }
.plan-skip { height: 34px; display: flex; align-items: center; font-size: 12.5px; color: var(--ink-2); }
.plan-sum { margin-left: auto; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-3); }
.plan-sum b { color: var(--ink); font-size: 14px; }

.plan-stage-head,
.stage-row {
  display: grid;
  grid-template-columns: 30px minmax(110px, 1.1fr) 58px 132px 54px 92px 86px minmax(110px, 1.3fr) 74px;
  gap: 6px;
  align-items: center;
}
.plan-stage-head { padding: 0 6px 7px; font-size: 11.5px; color: var(--ink-3); }
.plan-stage-list { display: flex; flex-direction: column; gap: 5px; }
.stage-row {
  padding: 5px 6px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: #fff;
}
.stage-row:hover { border-color: var(--line); }
.stage-row.is-manual { background: #fffaf7; border-color: #f6e0d7; }
.stage-no { text-align: center; font-size: 12px; color: var(--ink-3); }
.stage-row input,
.stage-row select {
  width: 100%;
  min-width: 0;
  height: 30px;
  border: 1px solid #e3e8ee;
  border-radius: 7px;
  padding: 0 8px;
  font-size: 12.5px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.stage-row input:focus,
.stage-row select:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(226, 99, 74, .1); }
.stage-row select { padding-right: 4px; max-width: none; }
.st-end { text-align: center; font-size: 12.5px; color: var(--ink-2); }
.st-ops { display: flex; gap: 2px; justify-content: flex-end; }
.icon-mini {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-3);
}
.icon-mini svg { width: 14px; height: 14px; }
.icon-mini:hover { background: #f1f4f7; color: var(--ink); }
.icon-mini.danger:hover { background: var(--red-soft); color: var(--red); }

.stage-empty {
  padding: 26px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.plan-stage-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 2px 0; }
.plan-hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }

.plan-note { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 6px; font-size: 12px; color: var(--ink-3); }
.plan-note textarea {
  border: 1px solid #dde3e9;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  resize: vertical;
  outline: none;
}
.plan-note textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(226, 99, 74, .09); }

.plan-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 22px 16px;
  border-top: 1px solid var(--line-2);
  background: #fff;
  flex: none;
}
.plan-save-tip { font-size: 12px; color: var(--ink-3); }

/* ---------- 选择客户 ---------- */
.plan-pick {
  width: min(560px, 100%);
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: planIn .18s ease;
}
.plan-pick-search { padding: 12px 18px; border-bottom: 1px solid var(--line-2); flex: none; }
.plan-pick-search input {
  width: 100%;
  height: 36px;
  border: 1px solid #dde3e9;
  border-radius: 9px;
  padding: 0 12px;
  font-size: 13px;
  outline: none;
  background: #fbfcfd;
}
.plan-pick-search input:focus { border-color: var(--brand); background: #fff; }
.plan-pick-list { overflow: auto; padding: 8px; flex: 1 1 auto; }
.pick-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}
.pick-row:hover { background: #f7fafc; }
.pick-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.pick-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pick-main strong { font-size: 13.5px; font-weight: 600; }
.pick-main em {
  font-style: normal;
  font-size: 12px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick-side { flex: none; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
.pick-flag { font-size: 11px; padding: 2px 7px; border-radius: 5px; background: #f1f4f7; color: var(--ink-3); }
.pick-flag.go { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- 打印 ---------- */
#printArea { display: none; }

@media print {
  @page { size: A4 portrait; margin: 12mm 10mm; }
  body { background: #fff; }
  .app, .drawer, .drawer-mask, .toast-wrap, .tone-mask, .auth-gate, .plan-mask { display: none !important; }
  #printArea { display: block !important; }
  .print-doc { color: #000; font-size: 12px; }
  .print-head { text-align: center; margin-bottom: 10px; }
  .print-head h1 { margin: 0 0 4px; font-size: 19px; letter-spacing: 3px; }
  .print-head p { margin: 0; font-size: 11.5px; color: #444; }
  table.print-info, table.print-stages { width: 100%; border-collapse: collapse; }
  table.print-info { margin-bottom: 10px; }
  table.print-info th, table.print-info td { border: 1px solid #8c8c8c; padding: 5px 7px; font-size: 11px; text-align: left; }
  table.print-info th { background: #f2f2f2; font-weight: 600; white-space: nowrap; }
  table.print-stages th, table.print-stages td { border: 1px solid #8c8c8c; padding: 5px 7px; font-size: 11px; }
  table.print-stages thead th { background: #f2f2f2; font-weight: 600; }
  table.print-stages .c { text-align: center; white-space: nowrap; }
  table.print-stages .nm { font-weight: 600; }
  .print-note { margin-top: 8px; font-size: 11px; line-height: 1.7; }
  .print-sign { display: flex; justify-content: space-between; margin-top: 26px; font-size: 11.5px; }
  .print-foot { margin-top: 14px; text-align: center; font-size: 10px; color: #777; }
  tr { page-break-inside: avoid; }
}

@media (max-width: 900px) {
  .plan-card { flex-wrap: wrap; gap: 10px; }
  .plan-card-ops { width: 100%; justify-content: flex-end; }
  .plan-card-addr { max-width: 100%; }
  .plan-toolbar .filters { margin-left: 0; width: 100%; }
  .plan-toolbar #btnPlanNew { margin-left: auto; }
  .plan-sum { margin-left: 0; width: 100%; }
}

@media (max-width: 860px) {
  .plan-mask { padding: 0; }
  .plan-sheet { width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .plan-head { padding: 14px 16px 12px; }
  .plan-body { padding: 12px 16px 6px; }
  .plan-foot { padding: 10px 16px 14px; }
  .plan-stage-head { display: none; }
  .stage-row {
    grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr) 74px;
    grid-template-areas:
      "no name name ops"
      "no days start end"
      "no owner status status"
      "no note note note";
    padding: 10px;
  }
  .stage-no { grid-area: no; align-self: start; padding-top: 8px; }
  .st-name { grid-area: name; }
  .st-days { grid-area: days; }
  .st-start { grid-area: start; }
  .st-end { grid-area: end; text-align: right; }
  .st-owner { grid-area: owner; }
  .st-status { grid-area: status; }
  .st-note { grid-area: note; }
  .st-ops { grid-area: ops; }
  .plan-pick { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
}

/* 阶段完成 / 延期时整行给一点视觉反馈（输入框仍可编辑） */
.stage-row.is-done { background: #f6fbf8; border-color: #dcefe4; }
.stage-row.is-done .st-name { color: #2c7a55; }
.stage-row.is-late { background: #fdf6f5; border-color: #f6dcda; }
.stage-row.is-late .st-name { color: var(--red); }

@media (max-width: 860px) {
  .plan-save-tip { display: none; }
  .st-end::before { content: '→ '; color: var(--ink-3); }
}

/* 打印签字栏：三列等宽，横线跟着列宽走，避免超出纸张右边界 */
@media print {
  table.print-info th, table.print-info td { padding: 6px 8px; }
  table.print-stages th, table.print-stages td { padding: 7px 8px; }
  .print-sign { gap: 18px; }
  .print-sign .sign-item { display: flex; align-items: flex-end; gap: 4px; white-space: nowrap; flex: 1 1 0; }
  .print-sign .sign-item i { flex: 1 1 auto; min-width: 40px; border-bottom: 1px solid #333; height: 14px; }
}

/* ============ 施工甘特图 ============ */
.gantt-block {
  margin: 16px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.gantt-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #fafcfd;
  border-bottom: 1px solid var(--line-2);
}
.gantt-bar strong { font-size: 13px; }
.gantt-range { font-size: 12px; color: var(--ink-3); }
.gantt-bar .spacer { flex: 1 1 auto; }

.gantt-scroll { overflow: auto; max-height: 340px; padding-bottom: 4px; }
.gantt-inner { min-width: max-content; }

.gantt-head { border-bottom: 1px solid var(--line-2); }
.gantt-months, .gantt-days { display: flex; align-items: stretch; }
.gantt-months { border-bottom: 1px solid var(--line-2); }

.gantt-corner {
  position: sticky;
  left: 0;
  z-index: 3;
  width: var(--namew);
  flex: none;
  padding-left: 10px;
  font-size: 11.5px;
  color: var(--ink-3);
  background: #fff;
  line-height: 22px;
}

.gantt-months .gantt-corner { background: #fafcfd; }
.gantt-month {
  flex: none;
  text-align: center;
  font-size: 11px;
  color: var(--ink-2);
  padding: 4px 0;
  border-left: 1px solid var(--line-2);
  background: #fafcfd;
  overflow: hidden;
  white-space: nowrap;
}

.gantt-day {
  flex: none;
  text-align: center;
  font-size: 10px;
  color: var(--ink-3);
  padding: 3px 0;
  border-left: 1px solid #f4f7f9;
}
.gantt-day.is-sun { background: #fdf6f4; color: #c08070; }

.gantt-body { position: relative; }
.gantt-row {
  display: flex;
  align-items: center;
  border-top: 1px solid #f4f7f9;
}
.gantt-row:first-child { border-top: 0; }

.gantt-name {
  position: sticky;
  left: 0;
  z-index: 2;
  width: var(--namew);
  flex: none;
  height: 30px;
  line-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--ink);
  background: #fff;
  border-right: 1px solid var(--line-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gantt-row.is-done .gantt-name { color: var(--ink-3); }

.gantt-track {
  position: relative;
  flex: none;
  height: 30px;
  background-image: linear-gradient(90deg, #f4f7f9 1px, transparent 1px);
  background-size: var(--colw) 100%;
}

.gantt-fill {
  position: absolute;
  top: 6px;
  height: 18px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(23, 32, 42, .07);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.gantt-fill em {
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.g-status-todo { background: #b3bfcc; }
.g-status-todo em { color: #57626e; }
.g-status-doing { background: #2f6fed; }
.g-status-done { background: #1f9d63; }
.g-status-late { background: #d9433b; }

.gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px dashed #e2634a;
  opacity: .7;
  pointer-events: none;
  z-index: 1;
}

.gantt-empty {
  padding: 22px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
}

@media (max-width: 860px) {
  .gantt-bar { flex-wrap: wrap; gap: 6px; }
  .gantt-bar .spacer { display: none; }
  .gantt-bar #btnGanttXlsx { margin-left: auto; }
  .gantt-inner { --namew: 104px !important; }
}

/* 拖动字段行时不要选中文字 */
.fm-custom tbody tr[data-row^="c:"] td { -webkit-user-select: none; user-select: none; }

/* 新建卡片：类型是单选时（没有下拉选项那格）只占两列，避免右边空一大块 */
.nf-grid:has(#nfOptionsItem[hidden]) { grid-template-columns: minmax(0, 280px) 160px; }

/* ============ 手机上的字段表：改成卡片，名字不再被压成竖排 ============ */
@media (max-width: 640px) {
  #fieldBox .field-table-wrap {
    max-width: none;
    border: 0;
    background: transparent;
    overflow: visible;
    border-radius: 0;
  }
  .fm-custom { display: block; min-width: 0; }
  .fm-custom thead { display: none; }
  .fm-custom tbody { display: block; }
  .fm-custom tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 10px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }
  .fm-custom tbody td {
    display: block;
    width: auto;
    padding: 0;
    border: 0;
    text-align: left;
  }
  .fm-grip-cell { flex: none; }
  .fm-td-name { flex: 1 1 0; min-width: 0; }
  .fm-custom .fm-label { white-space: normal; }
  .fm-custom .fm-opts {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11.5px;
  }
  .fm-custom tbody td:nth-child(3) { order: 2; }
  .fm-custom tbody td:nth-child(4),
  .fm-custom tbody td:nth-child(5) { order: 3; }
  .fm-custom tbody td:nth-child(6) { order: 4; }
  .fm-custom tbody td:nth-child(7) { order: 5; margin-left: auto; }
  .fm-custom tbody td:nth-child(8) { order: 6; }
  .fm-custom .field-order { display: flex; gap: 4px; }
  .fm-custom .field-order .icon-mini { width: 30px; height: 30px; border-color: var(--line); }
  #fieldBox .fm-note { margin-top: 4px; }
}

/* ============ 全版面：收起导航、内容铺满（字号不变） ============ */
.wide-btn { flex: none; }
.wide-btn .ico-compress { display: none; }
.wide-btn.is-on {
  color: var(--brand-dark);
  border-color: #f0c8bd;
  background: var(--brand-soft);
  box-shadow: none;
}
.wide-btn.is-on .ico-expand { display: none; }
.wide-btn.is-on .ico-compress { display: inline-block; }

body.wide .app { grid-template-columns: minmax(0, 1fr); }
body.wide .sidebar { display: none; }
body.wide .menu-btn { display: none; }
body.wide .view { max-width: none; }
body.wide .topbar { padding: 14px 22px; }
body.wide .scroller { padding: 18px 22px 40px; }

/* 只放开宽度，字号与行距保持原样 */
body.wide .col-addr { max-width: 380px; }
body.wide .col-note { max-width: 320px; }
body.wide .table-wrap { max-height: max(320px, calc(100dvh - 296px)); }

body.wide #builtinBox .field-table-wrap { max-width: 1200px; }
body.wide #fieldBox .field-table-wrap { max-width: 1280px; }
body.wide .plan-sheet { width: min(1440px, 100%); }
body.wide .drawer { width: min(680px, 94vw); }

@media (max-width: 900px) {
  .wide-btn { display: none; }
}

/* ============ 实时存档状态 & 固定每页条数 ============ */
.pager .page-fixed { color: var(--ink-3); font-size: 12px; }

.auto-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auto-save::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c6cfd8;
  transition: background .2s;
}
.auto-save.is-wait { color: #96661c; }
.auto-save.is-wait::before { background: #d98b1f; }
.auto-save.is-saving { color: var(--ink-2); }
.auto-save.is-saving::before { background: var(--brand); animation: autoPulse 1s ease-in-out infinite; }
.auto-save.is-ok { color: #1f7a52; }
.auto-save.is-ok::before { background: #1f9d63; }
.auto-save.is-warn { color: #96661c; }
.auto-save.is-warn::before { background: #d98b1f; }
.auto-save.is-err { color: var(--red); cursor: pointer; }
.auto-save.is-err::before { background: var(--red); }
@keyframes autoPulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

@media (max-width: 640px) {
  .auto-save { font-size: 11.5px; max-width: 48vw; }
  .drawer-foot { padding: 12px 16px; }
}

/* ============ 死单整行置灰 ============ */
table.grid tbody tr.is-dead { background: #e0e4e8; }
table.grid tbody tr.is-dead:hover { background: #d8dde2; }

table.grid tbody tr.is-dead td,
table.grid tbody tr.is-dead td.col-date,
table.grid tbody tr.is-dead td.col-no,
table.grid tbody tr.is-dead td.num,
table.grid tbody tr.is-dead td.due-cell {
  color: #4a5259 !important;
}
table.grid tbody tr.is-dead td.cell-strong { color: #3b434a !important; font-weight: 600; }
table.grid tbody tr.is-dead td.col-date { font-weight: 500 !important; }

/* 单元格里的彩色标签、账号色字统一压成同一种黑灰，整行才「一整条」 */
table.grid tbody tr.is-dead td .tag {
  background: #cbd1d7 !important;
  color: #454d54 !important;
  box-shadow: none !important;
}
table.grid tbody tr.is-dead td span[style] { color: #4a5259 !important; }
table.grid tbody tr.is-dead td .cell-muted { color: #7c858d !important; }
table.grid tbody tr.is-dead td.col-note { color: #545c64 !important; }
table.grid tbody tr.is-dead .row-act button { color: #5a626a; }
table.grid tbody tr.is-dead .row-act button:hover { color: #2f363c; }
/* 冻结列（勾选/日期/ID/操作）自带白底，要一起改，否则整行灰里夹着几条白 */
table.grid tbody tr.is-dead .col-check,
table.grid tbody tr.is-dead .col-date,
table.grid tbody tr.is-dead .col-no,
table.grid tbody tr.is-dead .col-act { background: #e0e4e8; }
table.grid tbody tr.is-dead:hover .col-check,
table.grid tbody tr.is-dead:hover .col-date,
table.grid tbody tr.is-dead:hover .col-no,
table.grid tbody tr.is-dead:hover .col-act { background: #d8dde2; }
table.grid tbody tr.is-dead.is-picked td,
table.grid tbody tr.is-dead.is-picked .col-check,
table.grid tbody tr.is-dead.is-picked .col-date,
table.grid tbody tr.is-dead.is-picked .col-no,
table.grid tbody tr.is-dead.is-picked .col-act { background: #dde2e6; }
table.grid tbody tr.is-dead .col-check input { opacity: .55; }

/* ============ 顶部统计卡：可点击筛选 ============ */
.kpi.is-clickable { cursor: pointer; transition: border-color .14s, box-shadow .14s, transform .14s, background .14s; }
.kpi.is-clickable:hover { border-color: #d6dde4; box-shadow: var(--shadow-sm); }
.kpi.is-clickable:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.kpi.is-clickable:active { transform: translateY(1px); }

.kpi-go {
  position: absolute;
  right: 11px;
  top: 8px;
  font-size: 17px;
  line-height: 1;
  color: #c3ccd6;
  opacity: 0;
  transition: opacity .14s, transform .14s;
}
.kpi.is-clickable:hover .kpi-go { opacity: 1; transform: translateX(2px); }

.kpi.is-on {
  background: #fff9f7;
  border-color: #f0b9a8;
  box-shadow: inset 0 0 0 1px rgba(226, 99, 74, .22);
}
.kpi.is-on .kpi-go { opacity: 1; color: var(--brand); transform: none; }
.kpi.is-on .kpi-label { color: var(--brand-dark); }
.kpi-on {
  font-style: normal;
  font-size: 10.5px;
  line-height: 1.5;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--brand-soft);
  color: var(--brand-dark);
}
