:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface-alt: #fbfaf8;
  --border: #e8e4dd;
  --text: #2b2823;
  --text-soft: #726c60;
  --text-faint: #a39c8d;
  --accent: #d98a6b;
  --accent-soft: #f3e3da;
  --accent-strong: #c06b47;
  --good: #4f9d69;
  --good-bg: #e7f4ea;
  --mid: #d0a02f;
  --mid-bg: #faf1dc;
  --bad: #c65858;
  --bad-bg: #fbe9e8;
  --shadow: 0 8px 24px rgba(60, 50, 35, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #fffdfa, var(--bg));
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 340px;
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 10px;
}

.login-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--text);
}

.login-sub {
  color: var(--text-soft);
  font-size: 14px;
  margin: 0 0 24px;
}

#login-form { display: flex; flex-direction: column; gap: 12px; }

#login-key {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}

#login-key:focus { border-color: var(--accent); }

#login-form button {
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

#login-form button:hover { background: var(--accent-strong); }

.login-error {
  color: var(--bad);
  font-size: 13px;
  min-height: 18px;
  margin: 14px 0 0;
}

/* ---------- App shell ---------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-logo { width: 26px; height: 26px; object-fit: contain; }

.tabs { display: flex; gap: 6px; flex: 1; }

.tab-btn {
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.tab-btn:hover { background: var(--surface-alt); }

.tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent-soft);
}

.topbar-actions { display: flex; align-items: center; gap: 14px; }

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(79,157,105,.5);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79,157,105,.45); }
  70% { box-shadow: 0 0 0 7px rgba(79,157,105,0); }
  100% { box-shadow: 0 0 0 0 rgba(79,157,105,0); }
}

.ghost-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}

.ghost-btn:hover { border-color: var(--accent); color: var(--accent-strong); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  flex-wrap: wrap;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }

.filter-group label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  font-weight: 600;
}

.filter-group select,
.filter-group input {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  outline: none;
  min-width: 180px;
}

.filter-group select:focus,
.filter-group input:focus { border-color: var(--accent); }

.count-pill {
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-soft);
}

.count-pill span { color: var(--text); font-weight: 700; }

.content { padding: 0 28px 40px; flex: 1; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}

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

thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  position: sticky;
  top: 0;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }

tbody td { padding: 12px 18px; font-size: 14px; vertical-align: middle; }

.thumb-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.thumb-cell img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.thumb-name { font-weight: 600; color: var(--text); font-size: 13px; }

.id-cell { color: var(--text-soft); font-size: 13px; }
.id-cell .time { display: block; font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.badge.good { background: var(--good-bg); color: var(--good); }
.badge.mid { background: var(--mid-bg); color: var(--mid); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.pending { background: var(--surface-alt); color: var(--text-faint); }

.quality-text { color: var(--text-soft); font-size: 13px; }

.feedback-cell { font-size: 13px; color: var(--text-soft); }
.feedback-cell .fb-label { font-weight: 700; color: var(--text); text-transform: capitalize; }
.feedback-cell .fb-folder {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
}

.details-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.details-btn:hover { background: var(--accent-soft); border-color: var(--accent-soft); }

.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-faint);
}

.empty-icon { font-size: 36px; margin-bottom: 10px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 34, 25, 0.45);
  backdrop-filter: blur(2px);
}

.lightbox-panel {
  position: relative;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: min(1000px, 92vw);
  max-height: 88vh;
  overflow: hidden;
  z-index: 1;
}

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 20px;
  line-height: 1;
  color: var(--text-soft);
  cursor: pointer;
  z-index: 2;
}

.lightbox-close:hover { color: var(--bad); }

.lightbox-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-height: 88vh;
}

.lightbox-image-pane {
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-image-pane img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 10px;
  object-fit: contain;
}

.lightbox-info-pane {
  padding: 28px 26px;
  overflow-y: auto;
}

.lightbox-info-pane h2 { margin: 0 0 10px; font-size: 18px; }
.lightbox-info-pane h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }

.lightbox-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.lightbox-feedback {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  display: none;
}

.lightbox-feedback.visible { display: block; }

.lightbox-text {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  max-height: 320px;
  overflow-y: auto;
}

@media (max-width: 760px) {
  .lightbox-body { grid-template-columns: 1fr; overflow-y: auto; }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .tabs { order: 3; width: 100%; }
}
