:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #138a4d;
  --warn: #a16207;
  --red-bg: #fff1f2;
  --yellow-bg: #fffbeb;
  --green-bg: #effaf3;
  --shadow: 0 16px 42px rgba(17, 24, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.boot-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  color: var(--muted);
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background: #f6f3ed;
}

.login-panel {
  width: min(480px, 100%);
  border: 1px solid #e4ded2;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.94);
  padding: 46px 40px 38px;
  box-shadow: 0 24px 70px rgba(45, 38, 28, 0.1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-panel .brand {
  margin-bottom: 30px;
}

.login-panel .brand h1 {
  color: #1f2933;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-panel .brand p {
  margin-top: 10px;
  color: #8a8175;
  font-size: 16px;
  font-weight: 600;
}

.login-panel .field {
  gap: 10px;
  margin-bottom: 22px;
}

.login-panel .field label {
  color: #7c746a;
  font-size: 15px;
  font-weight: 650;
}

.login-panel .field input {
  min-height: 56px;
  border-color: #eee8de;
  border-radius: 14px;
  background: #f9f7f2;
  color: #1f2933;
  padding: 0 18px;
  font-size: 16px;
}

.login-panel .field input::placeholder {
  color: #b5aa9d;
}

.login-panel .field input:focus {
  border-color: #c5b89f;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(197, 184, 159, 0.18);
}

.login-panel .btn.primary {
  width: 100%;
  min-height: 56px;
  margin-top: 6px;
  border-radius: 14px;
  background: #1f2933;
  color: #fff;
  font-size: 16px;
  letter-spacing: 0.16em;
  box-shadow: none;
}

.login-panel .btn.primary:hover {
  background: #111827;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.field label {
  color: #374151;
  font-size: 14px;
  font-weight: 650;
}

.field input,
.field textarea,
.field select,
.search-input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.native-file-input {
  position: fixed;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  pointer-events: none;
}

.btn {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 13px;
  background: #f3f4f6;
  color: var(--text);
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.ghost {
  border-color: var(--line);
  background: #fff;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.ok {
  background: var(--ok);
  color: #fff;
}

.btn.warn {
  background: #f59e0b;
  color: #111827;
}

.btn.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  display: flex;
  width: min(1180px, 100%);
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
}

.topbar .brand {
  margin: 0;
}

.topbar h1 {
  font-size: 17px;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 9px 13px;
  color: #374151;
  white-space: nowrap;
}

.tab.active {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.stats {
  margin-bottom: 14px;
}

.stats-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  padding: 16px 18px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

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

.stats-panel strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.stats-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.stats-pills span {
  border-radius: 999px;
  background: #eef2ff;
  color: #1f2937;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 650;
}

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

.toolbar-actions,
.card-actions,
.modal-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.search-wrap {
  flex: 1;
  min-width: 220px;
}

.list {
  display: grid;
  gap: 10px;
}

.hazard-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.hazard-card.status-open,
.hazard-card.status-pending {
  background: var(--red-bg);
}

.hazard-card.status-rejected {
  background: var(--yellow-bg);
}

.hazard-card.status-fixed {
  background: var(--green-bg);
}

.thumb {
  position: relative;
  width: 112px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 6px;
  background: #eef2f7;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-count {
  position: absolute;
  right: 6px;
  bottom: 6px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  padding: 2px 7px;
  font-size: 12px;
}

.card-main h3 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.35;
  word-break: break-word;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.reject-text {
  margin-top: 8px;
  color: var(--warn);
  font-size: 13px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 750;
}

.chip-open,
.chip-pending {
  background: #ffe4e6;
  color: #9f1239;
}

.chip-rejected {
  background: #fef3c7;
  color: #92400e;
}

.chip-fixed {
  background: #dcfce7;
  color: #166534;
}

.empty {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fff;
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.modal-backdrop,
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.58);
}

.modal {
  width: min(760px, 100%);
  max-height: min(88vh, 860px);
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.modal.wide {
  width: min(980px, 100%);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  overflow: auto;
  padding: 16px;
}

.x-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  background: #f3f4f6;
  color: #111827;
  font-size: 20px;
  line-height: 1;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  margin: 10px 0 16px;
}

.image-tile {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.image-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.image-tile.removed img {
  filter: grayscale(1);
  opacity: 0.6;
}

.image-tile label {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px;
  color: #374151;
  font-size: 12px;
}

.section-title {
  margin: 18px 0 8px;
  font-size: 15px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.detail-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fafafa;
}

.detail-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 3px solid #d1d5db;
  padding: 2px 0 2px 10px;
}

.timeline-item strong {
  display: block;
}

.timeline-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f9fafb;
  color: #374151;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 130;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.lightbox {
  z-index: 140;
  background: rgba(0, 0, 0, 0.86);
}

.lightbox img {
  max-width: 96vw;
  max-height: 90vh;
  object-fit: contain;
  touch-action: pinch-zoom;
}

.lightbox .x-button {
  position: fixed;
  top: 14px;
  right: 14px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.file-list {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.required {
  color: var(--danger);
}

@media (max-width: 760px) {
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-area {
    width: 100%;
    justify-content: space-between;
  }

  .stats-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-pills {
    justify-content: flex-start;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .btn,
  .search-wrap {
    flex: 1;
  }

  .hazard-card {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .thumb {
    width: 88px;
  }

  .card-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 0;
  }

  .login-page {
    padding: 18px;
  }

  .login-panel {
    border-radius: 22px;
    padding: 36px 24px 30px;
  }

  .login-panel .brand h1 {
    font-size: 28px;
  }

  .modal {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
}
