:root {
  --primary: #1d5fd6;
  --primary-dark: #164ba8;
  --primary-light: #eaf1fd;
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #e3e8f0;
  --text: #1f2733;
  --muted: #6b7686;
  --danger: #d64545;
  --ok: #1a9c6b;
  --warn: #d97f1d;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 30, 54, .08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }

/* ---- 布局 ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: #10203c; color: #cdd8ea; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand h1 { font-size: 16px; color: #fff; font-weight: 600; line-height: 1.4; }
.brand p { font-size: 11px; color: #8fa3c4; margin-top: 3px; }
.nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; margin: 2px 0;
  border-radius: 8px; color: #cdd8ea; font-size: 14px; transition: background .15s;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; font-weight: 500; }
.nav .group { font-size: 11px; color: #7288a8; padding: 12px 12px 4px; }
.side-foot { flex-shrink: 0; padding: 12px 14px 14px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 10px; }
.side-foot a { color: #9db4d8; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 10px 22px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: 16px; font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.userbox b { color: var(--text); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.content { padding: 20px 22px 60px; max-width: 1280px; width: 100%; }

/* ---- 组件 ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid.cols4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid.cols4, .grid.cols3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid.cols4, .grid.cols3, .grid.cols2 { grid-template-columns: 1fr; } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat .lab { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.warn .num { color: var(--warn); }
.stat.ok .num { color: var(--ok); }
.stat.danger .num { color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 13px; transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f0c9c9; }
.btn.danger:hover { background: #fdf1f1; }
.btn.ok { color: var(--ok); border-color: #bfe4d5; }
.btn.ok:hover { background: #effaf5; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; background: #fff; outline: none; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.field textarea { resize: vertical; min-height: 64px; }
.formgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 900px) { .formgrid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .formgrid { grid-template-columns: 1fr; } }

.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 640px; }
.tbl th { background: #f7f9fc; color: var(--muted); font-weight: 500; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fafbfe; }
.tbl td input, .tbl td select, .tbl td textarea {
  border: 1px solid transparent; background: transparent; border-radius: 5px; padding: 4px 6px; width: 100%; min-width: 60px;
}
.tbl td input:focus, .tbl td select:focus, .tbl td textarea:focus { border-color: var(--primary); background: #fff; }
.tbl td.center { text-align: center; }
.tbl .sub { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; white-space: nowrap; }
.badge.gray { background: #eef1f5; color: #5a6675; }
.badge.blue { background: #e5eefb; color: #1d5fd6; }
.badge.green { background: #e2f6ee; color: #12815a; }
.badge.orange { background: #fdefdd; color: #b26112; }
.badge.red { background: #fdeaea; color: #c23c3c; }

.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: #223; color: #fff; padding: 9px 18px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: .96; }
.toast.err { background: #b23434; }
.toast.ok { background: #157a53; }

.modal-mask { position: fixed; inset: 0; background: rgba(15,23,40,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 640px; max-width: 100%; padding: 20px 22px; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal.wide { width: 900px; }
.modal h3 { margin-bottom: 14px; font-size: 16px; }
.modal .close-x { float: right; border: none; background: none; font-size: 18px; color: var(--muted); }

.hint { font-size: 12px; color: var(--muted); }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.tiny { font-size: 12px; }
.sep { height: 1px; background: var(--border); margin: 12px 0; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #10203c 0%, #1d3a6b 55%, #1d5fd6 130%); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 34px 34px 28px; width: 400px; max-width: 100%; box-shadow: 0 18px 50px rgba(0,0,0,.3); }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .btn { width: 100%; justify-content: center; padding: 10px; font-size: 15px; margin-top: 6px; }
.login-foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.7; }

/* 报修公开页 */
.rx-wrap { max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; }
.rx-head { text-align: center; padding: 26px 10px 18px; }
.rx-head h1 { font-size: 24px; color: #fff; }
.rx-head p { color: #c6d4ec; margin-top: 6px; font-size: 14px; }
.rx-hero { background: linear-gradient(160deg, #10203c, #1d5fd6); margin: -24px -16px 0; padding-bottom: 30px; }
.hotline { display: inline-flex; align-items: center; gap: 10px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); color: #fff; padding: 8px 18px; border-radius: 30px; margin-top: 14px; font-size: 16px; font-weight: 600; letter-spacing: 1px; }
.rx-success { text-align: center; padding: 40px 20px; }
.rx-success .big { font-size: 40px; }
.rx-success code { display: inline-block; background: var(--primary-light); color: var(--primary-dark); font-size: 24px; padding: 8px 22px; border-radius: 10px; margin: 14px 0; letter-spacing: 2px; }

.tag { display:inline-block; background:#f1f4f9; border:1px solid var(--border); color:var(--muted); border-radius:6px; padding:1px 8px; font-size:11px; margin-right:4px; }
.pill-tabs { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:12px; }
.pill-tabs button { border:1px solid var(--border); background:#fff; border-radius:20px; padding:5px 14px; font-size:13px; }
.pill-tabs button.on { background:var(--primary); border-color:var(--primary); color:#fff; }
code.inline { background:#f1f4f9; padding:1px 6px; border-radius:5px; font-size:12px; word-break: break-all; }

@media (max-width: 760px) {
  .hamb { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 16px; flex-shrink: 0; }
  /* 抽屉式侧边导航 */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 240px; height: 100dvh; z-index: 60;
    transform: translateX(-105%); transition: transform .22s ease; box-shadow: 4px 0 20px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(10,18,32,.5); z-index: 55; }
  .scrim.show { display: block; }
  .content { padding: 12px 10px 60px; }
  .card { padding: 12px 12px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .uinfo { display: none; }
  .userbox { gap: 6px; }
  /* 弹窗全屏化 */
  .modal-mask { padding: 0; align-items: stretch; }
  .modal, .modal.wide { width: 100%; max-width: 100%; border-radius: 0; min-height: 100dvh; padding: 14px 12px 40px; }
  .modal { overflow-y: auto; }
  /* 表单控件触控优化（并防止 iOS 聚焦缩放） */
  input, select, textarea, .field input, .field select, .field textarea, .rinput { font-size: 15px; }
  .field input, .field select, .field textarea { padding: 10px 12px; }
  .btn { padding: 9px 16px; }
  .btn.sm { padding: 7px 11px; }
  .pill-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .pill-tabs button { white-space: nowrap; flex-shrink: 0; }
  .tablewrap { max-height: none !important; }
  /* 填报表格 → 卡片式 */
  .tbl.mobile-cards { min-width: 0 !important; }
  .tbl.mobile-cards thead { display: none; }
  .tbl.mobile-cards tr { display: block; border-bottom: none; }
  .tbl.mobile-cards td { display: flex; align-items: flex-start; gap: 8px; border: none; padding: 5px 0; }
  .tbl.mobile-cards td::before { content: attr(data-label); flex: 0 0 88px; color: var(--muted); font-size: 12px; padding-top: 6px; }
  .tbl.mobile-cards td input, .tbl.mobile-cards td select, .tbl.mobile-cards td textarea { flex: 1; min-width: 0; border: 1px solid var(--border); background: #fff; font-size: 15px; }
  .tbl.mobile-cards .c-idx { display: none; }
  .tbl.mobile-cards .c-sys { display: block; padding: 8px 0 2px; }
  .tbl.mobile-cards .c-sys::before { display: none; }
  .tbl.mobile-cards .c-cat { display: none; }
  .tbl.mobile-cards .c-points { display: block; padding: 0 0 6px; }
  .tbl.mobile-cards .c-points::before { display: none; }
  .tbl.mobile-cards .c-points span { color: var(--muted); font-size: 11px; line-height: 1.5; }
  .hide-sm { display: none !important; }
  .grid.cols4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid.cols3 { grid-template-columns: 1fr; }
  .grid.cols2 { grid-template-columns: 1fr; }
  .stat .num { font-size: 22px; }
  /* 宽汇总表格：冻结首列 + 横向滑动 */
  .sticky-first th:first-child, .sticky-first td:first-child { position: sticky; left: 0; background: #fff; z-index: 2; box-shadow: 1px 0 0 var(--border); }
  .sticky-first th:first-child { background: #f7f9fc; z-index: 3; }
  .sticky-first td[data-note-cell] { min-width: 160px; }
  .formgrid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .rx-hero { margin: -24px -10px 0; }
}
@media (max-width: 600px) {
  .formgrid { grid-template-columns: 1fr; }
}
@media (min-width: 761px) { .hamb { display: none; } .scrim { display: none !important; } .sidebar { transform: none !important; position: sticky; } }
