:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #262b36;
  --text: #e6e9ef;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --accent-hover: #3d78ea;
  --ok: #3ecf8e;
  --err: #ff6b6b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }

.nav { display: flex; gap: 6px; }

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.nav a:hover, .nav a.active { color: var(--text); background: #1f232c; }

.container { max-width: 640px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
label:first-of-type { margin-top: 0; }

input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  padding: 14px;
  background: #0f1115;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 20px;
  min-height: 52px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:active { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; }

.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-secondary:active { background: #1f232c; }

.btn-danger { background: rgba(255,107,107,0.15); color: var(--err); border: 1px solid rgba(255,107,107,0.35); }

.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { width: auto; flex: 1; }

.status {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  display: none;
}
.status.show { display: block; }
.status.ok { background: rgba(62,207,142,0.12); border: 1px solid rgba(62,207,142,0.35); color: var(--ok); }
.status.err { background: rgba(255,107,107,0.12); border: 1px solid rgba(255,107,107,0.35); color: var(--err); }

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.thumb-grid img, .thumb-grid .thumb-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

/* Gallery photo cards: thumbnail + OCR caption + copy button underneath.
   Separate from .thumb-grid/.thumb-item (used by the capture page's preview
   grid, which has no caption) so changes here can't affect that page. */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.photo-card {
  background: #0f1115;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.photo-card .photo-img-wrap { position: relative; }

.photo-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.photo-card .ocr-caption {
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 20px;
}

.photo-card .ocr-caption .ocr-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.photo-card .copy-text-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 26px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 12px;
}
.photo-card .copy-text-btn:active { background: #1f232c; color: var(--text); }
.photo-card .copy-text-btn.copied { color: var(--ok); border-color: var(--ok); }

.thumb-item { position: relative; }
.thumb-item .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 14px;
  cursor: pointer;
}

.date-group { margin-bottom: 22px; }
.date-group h3 { font-size: 14px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters input, .filters select { width: auto; flex: 1; min-width: 130px; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  flex-direction: column;
  padding: 16px;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 60vh; border-radius: 10px; }
.lightbox .meta { color: var(--text); font-size: 13px; margin-top: 14px; text-align: center; max-width: 480px; }
.lightbox .meta div { margin: 4px 0; color: var(--muted); }
.lightbox .close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.admin { background: rgba(79,140,255,0.15); color: var(--accent); }
.badge.staff { background: rgba(139,147,167,0.15); color: var(--muted); }

.empty-state { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 14px; }
