:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #151b24;
  --muted: #687385;
  --line: #dde4ec;
  --blue: #1f6feb;
  --blue-dark: #1758c7;
  --green: #16805a;
  --amber: #9a6700;
  --amber-soft: #fff7e0;
  --shadow: 0 12px 34px rgba(20, 30, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 16px;
  cursor: pointer;
  background: #fff;
  color: var(--text);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

button.secondary:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.app-shell {
  width: min(1500px, calc(100vw - 40px));
  margin: 22px auto 40px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.toolbar h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
}

.toolbar p {
  margin: 0;
  color: var(--muted);
}

.panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel h2,
.table-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.config-panel {
  margin-bottom: 14px;
}

.config-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.5fr 0.9fr 0.7fr;
  gap: 12px;
}

label {
  display: block;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.config-grid label {
  margin-top: 14px;
}

.filter-panel {
  margin-bottom: 14px;
}

.table-filter-panel {
  margin-bottom: 14px;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(180px, 1fr) minmax(180px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.filter-actions {
  display: grid;
  grid-template-columns: 96px;
  gap: 10px;
}

.record-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 6px 0 0;
  padding: 0;
  border: 0;
  color: var(--muted);
}

.summary-line strong {
  margin-left: 12px;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
}

.summary-line strong:first-child {
  margin-left: 0;
}

.table-panel {
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.table-header span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 360px);
  min-height: 330px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 58px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
  white-space: nowrap;
}

.page-size-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-size-control span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.page-size-control select {
  width: 76px;
  min-height: 34px;
  padding: 6px 8px;
}

.pagination-bar button {
  min-width: 78px;
  min-height: 34px;
  padding: 0 12px;
}

.page-input {
  width: 58px;
  min-height: 34px;
  padding: 6px 8px;
  text-align: center;
}

.page-info {
  min-width: 118px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #3d4856;
  font-weight: 650;
}

.empty {
  height: 220px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #eef1f5;
  color: #4c5664;
  font-size: 12px;
  white-space: nowrap;
}

.badge.good {
  background: #e9f8f1;
  color: var(--green);
}

.badge.leave {
  background: #e0f2fe;
  color: #075985;
}

.badge.missing {
  background: #fee2e2;
  color: #b91c1c;
}

.badge.time {
  background: #fef3c7;
  color: #b45309;
}

.photo-preview-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  border: 0;
  border-radius: 6px;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
}

.photo-thumb {
  width: 56px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  object-fit: cover;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.photo-preview-btn:hover .photo-thumb,
.photo-preview-btn:focus-visible .photo-thumb {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
  transform: translateY(-1px);
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 16, 24, 0.82);
}

.photo-viewer.open {
  display: flex;
}

.photo-viewer-viewport {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.photo-viewer-viewport:active {
  cursor: grabbing;
}

.photo-viewer-image {
  max-width: min(92vw, 1400px);
  max-height: 88vh;
  user-select: none;
  transform-origin: center center;
  transition: transform 0.04s linear;
  will-change: transform;
}

.photo-viewer-close {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 51;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  padding: 0;
  background: rgba(10, 16, 24, 0.72);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.photo-viewer-close:hover,
.photo-viewer-close:focus-visible {
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.16);
}

#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 220px;
  max-width: 440px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 6px;
  padding: 12px 14px;
  background: #101820;
  color: #fff;
  box-shadow: var(--shadow);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1060px) {
  .config-grid,
  .filter-grid,
  .record-filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .filter-actions {
    grid-template-columns: 1fr 1fr;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 24px, 720px);
    margin-top: 14px;
  }

  .toolbar,
  .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .action-row {
    width: 100%;
  }

  .action-row button {
    flex: 1;
  }

  .config-grid,
  .filter-grid,
  .record-filter-grid {
    grid-template-columns: 1fr;
  }

  .summary-line {
    flex-wrap: wrap;
  }

  .pagination-bar {
    justify-content: flex-start;
    overflow-x: auto;
  }
}

/* 登录页表单字段 */
.login-field { display: block; margin-bottom: 12px; }
.login-field span { display: block; font-size: 13px; color: #475569; margin-bottom: 4px; }
.login-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-sizing: border-box;
  font-size: 14px;
}
.login-error { color: #dc2626; font-size: 13px; min-height: 18px; margin: 4px 0 8px; }

/* 顶栏用户区 */
.toolbar-user { display: flex; align-items: center; gap: 10px; }
.current-user { font-size: 14px; color: #334155; }

/* 账号管理 */
.account-table { width: 100%; border-collapse: collapse; }
.account-table th, .account-table td {
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
  font-size: 13px;
  text-align: left;
}
.account-table th { background: #f1f5f9; }
.account-actions { white-space: nowrap; }
.account-actions .mini {
  font-size: 12px;
  padding: 3px 8px;
  margin-right: 4px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}
.account-actions .mini:hover { background: #f1f5f9; }
.account-actions .mini.danger { color: #dc2626; border-color: #fecaca; }
.muted { color: #9ca3af; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #334155; }

/* 账号弹窗 */
.account-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
}
.account-modal.open { display: flex; }
.account-modal-card {
  background: #fff;
  padding: 24px 26px;
  border-radius: 12px;
  width: 460px;
  max-width: 92vw;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.account-modal-card h2 { margin: 0 0 16px; font-size: 18px; }
.account-field { display: block; margin-bottom: 12px; }
.account-field span { display: block; font-size: 13px; color: #475569; margin-bottom: 4px; }
.account-field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-sizing: border-box;
  font-size: 14px;
}
.account-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.account-modal-actions button { min-width: 90px; }

/* 齿轮图标按钮 + 悬浮提示 */
.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  position: relative;
  padding: 0;
}
.icon-btn:hover { background: #f1f5f9; color: #1d4ed8; }
.icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  white-space: nowrap;
  padding: 4px 8px;
  font-size: 12px;
  background: #1e293b;
  color: #fff;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 50;
}
.icon-btn[data-tooltip]:hover::after { opacity: 1; }

/* 账号管理弹窗 */
.account-manage-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
}
.account-manage-modal.open { display: flex; }
.account-manage-card {
  background: #fff;
  border-radius: 12px;
  width: 820px;
  max-width: 94vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.account-manage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.account-manage-header h2 { margin: 0; font-size: 18px; }
.account-manage-toolbar { padding: 12px 20px; border-bottom: 1px solid #f1f5f9; }
.account-manage-card .table-wrap { overflow: auto; padding: 0 20px 20px; }

/* 多选下拉（紧凑） */
.multi-select { position: relative; }
.multi-select-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}
.multi-select-trigger:hover { border-color: #94a3b8; }
.multi-select-display {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}
.multi-placeholder { color: #9ca3af; font-size: 13px; }
.multi-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
  line-height: 18px;
}
.multi-tag-remove {
  border: none;
  background: none;
  color: #6366f1;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}
.multi-tag-remove:hover { color: #312e81; }
.multi-select-arrow { color: #94a3b8; font-size: 12px; flex-shrink: 0; }
.multi-select-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: none;
  z-index: 30;
  overflow: hidden;
}
.multi-select-panel.open { display: block; }
.multi-select-searchbox { padding: 6px 8px; border-bottom: 1px solid #f1f5f9; }
.multi-select-searchbox input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.multi-select-searchbox input:focus { border-color: #94a3b8; }
.multi-select-options {
  padding: 4px;
  max-height: 168px;
  overflow-y: auto;
}
.multi-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.multi-option:hover { background: #f1f5f9; }
.multi-option.selected { background: #eef2ff; }
.multi-option input { width: 14px; height: 14px; margin: 0; accent-color: #2563eb; cursor: pointer; }
.multi-empty { padding: 12px; color: #9ca3af; font-size: 13px; text-align: center; }

/* 迷你复选框 */
.check-mini { gap: 5px; }
.check-mini input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #2563eb;
  cursor: pointer;
}

/* 预览窗口保存按钮 */
.photo-viewer-save {
  position: fixed;
  top: 18px;
  left: 20px;
  z-index: 51;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(10, 16, 24, 0.72);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.photo-viewer-save:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.72);
}
.photo-viewer-save:disabled { opacity: 0.4; cursor: not-allowed; }

/* ICP 备案底部 */
.icp-footer {
  padding: 14px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.icp-footer a {
  color: var(--blue);
  text-decoration: none;
}
.icp-footer a:hover {
  text-decoration: underline;
}
.icp-footer img { height: 20px; width: auto; vertical-align: middle; margin-right: 4px; }
