*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0f1117;
  color: #f0f0f0;
  min-height: 100vh;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 10px;
  gap: 10px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #0d7a3e 0%, #1a5c2a 100%);
  border-radius: 10px;
  padding: 10px 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.header-actions { display: flex; gap: 8px; align-items: center; }
.title-name {
  font-size: 1.4rem; font-weight: 700; color: #fff; letter-spacing: 1px;
  text-decoration: none;
}
.lookup-btn {
  background: #fff; color: #0d7a3e; border: none; border-radius: 7px;
  padding: 7px 16px; font-size: 0.88rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
.lookup-btn:hover { background: #d4f5e0; }
.admin-only { display: none; }
body.admin-mode .admin-only { display: inline-flex; }
.admin-donate-btn {
  border: none;
  border-radius: 7px;
  background: #fde68a;
  color: #6b3f00;
  padding: 7px 13px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.admin-donate-btn:hover { background: #fcd34d; }

.admin-banner {
  background: linear-gradient(90deg, #b71c1c, #d32f2f);
  color: #fff; text-align: center; padding: 7px 14px; border-radius: 8px;
  font-weight: 600; font-size: 0.87rem;
  animation: pulse-opacity 2s ease-in-out infinite;
}
@keyframes pulse-opacity { 0%,100% { opacity:1; } 50% { opacity:0.72; } }

.hall-container { flex: 1; overflow-x: auto; overflow-y: auto; border-radius: 10px; }
.hall {
  position: relative; min-width: 860px;
  background: #111827; border: 2px solid #1e2d40; border-radius: 10px;
  padding: 56px 16px 16px;
}

.bar {
  position: absolute; top: 12px;
  background: #1f2d3d; color: #6b7f93; font-size: 0.68rem;
  padding: 3px 10px; border-radius: 4px; border: 1px solid #2d3f52; letter-spacing: 0.5px;
}
.bar-left  { left:  70px; }
.bar-right { right: 70px; }

.stage {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: #c8970f; color: #1a1200; font-size: 0.62rem; font-weight: 700;
  padding: 5px 16px; border-radius: 5px; white-space: nowrap; z-index: 2;
  box-shadow: 0 2px 8px rgba(200,151,15,0.4);
}

.runway {
  position: absolute; top: 46px; left: 50%; transform: translateX(-50%);
  width: 50px; bottom: 16px;
  background: rgba(200,151,15,0.07);
  border-left:  2px dashed rgba(200,151,15,0.25);
  border-right: 2px dashed rgba(200,151,15,0.25);
  z-index: 1; pointer-events: none;
}

.seating-grid {
  display: grid; gap: 6px; position: relative; z-index: 2;
  justify-items: center; align-items: center;
}

.table-node {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: default; user-select: none;
  transition: opacity 0.4s, transform 0.2s;
}

.table-circle {
  width: 58px; height: 58px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px solid transparent; position: relative;
  transition: box-shadow 0.3s, border-color 0.3s, transform 0.3s;
}
.table-circle::before {
  content: ''; position: absolute; inset: -9px; border-radius: 50%;
  border: 5px dotted rgba(255,255,255,0.1); pointer-events: none;
}

.tid  { font-size: 0.76rem; font-weight: 700; color: #111; line-height: 1.1; }
.tcnt { font-size: 0.52rem; color: rgba(0,0,0,0.55); }
.tlabel { font-size: 0.56rem; font-weight: 600; white-space: nowrap; color: #6b7f93; margin-top: 1px; }

.nha-trai .table-circle { background: #00bcd4; }
.ban-cdcr .table-circle { background: #ffd600; }
.nha-gai  .table-circle { background: #ce93d8; }

@keyframes led-cyan {
  0%,100% { box-shadow: 0 0 6px 2px rgba(0,188,212,0.65),  0 0 16px 6px rgba(0,188,212,0.35); }
  50%     { box-shadow: 0 0 14px 5px rgba(0,188,212,1),    0 0 32px 12px rgba(0,188,212,0.55), 0 0 56px 20px rgba(0,188,212,0.2); }
}
@keyframes led-yellow {
  0%,100% { box-shadow: 0 0 6px 2px rgba(255,214,0,0.65),  0 0 16px 6px rgba(255,214,0,0.35); }
  50%     { box-shadow: 0 0 14px 5px rgba(255,214,0,1),    0 0 32px 12px rgba(255,214,0,0.55), 0 0 56px 20px rgba(255,214,0,0.2); }
}
@keyframes led-purple {
  0%,100% { box-shadow: 0 0 6px 2px rgba(206,147,216,0.65), 0 0 16px 6px rgba(206,147,216,0.35); }
  50%     { box-shadow: 0 0 14px 5px rgba(206,147,216,1),   0 0 32px 12px rgba(206,147,216,0.55), 0 0 56px 20px rgba(206,147,216,0.2); }
}

.table-node.led-on .table-circle { transform: scale(1.06); border-color: rgba(255,255,255,0.7); }
.nha-trai.led-on .table-circle { animation: led-cyan   1.1s ease-in-out infinite; }
.ban-cdcr.led-on .table-circle { animation: led-yellow 1.1s ease-in-out infinite; }
.nha-gai.led-on  .table-circle { animation: led-purple 1.1s ease-in-out infinite; }

.table-node.led-dim { opacity: 0.18; pointer-events: none; }
.table-node.led-dim .table-circle { filter: grayscale(0.6); }

@keyframes found-pulse {
  0%,100% { box-shadow: 0 0 0 4px rgba(255,255,255,0.3), 0 0 28px 10px rgba(255,230,0,0.7);  transform: scale(1.18); }
  50%     { box-shadow: 0 0 0 8px rgba(255,255,255,0.15),0 0 48px 18px rgba(255,230,0,0.9); transform: scale(1.22); }
}
.table-node.pinned .table-circle { animation: found-pulse 0.9s ease-in-out infinite; border-color: #fff; z-index: 10; }
.table-node.pinned .tlabel { color: #ffd700; font-weight: 700; }

body.admin-mode .table-node { cursor: pointer; }
body.admin-mode .table-node:hover .table-circle {
  transform: scale(1.1); border-color: rgba(255,255,255,0.8);
  box-shadow: 0 0 12px 4px rgba(255,255,255,0.3);
}

.legend { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; padding: 6px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 0.82rem; color: #9ca3af; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.nha-trai { background: #00bcd4; }
.dot.ban-cdcr { background: #ffd600; }
.dot.nha-gai  { background: #ce93d8; }

.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 100;
  align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(1px);
}
.overlay.active { display: flex; }

.popup {
  background: rgba(20,28,42,0.97); border: 1px solid #2a3a52; border-radius: 14px;
  width: 100%; max-width: 420px; padding: 24px 22px 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  display: flex; flex-direction: column; gap: 14px;
}
.popup-header h2 { font-size: 1.2rem; font-weight: 700; color: #f1f5f9; margin-bottom: 3px; }
.popup-header p  { font-size: 0.82rem; color: #7a8fa6; }

.popup-body { display: flex; flex-direction: column; gap: 12px; }
.form-row   { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 0.78rem; font-weight: 600; color: #8fa8c0; display: flex; align-items: center; gap: 6px; }

.step-num {
  width: 18px; height: 18px; background: #1e3a5f; border: 1px solid #2e5080;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700; color: #7ab3e0; flex-shrink: 0;
}
.optional { font-size: 0.7rem; color: #4a6278; font-weight: 400; }

.form-select {
  width: 100%; padding: 9px 30px 9px 12px;
  background: #0d1520; border: 1px solid #2a3a52; border-radius: 7px;
  color: #e2e8f0; font-size: 0.88rem; outline: none; cursor: pointer;
  transition: border-color 0.2s; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7f93'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.form-select:focus { border-color: #3b82f6; }
.form-select option { background: #0d1520; }

.input-row { display: flex; gap: 7px; }
.input-row input {
  flex: 1; padding: 9px 12px; background: #0d1520;
  border: 1px solid #2a3a52; border-radius: 7px;
  color: #e2e8f0; font-size: 0.9rem; outline: none; transition: border-color 0.2s;
}
.input-row input:focus { border-color: #10b981; }

#find-btn {
  padding: 9px 18px; background: #10b981; color: #fff;
  border: none; border-radius: 7px; font-weight: 700; font-size: 0.88rem;
  cursor: pointer; white-space: nowrap; transition: background 0.2s;
}
#find-btn:hover { background: #059669; }

.lookup-result { font-size: 0.87rem; line-height: 1.6; padding: 10px 12px; border-radius: 8px; }
.lookup-result.hidden  { display: none; }
.lookup-result.success { background: rgba(16,185,129,0.12); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.25); }
.lookup-result.error   { background: rgba(239,68,68,0.1);   color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }
.lookup-result.disambig { background: rgba(99,102,241,0.08); border: 1px solid rgba(99,102,241,0.2); color: #c7d2fe; padding: 14px; }
.disambig-title { margin: 0 0 10px; font-size: 0.9rem; }
.disambig-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.disambig-btn {
  flex: 1 1 120px; min-width: 100px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 10px; border-radius: 10px; cursor: pointer;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1.5px solid #334155;
  color: #e2e8f0; transition: all 0.25s ease;
  animation: disambig-pop 0.35s ease both;
}
.disambig-btn:hover {
  border-color: #6366f1; background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
  transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99,102,241,0.25);
}
.disambig-btn:active { transform: translateY(0); }
.disambig-name { font-size: 1.05rem; font-weight: 700; color: #e2e8f0; }
.disambig-group { font-size: 0.82rem; color: #a5b4fc; }
.disambig-table { font-size: 0.72rem; color: #94a3b8; }
@keyframes disambig-pop {
  0%   { opacity: 0; transform: scale(0.85) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.close-btn {
  align-self: flex-end; background: transparent;
  border: 1px solid #2a3a52; color: #6b7f93; border-radius: 7px;
  padding: 5px 14px; cursor: pointer; font-size: 0.82rem;
  transition: border-color 0.2s, color 0.2s;
}
.close-btn:hover { border-color: #6b7f93; color: #e2e8f0; }

.donate-float-btn {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 120;
  border: none;
  border-radius: 999px;
  padding: 11px 16px;
  background: linear-gradient(135deg, #ec4899, #db2777);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(236, 72, 153, 0.35);
}
.donate-float-btn:hover { filter: brightness(1.06); }

.donate-popup { max-width: 360px; }
.donate-qr-image {
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
  border-radius: 10px;
  border: 1px solid #2a3a52;
  background: #fff;
  display: block;
}
.donate-info-card {
  background: #0d1520;
  border: 1px solid #2a3a52;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.86rem;
  color: #d1dce8;
}
.copy-bank-btn {
  border: none;
  border-radius: 8px;
  background: #16a34a;
  color: #fff;
  padding: 10px 12px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}
.copy-bank-btn:hover { background: #15803d; }
.donate-admin-popup { max-width: 420px; }

#admin-donate-bank,
#admin-donate-account,
#admin-donate-qr-url {
  width: 100%;
  padding: 9px 12px;
  background: #0d1520;
  border: 1px solid #2a3a52;
  border-radius: 7px;
  color: #e2e8f0;
  font-size: 0.9rem;
  outline: none;
}
#admin-donate-bank:focus,
#admin-donate-account:focus,
#admin-donate-qr-url:focus { border-color: #3b82f6; }

#save-donate-config-btn {
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  padding: 10px 14px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}
#save-donate-config-btn:hover { background: #1d4ed8; }

.admin-add-row {
  display: flex;
  gap: 8px;
}
.admin-group-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #101a27;
  border: 1px solid #2a3a52;
  border-radius: 8px;
  padding: 10px;
}
.admin-group-card label {
  font-size: 0.78rem;
  color: #8fa8c0;
  font-weight: 600;
}
.admin-group-row {
  display: flex;
  gap: 7px;
}
.admin-group-row select,
.admin-group-row input {
  flex: 1;
  padding: 8px 10px;
  background: #0d1520;
  border: 1px solid #2a3a52;
  border-radius: 7px;
  color: #e2e8f0;
  font-size: 0.82rem;
  outline: none;
}
.admin-group-row select:focus,
.admin-group-row input:focus { border-color: #3b82f6; }
#admin-assign-group-btn,
#admin-add-group-btn,
#admin-rename-group-btn,
#admin-delete-group-btn {
  border: none;
  border-radius: 7px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0 10px;
  cursor: pointer;
}
#admin-assign-group-btn { background: #2563eb; }
#admin-add-group-btn { background: #0891b2; }
#admin-rename-group-btn { background: #7c3aed; }
#admin-delete-group-btn { background: #b91c1c; }
#admin-assign-group-btn:hover { background: #1d4ed8; }
#admin-add-group-btn:hover { background: #0e7490; }
#admin-rename-group-btn:hover { background: #6d28d9; }
#admin-delete-group-btn:hover { background: #991b1b; }
.admin-add-row input {
  flex: 1;
  padding: 9px 11px;
  background: #0d1520;
  border: 1px solid #2a3a52;
  border-radius: 7px;
  color: #e2e8f0;
  font-size: 0.86rem;
  outline: none;
}
.admin-add-row input:focus { border-color: #10b981; }
#admin-add-btn {
  border: none;
  border-radius: 7px;
  background: #0ea5e9;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}
#admin-add-btn:hover { background: #0284c7; }

.attendee-list { list-style: none; display: flex; flex-direction: column; gap: 5px; max-height: 300px; overflow-y: auto; }
.attendee-list li { display: flex; flex-direction: column; gap: 4px; padding: 8px 11px; background: #0d1520; border-radius: 7px; font-size: 0.88rem; color: #d1dce8; }
.attendee-list .empty { color: #4a5568; font-style: italic; }
.guest-row-top { display: flex; align-items: center; gap: 8px; }
.guest-row-bottom { display: flex; align-items: center; justify-content: space-between; padding-left: 28px; }
.guest-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.admin-actions { display: flex; gap: 6px; flex-shrink: 0; }
.checkin-tag {
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid transparent;
}
.checkin-tag.checked {
  background: rgba(22, 163, 74, 0.18);
  color: #86efac;
  border-color: rgba(22, 163, 74, 0.45);
}
.checkin-tag.pending {
  background: rgba(234, 179, 8, 0.18);
  color: #fde68a;
  border-color: rgba(234, 179, 8, 0.45);
}
.checkin-time {
  font-size: 0.7rem;
  color: #86efac;
  opacity: 0.75;
  white-space: nowrap;
}
.admin-check-btn,
.admin-edit-btn,
.admin-del-btn {
  border: 1px solid #31445c;
  background: #162231;
  color: #c7d7e7;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.admin-check-btn {
  border-color: #165e31;
  background: #12301d;
  color: #9ae6b4;
}
.admin-check-btn:hover { border-color: #22c55e; color: #dcfce7; }
.admin-edit-btn:hover { border-color: #7ab3e0; color: #dff2ff; }
.admin-del-btn {
  border-color: #61333b;
  background: #31161b;
  color: #f7b6be;
}
.admin-del-btn:hover { border-color: #f87171; color: #ffd4d4; }
.seat-num {
  width: 20px; height: 20px; background: #1e2d3d; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.66rem; font-weight: 700; color: #7a8fa6; flex-shrink: 0;
}

/* ── Admin List button ── */
.admin-list-btn {
  border: none; border-radius: 7px;
  background: #a5b4fc; color: #1e1b4b;
  padding: 7px 13px; font-size: 0.8rem;
  font-weight: 700; cursor: pointer;
  transition: background 0.2s;
}
.admin-list-btn:hover { background: #818cf8; }

/* ── Attendee List overlay ── */
.attendee-list-popup {
  max-width: 700px; width: 95vw; max-height: 90vh;
  display: flex; flex-direction: column;
}
.attendee-list-popup .popup-body { overflow-y: auto; flex: 1; }

.al-toolbar {
  display: flex; gap: 10px; align-items: center;
  flex-wrap: wrap; margin-bottom: 12px;
}
.al-toolbar .form-select { flex: 0 0 140px; }
.al-export-btn {
  border: none; border-radius: 7px; cursor: pointer;
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff; padding: 8px 14px; font-size: 0.8rem;
  font-weight: 700; white-space: nowrap;
  transition: opacity 0.2s;
}
.al-export-btn:hover { opacity: 0.85; }

.al-content { display: flex; flex-direction: column; gap: 16px; }

.al-group-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: 8px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid #334155; margin-bottom: 4px;
}
.al-group-name { font-weight: 700; font-size: 0.95rem; color: #a5b4fc; }
.al-group-count { font-size: 0.78rem; color: #94a3b8; }

.al-table {
  width: 100%; border-collapse: collapse; font-size: 0.8rem;
}
.al-table th {
  text-align: left; padding: 6px 8px;
  color: #64748b; font-weight: 600; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid #1e293b;
}
.al-table td {
  padding: 6px 8px; border-bottom: 1px solid #1e293b10;
  color: #cbd5e1;
}
.al-table tr.al-checked td { color: #86efac; }
.al-table tr.al-pending td { color: #94a3b8; opacity: 0.7; }

.al-empty { color: #4a5568; font-style: italic; text-align: center; padding: 20px; }

@media (max-width: 600px) {
  .table-circle { width: 48px; height: 48px; }
  .tid { font-size: 0.68rem; }
  .tlabel { font-size: 0.48rem; }
  .input-row { flex-direction: column; }
  .al-table { font-size: 0.72rem; }
  .al-table th, .al-table td { padding: 4px 5px; }
  .al-toolbar { flex-direction: column; }
}
