/* ─── Sale Tracker — Shared Styles ────────────────────────────
 * Mobile-first. Hindi typography-aware. Minimal.
 * The uploader must feel instant; the dashboard must feel serious.
 */

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Noto Sans Devanagari', 'Noto Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  color: #1a1a1a;
  background: #f7f7f9;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 1rem;
  background: #111;
  color: #fff;
  transition: opacity 0.15s ease;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.secondary { background: #e5e7eb; color: #111; }
.btn.primary { background: #6d28d9; }
.btn.danger { background: #dc2626; }

.input, .select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d4d4d8;
  border-radius: 10px;
  background: #fff;
}
.input:focus, .select:focus { outline: 2px solid #a78bfa; border-color: #a78bfa; }

.card {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid #ececef;
}

.row { display: flex; gap: 12px; align-items: center; }
.stack > * + * { margin-top: 12px; }
.muted { color: #6b7280; font-size: 0.9rem; }

/* ─── Login page ───────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
.login-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: #6b7280; margin-bottom: 20px; font-size: 0.95rem; }
.login-error {
  color: #b91c1c; background: #fef2f2;
  padding: 10px 12px; border-radius: 8px;
  font-size: 0.9rem; margin-top: 12px;
}

/* ─── Uploader ─────────────────────────────────────────────── */
.uploader-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.uploader-header {
  background: #111;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.uploader-header h1 { margin: 0; font-size: 1rem; font-weight: 600; }
.uploader-lang-toggle {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
}
.pending-pill {
  background: #f59e0b;
  color: #fff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  margin-left: 8px;
}
.pending-pill[hidden] { display: none; }

.uploader-main {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.uploader-main[hidden] { display: none; }

.today-total {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.today-total-label {
  color: #6b7280;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.today-total-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #111;
  line-height: 1.15;
}
.today-total-sub {
  color: #6b7280;
  font-size: 0.85rem;
}

.viewfinder-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.viewfinder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
  display: block;
}
.viewfinder-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 20px;
  background: linear-gradient(135deg, #6d28d9 0%, #4c1d95 100%);
  color: #fff;
}
.viewfinder-fallback[hidden] { display: none; }
.vf-fallback-title { font-weight: 700; font-size: 1.05rem; }
.vf-fallback-sub { color: rgba(255, 255, 255, 0.75); font-size: 0.85rem; }

.shutter-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.shutter-spacer { width: 48px; }
.shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 0 0 4px #111, 0 8px 20px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  justify-self: center;
  transition: transform 120ms ease;
}
.shutter:active { transform: scale(0.94); }
.shutter-inner {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #6d28d9;
  transition: background 120ms ease;
}
.shutter:active .shutter-inner { background: #4c1d95; }

.gallery-icon-btn {
  justify-self: end;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: none;
  background: #e5e7eb;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease;
}
.gallery-icon-btn:active { transform: scale(0.94); background: #d1d5db; }

.photo-preview {
  width: 100%;
  max-width: 200px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 14px;
  background: #e5e7eb center/cover no-repeat;
  position: relative;
}
.photo-preview.empty {
  border: 2px dashed #d4d4d8;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}

.face-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
}
.face-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  background: #ddd center/cover no-repeat;
  cursor: pointer;
  border: 3px solid transparent;
  font-size: 0.7rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}
.face-cell.selected {
  border-color: #fbbf24;
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.35), 0 6px 16px rgba(109, 40, 217, 0.25);
  transform: scale(1.04);
  transition: transform 120ms ease;
}
.face-cell.selected::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fbbf24;
  color: #1f2937;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.face-cell.no-photo { background: #7e22ce; }

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: #eee;
  border: 2px solid transparent;
  font-size: 0.9rem;
}
.chip.selected { background: #ede9fe; border-color: #6d28d9; color: #5b21b6; }

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── Date groups (uploader recent list + dashboard gallery) ─── */
.date-group { border-top: 1px solid #ececef; }
.date-group:first-child { border-top: none; }
.date-group > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 4px;
  font-weight: 600;
  font-size: 0.95rem;
  color: #374151;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.date-group > summary::-webkit-details-marker { display: none; }
.date-group > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  color: #9ca3af;
  font-size: 0.7rem;
  transition: transform 120ms ease;
}
.date-group[open] > summary::before { transform: rotate(90deg); }
.date-group > summary > span:first-child { flex: 1; }
.date-group-count {
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 700;
}
.date-group-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0 10px;
}
.recent-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #fff;
  border-radius: 10px;
}
.recent-thumb {
  width: 48px; height: 48px;
  border-radius: 8px;
  background: #ddd center/cover no-repeat;
  flex-shrink: 0;
}
.recent-text { flex: 1; min-width: 0; }
.recent-del {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.recent-del:hover { background: #fecaca; }
.recent-del:active { transform: scale(0.92); }

/* ─── Admin Dashboard ──────────────────────────────────────── */
.admin-wrap { padding: 20px; max-width: 1400px; margin: 0 auto; }
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.admin-title { font-size: 1.6rem; font-weight: 700; margin: 0; }
.admin-sub { color: #6b7280; font-size: 0.95rem; }

.range-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.range-bar button {
  border: 1px solid #d4d4d8;
  background: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
}
.range-bar button.active { background: #111; color: #fff; border-color: #111; }

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.sc-card {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.sc-label { color: #6b7280; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.sc-value { font-size: 1.8rem; font-weight: 700; margin-top: 6px; }

.grid-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 860px) { .grid-2col { grid-template-columns: 1fr; } }

.panel-title { margin: 0 0 12px 0; font-size: 1.05rem; font-weight: 700; }

/* 2x2 dashboard grid — all four panels identical fixed height */
.panel-equal { display: flex; flex-direction: column; height: 320px; }
.panel-equal .panel-body { flex: 1; min-height: 0; position: relative; }
.panel-equal .panel-body canvas { max-height: 100% !important; }

.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th, .leaderboard-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #f0f0f3;
  font-size: 0.92rem;
}
.leaderboard-table th { color: #6b7280; font-weight: 600; font-size: 0.78rem; }

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.photo-tile {
  aspect-ratio: 3/4;
  border-radius: 10px;
  background: #eee center/cover no-repeat;
  position: relative;
  overflow: hidden;
}
.photo-tile-meta {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  padding: 20px 8px 6px;
  font-size: 0.75rem;
}
.tile-del {
  position: absolute;
  top: 6px; right: 6px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(220, 38, 38, 0.85);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease;
}
.photo-tile:hover .tile-del { opacity: 1; }
.tile-del:active { transform: scale(0.92); }
@media (hover: none) { .tile-del { opacity: 1; } }

.heatmap { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; }
.heat-cell {
  min-height: 36px;
  background: #ede9fe;
  border-radius: 2px;
  font-size: 0.55rem;
  color: #6b7280;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.toast.ok { background: #16a34a; }
.toast.err { background: #dc2626; }
