/* 张村镇四农普核实系统 - light theme, no external deps */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #1f2329;
  --dim: #8a919f;
  --brand: #2f6bff;
  --brand-dark: #1f4fd8;
  --ok-bg: #e8f7ee; --ok-tx: #0a8a4a;
  --err-bg: #fdecec; --err-tx: #c0392b;
  --yes-bg: #fff4e8; --yes-tx: #b45309; --yes-line: #f6c893;
  --no-bg: #eef7f1;  --no-tx: #0a8a4a;  --no-line: #bfe3cd;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
a { color: var(--brand); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.warn { color: #b45309; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: #fff; border: 1px solid var(--brand);
  border-radius: 8px; padding: 9px 18px; font: inherit; font-size: 13px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: #f7f8fa; border-color: #d6dae1; }
.btn-danger { background: #fff; color: var(--err-tx); border-color: #f0cfcb; }
.btn-danger:hover { background: var(--err-bg); border-color: #e5b3ac; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
form.inline { display: inline; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 28px; height: 56px; position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 16px; font-weight: 700; white-space: nowrap; flex: none; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: var(--dim); text-decoration: none; padding: 6px 14px; border-radius: 8px; white-space: nowrap;
}
.topbar nav a:hover { color: var(--text); background: #f2f3f5; }
.topbar nav a.on { color: var(--brand); background: #eef3ff; font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.top-actions .who { color: var(--dim); font-size: 12px; }
.link { color: var(--dim); text-decoration: none; font-size: 12px; }
.link:hover { color: var(--brand); }

/* ---------- 布局 ---------- */
.wrap { max-width: 1080px; margin: 24px auto 40px; padding: 0 20px; }
.wrap-wide { max-width: 1400px; }
.panel-intro { margin-bottom: 18px; }
.panel-intro h1 { font-size: 20px; margin-bottom: 4px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; margin-bottom: 18px; }
.panel.empty { text-align: center; padding: 48px 24px; color: var(--dim); }
.panel.empty p:first-child { font-size: 15px; color: var(--text); margin-bottom: 6px; }
.panel h3 { font-size: 14px; margin-bottom: 8px; }
.tips ul { margin: 6px 0 0 18px; }
.tips li { margin: 4px 0; }
.hint {
  background: #f7f9ff; border: 1px solid #e2e9ff; color: #445; border-radius: 8px;
  padding: 8px 14px; font-size: 12px; margin-bottom: 12px;
}
.foot { text-align: center; color: var(--dim); font-size: 12px; padding: 6px 0 28px; }

/* ---------- flash ---------- */
.flash {
  max-width: 1400px; margin: 16px auto 0; padding: 10px 16px; border-radius: 8px;
  background: var(--ok-bg); color: var(--ok-tx); font-size: 13px;
}
.flash-err { background: var(--err-bg); color: var(--err-tx); }
.wrap > .flash, .wrap-wide > .flash { margin: 0 0 14px; }

/* ---------- 表格卡片列表 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.sheet-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 8px;
}
.sc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sc-top h3 { font-size: 15px; line-height: 1.4; }
.sc-meta { line-height: 1.5; }
.bar { height: 6px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #7aa2ff, var(--brand)); border-radius: 999px; }
.sc-progress { margin-top: -2px; }
.sc-actions { display: flex; gap: 8px; margin-top: 4px; }
.chip {
  display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; line-height: 1.7;
}
.chip-n { background: #f1f3f6; color: #5a6272; }
.chip-yes { background: var(--yes-bg); color: var(--yes-tx); }
.chip-no { background: var(--no-bg); color: var(--no-tx); }

/* ---------- 表格页 ---------- */
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.sheet-head h1 { font-size: 19px; margin-bottom: 3px; }
.sheet-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.table-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: auto; max-height: calc(100vh - 210px);
}

/* ---------- 表格工具栏：搜索 / 筛选 / 排序 ---------- */
.grid-tools {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.grid-tools input[type=search] {
  width: 260px; padding: 7px 10px; font: inherit; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
.grid-tools input[type=search]:focus,
.grid-tools select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.grid-tools select {
  padding: 7px 8px; font: inherit; font-size: 13px; max-width: 230px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
.grid-tools .flt-count {
  margin-left: auto; color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums;
}
.grid-tools .flt-count b { color: var(--text); }
table.grid thead th.sortable { cursor: pointer; user-select: none; }
table.grid thead th.sortable:hover { color: var(--brand); }
table.grid thead th.sort-asc::after { content: " ↑"; color: var(--brand); }
table.grid thead th.sort-desc::after { content: " ↓"; color: var(--brand); }

.grid-empty {
  padding: 46px 20px; text-align: center; color: var(--dim); font-size: 13px;
}
.grid-empty b { display: block; color: var(--text); font-size: 14px; margin-bottom: 6px; }
.grid-empty[hidden] { display: none; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.grid th, table.grid td {
  padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
table.grid thead th {
  position: sticky; top: 0; z-index: 3; background: #fafbfc;
  font-weight: 600; color: #4a5160; font-size: 12px;
  border-bottom: 1px solid var(--line);
  /* 列名过长时自动换行，避免整列被标题撑得过宽 */
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
  min-width: 84px;
  max-width: 190px;
}
table.grid thead th.col-no { min-width: 0; max-width: none; }
table.grid tbody tr:hover td { background: #fcfdff; }
table.grid td.cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #3d4352; }
.col-no { width: 48px; color: var(--dim); text-align: right !important; font-variant-numeric: tabular-nums; }
th.col-no, td.col-no { position: sticky; left: 0; background: #fff; z-index: 2; }
table.grid thead th.col-no { background: #fafbfc; z-index: 4; }

/* 反馈列：横向滚动时固定在右侧 */
.col-fb {
  position: sticky; right: 0; background: #fff; z-index: 2;
  min-width: 250px; max-width: 300px;
  border-left: 1px solid var(--line);
  box-shadow: -6px 0 12px -8px rgba(20,24,33,.18);
}
table.grid thead th.col-fb { background: #fafbfc; z-index: 4; min-width: 250px; max-width: 300px; }
table.grid tbody tr:hover td.col-fb { background: #fcfdff; }

/* ---------- 反馈控件 ---------- */
.fb-form { display: flex; flex-direction: column; gap: 6px; }
.opt-row { display: flex; gap: 6px; }
.opt {
  flex: 1; padding: 5px 8px; font: inherit; font-size: 12px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: #5a6272;
  border-radius: 7px; white-space: nowrap; transition: all .12s;
}
.opt:hover { border-color: #c9d3e6; color: var(--text); }
.opt.on.opt-yes { background: var(--yes-bg); border-color: var(--yes-line); color: var(--yes-tx); font-weight: 600; }
.opt.on.opt-no  { background: var(--no-bg);  border-color: var(--no-line);  color: var(--no-tx);  font-weight: 600; }
.note {
  width: 100%; padding: 5px 8px; font: inherit; font-size: 12px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--text);
}
.note:focus { outline: none; border-color: #a9c0f5; box-shadow: 0 0 0 3px rgba(47,107,255,.08); }
.note.miss { border-color: #e0a9a2; background: #fffafa; }
.note.miss:focus { border-color: #e0a9a2; box-shadow: 0 0 0 3px rgba(192,57,43,.09); }
.saved { font-size: 11px; color: var(--dim); min-height: 15px; }
.saved.ok { color: var(--ok-tx); }
.saved.err { color: var(--err-tx); }

/* 镇级汇总 */
.fb-sum { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.fb-detail summary { cursor: pointer; font-size: 12px; color: var(--dim); outline: none; }
.fb-detail summary:hover { color: var(--brand); }
.fb-detail ul { list-style: none; margin: 6px 0 0; display: flex; flex-direction: column; gap: 4px; }
.fb-detail li { font-size: 12px; line-height: 1.5; color: #4a5160; }
.t-yes { color: var(--yes-tx); font-weight: 600; }
.t-no { color: var(--no-tx); }
.fb-note { color: #5a6272; }
.fb-note::before { content: "— "; color: #c3c8d2; }

/* ---------- 表单 ---------- */
form label { display: block; font-size: 13px; color: #4a5160; margin-bottom: 12px; }
form label input[type=text], form label input[type=password], form label input[type=file] {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
form label input:focus { outline: none; border-color: #a9c0f5; box-shadow: 0 0 0 3px rgba(47,107,255,.08); }
.upload-form { max-width: 560px; }

/* ---------- 登录 ---------- */
.center-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 34px 38px; width: 380px; box-shadow: 0 6px 30px rgba(0,0,0,.05);
}
.auth-card h1 { font-size: 19px; margin-bottom: 6px; }
.auth-card .flash { max-width: none; margin: 12px 0; }
.auth-card p.small a { color: var(--brand); }
.auth-back { display: inline-block; margin: -4px 0 12px; font-size: 12px; color: var(--dim); text-decoration: none; }
.auth-back:hover { color: var(--brand); text-decoration: underline; }
.foot-link { margin-top: 18px; font-size: 12px; text-align: center; color: var(--dim); }

/* 自定义确认框 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,24,33,.38);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 12px; padding: 22px 24px; width: 360px;
  box-shadow: 0 12px 40px rgba(20,24,33,.18);
}
.modal p { font-size: 13px; line-height: 1.7; margin-bottom: 16px; }
.modal-btns { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- 注意事项（表格之外） ---------- */
.notice-card {
  background: #fffdf5; border: 1px solid #f0e3c4; border-radius: 12px;
  padding: 14px 18px 16px; margin-bottom: 12px;
}
.notice-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.notice-head h3 { font-size: 14px; color: #8a6a26; }
.notice-body { white-space: pre-wrap; font-size: 13px; line-height: 1.85; color: #4a4132; }
.notice-form textarea {
  display: block; width: 100%; min-height: 88px; padding: 9px 11px; font: inherit;
  font-size: 13px; line-height: 1.75; color: var(--text); background: #fff;
  border: 1px solid #e7dcc2; border-radius: 8px; resize: vertical;
}
.notice-form textarea:focus { outline: none; border-color: #d9c69a; box-shadow: 0 0 0 3px rgba(180,150,90,.12); }
.notice-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- 镇级可编辑单元格 ---------- */
table.grid td.cell-edit { cursor: text; }
table.grid td.cell-edit:hover { background: #f2f7ff; box-shadow: inset 0 0 0 1px #dbe6ff; }
table.grid td.cell-edit:focus { outline: none; background: #fff; box-shadow: inset 0 0 0 2px #a9c0f5; }
table.grid td.cell.edited { background: #fffaf0; box-shadow: inset 2px 0 0 #f0c674; color: #8a5b00; }
table.grid td.cell.edited:hover { background: #fff5e2; }
table.grid td.cell:empty::before { content: "—"; color: #c9ced8; }
table.grid td.cell.editing { overflow: visible; max-width: none; white-space: nowrap; padding: 5px 6px; }
table.grid td.cell.saving { opacity: .5; }
.cell-input {
  flex: 1; width: 100%; min-width: 120px; padding: 4px 7px; font: inherit; font-size: 13px;
  color: var(--text); background: #fff; border: 1px solid #a9c0f5; border-radius: 6px;
}
.cell-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(47,107,255,.10); }
.cell-edit-box { display: flex; align-items: center; gap: 5px; }
.cell-restore {
  flex: none; font-size: 11px; color: var(--brand); cursor: pointer;
  padding: 2px 6px; border: 1px solid #d8e4ff; border-radius: 6px; background: #f5f8ff;
}
.cell-restore:hover { background: #eaf1ff; }
.chip-upd { background: #fff4e8; color: var(--yes-tx); border: 1px solid var(--yes-line); margin-bottom: 2px; }

/* ---------- 完成期限 ---------- */
.dl-card {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: 10px; padding: 10px 16px; margin-bottom: 12px;
}
.dl-card.dl-blank { border-left-color: #dfe3ea; }
.dl-info { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dl-k { font-size: 12px; color: var(--dim); }
.dl-date { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dl-left { font-size: 13px; font-weight: 600; }
.dl-left.dl-ok { color: var(--ok-tx); }
.dl-left.dl-urgent { color: var(--err-tx); }
.dl-left.dl-over { color: #a5281b; }
.dl-none { font-size: 13px; color: var(--dim); }
.dl-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dl-form input[type=date] {
  padding: 6px 10px; font: inherit; font-size: 13px; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.dl-form input[type=date]:focus { outline: none; border-color: #a9c0f5; box-shadow: 0 0 0 3px rgba(47,107,255,.08); }
.sc-dl { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
.sc-dl .dl-date { font-size: 12px; }
.sc-dl .dl-left, .sc-dl .dl-none { font-size: 12px; }

/* ---------- 区划代码权限 ---------- */
.code-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; margin-bottom: 10px; font-size: 12px;
}
.code-bar-label { color: #4a5160; font-weight: 600; }
.code-bar select {
  padding: 5px 8px; font: inherit; font-size: 12px; color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; background: #fff; max-width: 280px;
}
.code-bar select:focus { outline: none; border-color: #a9c0f5; box-shadow: 0 0 0 3px rgba(47,107,255,.08); }
.chip-lock { background: #f1f3f6; color: #8a919f; }
.fb-lock { display: flex; flex-direction: column; gap: 4px; }
.fb-saved-ro { font-size: 12px; color: #5a6272; }
.code-table-wrap { max-height: none; }
.code-grid td { vertical-align: middle; }
.code-grid th, .code-grid td { white-space: nowrap; }
.code-txt { font-family: Consolas, "Courier New", monospace; font-size: 13px; color: var(--text); }
.code-form { display: flex; gap: 6px; align-items: center; }
.code-form input[type=text] {
  width: 152px; padding: 5px 8px; font: inherit; font-size: 12px;
  font-family: Consolas, "Courier New", monospace; color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
}
.code-form input[type=text]:focus { outline: none; border-color: #a9c0f5; box-shadow: 0 0 0 3px rgba(47,107,255,.08); }
.code-hint { margin-top: 4px; font-size: 11px; }

/* ---------- 只看相关（村级筛选） ---------- */
.flt-on { color: var(--brand); font-weight: 600; }
.flt-empty {
  padding: 26px 20px; text-align: center; border-bottom: 1px solid var(--line);
  background: #fafbff;
}
.flt-empty p { margin-bottom: 5px; }
.flt-empty p:first-child { font-size: 14px; }
.flt-empty .btn { margin-top: 10px; }
table.grid.is-filtered tbody tr.row-mine td.col-no { color: var(--brand); font-weight: 600; }

/* ---------- 修改密码 ---------- */
.pwd-form { max-width: 440px; }
.pwd-form label { margin-bottom: 12px; }
.pwd-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: #4a5160; margin-bottom: 16px;
  padding-bottom: 14px; border-bottom: 1px dashed var(--line);
}
.pwd-meta b { font-family: Consolas, "Courier New", monospace; color: var(--text); }
.auth-out { margin-top: 10px; padding-top: 12px; border-top: 1px dashed var(--line); }
.pwd-rule {
  background: #f7f9ff; border: 1px solid #e2e9ff; border-radius: 8px;
  padding: 10px 13px; margin: 2px 0 14px;
  font-size: 12px; line-height: 1.9; color: #445;
}
.pwd-rule b { color: var(--text); }
.pwd-rule code {
  font-family: Consolas, "Courier New", monospace; font-size: 12px;
  background: #fff; border: 1px solid #e2e9ff; border-radius: 4px;
  padding: 0 4px; color: #2f4a86;
}
.form-acts { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 平板：右侧核实列收窄，把宽度让给数据列 */
@media (max-width: 980px) {
  .col-fb { min-width: 206px; max-width: 216px; }
  table.grid thead th.col-fb { min-width: 206px; max-width: 216px; }
}

@media (max-width: 720px) {
  .topbar { padding: 0 14px; gap: 12px; height: auto; min-height: 56px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .top-actions .who { display: none; }
  .wrap { padding: 0 12px; }
  .cards { grid-template-columns: 1fr; }

  /* 手机：右侧核实列不再吸边，随表格一起左右滑动；宽度也压窄，左右各留一点余量 */
  .col-fb {
    position: static; min-width: 176px; max-width: 196px;
    box-shadow: none;
  }
  /* 表头必须单独覆盖：通用表头规则优先级更高，否则列名仍会粘在右边（只吸顶、不吸右） */
  table.grid thead th.col-fb {
    position: sticky; top: 0; right: auto; left: auto;
    min-width: 176px; max-width: 196px;
    box-shadow: none;
  }

  /* 手机：表格内边距与列宽收紧，一屏能多看一列 */
  table.grid th, table.grid td { padding: 8px 8px; }
  table.grid thead th { min-width: 64px; max-width: 150px; }
  table.grid thead th.col-no { min-width: 0; max-width: none; }
  td.cell, table.grid td.cell { max-width: 160px; }
  .col-no { width: 38px; }
  .opt { padding: 6px 4px; }

  /* 工具栏在窄屏占满一行，避免出现横向溢出 */
  .grid-tools input[type=search] { width: 100%; }
  .grid-tools select { flex: 1; max-width: none; }
  .grid-tools .flt-count { width: 100%; margin-left: 0; }
}
