:root {
  --bg: #f7f4ef;
  --panel: #fff;
  --text: #1f1f1f;
  --muted: #8a8378;
  --border: #e8dfd4;
  --accent: #b38345;
  --dark: #111;
  --danger: #d94f4f;
  --success: #4b8f5a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans Thai", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

.brand {
  font-family: "Cormorant Garamond", serif;
  font-size: 2rem;
  letter-spacing: 0.03em;
}

.brand em { color: var(--accent); font-style: italic; }

.eyebrow {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.pill-btn {
  min-height: 42px;
  border: 1px solid var(--dark);
  border-radius: 999px;
  background: var(--dark);
  color: #fff;
  padding: 0.68rem 1.15rem;
  font: 600 0.8rem "Noto Sans Thai", sans-serif;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.pill-btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.8rem;
  cursor: pointer;
}

.toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1000;
  max-width: 360px;
  padding: 0.9rem 1.2rem;
  border-radius: 16px;
  background: var(--dark);
  color: #fff;
  opacity: 0;
  transform: translateY(20px);
  transition: 0.25s ease;
}

.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* Admin */
.qr-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.qr-login-card {
  width: min(100%, 390px);
  padding: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0,0,0,.06);
}

.qr-login-card p { color: var(--muted); margin: 0.2rem 0 2rem; }

.qr-login-card input,
.event-form input,
.event-form select,
.event-form textarea,
.drive-tools input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.82rem 0.95rem;
  background: #fff;
  color: var(--text);
  font: 400 0.9rem "Noto Sans Thai", sans-serif;
  outline: none;
}

.qr-login-card button { width: 100%; margin-top: 1rem; }

.form-error {
  display: none;
  margin-top: 1rem;
  color: var(--danger);
  font-size: 0.85rem;
}

.qr-admin-shell {
  display: none;
  width: min(1480px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 5rem;
}

.qr-admin-head,
.drive-panel,
.list-head,
.form-actions,
.head-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.qr-admin-head h1 {
  margin: 0.15rem 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2.3rem, 5vw, 4rem);
  font-weight: 500;
}

.drive-panel,
.admin-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(0,0,0,.04);
}

.drive-panel {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
}

.drive-panel strong { display: block; }
.drive-panel span { color: var(--muted); font-size: 0.86rem; }

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.admin-card { padding: 1.25rem; }
.admin-card h2 { margin: 0 0 1rem; font-size: 1.2rem; }

.event-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.event-form label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.event-form input[type="file"] {
  padding: 0.65rem;
  font-size: 0.82rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
}

.event-list {
  display: grid;
  gap: 0.75rem;
}

.event-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.event-thumb {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  background: #eee;
  object-fit: cover;
}

.event-name { font-weight: 600; }
.event-meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }
.event-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.45rem; }
.event-actions .pill-btn { min-height: 36px; padding: 0.5rem 0.8rem; font-size: 0.72rem; }
.event-actions .danger { border-color: rgba(217,79,79,.35); color: var(--danger); }

.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  padding: 1rem;
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
}

.modal-bg.open { display: flex; }

.drive-modal {
  width: min(920px, 100%);
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  background: var(--panel);
}

.qr-code-modal {
  width: min(440px, 100%);
  overflow: hidden;
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0,0,0,.22);
}

.drive-modal header,
.qr-code-modal header,
.drive-tools {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.drive-modal h2,
.qr-code-modal h2 { margin: 0; }

.drive-modal p,
.qr-code-modal p { margin: 0.25rem 0 0; color: var(--muted); }

.qr-code-body {
  display: grid;
  gap: 1rem;
  padding: 1.15rem;
}

.qr-code-preview {
  display: grid;
  place-items: center;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
}

.qr-code-preview img {
  width: min(100%, 320px);
  aspect-ratio: 1;
  display: block;
}

.qr-code-link {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.qr-code-link input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.82rem 0.95rem;
  background: #fff;
  color: var(--text);
  font: 400 0.86rem "Noto Sans Thai", sans-serif;
}

.qr-code-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.qr-code-actions .pill-btn:first-child {
  grid-column: 1 / -1;
}

.drive-tools { align-items: center; }
.drive-tools input { border-radius: 999px; }

.folder-list {
  overflow: auto;
  padding: 0.75rem;
}

.folder-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem;
  border-bottom: 1px solid var(--border);
}

.folder-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #f3eadf;
  color: var(--accent);
}

.folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.folder-meta,
.empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.empty { padding: 3rem 1rem; text-align: center; }

/* Event page */
.page-loading,
.page-error {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.qr-landing-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 28% 16%, rgba(181, 132, 65, 0.14), transparent 28rem),
    radial-gradient(circle at 70% 82%, rgba(196, 174, 145, 0.24), transparent 30rem),
    var(--bg);
}

.qr-landing {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.qr-landing-shell {
  width: min(100%, 960px);
  text-align: center;
}

.qr-landing-brand {
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: 0.04em;
  margin-bottom: 1.2rem;
}

.qr-landing-brand em {
  color: var(--accent);
  font-style: italic;
}

.qr-landing h1 {
  margin: 0.7rem 0 1rem;
  font-size: clamp(2.6rem, 8vw, 5.2rem);
  line-height: 1.05;
  color: var(--text);
}

.qr-landing-lead {
  max-width: 720px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.9;
}

.qr-landing-actions {
  display: flex;
  justify-content: center;
  gap: 0.85rem;
  margin: 2.2rem 0;
}

.qr-landing-actions .pill-btn {
  min-width: 170px;
}

.qr-landing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.qr-landing-grid article {
  display: grid;
  gap: 0.55rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  text-align: left;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.035);
}

.qr-landing-grid strong {
  color: var(--text);
}

.qr-landing-grid span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.qr-landing-contact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.qr-landing-contact a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.qr-hero {
  min-height: 52vh;
  background: linear-gradient(120deg, rgba(0,0,0,.72), rgba(0,0,0,.16)), var(--cover, #111);
  background-size: cover;
  background-position: center;
  position: relative;
}

.qr-top-actions {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.55rem;
}

.round-action {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.22);
  color: #fff;
  display: grid;
  place-items: center;
  text-decoration: none;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.round-action svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.qr-panel {
  position: relative;
  width: min(84vw, 1480px);
  min-height: 50vh;
  margin: -70px auto 0;
  padding: 6.5rem 2rem 4rem;
  border-radius: 34px 34px 0 0;
  background: var(--panel);
  box-shadow: 0 -20px 60px rgba(0,0,0,.08);
}

.qr-avatar {
  position: absolute;
  top: -62px;
  left: 50%;
  width: 124px;
  height: 124px;
  padding: 5px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 14px 32px rgba(0,0,0,.22);
}

.qr-avatar img,
.qr-avatar div {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  border: 2px solid var(--dark);
  background: #f2eee7;
}

.qr-head {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 2.5rem;
}

.qr-head h1 {
  margin: 0.55rem 0 0.45rem;
  font-size: clamp(1.55rem, 4vw, 2.7rem);
  line-height: 1.25;
  font-weight: 500;
}

.qr-head p { color: var(--muted); line-height: 1.8; margin: 0.35rem auto; }

.qr-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.2rem;
}

.qr-download-note {
  display: inline-grid;
  gap: 0.25rem;
  max-width: 520px;
  margin: 1.1rem auto 0;
  padding: 0.85rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.86rem;
}

.qr-download-note strong {
  color: var(--text);
  font-size: 0.82rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.photo-card {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: #eee;
  cursor: pointer;
}

.photo-card:nth-child(7n + 1),
.photo-card:nth-child(7n + 5) { grid-column: span 2; aspect-ratio: 4 / 3; }

.photo-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform .45s ease;
}

.photo-card:hover img { transform: scale(1.035); }

.photo-card.is-broken::after {
  content: "โหลดรูปไม่สำเร็จ";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: var(--muted);
  background: #eee;
  font-size: 0.9rem;
}

.photo-dl {
  position: absolute;
  right: 0.55rem;
  bottom: 0.55rem;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0,0,0,.58);
  color: #fff;
  text-decoration: none;
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1100;
  align-items: center;
  justify-content: center;
  background: #101010;
}

.lightbox.open { display: flex; }

.lb-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  color: #fff;
}

.lb-title { font-weight: 600; }
.lb-count { color: rgba(255,255,255,.62); font-size: 0.82rem; }
.lb-actions { display: flex; gap: 0.6rem; align-items: center; }
.lb-download,
.lb-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  color: #fff;
  padding: 0 0.9rem;
  text-decoration: none;
  text-align: center;
  line-height: 1;
}

.lb-close { width: 40px; padding: 0; font-size: 1.4rem; cursor: pointer; }
.lb-img { max-width: calc(100vw - 2rem); max-height: calc(100dvh - 8rem); object-fit: contain; }
.lb-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
}
.lb-prev { left: 0.85rem; }
.lb-next { right: 0.85rem; }

.qr-guide {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  background: rgba(26, 26, 26, 0.16);
  pointer-events: none;
}

.qr-guide-card {
  width: min(100%, 390px);
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
}

.qr-guide-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.qr-guide-count {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.qr-guide h2 {
  margin: 0.18rem 0 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.qr-guide p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.75;
}

.qr-guide-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft, #f4ede5);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
}

.qr-guide-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.8rem;
  margin-top: 1rem;
}

.qr-guide-next,
.qr-guide-ghost {
  min-height: 40px;
  border-radius: 999px;
  padding: 0 1rem;
  font: 700 0.82rem "Noto Sans Thai", sans-serif;
  cursor: pointer;
}

.qr-guide-next {
  border: 1px solid var(--dark);
  background: var(--dark);
  color: #fff;
}

.qr-guide-ghost {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

@media (max-width: 900px) {
  .qr-admin-head,
  .drive-panel,
  .list-head,
  .head-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-grid,
  .two-col,
  .inline-field {
    grid-template-columns: 1fr;
  }

  .event-row {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .event-thumb {
    width: 58px;
    height: 58px;
  }

  .event-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .event-actions .pill-btn { flex: 1; }

  .drive-modal {
    max-height: calc(100dvh - 1rem);
    border-radius: 18px;
  }

  .drive-modal header,
  .drive-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .folder-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .folder-row .pill-btn {
    width: 100%;
  }

  .qr-hero {
    min-height: 36vh;
  }

  .qr-panel {
    width: calc(100% - 1.2rem);
    margin-top: -42px;
    padding: 5.4rem 0.7rem 3rem;
    border-radius: 28px 28px 0 0;
  }

  .qr-avatar {
    top: -48px;
    width: 96px;
    height: 96px;
  }

  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.32rem;
  }

  .photo-card,
  .photo-card:nth-child(7n + 1),
  .photo-card:nth-child(7n + 5) {
    grid-column: span 1;
    aspect-ratio: 3 / 4;
  }

  .qr-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .qr-download-note {
    width: 100%;
    border-radius: 16px;
    text-align: left;
  }

  .qr-landing {
    padding: 1rem;
  }

  .qr-landing-grid {
    grid-template-columns: 1fr;
  }

  .qr-landing-contact {
    align-items: stretch;
    flex-direction: column;
  }

  .qr-landing-contact a {
    min-height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
  }

  .toast {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

/* Padchafoto QR admin dashboard */
body.qr-admin-page {
  --bg: #fdfbf7;
  --panel: #fff;
  --text: #1a1a1a;
  --muted: #7c746b;
  --border: #eae5de;
  --accent: #b58441;
  --accent-soft: #f4ede5;
  --dark: #1a1a1a;
  --danger: #d34c4c;
  --success: #4c9f58;
  min-height: 100vh;
  background:
    radial-gradient(circle at 32% 18%, rgba(181, 132, 65, 0.12), transparent 28rem),
    radial-gradient(circle at 64% 72%, rgba(196, 174, 145, 0.22), transparent 30rem),
    var(--bg);
  color: var(--text);
}

body.qr-admin-page::before,
body.qr-admin-page::after {
  content: "";
  position: fixed;
  z-index: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(181, 132, 65, 0.34);
  pointer-events: none;
}

body.qr-admin-page::before { top: 8%; left: 5%; }
body.qr-admin-page::after { right: 6%; bottom: 9%; }

.qr-admin-page button,
.qr-admin-page input,
.qr-admin-page select,
.qr-admin-page textarea {
  font-family: "Noto Sans Thai", sans-serif;
}

.qr-admin-page .pill-btn {
  min-height: 42px;
  border-color: var(--dark);
  background: var(--dark);
  color: #fff;
  border-radius: 999px;
  box-shadow: 0 14px 26px rgba(26, 26, 26, 0.08);
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}

.qr-admin-page .pill-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--accent);
}

.qr-admin-page .pill-btn.ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}

.qr-admin-page .pill-btn.ghost:hover {
  color: #fff;
  border-color: var(--dark);
  background: var(--dark);
}

.qr-admin-page .pill-btn.compact {
  min-height: 38px;
  padding: 0.56rem 1rem;
}

.qr-login {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 2rem;
}

.login-back {
  position: absolute;
  top: 2rem;
  left: max(1.25rem, calc(50% - 220px));
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
}

.qr-login-card {
  width: min(100%, 448px);
  padding: 3rem 2.5rem;
  border-radius: 18px;
  border-color: var(--border);
  text-align: center;
  box-shadow: 0 28px 80px rgba(26, 26, 26, 0.08);
}

.brand-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin: 0 auto 0.9rem;
  border: 2px solid var(--dark);
  border-radius: 16px;
  background: var(--dark);
  color: var(--accent);
  font-family: "Cormorant Garamond", serif;
  font-size: 1.45rem;
  font-style: italic;
  letter-spacing: 0.04em;
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  margin: 0;
  border-radius: 10px;
  font-size: 0.86rem;
}

.qr-login-card .brand {
  color: var(--text);
  font-size: 1.65rem;
  margin-bottom: 1.7rem;
}

.qr-login-card h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0;
}

.qr-login-card p {
  margin: 0.65rem 0 2rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.qr-login-card input {
  min-height: 50px;
  border-radius: 999px;
  text-align: center;
}

.google-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.72rem;
}

.google-dot {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #4285f4;
  font-weight: 800;
  line-height: 1;
}

.qr-admin-shell {
  position: relative;
  z-index: 1;
  display: none;
  grid-template-columns: 256px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

.qr-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.2rem 1rem;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(18px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.sidebar-label {
  margin: 1.6rem 0 0.55rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 0.42rem;
}

.side-link {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  padding: 0 0.9rem;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}

.side-link.link-like {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.side-link.active,
.side-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.user-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--dark);
  color: #fff;
  font-weight: 700;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.super-shell .qr-workspace {
  max-width: 1280px;
}

.super-stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.super-card {
  margin-top: 1.4rem;
}

.super-user-list {
  display: grid;
  gap: 0.85rem;
}

.super-user-card {
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(360px, 1.35fr) minmax(220px, 0.85fr) auto;
  gap: 0.9rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.super-user-main {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.super-avatar {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--dark);
  color: #fff;
  font-weight: 700;
  overflow: hidden;
}

.super-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.super-user-copy {
  display: grid;
  min-width: 0;
}

.super-user-copy strong,
.super-user-copy span,
.super-user-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.super-user-copy span,
.super-user-copy small {
  color: var(--muted);
  font-size: 0.8rem;
}

.super-user-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 0.55rem;
}

.super-user-controls label,
.super-user-meta {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.super-user-controls select,
.super-user-controls input,
.super-user-meta textarea,
.super-card .list-tools input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 0.6rem 0.7rem;
  font: 500 0.82rem "Noto Sans Thai", sans-serif;
  outline: none;
}

.super-user-meta {
  display: grid;
  gap: 0.45rem;
}

.super-user-meta textarea {
  min-height: 48px;
  resize: vertical;
}

.super-expire-field {
  display: grid;
  gap: 0.28rem;
}

.super-user-actions {
  display: flex;
  gap: 0.45rem;
  justify-content: flex-end;
}

.pill-btn.danger {
  color: var(--danger);
  border-color: rgba(217, 79, 79, 0.35);
}

.sidebar-user strong,
.sidebar-user span {
  display: block;
}

.sidebar-user span {
  color: var(--muted);
  font-size: 0.78rem;
}

.sidebar-logout {
  min-height: 42px;
  margin-top: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.sidebar-logout:hover {
  border-color: var(--dark);
  background: var(--dark);
  color: #fff;
}

.qr-workspace {
  width: min(1280px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 2rem 0 5rem;
}

.qr-view {
  display: none;
}

.qr-view.active {
  display: block;
}

.qr-admin-head {
  align-items: flex-start;
  margin: 0 0 1.7rem;
  padding-top: 0.25rem;
}

.qr-admin-head h1 {
  margin: 0.1rem 0 0.2rem;
  font-family: "Noto Sans Thai", sans-serif;
  font-size: clamp(2rem, 4vw, 3.05rem);
  font-weight: 700;
  color: var(--accent);
}

.qr-admin-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.8rem;
}

.stat-card,
.admin-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 20px 48px rgba(26, 26, 26, 0.04);
}

.stat-card {
  min-height: 172px;
  padding: 1.8rem;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stat-card strong {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-top: 1rem;
  color: var(--text);
}

.stat-card b {
  font-size: 3.2rem;
  line-height: 1;
}

.stat-card small,
.stat-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-line {
  height: 5px;
  margin-top: 1.3rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--accent-soft);
}

.stat-line i {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .25s ease;
}

.drive-stat {
  display: grid;
  gap: 0.55rem;
}

.drive-stat strong {
  display: block;
  margin-top: 0.6rem;
  font-size: 1rem;
}

.text-btn {
  justify-self: start;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.admin-grid {
  grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  gap: 1.25rem;
}

.dashboard-recent {
  margin-top: 1.25rem;
}

.recent-event-list {
  display: grid;
  gap: 0.65rem;
}

.recent-event-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.admin-card {
  padding: 1.35rem;
}

.card-head,
.list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.admin-card h2 {
  margin: 0;
  font-size: 1.1rem;
}

.list-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

#eventListCount {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
}

.list-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.list-tools input,
.event-form input,
.event-form select,
.event-form textarea,
.drive-tools input,
.qr-code-link input {
  border-radius: 12px;
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.92);
}

.list-tools input {
  width: min(280px, 32vw);
  min-height: 44px;
  padding: 0 1rem;
}

.event-form label {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.event-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.event-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
}

.event-table th,
.event-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.event-table th {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.event-table tr:last-child td {
  border-bottom: 0;
}

.event-title-cell {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.event-thumb {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 10px;
}

.event-name {
  font-size: 0.98rem;
  font-weight: 700;
}

.event-url {
  display: block;
  max-width: 360px;
  margin-top: 0.28rem;
  overflow: hidden;
  color: var(--accent);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 0.75rem;
  border-radius: 999px;
  background: rgba(76, 159, 88, 0.12);
  color: var(--success);
  font-size: 0.76rem;
  font-weight: 700;
}

.status-pill.disabled {
  background: rgba(211, 76, 76, 0.1);
  color: var(--danger);
}

.event-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: nowrap;
}

.icon-action {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 0.42rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.icon-action.primary {
  border-color: var(--dark);
  background: var(--dark);
  color: #fff;
}

.icon-action.danger {
  color: var(--danger);
  border-color: rgba(211, 76, 76, 0.3);
}

.modal-bg {
  background: rgba(26, 26, 26, 0.42);
}

.drive-modal,
.qr-code-modal {
  border: 1px solid var(--border);
  border-radius: 18px;
}

@media (max-width: 1100px) {
  .qr-admin-shell {
    grid-template-columns: 1fr;
  }

  .qr-sidebar {
    position: sticky;
    z-index: 40;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  .sidebar-label,
  .sidebar-user {
    display: none;
  }

  .sidebar-logout {
    margin-top: 0;
    margin-left: auto;
    padding: 0 1rem;
  }

  .sidebar-nav {
    display: flex;
    margin-left: auto;
  }

  .qr-workspace {
    width: min(100% - 2rem, 1100px);
  }

  .stat-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .super-user-card {
    grid-template-columns: 1fr;
  }

  .super-user-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .login-back {
    left: 1rem;
  }

  .qr-login {
    padding: 1rem;
  }

  .qr-login-card {
    padding: 2.25rem 1.25rem;
  }

  .qr-sidebar {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar-nav {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-logout {
    width: 100%;
    margin-left: 0;
  }

  .side-link {
    padding: 0 0.35rem;
    text-align: center;
    font-size: 0.78rem;
  }

  .qr-workspace {
    width: calc(100% - 1rem);
    padding: 1rem 0 3rem;
  }

  .qr-admin-head,
  .head-actions,
  .card-head,
  .list-head,
  .list-tools,
  .inline-field,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .head-actions .pill-btn,
  .list-tools .pill-btn,
  .list-tools input {
    width: 100%;
  }

  .stat-card {
    min-height: 148px;
    padding: 1.25rem;
  }

  .event-table {
    min-width: 0;
  }

  .event-table thead {
    display: none;
  }

  .event-table,
  .event-table tbody,
  .event-table tr,
  .event-table td {
    display: block;
    width: 100%;
  }

  .event-table tr {
    border-bottom: 1px solid var(--border);
  }

  .event-table tr:last-child {
    border-bottom: 0;
  }

  .event-table td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem;
    border-bottom: 1px solid var(--border);
  }

  .event-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .event-title-cell,
  .event-actions {
    width: 100%;
  }

  .event-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .icon-action {
    text-align: center;
  }

  .event-url {
    max-width: 58vw;
  }

  .super-stat-grid,
  .super-user-controls {
    grid-template-columns: 1fr;
  }

  .super-user-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
