:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1f2333;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --error: #dc2626;
  --error-bg: #fee2e2;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}

.topbar nav a {
  margin-left: 18px;
  color: var(--muted);
  font-weight: 500;
}
.topbar nav a.active { color: var(--primary); }

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 20px;
}

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
}
.auth-card p.sub {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 22px;
  font-size: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

input[type=text], input[type=password], input[type=email], input[type=date], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

button, .btn {
  display: inline-block;
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--primary-dark); text-decoration: none; }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f3f4f6; }

.btn-danger { background: var(--error); }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--error-bg); color: var(--error); }

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

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-shop { background: #e0f2fe; color: #0369a1; }
.badge-trial { background: #fef9c3; color: #a16207; }
.badge-active { background: #dcfce7; color: #16a34a; }
.badge-expired { background: #fee2e2; color: #dc2626; }

.uid {
  font-family: "SFMono-Regular", Consolas, monospace;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.section-title h2 { margin: 0; font-size: 20px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-bg.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 400px;
}
.modal-box h3 { margin-top: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.file-row-icon {
  font-size: 20px;
  margin-right: 6px;
}

.actions-inline form { display: inline; }
.actions-inline .btn { margin-right: 6px; }

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

.upload-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  margin-bottom: 20px;
}

.helper-text { color: var(--muted); font-size: 13px; margin-top: -8px; margin-bottom: 16px; }

.qr-box { text-align: center; }
.qr-box img { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: #fff; }

footer.foot-note {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px;
}

/* ---------- File gallery grid ---------- */
.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.file-count {
  color: var(--muted);
  font-size: 13px;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
}

.file-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.file-card:hover {
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
  transform: translateY(-2px);
}

.file-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.file-thumb.pdf-thumb {
  background: linear-gradient(160deg, #fee2e2 0%, #fecaca 100%);
}
.file-thumb .pdf-icon {
  font-size: 48px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.08));
}

.file-type-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
}

.file-info {
  padding: 10px 12px 8px;
}
.file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.file-actions {
  display: flex;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.file-actions a {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  border-right: 1px solid var(--border);
}
.file-actions a:last-child { border-right: none; }
.file-actions a:hover {
  background: #f9fafb;
  text-decoration: none;
  color: var(--primary);
}

/* ---------- Upload progress queue (customer-facing upload page) ---------- */
.file-queue {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fafafa;
}

.upload-item-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.upload-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-item-meta {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.upload-progress-track {
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.15s ease;
}

.upload-item-status {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

.upload-item-done .upload-progress-fill { background: var(--success); }
.upload-item-done .upload-item-status { color: var(--success); font-weight: 600; }

.upload-item-error .upload-progress-fill { background: var(--error); }
.upload-item-error .upload-item-status { color: var(--error); font-weight: 600; }
