:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --pending: #f59e0b;
}

* { 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);
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

body.hero-bg {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #0b0f14;
}

.hero-photo {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: linear-gradient(180deg, rgba(11, 20, 38, 0.5) 0%, rgba(11, 20, 38, 0.25) 40%, rgba(11, 20, 38, 0.8) 100%), url('toco-tower.webp');
  background-size: cover, cover;
  background-position: center, center 22%;
  background-repeat: no-repeat, no-repeat;
  z-index: -1;
}

.hero-bg .container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
}

.hero-bg .card {
  border: none;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.lang-switch {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 14px;
}
.lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
}
.lang-btn svg { width: 100%; height: 100%; display: block; }
.lang-btn:hover { border-color: var(--primary); }
.lang-btn.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.container.wide {
  max-width: 1400px;
}

.table-wrap {
  overflow-x: auto;
}

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

h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 24px 0 12px; }
.subtitle { color: var(--muted); font-size: 0.9rem; margin: 0 0 20px; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin: 16px 0 6px;
}

input[type="text"], input[type="tel"], input[type="date"], input[type="password"], input[type="email"], select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.id-photo-capture {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.id-photo-preview {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1.586 / 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.id-photo-btn { width: 100%; text-align: center; }

.crop-frame {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1.586 / 1;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111;
  margin: 12px auto;
  touch-action: none;
  cursor: grab;
}
.crop-frame:active { cursor: grabbing; }
.crop-frame img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  user-select: none;
  pointer-events: none;
}
.crop-zoom {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

button, .btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

button:hover, .btn:hover { background: var(--primary-dark); }
button:disabled { background: #94a3b8; cursor: not-allowed; }

.btn-block { width: 100%; margin-top: 24px; }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { background: #fca5a5; cursor: not-allowed; }

.toolbar { display: flex; justify-content: flex-end; margin: 16px 0 10px; }

.edit-cell {
  white-space: nowrap;
}
.edit-cell button + button {
  margin-left: 6px;
}

.photo-cell {
  white-space: nowrap;
  text-align: center;
}
.id-photo-thumb {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 0 auto 4px;
}
.photo-placeholder {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}
.photo-upload-btn {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}
.photo-upload-btn:hover {
  color: var(--primary-dark);
}
.photo-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.photo-remove-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.78rem;
  color: var(--danger);
  cursor: pointer;
  text-decoration: underline;
}
.photo-remove-btn:hover {
  color: #b91c1c;
}

th input[type="checkbox"], td input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.success-icon { font-size: 2.5rem; text-align: center; margin-bottom: 8px; }

.closed-card { text-align: center; }
.warning-icon { display: block; margin: 0 auto 16px; }
.closed-heading {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0 0 10px;
}
.closed-heading-en {
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 10px;
}
.closed-contact {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 4px;
}
.closed-phone {
  display: inline-block;
  margin-top: 4px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.closed-phone:hover { text-decoration: underline; }
.closed-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}
.closed-thanks {
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.info-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}
.info-box div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.92rem; }
.info-box .label { color: var(--muted); }

nav.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}
nav.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
nav.topbar .brand-logo { height: 40px; width: auto; display: block; }

.page-header {
  display: flex;
  align-items: center;
  padding: 20px 16px 0;
}
.page-header .brand-logo { height: 56px; width: auto; display: block; }
nav.topbar a { color: var(--text); text-decoration: none; margin-left: 18px; font-size: 0.9rem; }
nav.topbar a.active { color: var(--primary); font-weight: 600; }

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

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.issued { background: #dcfce7; color: #166534; }
.badge.returned { background: #e2e8f0; color: #475569; }

.pending-row { background: #fffbeb; }
.pending-row.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: #fde68a; } 100% { background: #fffbeb; } }

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

.compact-input {
  width: 120px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.issue-btn { padding: 6px 12px; font-size: 0.85rem; }
.return-form { display: inline-block; margin-left: 10px; }

.search-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 20px; }
.search-form .field { display: flex; flex-direction: column; }
.search-form label { margin: 0 0 4px; }
.search-form input { padding: 8px 10px; }

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

.card-code { font-family: "SFMono-Regular", Consolas, monospace; font-weight: 700; }

.permission-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 16px; }
.permission-item { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 0.88rem; margin: 0; }
.permission-item input { width: 15px; height: 15px; }

.permission-form .permission-list, .reset-form { margin: 0 0 8px; }
.reset-form { display: flex; gap: 6px; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button { flex: 1; }
.reset-form input { padding: 6px 8px; }
/* ================= Khao sat muc do hai long ================= */
textarea { font-family: inherit; resize: vertical; min-height: 90px; }
select { background: #fff; font-family: inherit; }

.container.survey { max-width: 760px; }

.survey-head { text-align: center; margin-bottom: 18px; }
.survey-kicker {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  background: #e6f4f1;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.survey-title { font-size: 1.35rem; text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.35; }
.survey-intro { color: #334155; font-size: 0.95rem; line-height: 1.6; margin: 0 0 6px; }
.survey-intro p { margin: 0 0 8px; }

.form-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 26px 0 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.req { color: var(--danger); }

.q-block {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfd;
  transition: border-color 0.15s, background 0.15s;
}
.q-block.answered { border-color: #99d5cb; background: #f5fbfa; }
.q-block.missing { border-color: #fca5a5; background: #fef7f7; }
.q-text { display: flex; gap: 10px; font-weight: 600; line-height: 1.5; margin: 0 0 12px; }
.q-num {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.rating-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rating-opt { position: relative; margin: 0; font-weight: 500; }
.rating-opt input { position: absolute; opacity: 0; pointer-events: none; }
.rating-opt span {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 48px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
  line-height: 1.3;
  cursor: pointer;
  transition: all 0.12s;
}
.rating-opt span::before {
  content: "";
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  margin-right: 8px;
  background: #fff;
}
.rating-opt:hover span { border-color: var(--primary); }
.rating-opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }
.rating-opt input:checked + span { border-color: var(--primary); background: #e6f4f1; color: var(--primary-dark); font-weight: 700; }
.rating-opt input:checked + span::before { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 2px #fff; }
@media (max-width: 640px) {
  .rating-row { grid-template-columns: 1fr; gap: 6px; }
  .rating-opt span { justify-content: flex-start; min-height: 42px; padding: 8px 12px; }
}

.survey-progress {
  position: sticky;
  bottom: 0;
  margin: 20px -24px -24px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.survey-progress .bar { flex: 1; height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.survey-progress .bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }
.survey-progress .count { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.survey-progress button { margin: 0; white-space: nowrap; }
.survey-closing { text-align: center; color: var(--muted); font-style: italic; margin: 18px 0 0; }

.survey-pick { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.survey-pick a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.survey-pick a:hover { border-color: var(--primary); background: #f5fbfa; }
.survey-pick small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* ---- Admin ---- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.stat .v { font-size: 1.7rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 0.9rem; color: var(--muted); font-weight: 600; }

.dist { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--border); min-width: 180px; }
.dist i { display: block; height: 100%; }
.s5 { background: #0f766e; } .s4 { background: #5eb8a8; } .s3 { background: #cbd5e1; } .s2 { background: #f59e0b; } .s1 { background: #dc2626; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.8rem; color: var(--muted); margin: 0 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.center, th.center { text-align: center; }
.score-pill { display: inline-block; min-width: 24px; padding: 1px 6px; border-radius: 6px; text-align: center; font-weight: 700; font-size: 0.82rem; }
.score-pill.p5 { background: #ccebe6; color: #0b5a53; }
.score-pill.p4 { background: #e3f3ef; color: #115e59; }
.score-pill.p3 { background: #eef2f6; color: #475569; }
.score-pill.p2 { background: #fef3c7; color: #92400e; }
.score-pill.p1 { background: #fee2e2; color: #991b1b; }
.q-cell { max-width: 520px; line-height: 1.45; }
.muted { color: var(--muted); }
.link-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.link-box code { background: #f1f5f9; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 0.85rem; word-break: break-all; }
.toolbar-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: #e6f4f1; }
.comment-cell { max-width: 320px; white-space: pre-wrap; font-size: 0.85rem; }
.q-editor-item { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }
.q-editor-item .q-num { margin-top: 10px; }
.q-editor-item textarea { min-height: 54px; flex: 1; }
.q-editor-actions { display: flex; flex-direction: column; gap: 4px; }
.q-editor-actions button { padding: 4px 8px; font-size: 0.8rem; background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.q-editor-actions button:hover { background: #e2e8f0; }
.q-editor-actions button.del { color: var(--danger); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #16a34a; margin-right: 6px; box-shadow: 0 0 0 3px #dcfce7; }
.flash-row { animation: flashrow 1.6s ease; }
@keyframes flashrow { 0% { background: #ccfbf1; } 100% { background: transparent; } }
.notice { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; padding: 10px 14px; border-radius: 8px; font-size: 0.9rem; margin-bottom: 16px; }
.card + .card, .card + h2 { margin-top: 20px; }
nav.topbar { flex-wrap: wrap; gap: 8px; }

/* ---- Nen trang khao sat cong khai: anh YTECO "Khach hang la dong luc..." ----
   Anh nen phu kin man hinh, co dinh khi cuon (dung lop fixed rieng thay vi
   background-attachment: fixed vi iOS Safari khong ho tro). Khung phieu dat
   thap xuong de lo logo + khau hieu goc tren ben trai cua anh. */
body.banner-bg {
  min-height: 100vh;
  background: #cfe8fb;
}
.survey-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url('survey-bg.jpg?v=1') left top / cover no-repeat;
}
.banner-bg .container {
  position: relative;
  padding-top: clamp(170px, 22vw, 300px);
}
.banner-bg .card {
  border: none;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 60px rgba(10, 50, 90, 0.22);
}
@media (max-width: 640px) {
  .survey-bg { background-position: 4% top; }
  .banner-bg .container { padding-top: 285px; }
}

/* ---- Nen giao dien quan tri: cung anh nen, phu lop trang mo de bang/so lieu
   van de doc; thanh menu trong suot nhe (hieu ung kinh mo). ---- */
.admin-bg-layer {
  background-position: right bottom;
  background-size: auto 150%; /* day phan logo + khau hieu ra ngoai man hinh */
  filter: blur(3px);
  transform: scale(1.04); /* tranh vien mo o mep khi blur */
}
.admin-bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(244, 248, 252, 0.55) 0%, rgba(244, 248, 252, 0.6) 50%, rgba(244, 248, 252, 0.7) 100%);
}
body:has(.admin-bg-layer) { background: #eef5fb; }
.admin-bg-layer ~ nav.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom-color: rgba(226, 232, 240, 0.8);
}
body:has(.admin-bg-layer) .card,
body:has(.admin-bg-layer) .stat {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 24px rgba(15, 60, 90, 0.08);
}
