* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1a1a1a;
  background: #fafafa;
  overflow-x: hidden;
}
a { color: #1a1a1a; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid #e5e5e5;
  padding: 0 24px; height: 56px;
}
.brand { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 28px; height: 28px; object-fit: contain; }
.tabs { display: flex; gap: 4px; }
.tab {
  border: none; background: none; padding: 8px 16px; font-size: 14px;
  cursor: pointer; color: #666; border-bottom: 2px solid transparent;
}
.tab.active { color: #1a1a1a; font-weight: 600; border-bottom-color: #1a1a1a; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.panel { display: none; }
.panel.active { display: block; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 8px; }
.muted { color: #999; font-size: 13px; }

.btn {
  border: 1px solid #d9d9d9; background: #fff; color: #1a1a1a;
  padding: 7px 14px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.btn:hover { border-color: #1a1a1a; }
.btn.primary { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.btn.primary:hover { opacity: .85; }
.btn.danger { color: #c00000; border-color: #e0c0c0; }
.btn.sm { padding: 4px 10px; font-size: 12px; }

.input, select.input {
  border: 1px solid #d9d9d9; border-radius: 6px; padding: 7px 10px;
  font-size: 13px; width: 100%;
}
.input:focus { outline: none; border-color: #1a1a1a; }
#line-search { width: 240px; }

.table-wrap { background: #fff; border: 1px solid #e5e5e5; border-radius: 8px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
th { background: #f7f7f7; font-weight: 600; position: sticky; top: 0; }
tbody tr:hover { background: #fafafa; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge.on { background: #e8f5e9; color: #1e7b1e; }
.badge.off { background: #f0f0f0; color: #999; }
.badge.ok { background: #e8f5e9; color: #1e7b1e; }
.badge.fail { background: #fdecea; color: #c00000; }
.badge.run { background: #fff8e1; color: #b26a00; }

.task-card {
  background: #fff; border: 1px solid #e5e5e5; border-radius: 8px;
  padding: 14px 16px; margin-bottom: 12px;
}
.task-card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.task-card .name { font-size: 15px; font-weight: 600; }
.task-card .meta { color: #888; font-size: 12px; margin-bottom: 8px; }
.task-card .actions { display: flex; gap: 8px; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 10px; padding: 22px; width: 620px;
  max-height: 90vh; overflow: auto;
}
.modal.wide { width: 760px; }
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.form-grid label { font-size: 12px; color: #666; display: flex; flex-direction: column; gap: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.line-picker { border: 1px solid #e5e5e5; border-radius: 8px; margin-top: 12px; }
.picker-head {
  display: flex; justify-content: space-between; padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0; font-size: 13px; font-weight: 600;
}
.picker-search { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; }
.picker-list { max-height: 320px; overflow: auto; padding: 6px; }
.picker-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  font-size: 13px; border-radius: 6px; cursor: pointer;
}
.picker-item:hover { background: #f5f5f5; }
.picker-item .code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #555; }

/* ============ 检测报告：任务/日期分组折叠 ============ */
.run-group { background: #fff; border: 1px solid #e5e5e5; border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.g-head { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.g-head:hover { background: #fafafa; }
.g-head .g-arrow { font-size: 10px; color: #999; transition: transform .15s; width: 14px; text-align: center; flex: none; }
.g-head.closed .g-arrow { transform: rotate(-90deg); }
.g-head .title { font-weight: 600; font-size: 14px; }
.g-head .sub { color: #999; font-size: 12px; }
.task-head { padding: 12px 14px; }
.task-body { border-top: 1px solid #f0f0f0; }
.date-group + .date-group { border-top: 1px solid #f0f0f0; }
.date-head { padding: 8px 14px 8px 30px; background: #fcfcfc; }
.date-head .title { font-size: 13px; }
.g-body[hidden] { display: none; }
.date-body table { font-size: 12.5px; }
.date-body th { position: static; }
.date-body th, .date-body td { padding: 7px 10px; }

/* ============ 台账项目分组 ============ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-block; padding: 5px 14px; border-radius: 16px;
  border: 1px solid #d9d9d9; background: #fff; font-size: 13px;
  cursor: pointer; user-select: none;
}
.chip:hover { border-color: #1a1a1a; }
.chip.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.batch-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e5e5e5; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 12px;
}
.pm-new { display: flex; gap: 10px; margin-bottom: 14px; }
.pm-new .input { flex: 1; }
.pm-list { max-height: 320px; overflow: auto; border-top: 1px solid #f0f0f0; }
.pm-item { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid #f5f5f5; }
.pm-item .name { font-weight: 600; }

/* ============ 质量概况 ============ */
.q-filters label { display: flex; align-items: center; gap: 6px; }
.q-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e5e5e5; border-radius: 8px;
  padding: 10px 16px; margin-bottom: 12px; font-size: 14px;
}
.q-strip .sep { color: #ddd; }
.q-strip .ok-text b { color: #1e7b1e; }
.q-strip .bad-text b { color: #c00000; }
.q-card {
  background: #fff; border: 1px solid #e5e5e5; border-radius: 8px;
  padding: 14px 16px; margin-bottom: 12px;
}
.q-card .q-title { font-weight: 600; font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart-box { position: relative; height: 320px; }
#q-status-table th { position: static; }

/* ============ 报告内嵌查看器 ============ */
body.no-scroll { overflow: hidden; }
.report-viewer { position: fixed; inset: 0; background: #fff; z-index: 200; display: flex; flex-direction: column; }
.report-viewer[hidden] { display: none; }
.rv-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #e5e5e5; background: #fff; flex: none; }
.rv-title { flex: 1; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rv-frame { flex: 1; width: 100%; border: none; background: #fff; }

/* ============ 移动端适配 ============ */
.table-wrap, .date-body { -webkit-overflow-scrolling: touch; }

@media (max-width: 640px) {
  /* 顶栏：品牌+用户区一行，tab 独占第二行，高度自适应不再裁切 */
  .topbar {
    flex-wrap: wrap; height: auto; min-height: 56px;
    padding: 6px 10px 0; row-gap: 0;
  }
  .brand { font-size: 13px; white-space: nowrap; flex: 1 1 auto; min-width: 0; }
  .brand-logo { width: 20px; height: 20px; }
  .user-area { width: auto; margin-left: auto; padding: 0 0 5px; flex: none; }
  .user-area .muted { font-size: 12px; white-space: nowrap; }
  .tabs { order: 3; width: 100%; overflow-x: auto; border-top: 1px solid #f0f0f0; flex-wrap: nowrap; }
  .tab { padding: 9px 10px; font-size: 13px; flex: none; }

  .container { padding: 12px 10px 24px; }
  /* 工具栏统一允许换行，杜绝横向撑破 */
  .toolbar { gap: 8px; }
  .toolbar-left { flex-wrap: wrap; row-gap: 8px; }
  .toolbar-right { width: 100%; }
  .toolbar > .muted { width: 100%; }
  #line-search { width: 100%; }
  th, td { padding: 7px 8px; font-size: 12px; }
  .btn { padding: 8px 12px; }
  .btn.sm { padding: 6px 10px; }
  .modal, .modal.wide { width: calc(100vw - 16px); padding: 16px; max-height: 94vh; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .task-card { padding: 12px; }
  .task-card .actions { flex-wrap: wrap; }
  .g-head { flex-wrap: wrap; row-gap: 2px; }
  .g-head .sub { font-size: 11px; }
  .date-head { padding-left: 20px; }
  .date-body { overflow-x: auto; }
  .rv-bar { padding: 8px 10px; }
  .rv-title { font-size: 13px; }
  .chips { gap: 6px; }
  .chip { padding: 4px 10px; font-size: 12px; }
  .batch-bar { padding: 8px 10px; }
  .chart-box { height: 240px; }
  .q-card { padding: 12px; }
  .q-filters { width: 100%; }
  .q-filters label { flex-wrap: wrap; row-gap: 6px; }
  #q-start, #q-end { flex: 1 1 110px; width: auto !important; }
  #q-status-table { display: block; overflow-x: auto; white-space: nowrap; }
  .pm-new { flex-wrap: wrap; }
  /* 用户管理：创建账号表单自动换行、输入框弹性撑满 */
  #u-username, #u-password { width: auto !important; flex: 1 1 120px; }
  #panel-admin .toolbar .muted { line-height: 1.6; }
  #reports-meta { line-height: 1.6; }
}

/* 台账分页条 */
.pagination {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px; font-size: 13px;
}
.pagination .input { width: auto; padding: 5px 8px; }
.pagination button:disabled { opacity: .45; cursor: default; }

@media (max-width: 640px) {
  .pagination { flex-wrap: wrap; gap: 8px; }
}

/* ===== 登录 / 用户 / 分享 ===== */
.user-area { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.login-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 30, 55, .45);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.login-box {
  background: #fff; border-radius: 12px; padding: 28px 30px;
  width: 320px; box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.login-brand {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px;
  margin-bottom: 18px; color: #1a3a5c;
}
.login-brand img { width: 22px; height: 22px; }
.login-box label { display: block; margin-bottom: 12px; font-size: 13px; color: #555; }
.login-box .input { width: 100%; margin-top: 4px; }

.share-badge {
  margin-left: auto; font-size: 12px; color: #1a6fc4;
  border: 1px solid #1a6fc4; border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}

.perm-cols { display: flex; gap: 16px; }
.perm-cols > div { flex: 1; min-width: 0; }
.perm-col-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.perm-list {
  border: 1px solid #e3e8ef; border-radius: 8px; padding: 6px;
  max-height: 300px; overflow: auto;
}
.perm-item {
  display: flex; align-items: center; gap: 6px; padding: 5px 6px;
  font-size: 13px; border-radius: 6px; cursor: pointer;
}
.perm-item:hover { background: #f2f6fa; }

@media (max-width: 640px) {
  .perm-cols { flex-direction: column; }
  .login-box { width: calc(100vw - 24px); padding: 22px 20px; }
}
