*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #faf9f7;
  --text: #1a1a1a;
  --muted: #777;
  --border: #e0ddd8;
  --accent: #2a2a2a;
  --accent-light: #f0eeeb;
  --white: #fff;
  --radius: 4px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Admin layout */
.admin-wrap { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.admin-header h1 { font-size: 1.25rem; font-weight: 600; }
.admin-header a { color: var(--muted); text-decoration: none; font-size: 0.875rem; }
.admin-header .header-actions { display: flex; align-items: center; gap: 0.75rem; }

.btn-back {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.4rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--white); color: var(--text); font-size: 0.8125rem; font-weight: 500;
  text-decoration: none; transition: border-color 0.15s, background 0.15s;
}
.btn-back:hover { border-color: var(--accent); background: var(--accent-light); }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.9375rem; background: var(--white);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-block; padding: 0.5rem 1.25rem; border: none; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500; cursor: pointer; text-decoration: none; text-align: center;
}
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { background: var(--accent-light); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: #c0392b; color: var(--white); }
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8125rem; }

/* Gallery list */
.gallery-list { list-style: none; }
.gallery-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.5rem;
  background: var(--white); position: relative;
}
.gallery-item:hover { border-color: var(--accent); }
.gallery-item .meta { font-size: 0.8125rem; color: var(--muted); }
.gallery-item-link {
  display: flex; justify-content: space-between; align-items: center;
  flex: 1; min-width: 0; text-decoration: none; color: var(--text);
}
.gallery-delete-form { margin-left: 0.75rem; flex-shrink: 0; }
.gallery-delete-btn {
  padding: 0.15rem 0.5rem; font-size: 0.8125rem; line-height: 1; border-radius: var(--radius);
  opacity: 0.35; background: transparent; color: var(--muted); border: 1px solid transparent;
}
.gallery-delete-btn:hover {
  opacity: 1; background: #c0392b; color: var(--white); border-color: #c0392b;
}
.badge { display: inline-block; padding: 0.125rem 0.5rem; border-radius: 2px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.badge-proofing { background: #eee8d5; color: #6a5d3f; }
.badge-delivery { background: #d5e8ee; color: #3f5d6a; }
.badge-draft { background: #eee; color: #888; }
.badge-active { background: #d5eed8; color: #3f6a45; }
.badge-submitted { background: #ffecd2; color: #8a6d3b; }
.badge-archived { background: #e0e0e0; color: #666; }

/* Upload dropzone */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 3rem; text-align: center;
  cursor: pointer; transition: border-color 0.2s; margin-bottom: 1.5rem; color: var(--muted);
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-light); }

.upload-progress {
  display: none; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--white); margin-bottom: 1.5rem; overflow: hidden;
}
.upload-progress.active { display: block; }
.upload-progress .upload-summary {
  font-size: 0.8125rem; font-weight: 600; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--accent-light);
}
.upload-progress .upload-list { max-height: 220px; overflow-y: auto; }
.upload-file-row {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: 0.5rem 1rem; font-size: 0.8125rem; border-bottom: 1px solid var(--border);
}
.upload-file-row:last-child { border-bottom: none; }
.upload-file-row .upload-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-file-row .upload-file-status { color: var(--muted); flex-shrink: 0; }
.upload-file-row.status-processing .upload-file-status { color: #8a6d3b; }
.upload-file-row.status-done .upload-file-status { color: #3f6a45; }
.upload-file-row.status-skipped .upload-file-status { color: var(--muted); }
.upload-file-row.status-error .upload-file-status { color: #c0392b; }

/* Image grid (admin) */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.image-grid .img-card { position: relative; border-radius: var(--radius); overflow: hidden; background: #eee; }
.image-grid .img-card img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.image-grid .img-card .img-actions { position: absolute; top: 0.25rem; right: 0.25rem; }
.img-filename { font-size: 0.6875rem; color: var(--muted); padding: 0.25rem 0.375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Client gallery */
.client-wrap { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.client-header { text-align: center; margin-bottom: 2.5rem; }
.client-header h1 { font-size: 1.125rem; font-weight: 400; letter-spacing: 0.05em; text-transform: uppercase; }
.client-header .subtitle { font-size: 0.8125rem; color: var(--muted); margin-top: 0.25rem; }

.client-grid { columns: 3; column-gap: 0.75rem; }
@media (max-width: 900px) { .client-grid { columns: 2; } }
@media (max-width: 500px) { .client-grid { columns: 1; } }

.client-card {
  position: relative; cursor: pointer; border-radius: 2px; overflow: hidden;
  break-inside: avoid; margin-bottom: 0.75rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.client-card:hover {
  transform: scale(1.015);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.client-card img,
.client-card .card-bg {
  width: 100%; display: block;
  -webkit-user-select: none; user-select: none; pointer-events: none;
}
.client-card.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.client-card .select-badge {
  position: absolute; top: 0.5rem; left: 0.5rem; width: 1.5rem; height: 1.5rem;
  background: var(--accent); color: var(--white); border-radius: 50%; display: none;
  align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600;
}
.client-card.selected .select-badge { display: flex; }

/* Selection bar */
.selection-bar {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--white);
  border-top: 1px solid var(--border); padding: 0.75rem 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.875rem; z-index: 100;
}
.selection-bar .info { color: var(--muted); }
.selection-bar-actions { display: flex; align-items: flex-end; gap: 0.75rem; }
.selection-bar .note-input {
  font-family: inherit; font-size: 0.8125rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.4rem 0.6rem; width: 16rem; max-width: 40vw; height: 2rem; min-height: 2rem;
  max-height: 6rem; resize: none; overflow-y: auto; line-height: 1.2;
  transition: border-color 0.15s, background 0.15s;
}
.selection-bar .note-input::placeholder { color: var(--muted); }
.selection-bar .note-input:focus {
  outline: none; border-color: var(--accent); background: var(--white);
}

@media (max-width: 640px) {
  .selection-bar {
    flex-direction: column; align-items: stretch; gap: 0.5rem;
  }
  .selection-bar .info { text-align: center; }
  .selection-bar-actions { flex-direction: column; align-items: stretch; }
  .selection-bar .note-input { width: 100%; max-width: none; }
}

/* Access code page */
.access-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.access-box {
  text-align: center; max-width: 320px;
}
.access-box input {
  text-align: center; font-size: 1.5rem; letter-spacing: 0.3em; padding: 0.75rem;
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius); margin: 1rem 0;
}

/* Login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-box { width: 100%; max-width: 360px; padding: 2rem; }
.login-box h1 { font-size: 1.125rem; margin-bottom: 1.5rem; }
.error { color: #c0392b; font-size: 0.875rem; margin-bottom: 1rem; }

/* Detail page */
.detail-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem; }
.detail-header h2 { font-size: 1.125rem; }
.detail-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.share-url { font-size: 0.8125rem; color: var(--muted); word-break: break-all; margin-bottom: 1rem; }
.share-url a { color: var(--accent); }
.submission-info { background: var(--accent-light); padding: 1.25rem; border-radius: var(--radius); margin-bottom: 1.5rem; }
.submission-info h3 { font-size: 0.9375rem; margin-bottom: 0.5rem; }
.submission-info p { font-size: 0.875rem; color: var(--muted); }
.filename-list { font-family: monospace; font-size: 0.8125rem; line-height: 1.8; }

/* Download button for delivery */
.download-btn {
  position: absolute; bottom: 0.5rem; right: 0.5rem; background: rgba(0,0,0,0.6);
  color: white; border: none; border-radius: 2px; padding: 0.25rem 0.5rem; font-size: 0.75rem;
  cursor: pointer; opacity: 0; transition: opacity 0.2s;
}
.client-card:hover .download-btn { opacity: 1; }

/* Thank you state */
.thank-you { text-align: center; padding: 4rem 2rem; }
.thank-you h2 { font-size: 1.25rem; font-weight: 400; margin-bottom: 0.5rem; }
.thank-you p { color: var(--muted); }

/* Conditional proofing fields */
.proofing-fields, .delivery-fields { display: none; }
