/* 基础设计系统 —— 巡检系统通用样式 */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e7eaf0;
  --line-2: #d0d5dd;
  --brand: #0b5cd5;
  --brand-dark: #0a4aad;
  --brand-soft: #eaf1fe;
  --green: #067647;
  --green-soft: #ecfdf3;
  --red: #b42318;
  --red-soft: #fef3f2;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --purple: #6941c6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 18px 40px rgba(16, 24, 40, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: #f9fafb; border-color: #b8c0cc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--red); border-color: #f4c7c3; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: #eef1f6; color: var(--ink); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 16px; border-radius: 10px; }
.btn-block { width: 100%; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.label .req, .field > label.req::after { color: var(--red); }
.input, .select, .textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 76px; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 92, 213, 0.12); }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.select { appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.hint { font-size: 12px; color: var(--muted); }
.error-text { font-size: 12px; color: var(--red); }

/* 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 15px; }
.card-body { padding: 18px; }

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: #f2f4f7;
  color: var(--ink-2);
  white-space: nowrap;
}
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-amber { background: var(--amber-soft); color: var(--amber); }
.tag-blue { background: var(--brand-soft); color: var(--brand); }
.tag-gray { background: #f2f4f7; color: var(--muted); }
.tag-purple { background: #f4f3ff; color: var(--purple); }

/* 表格 */
.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-2);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-size: 12.5px;
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-2);
}
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { font-variant-numeric: tabular-nums; }
.table .strong { color: var(--ink); font-weight: 500; }

/* 弹窗 / 抽屉 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  backdrop-filter: blur(2px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: min(720px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: pop 0.18s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(0.99); opacity: 0; } }
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px 22px; overflow: auto; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 0 0 14px 14px;
}
.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; border-radius: 8px; color: var(--muted);
}
.icon-btn:hover { background: #f2f4f7; color: var(--ink); }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(760px, 100%);
  background: #fff;
  box-shadow: var(--shadow-lg);
  z-index: 61;
  display: flex;
  flex-direction: column;
  animation: slide 0.2s ease;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0.6; } }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.drawer-body { padding: 20px 22px; overflow: auto; flex: 1; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; background: var(--surface-2); }

/* 提示 */
.toast-wrap { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #101828;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: toastin 0.2s ease;
  max-width: 86vw;
}
.toast.err { background: #b42318; }
.toast.ok { background: #067647; }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } }

/* 空状态 / 加载 */
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; opacity: 0.5; }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner.dark { border-color: rgba(11,92,213,0.2); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* 分段控件 */
.seg { display: inline-flex; background: #eef1f6; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 7px;
  color: var(--muted); font-weight: 500; font-size: 13px;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* 通用布局工具 */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* 图片九宫格 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.gallery a, .gallery figure {
  position: relative; display: block; aspect-ratio: 1/1; border-radius: 8px; overflow: hidden;
  background: #eef1f6; border: 1px solid var(--line);
}
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: rgba(16,24,40,0.65); color: #fff; font-size: 14px; line-height: 1;
}

/* 灯箱 */
.lightbox { position: fixed; inset: 0; background: rgba(8,12,20,0.92); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; }
.lightbox img, .lightbox video { max-width: 92vw; max-height: 88vh; border-radius: 8px; }
.lightbox .close { position: absolute; top: 20px; right: 24px; color: #fff; font-size: 30px; background: none; border: 0; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; border: 0; font-size: 34px; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; }
.lightbox .lb-nav:hover { background: rgba(255,255,255,.28); }
.lightbox .lb-prev { left: 20px; }
.lightbox .lb-next { right: 20px; }
.lightbox .lb-count { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; background: rgba(0,0,0,.45); padding: 4px 10px; border-radius: 999px; }
@media (max-width: 640px) {
  .lightbox .lb-prev { left: 8px; }
  .lightbox .lb-next { right: 8px; }
}

@media (max-width: 720px) {
  .overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 94vh; }
  .drawer { width: 100%; }
}
