:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --border: #d9dee7;
  --blue: #1d4ed8;
  --blue-soft: #eaf1ff;
  --green: #16803c;
  --green-soft: #e8f7ed;
  --orange: #ea580c;
  --orange-soft: #fff3e8;
  --red: #dc2626;
  --red-soft: #feecec;
  --shadow: 0 18px 40px rgba(17, 24, 39, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: #e5e7eb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
}

.app-shell {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}

.screen {
  min-height: 100dvh;
  animation: pageIn 180ms ease-out;
}

.login-hero {
  min-height: 300px;
  padding: 48px 28px;
  color: #fff;
  background: var(--ink);
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--blue);
  font-size: 24px;
  font-weight: 800;
}

.brand-title {
  font-size: 22px;
  font-weight: 800;
}

.login-flow {
  margin-top: 22px;
  padding: 14px;
  display: grid;
  gap: 8px;
  border-radius: 4px;
  background: #242a33;
  color: #f9fafb;
  font: 12px/1.35 "SFMono-Regular", Consolas, monospace;
}

.login-card {
  padding: 34px 28px;
  background: var(--surface);
}

.topbar {
  height: 72px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.title {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.content {
  display: grid;
  gap: 12px;
  padding: 14px;
  padding-bottom: 82px;
}

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

.label {
  font-size: 13px;
  font-weight: 800;
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.textarea {
  min-height: 104px;
  padding-top: 12px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.btn {
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn[disabled] {
  opacity: 0.58;
  cursor: not-allowed;
}

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

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

.btn.warn {
  border-color: var(--orange);
  background: var(--orange);
  color: #fff;
}

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

.btn.full {
  width: 100%;
  min-height: 44px;
}

.icon {
  width: 18px;
  height: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat-card,
.card,
.panel,
.user-card,
.log-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.stat-card {
  padding: 10px;
  appearance: none;
  color: inherit;
  text-align: left;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

button.stat-card {
  cursor: pointer;
}

.stat-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(45, 99, 255, 0.12);
}

.stat-card:active {
  transform: scale(0.98);
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
}

.stat-value {
  margin-top: 4px;
  font: 700 22px/1 "SFMono-Regular", Consolas, monospace;
}

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

.search-box {
  position: relative;
}

.search-box input {
  padding-left: 36px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

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

.card {
  padding: 12px;
  display: grid;
  gap: 9px;
  animation: cardIn 220ms ease both;
}

.hazard-body {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.hazard-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #e5e7eb;
}

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

.hazard-thumb.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.hazard-thumb-count {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 20px;
  min-height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.hazard-meta {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.card-title {
  flex: 1;
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.meta,
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.reject-text {
  color: var(--red);
}

.chip {
  white-space: nowrap;
  min-height: 24px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.chip.open {
  color: var(--orange);
  background: var(--orange-soft);
}

.chip.pending {
  color: var(--blue);
  background: var(--blue-soft);
}

.chip.fixed {
  color: var(--green);
  background: var(--green-soft);
}

.chip.rejected {
  color: var(--red);
  background: var(--red-soft);
}

.actions,
.row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.row > .btn {
  flex: 1 1 0;
}

.pager {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  width: min(100%, 430px);
  height: 62px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.bottom-tabs.worker {
  grid-template-columns: 1fr;
}

.tab {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.tab.active {
  color: var(--blue);
}

.modal-backdrop,
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(17, 24, 39, 0.8);
  animation: fadeIn 160ms ease;
}

.sheet {
  width: min(100%, 430px);
  max-height: 92dvh;
  overflow: auto;
  padding: 18px;
  border-radius: 14px 14px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: sheetIn 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet.full {
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.sheet-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.share-button {
  min-height: 34px;
  padding: 7px 10px;
  color: #fff;
  background: #16803c;
  border-color: #16803c;
}

.sheet-title {
  margin: 0;
  min-width: 0;
  font-size: 22px;
}

.x-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
}

.upload-box {
  display: grid;
  gap: 9px;
  margin: 12px 0;
}

.upload-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.upload-preview {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  padding: 0;
  border-radius: 4px;
  background: #e5e7eb;
  border: 1px solid var(--border);
}

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

.upload-preview-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 6px 6px;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0), rgba(17, 24, 39, 0.78));
  color: #fff;
  font-size: 10px;
  line-height: 1.2;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.upload-preview-remove {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}

.native-file-input {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-list,
.info-grid,
.empty {
  padding: 10px;
  border-radius: 4px;
  background: #f3f4f6;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.image-tile {
  min-height: 74px;
  overflow: hidden;
  border-radius: 4px;
  background: #e5e7eb;
  border: 0;
  padding: 0;
}

.image-tile img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  display: block;
}

.image-tile.removed {
  outline: 2px solid var(--red-soft);
}

.section {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.section-title {
  font-size: 14px;
  font-weight: 900;
}

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

.timeline-item,
.user-card,
.log-card {
  padding: 12px;
}

.user-card.top-admin {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(45, 99, 255, 0.08);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 82px;
  z-index: 50;
  width: min(calc(100% - 28px), 402px);
  transform: translateX(-50%);
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toastIn 180ms ease;
}

.skeleton {
  min-height: 96px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eef1f5, #f8fafc, #eef1f5);
  background-size: 220% 100%;
  animation: skeleton 1s ease-in-out infinite;
}

.lightbox {
  align-items: center;
  padding: 18px;
}

.lightbox img {
  max-width: 100%;
  max-height: 82dvh;
  border-radius: 6px;
  background: #fff;
}

.lightbox .x-button {
  position: absolute;
  right: 18px;
  top: 18px;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheetIn {
  from { transform: translateY(28px); }
  to { transform: translateY(0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes skeleton {
  to { background-position-x: -220%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
