/* ============================================================
   网上报修系统 - 响应式样式（移动优先，无任何前端框架依赖）
   ============================================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #0891b2;
  --info-bg: #ecfeff;
  --gray-1: #f8fafc;
  --gray-2: #f1f5f9;
  --gray-3: #e2e8f0;
  --gray-5: #94a3b8;
  --gray-7: #334155;
  --gray-9: #0f172a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--gray-1);
  color: var(--gray-9);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 17px; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }
.brand-logo { width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.who { color: rgba(255,255,255,.9); }
.role-tag {
  font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: rgba(255,255,255,.25); color: #fff;
}
.role-tag.tag-wx { background: #fbbf24; color: #7c2d12; }
.btn-logout { color: #fff; background: rgba(255,255,255,.18); padding: 4px 12px; border-radius: 999px; font-size: 13px; }

/* ---------- 桌面导航（>760px 显示，手机隐藏） ---------- */
.desk-nav { display: none; background: #fff; border-bottom: 1px solid var(--gray-3); }
.desk-nav-inner { max-width: 960px; margin: 0 auto; padding: 0 16px; display: flex; gap: 4px; overflow-x: auto; }
.desk-nav a {
  padding: 12px 16px; color: var(--gray-7); font-size: 15px; white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.desk-nav a.on, .desk-nav a:hover { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.desk-nav .admin-link { margin-left: auto; color: var(--warning); font-weight: 600; }

/* ---------- 后台导航（手机与桌面均可见，胶囊式横向滑动） ---------- */
.admin-nav {
  background: #fff; border-bottom: 1px solid var(--gray-3);
  position: sticky; top: 0; z-index: 60;
}
.admin-nav-inner {
  max-width: 960px; margin: 0 auto; display: flex; gap: 8px;
  overflow-x: auto; padding: 10px 12px; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.admin-nav-inner::-webkit-scrollbar { display: none; }
.admin-nav a {
  flex: 0 0 auto; white-space: nowrap; padding: 8px 14px; border-radius: 999px;
  font-size: 14px; color: var(--gray-7); background: var(--gray-2);
}
.admin-nav a.on { background: var(--primary); color: #fff; font-weight: 600; }
.admin-nav a:active { opacity: .8; }

/* ---------- 用户编辑弹窗（不撑破表格，手机/桌面居中显示） ---------- */
.pop-edit { position: relative; display: inline-block; }
.pop-edit > summary { list-style: none; }
.pop-edit > summary::-webkit-details-marker { display: none; }
.pop-edit[open] > summary { opacity: .6; }
.pop-panel {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 14px 24px;
  overflow-y: auto;
}
.pop-card {
  background: #fff; border-radius: 14px; box-shadow: 0 12px 48px rgba(15, 23, 42, .35);
  width: 100%; max-width: 520px; padding: 18px 16px;
}
.pop-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-weight: 700; font-size: 15px; margin-bottom: 14px; color: var(--gray-9);
}
.pop-close {
  border: none; background: var(--gray-2); color: var(--gray-7);
  width: 30px; height: 30px; border-radius: 50%; font-size: 18px; line-height: 1;
  cursor: pointer; flex: 0 0 auto;
}
.pop-close:hover { background: var(--gray-3); }

/* ---------- 主容器 ---------- */
.container { max-width: 960px; width: 100%; margin: 0 auto; padding: 16px 14px 90px; flex: 1; }
.container.no-tab { padding-bottom: 30px; }

/* 提交成功提示卡 */
.card-ok { border: 1px solid #86efac; background: #f0fdf4; }

/* 最近报修列表 */
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--gray-2);
}
.mini-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.mini-list .mini-main { min-width: 0; }
.mini-list .mini-main b { display: block; font-size: 14px; word-break: break-all; }
.mini-list .mini-sub { display: block; font-size: 12px; color: var(--gray-5); margin-top: 2px; }

/* ---------- 卡片 ---------- */
.card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 16px; margin-bottom: 16px;
}
.card-title {
  font-size: 16px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}
.card-title::before {
  content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--primary); display: inline-block;
}

/* ---------- 表单 ---------- */
.form-item { margin-bottom: 15px; }
.form-item label { display: block; font-size: 14px; font-weight: 600; color: var(--gray-7); margin-bottom: 6px; }
.form-item label .req { color: var(--danger); margin-left: 2px; }
.form-item .tip { font-size: 12px; color: var(--gray-5); margin-top: 4px; }
input[type=text], input[type=password], input[type=tel], input[type=email], input[type=number],
select, textarea {
  width: 100%; font-size: 16px; /* 16px 防 iOS 聚焦自动放大 */
  padding: 11px 12px; border: 1px solid var(--gray-3); border-radius: 10px;
  background: #fff; color: var(--gray-9); outline: none; transition: border .15s, box-shadow .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { min-height: 110px; resize: vertical; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 140px; }
.form-item[readonly] input, input[readonly], input.readonly {
  background: var(--gray-2); color: var(--gray-7);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 22px; border: none; border-radius: 10px;
  font-size: 16px; font-weight: 600; cursor: pointer; text-align: center;
  background: var(--primary); color: #fff; transition: filter .15s;
  font-family: inherit; line-height: 1.4;
}
.btn:active { filter: brightness(.9); }
.btn-block { width: 100%; }
.btn-ghost { background: var(--gray-2); color: var(--gray-7); }
.btn-danger { background: var(--danger); }
.btn-success { background: var(--success); }
.btn-warning { background: var(--warning); }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: flex; flex-direction: column; gap: 2px;
}
.stat b { font-size: 24px; color: var(--primary); }
.stat span { font-size: 12px; color: var(--gray-5); }
@media (min-width: 760px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------- 筛选 Tabs ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
.tabs a {
  flex-shrink: 0; padding: 7px 15px; border-radius: 999px; font-size: 14px;
  background: #fff; color: var(--gray-7); border: 1px solid var(--gray-3);
}
.tabs a.on { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

/* ---------- 工单列表 ---------- */
.ticket-item {
  display: block; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px; color: var(--gray-9);
  transition: transform .1s;
}
.ticket-item:active { transform: scale(.99); }
.ticket-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.ticket-no { font-size: 13px; color: var(--gray-5); font-family: Consolas, monospace; }
.ticket-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.ticket-meta { font-size: 13px; color: var(--gray-5); display: flex; flex-wrap: wrap; gap: 4px 12px; }

/* ---------- 状态徽章 ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.st-wait   { background: var(--danger-bg);  color: var(--danger); }
.st-doing  { background: var(--info-bg);    color: var(--info); }
.st-done   { background: var(--success-bg); color: var(--success); }
.st-cancel { background: var(--gray-2);     color: var(--gray-5); }

/* ---------- 详情表格 ---------- */
.detail-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.detail-table th {
  text-align: left; width: 88px; color: var(--gray-5); font-weight: 500;
  padding: 9px 8px 9px 0; vertical-align: top; white-space: nowrap;
}
.detail-table td { padding: 9px 0; color: var(--gray-9); word-break: break-all; }

/* ---------- 时间线 ---------- */
.timeline { list-style: none; margin-top: 6px; }
.timeline li { position: relative; padding: 0 0 18px 22px; }
.timeline li::before {
  content: ""; position: absolute; left: 5px; top: 7px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::after {
  content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--gray-3);
}
.timeline li:last-child::after { display: none; }
.tl-time { font-size: 12px; color: var(--gray-5); }
.tl-text { font-size: 14px; margin-top: 2px; word-break: break-all; }
.tl-note {
  margin-top: 6px; padding: 8px 10px; border-radius: 8px; font-size: 13px;
  background: var(--gray-2); color: var(--gray-7); word-break: break-all;
}
.tl-accept { --dot: var(--info); }
.tl-accept::before { background: var(--info); box-shadow: 0 0 0 3px var(--info-bg); }
.tl-done::before { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.tl-fail::before { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.tl-cancel::before { background: var(--gray-5); box-shadow: 0 0 0 3px var(--gray-2); }
.tl-rate::before { background: #f59e0b; box-shadow: 0 0 0 3px var(--warning-bg); }

/* ---------- 操作按钮组 ---------- */
.op-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.op-grid .btn { min-height: 44px; }

/* ---------- 分页 ---------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; justify-content: center; margin: 18px 0 6px; font-size: 14px; }
.pager a, .pager .cur {
  padding: 6px 12px; border-radius: 8px; background: #fff; color: var(--gray-7); border: 1px solid var(--gray-3);
}
.pager .cur { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.pager .dots { border: none; background: none; }
.pager span:first-child { font-size: 12px; color: var(--gray-5); margin-right: 4px; }

/* ---------- 公告 ---------- */
.notice-box { background: var(--warning-bg); border: 1px solid #fde68a; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.notice-box h4 { font-size: 14px; color: var(--warning); margin-bottom: 6px; }
.notice-box p { font-size: 13px; color: #92400e; white-space: pre-wrap; }

/* ---------- 后台表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
.tbl th, .tbl td { padding: 10px 10px; border-bottom: 1px solid var(--gray-2); text-align: left; white-space: nowrap; }
.tbl th { background: var(--gray-2); color: var(--gray-7); font-weight: 600; position: sticky; top: 0; }
.tbl td.wrap, .tbl td div.wrap { white-space: normal; word-break: break-all; }
.tbl tr:hover td { background: var(--gray-1); }

/* 工单表格优化：勾选列、可换行内容列 */
.tbl .ck { width: 36px; text-align: center; padding-right: 0; }
.tbl .ck input[type="checkbox"] { width: 17px; height: 17px; vertical-align: middle; cursor: pointer; }
.tbl td.allow-wrap { white-space: normal; word-break: break-all; min-width: 110px; }
.tbl td .cell-sub { display: block; font-size: 12px; color: var(--gray-5); margin-top: 2px; }
.tbl.tickets td[data-label="时间"] { min-width: 112px; white-space: nowrap; }
.tbl.tickets th, .tbl.tickets td { padding-left: 8px; padding-right: 8px; }
.batch-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 0 0 12px; padding: 9px 12px; font-size: 14px;
  background: var(--gray-1); border: 1px solid var(--gray-2); border-radius: 10px;
}
.batch-bar label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.batch-bar input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; }
.batch-bar .sel-count { color: var(--gray-5); }
@media (max-width: 700px) {
  .hide-sm { display: none; }
  .batch-bar { gap: 10px; }
  /* 工单表格：窄屏转为卡片式，彻底告别横向滚动 */
  .tbl.tickets { display: block; background: transparent; }
  .tbl.tickets tr {
    display: block; position: relative; background: #fff;
    border: 1px solid var(--gray-2); border-radius: 12px;
    margin-bottom: 10px; padding: 8px 12px 10px;
  }
  .tbl.tickets tr:first-child { display: none; }
  .tbl.tickets td { display: block; border: 0; padding: 5px 0; white-space: normal; }
  .tbl.tickets td.ck { position: absolute; top: 12px; right: 12px; padding: 0; }
  .tbl.tickets td[data-label]::before {
    content: attr(data-label) "："; color: var(--gray-5); font-size: 12px; margin-right: 4px;
  }
  .tbl.tickets td .cell-sub { display: inline; margin: 0; }
  .tbl.tickets td.ops { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
  .tbl.tickets td.ops::before { content: none; }
  .tbl.tickets td.ops form { display: inline; }
  .tbl.tickets td.ops .btn { min-height: 34px; padding: 5px 12px; }
}

/* ---------- 搜索栏 ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input { flex: 1; }
.search-bar .btn { flex-shrink: 0; min-height: 44px; padding: 8px 18px; }

/* ---------- 登录页 ---------- */
.login-wrap { max-width: 420px; margin: 4vh auto 0; }
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo .brand-logo { width: 76px; height: 76px; border-radius: 16px; box-shadow: 0 6px 18px rgba(37, 99, 235, .18); }
.login-logo h1 { font-size: 20px; color: var(--gray-9); }
.login-logo p { font-size: 13px; color: var(--gray-5); }
.login-extra { display: flex; justify-content: space-between; font-size: 13px; margin-top: 14px; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--gray-5); padding: 44px 0; font-size: 14px; }
.empty svg { width: 46px; height: 46px; fill: var(--gray-3); margin-bottom: 8px; }

/* ---------- flash 提示 ---------- */
.flash {
  background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0;
  border-radius: 10px; padding: 11px 14px; margin-bottom: 14px; font-size: 14px;
}

/* ---------- 星级选择 ---------- */
.star-select { display: flex; gap: 4px; flex-direction: row-reverse; justify-content: flex-end; }
.star-select input { display: none; }
.star-select label {
  font-size: 30px; color: var(--gray-3); cursor: pointer; transition: color .1s; margin: 0;
}
.star-select label:hover, .star-select label:hover ~ label,
.star-select input:checked ~ label { color: #f59e0b; }

/* ---------- 页脚 ---------- */
.foot { text-align: center; color: var(--gray-5); font-size: 12px; padding: 10px 0 90px; }

/* ---------- 底部 Tabbar（手机端） ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--gray-3);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0 6px; color: var(--gray-5); font-size: 11px;
}
.tabbar a svg { width: 23px; height: 23px; fill: currentColor; }
.tabbar a.on { color: var(--primary); font-weight: 600; }
.tabbar a.tab-new svg { fill: #fff; }
.tabbar a.tab-new {
  color: var(--primary); font-weight: 600;
}
.tabbar a.tab-new .tab-fab {
  width: 44px; height: 44px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center; margin-top: -18px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .4);
}

/* ---------- 桌面适配 ---------- */
@media (min-width: 760px) {
  body { font-size: 15px; }
  .container { padding: 24px 20px 40px; }
  .tabbar { display: none; }
  .desk-nav { display: block; }
  .foot { padding-bottom: 20px; }
  .card { padding: 22px 24px; }
  .op-grid { grid-template-columns: repeat(4, 1fr); }
}
@media print {
  .topbar, .desk-nav, .tabbar, .foot, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #eee; }
}
