/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #1a1a1a;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* === Layout === */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}
.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

/* === Header Row === */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* === Typography === */
h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.2rem; margin-bottom: 0.75rem; color: #333; }
h3 { font-size: 1.05rem; }
.muted { color: #888; }
.back-link { display: inline-block; margin-bottom: 1rem; color: #0066cc; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* === Flash Messages === */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 0.5rem 1rem;
  font-size: 0.9rem;
}
.flash.error { background: #fdd; color: #900; }
.flash.success { background: #dfd; color: #060; }

/* === Cards === */
.card-list { display: flex; flex-direction: column; gap: 0.75rem; }
.card {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-decoration: none;
  color: inherit;
  display: block;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.project-card h3 { margin-bottom: 0.25rem; }
.stats { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.25rem 0; }

/* === Defect Cards === */
.defect-card { border-left: 4px solid #ddd; }
.defect-card.status-open { border-left-color: #f0ad4e; }
.defect-card.status-resolved { border-left-color: #28a745; }
.defect-card.status-disputed { border-left-color: #dc3545; }
.defect-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.defect-desc { color: #555; font-size: 0.9rem; margin-bottom: 0.5rem; }
.photo-notice { color: #666; font-size: 0.85rem; margin-bottom: 0.5rem; }

/* === Photo required banner (worker view) === */
.photo-required-banner {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  color: #856404;
}

/* === Photo required icon (admin + worker list) === */
.photo-required-icon {
  font-size: 0.9em;
  margin-left: 0.3rem;
  cursor: default;
}

/* === Photo warning message (worker close form) === */
.photo-warning-msg {
  background: #f8d7da;
  border: 1px solid #f5c2c7;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  color: #842029;
  margin-top: 0.4rem;
}

/* === Drag handle === */
.drag-handle {
  cursor: grab;
  color: #bbb;
  font-size: 1.1rem;
  padding-right: 0.5rem;
  user-select: none;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }

/* === Images === */
.defect-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #ddd;
}

/* === Badges === */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e9ecef;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-green { background: #d4edda; color: #155724; }
.badge-red { background: #f8d7da; color: #721c24; }
.badge-yellow { background: #fff3cd; color: #856404; }

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: #0066cc; color: #fff; }
.btn-primary:hover { background: #0055aa; }
.btn-green { background: #28a745; color: #fff; }
.btn-green:hover { background: #218838; }
.btn-red { background: #dc3545; color: #fff; }
.btn-red:hover { background: #c82333; }
.btn-outline {
  background: transparent;
  border: 1.5px solid #888;
  color: #555;
}
.btn-outline:hover { background: #f0f0f0; }
.btn-danger { background: #dc3545; color: #fff; font-size: 0.8rem; }
.btn-danger:hover { background: #c82333; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; }

/* === Forms === */
.form-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.form-card label {
  display: block;
  font-weight: 600;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.9rem;
}
.form-card input[type="text"],
.form-card input[type="password"],
.form-card textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}
.form-card input[type="text"]:focus,
.form-card input[type="password"]:focus,
.form-card textarea:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0,102,204,0.15);
}
.form-card input[type="checkbox"] {
  margin-right: 0.4rem;
  transform: scale(1.2);
}
.form-card .btn { margin-top: 0.5rem; }

.inline-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.inline-form input[type="text"] {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
}
.inline { display: inline; }

/* === Token List === */
.token-list { display: flex; flex-direction: column; gap: 0.5rem; }
.token-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  padding: 0.75rem;
  border-radius: 8px;
  gap: 0.5rem;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.share-url {
  font-size: 0.75rem;
  color: #0066cc;
  word-break: break-all;
}

/* === Resolution Info === */
.resolution-info {
  background: #f8f9fa;
  padding: 0.75rem;
  border-radius: 8px;
  margin: 0.5rem 0;
}
.resolved-label { color: #155724; font-weight: 600; }
.disputed-label { color: #721c24; font-weight: 600; }
.dispute-reason { color: #555; font-size: 0.9rem; margin-top: 0.25rem; }

/* === Action Forms (Share View) === */
.action-forms {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.resolve-form, .dispute-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.file-label {
  display: block;
  padding: 0.75rem;
  background: #f0f0f0;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  font-size: 0.9rem;
  color: #555;
}
.file-label input[type="file"] { display: none; }
.file-label:has(input:valid)::after { content: ' ✓'; color: #28a745; }
.dispute-details {
  border: 1.5px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}
.dispute-details summary {
  border-radius: 8px;
  list-style: none;
}
.dispute-details summary::-webkit-details-marker { display: none; }
.dispute-details[open] summary { border-radius: 8px 8px 0 0; border-bottom: 1px solid #ddd; }
.dispute-form {
  padding: 0.75rem;
}
.dispute-form textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  resize: vertical;
}
.dispute-form textarea:focus {
  outline: none;
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220,53,69,0.15);
}

/* === Summary Bar === */
.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* === Defect Actions === */
.defect-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.footer-note {
  text-align: center;
  margin-top: 2rem;
  padding: 1rem;
  color: #888;
}

/* === Sections === */
.section { margin-bottom: 1.5rem; }

/* === Case List (Builder Share View) === */
.case-list-item {
  border-left: 4px solid #ddd;
  padding: 0.75rem;
  transition: transform 0.1s;
}
.case-list-item:active { transform: scale(0.98); }
.case-list-item.status-open { border-left-color: #f0ad4e; }
.case-list-item.status-resolved { border-left-color: #28a745; }
.case-list-item.status-disputed { border-left-color: #dc3545; }
.case-list-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.case-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid #eee;
}
.case-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  font-size: 1.5rem;
}
.case-list-info {
  flex: 1;
  min-width: 0;
}
.case-list-info h3 {
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.case-arrow {
  font-size: 1.5rem;
  color: #ccc;
  flex-shrink: 0;
}

/* === Detail View (Builder) === */
.detail-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.detail-img {
  width: 100%;
  max-width: 320px;
  border-radius: 8px;
  border: 1px solid #ddd;
}
.detail-actions {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}
.detail-actions h2 {
  margin-bottom: 0.75rem;
}
.close-case-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.file-label-detail {
  display: block;
  padding: 1rem;
  background: #f0f0f0;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  font-size: 1rem;
  color: #555;
  border: 2px dashed #ccc;
}
.file-label-detail input[type="file"] { display: none; }
.photo-preview {
  margin: 0.25rem 0;
}
.photo-preview img {
  max-width: 200px;
  border-radius: 8px;
}
.btn-lg {
  padding: 0.85rem 1.5rem;
  font-size: 1.1rem;
  min-height: 52px;
}
.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  color: #aaa;
  font-size: 0.85rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid #ddd;
}

/* === Image Management Grid (Admin Edit) === */
.image-manage-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}
.image-manage-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
}
.thumb-lg {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #ddd;
}
.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* === Admin Dropzone Upload === */
.dropzone {
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
  border: 2px dashed #9bb4cc;
  border-radius: 10px;
  background: #f8fbff;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.dropzone:hover,
.dropzone:focus {
  background: #eef6ff;
  border-color: #4f91d8;
  outline: none;
}
.dropzone.is-dragging {
  background: #e3f0ff;
  border-color: #2a7ad1;
}
.dropzone-title {
  font-weight: 700;
  color: #24588e;
  margin-bottom: 0.2rem;
}
.dropzone-subtitle {
  font-size: 0.85rem;
  color: #5d7489;
}
.dropzone-input {
  display: none;
}
.selected-files {
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
  word-break: break-word;
}

.upload-progress-wrap {
  display: none;
  margin-bottom: 0.75rem;
}
.upload-progress-wrap.visible {
  display: block;
}
.upload-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #4b647b;
  margin-bottom: 0.3rem;
}
.upload-progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e5edf6;
  overflow: hidden;
}
.upload-progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #2f80ed, #56ccf2);
  transition: width 0.1s linear;
}

/* === Mobile Tweaks === */
@media (max-width: 480px) {
  .container { padding: 0.75rem; }
  h1 { font-size: 1.3rem; }
  .thumb { width: 64px; height: 64px; }
  .btn { padding: 0.7rem 1rem; font-size: 1rem; }
  .btn-block { min-height: 48px; }
}
