:root {
  --pri: #2f7d4f; --pri-dark: #256240; --bg: #f4f6f5; --line: #dfe5e2;
  --danger: #c0392b; --warn: #b7791f; --text: #26322b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

header { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; position: sticky; top: 0; z-index: 10; }
.brand { font-size: 17px; font-weight: 700; color: var(--pri-dark); }
.brand .sub { font-size: 12px; color: #8a9a90; font-weight: 400; margin-left: 8px; }
nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
nav .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.nav-btn { border: none; background: none; padding: 7px 12px; border-radius: 7px; cursor: pointer; color: #55655c; font-size: 14px; }
.nav-btn.active { background: var(--pri); color: #fff; }
.nav-btn:hover:not(.active) { background: #edf2ef; }
.badge { background: var(--danger); color: #fff; border-radius: 9px; font-size: 11px; padding: 1px 6px; }

main { padding: 16px 28px; max-width: 1536px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
input[type=search], select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; background: #fff; outline: none; }
input[type=search]:focus, select:focus { border-color: var(--pri); }
input[type=search] { width: 320px; }
.muted { color: #8a9a90; font-size: 13px; }

button { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 7px; cursor: pointer; font-size: 14px; color: var(--text); }
button:hover { filter: brightness(0.97); }
.primary { background: var(--pri); color: #fff; border-color: var(--pri); }
.ghost { color: var(--pri-dark); }
.linkish { border: none; background: none; color: var(--pri); padding: 2px 6px; }
.linkish.danger { color: var(--danger); }

.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: calc(100vh - 230px); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #f0f5f2; position: sticky; top: 0; cursor: pointer; user-select: none; font-size: 13px; }
th:hover { background: #e3ede7; }
tbody tr:hover { background: #f7faf8; }
td .tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; }
.tag.yes { background: #e3f3e8; color: var(--pri-dark); }
.tag.no { background: #fdeceb; color: var(--danger); font-weight: 600; }
.tag.cs { background: #e8eefc; color: #2c5aa0; }

/* 列表行内切换按钮：固定宽度对齐，切换不跳动 */
.click-tag { display: inline-block; min-width: 58px; text-align: center; cursor: pointer; box-sizing: border-box; }

/* 列表行内数字输入（户籍/成员人数） */
.inline-num { width: 70px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; text-align: center; background: #fff; }
.inline-num:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 2px rgba(47, 125, 79, .12); }

/* 点击复制 */
.copyable { cursor: copy; }
.copyable:hover { color: var(--pri); text-decoration: underline dotted; }
.copyable.mono { font-family: Consolas, monospace; letter-spacing: .3px; }
.idlink { font-weight: 700; }

.pager { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card .num { font-size: 26px; font-weight: 700; color: var(--pri-dark); }
.card .lbl { font-size: 12px; color: #8a9a90; margin-top: 2px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.panel h3 { margin-bottom: 10px; font-size: 15px; }
.note { padding-left: 18px; line-height: 1.9; color: #55655c; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(20, 30, 25, .45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-mask[hidden] { display: none; }
.modal { background: #fff; border-radius: 12px; width: min(980px, 94vw); max-height: 92vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; }
.modal-head button { border: none; background: none; font-size: 16px; cursor: pointer; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; align-items: center; }
.fgroup { margin-bottom: 16px; }
.fgroup > h4 { font-size: 13px; color: var(--pri-dark); background: #eef5f0; padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px 14px; }

/* 耕地面积分组：总量居右醒目 + 4 列分项 */
.h4-land { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.land-total { display: flex; align-items: center; gap: 6px; background: var(--pri); color: #fff; font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 7px; box-shadow: 0 1px 4px rgba(47, 125, 79, .35); }
.land-total input { width: 96px; text-align: right; font-weight: 700; font-size: 16px; color: var(--pri-dark); border: none; border-radius: 4px; padding: 3px 8px; background: #fff; cursor: default; }
.auto-tag.light { background: rgba(255, 255, 255, .35); }

/* 表内从属结构：父项总量 + 子项分块（对应源表两级表头） */
.subblock { border: 1px solid var(--line); border-left: 3px solid var(--pri); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: #fbfdfb; }
.subhead { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--pri-dark); font-size: 13px; margin-bottom: 8px; }
.subhead input { width: 92px; text-align: right; font-weight: 700; font-size: 14px; color: var(--pri-dark); border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px; background: #f0f6f2; cursor: default; }
.subbody .subblock, .subblock .subblock { background: #fff; margin-bottom: 0; }
.fgrid-in { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; }
.subblock .fgrid-in { margin-top: 8px; }
.fgrid4 { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.fi input[readonly] { background: #f0f6f2; color: var(--pri-dark); font-weight: 600; }
.auto-tag { font-size: 10px; color: #fff; background: #9db8aa; border-radius: 4px; padding: 0 4px; margin-left: 2px; }
.hint { font-size: 12px; color: #8a9a90; margin-top: 8px; }

/* 两列行内布局（标签左、控件右） */
.fgrid2 { grid-template-columns: repeat(2, minmax(300px, 1fr)); }
.fi.row { display: flex; align-items: center; gap: 10px; }
.fi.row label { margin: 0; white-space: nowrap; flex-shrink: 0; font-size: 13px; }

/* 清查信息：3 列网格，空位占位 */
.fgrid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; margin-bottom: 10px; }

/* 顶部经营判定区 */
.judge-panel { border: 2px solid var(--pri); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; background: #f4faf6; }
.judge-panel > h4 { margin-bottom: 10px; }
.judge-panel .fi.row label { font-weight: 600; }

/* 二~七生产明细：可收起分组 */
details.prod > summary { cursor: pointer; list-style: none; position: relative; user-select: none; }
details.prod > summary::-webkit-details-marker { display: none; }
details.prod > summary::after { content: '▸ 展开'; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--pri-dark); }
details.prod[open] > summary::after { content: '▾ 收起'; }
details.prod > summary h4 { margin-bottom: 0; }
details.prod[open] > summary h4 { margin-bottom: 8px; }
details.prod > summary h4.h4-land { padding-right: 70px; }

/* 八/九/十 清查填报独立面板（弹窗内） */
.check-panel { margin-top: 22px; border: 2px solid var(--pri); border-radius: 10px; padding: 14px 16px; background: #f4faf6; }
.check-panel-title { font-weight: 700; color: var(--pri-dark); font-size: 15px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }

/* 单选钮组（替代是/否下拉） */
.seg { display: inline-flex; align-items: center; gap: 2px; background: #eef3f0; border: 1px solid var(--line); border-radius: 14px; padding: 2px; white-space: nowrap; }
.seg label { padding: 3px 12px; border-radius: 12px; cursor: pointer; font-size: 13px; color: #6b7a72; user-select: none; }
.seg label:has(input:checked) { background: var(--pri); color: #fff; font-weight: 600; }
.seg label input { display: none; }
.seg-clear { border: none; background: none; color: #b3c0b8; font-size: 11px; padding: 0 6px; cursor: pointer; }
.seg-clear:hover { color: var(--danger); }

/* 列表行内可点击切换标签 */
.click-tag { cursor: pointer; }
.click-tag:hover { outline: 2px solid var(--pri); outline-offset: 1px; }
.tag.auto { opacity: .82; }
.tag.manual { box-shadow: inset 0 0 0 1.5px var(--pri-dark); }
.cs-sel { padding: 3px 5px; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); }
.auto-note { font-size: 12px; color: #55655c; background: #eef5f0; border-radius: 6px; padding: 7px 10px; margin-bottom: 12px; line-height: 1.7; }

/* 清查填报页表格内的输入控件 */
#tbl-check .qc { padding: 4px 7px; border: 1px solid var(--line); border-radius: 5px; font-size: 13px; width: 90px; }
#tbl-check .qc:focus { outline: none; border-color: var(--pri); }
#tbl-check td { vertical-align: middle; }
#tbl-check select.qc { width: auto; min-width: 150px; }
.fi label { display: block; font-size: 12px; color: #6b7a72; margin-bottom: 3px; }
.fi label .req { color: var(--danger); }
.fi input, .fi select { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.fi input:focus, .fi select:focus { outline: none; border-color: var(--pri); }
.fi input.err { border-color: var(--danger); background: #fdf3f2; }

#toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #2c3a32; color: #fff; padding: 10px 20px; border-radius: 8px; z-index: 99; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
#toast.err { background: var(--danger); }
.lv-error { color: var(--danger); font-weight: 600; }
.lv-warn { color: var(--warn); }
