/* ==========================================================================
   STYLING CHUẨN TRANG KHẢO SÁT & QUẢN TRỊ CÁN BỘ - HÀNH CHÍNH CÔNG
   ========================================================================== */

:root {
  --primary-color: #0f2942;       /* Deep Executive Navy */
  --primary-hover: #1e3a5f;
  --accent-red: #da251d;          /* Vietnam Flag Red */
  --accent-gold: #f59e0b;         /* Gold Star */
  --accent-gold-light: #fef3c7;
  --success-color: #10b981;       /* Emerald Green */
  --success-light: #ecfdf5;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
  --border-hover: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(15,41,66,0.08);
  --shadow-lg: 0 12px 30px rgba(15,41,66,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* Base Resets */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.hidden,
.app-page.hidden,
.modal-backdrop.hidden,
.modal-overlay.hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html {
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Compact Utility Bar */
.utility-bar {
  background-color: var(--primary-color);
  color: #ffffff;
  padding: 0.55rem 0;
  font-size: 0.8rem;
  border-bottom: 2px solid var(--accent-red);
}
.utility-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.agency-badge {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}
.agency-logo-img {
  height: 48px;
  width: 48px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 50%;
  padding: 2px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}
.agency-badge-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.18;
  text-align: left;
  min-width: 0;
}
.badge-dept-line {
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff; /* Trắng sáng trang nghiêm */
  letter-spacing: 0.35px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.18;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.badge-unit-line {
  font-size: 0.88rem;
  font-weight: 800;
  color: #ffffff; /* Trắng sáng đồng bộ */
  letter-spacing: 0.45px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.18;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.badge-slogan-line {
  font-size: 0.68rem;
  font-weight: 700;
  color: #fbbf24; /* Vàng kim nổi bật rực rỡ */
  letter-spacing: 0.6px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.18;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.star-icon {
  color: var(--accent-gold);
  font-size: 1rem;
}
.utility-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-text-mobile {
  display: none;
}
.btn-text-desktop {
  display: inline;
}

.btn-utility {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--accent-gold);
  color: var(--primary-color);
  border: none;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-utility:hover {
  background: #eab308;
  transform: translateY(-1px);
}
.btn-utility.logged-in {
  background: #10b981;
  color: #ffffff;
}

/* Compact Hero Banner */
.hero-header {
  background: linear-gradient(135deg, #0f2942 0%, #1e3a5f 100%);
  color: #ffffff;
  padding: 1.25rem 0 1rem;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.national-emblem {
  width: 44px;
  height: 44px;
  background: radial-gradient(circle, #da251d 60%, #b91c1c 100%);
  border: 2px solid var(--accent-gold);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(218, 37, 29, 0.4);
  margin-bottom: 0.5rem;
}
.emblem-star {
  color: var(--accent-gold);
  font-size: 1.3rem;
  line-height: 1;
}
.emblem-text {
  font-size: 0.45rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-top: -3px;
  color: var(--accent-gold);
}

.header-titles .sub-heading {
  font-size: 0.85rem;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.95;
}
.header-titles .motto {
  font-size: 0.8rem;
  font-style: italic;
  margin-top: 0.15rem;
  opacity: 0.85;
}
.divider-gold {
  width: 60px;
  height: 2px;
  background: var(--accent-gold);
  margin: 0.5rem auto;
  border-radius: 2px;
}
.main-heading {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffffff;
}
.heading-desc {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-gold-light);
  margin-top: 0.1rem;
}

/* Main Content Wrapper */
.main-wrapper {
  padding: 1.25rem 0 3rem;
  flex: 1;
}

.purpose-card {
  background: var(--card-bg);
  border-left: 4px solid var(--accent-red);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.25rem;
}
.purpose-icon {
  background: #fef2f2;
  color: var(--accent-red);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.purpose-text h3 {
  font-size: 0.95rem;
  color: var(--primary-color);
  margin-bottom: 0.15rem;
  font-weight: 700;
}
.purpose-text p {
  font-size: 0.875rem;
  color: var(--text-main);
  line-height: 1.5;
}

/* Sticky Progress Indicator */
.sticky-progress {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.3rem;
}
.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-red) 0%, var(--accent-gold) 100%);
  transition: width 0.3s ease-out;
}

/* Compact Card Section */
.card-section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-color);
  padding: 0 0.25rem;
  margin-bottom: 0.75rem;
  white-space: nowrap;
}
.step-num {
  background: var(--primary-color);
  color: #ffffff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.badge-optional {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  flex-shrink: 0;
}
.section-instruction {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Grids & Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}
.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }

@media (max-width: 640px) {
  .col-6 { grid-column: span 12; }
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--primary-color);
  margin-bottom: 0.3rem;
}
.label-heading {
  font-size: 0.9rem !important;
  margin-bottom: 0.5rem !important;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-main);
  transition: border-color 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(15, 41, 66, 0.12);
}
.inline-input {
  border: none;
  border-bottom: 2px solid var(--border-color);
  background: transparent;
  padding: 0.15rem 0.4rem;
  font-family: inherit;
  font-size: 0.875rem;
  width: 60%;
  margin-left: 0.4rem;
  color: inherit;
}
.inline-input:focus {
  outline: none;
  border-color: var(--primary-color);
}
.inline-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Selection Grids */
.options-grid {
  display: grid;
  gap: 0.6rem;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.col-span-2 { grid-column: span 2; }

@media (max-width: 768px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .col-span-2 { grid-column: span 1; }
}
@media (max-width: 480px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: 1; }
}

.radio-card, .checkbox-card {
  position: relative;
  cursor: pointer;
  user-select: none;
  display: block;
}
.radio-card input[type="radio"], 
.checkbox-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.card-box {
  display: flex;
  align-items: center;
  padding: 0.65rem 0.85rem;
  min-height: 44px;
  background: #f8fafc;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-main);
  transition: all 0.15s ease;
}
.card-boxhighlight {
  display: flex;
  align-items: center;
  padding: 0.65rem 0.85rem;
  min-height: 44px;
  background: #fffbe6;
  border: 1.5px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--primary-color);
}

/* Card Active/Checked Selection States */
.card-box {
  transition: all 0.2s ease;
}
.card-box:hover {
  border-color: #0284c7;
  background-color: #f0f9ff;
}

.card-box:has(input:checked),
.card-box.is-selected,
.radio-card:has(input:checked),
.checkbox-card:has(input:checked) {
  background-color: #e0f2fe !important;
  border-color: #0284c7 !important;
  color: #0369a1 !important;
  font-weight: 700 !important;
  box-shadow: 0 3px 10px rgba(2, 132, 199, 0.18) !important;
}

.radio-card input:checked + .card-box,
.checkbox-card input:checked + .card-box {
  border-color: #0284c7 !important;
  background: #e0f2fe !important;
  color: #0369a1 !important;
  font-weight: 700 !important;
}

/* Inline Input Box inside "Khác:" cards */
.card-box-other {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
}
.card-label-inner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}
.card-label-inner input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.form-control-inline {
  position: relative !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  flex: 1;
  width: 100%;
  min-width: 120px;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff !important;
  color: var(--text-main) !important;
  font-weight: 400;
  transition: all 0.2s ease;
  z-index: 5;
}
.card-box:has(input:checked) .form-control-inline,
.card-box.is-selected .form-control-inline {
  border-color: #0284c7 !important;
  background-color: #ffffff !important;
  color: #0f172a !important;
}
.form-control-inline:focus {
  outline: none;
  border-color: #0284c7 !important;
  background-color: #ffffff !important;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25) !important;
}

/* Category Box for TTHC */
.tthc-category-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}
.category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid #e2e8f0;
}
.category-badge {
  background: var(--accent-red);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.category-header h4 {
  font-size: 0.95rem;
  color: var(--primary-color);
  font-weight: 700;
}
.tthc-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tthc-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: #ffffff;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}
.tthc-item:hover {
  border-color: #0284c7;
  background: #f0f9ff;
}
.tthc-item:has(input:checked),
.tthc-item.is-selected {
  border-color: #0284c7 !important;
  background: #e0f2fe !important;
  color: #0369a1 !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.12) !important;
}

.tthc-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: #0284c7;
  cursor: pointer;
  flex-shrink: 0;
}
.tthc-text {
  font-size: 0.875rem;
  line-height: 1.45;
}

/* Rating Scale */
.rating-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}
@media (max-width: 600px) {
  .rating-scale { grid-template-columns: 1fr; }
}
.rating-item {
  position: relative;
  cursor: pointer;
  text-align: center;
}
.rating-item input {
  position: absolute;
  opacity: 0;
}
.rating-box, .rating-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.4rem;
  background: #f8fafc;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}
.rating-box .emoji, .rating-card .emoji {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}
.rating-box .text, .rating-card .text {
  font-size: 0.8rem;
  font-weight: 600;
}
.rating-item input:checked + .rating-box,
.rating-card:has(input:checked),
.rating-card.is-selected {
  border-color: #eab308 !important;
  background: #fef08a !important;
  color: #854d0e !important;
  font-weight: 800 !important;
  box-shadow: 0 4px 14px rgba(234, 179, 8, 0.3) !important;
  transform: translateY(-2px);
}

.question-block {
  margin-bottom: 1.25rem;
}
.q-title {
  font-size: 0.925rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.65rem;
}
.mt-3 { margin-top: 0.65rem; }
.mt-4 { margin-top: 1.25rem; }
.hidden { display: none !important; }
.text-left { text-align: left; }
.w-full { width: 100%; }

.sub-input-box {
  background: #fffbe6;
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
}

/* Commitment & Submit */
.commitment-box {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  color: #065f46;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}
.commitment-box svg {
  color: var(--success-color);
  flex-shrink: 0;
  margin-top: 2px;
}

.submit-actions {
  display: flex;
  gap: 0.85rem;
  justify-content: center;
  align-items: center;
}
.btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--accent-red) 0%, #b91c1c 100%);
  color: #ffffff;
  border: none;
  padding: 0.85rem 2rem;
  font-size: 1rem;
  font-weight: 800;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(218, 37, 29, 0.3);
  transition: all 0.2s ease;
}
.btn-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(218, 37, 29, 0.4);
}
.btn-reset {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
}

/* Detail Modal Layout */
.detail-body-wrapper {
  overflow-y: auto;
  max-height: 70vh;
  padding-right: 0.5rem;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1rem;
}
@media (max-width: 600px) {
  .detail-grid { grid-template-columns: 1fr; }
}
.detail-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
}
.detail-box.full-width {
  grid-column: span 2;
}
@media (max-width: 600px) {
  .detail-box.full-width { grid-column: span 1; }
}
.detail-box-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}
.detail-box-val {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-color);
}
.detail-list-item {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--primary-color);
  padding: 0.4rem 0.7rem;
  margin-top: 0.35rem;
  border-radius: 4px;
  font-size: 0.85rem;
}
.text-right { text-align: right; }

/* Modals System */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  /* dvh follows the real visible area on mobile, so the browser address bar
     can never sit on top of the modal's action buttons. */
  height: 100dvh;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  position: relative;
  animation: modalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  /* Any modal taller than the screen scrolls inside itself instead of
     having its lower half clipped away. */
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal-sm {
  max-width: 380px !important;
}
.modal-lg {
  max-width: 920px !important;
  text-align: left !important;
  padding: 1.25rem !important;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* Staff Login Modal Specifics */
.modal-header-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 0.5rem;
}
.login-badge {
  font-size: 2.2rem;
  margin-bottom: 0.25rem;
}
.modal-header-login h2 {
  font-size: 1.25rem;
  color: var(--primary-color);
  font-weight: 800;
}
.login-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.login-error-msg {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 0.75rem;
}

/* Success Modal Details */
.success-icon-wrapper {
  margin: 0 auto 1rem;
  width: 60px;
  height: 60px;
}
.checkmark__circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke: var(--success-color);
  fill: none;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: block;
  stroke-width: 3;
  stroke: #fff;
  stroke-miterlimit: 10;
  box-shadow: inset 0px 0px 0px var(--success-color);
  animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
@keyframes stroke { 100% { stroke-dashoffset: 0; } }
@keyframes scale { 0%, 100% { transform: none; } 50% { transform: scale3d(1.1, 1.1, 1); } }
@keyframes fill { 100% { box-shadow: inset 0px 0px 0px 40px var(--success-color); } }

.modal-card h2 {
  font-size: 1.35rem;
  color: var(--primary-color);
  margin-bottom: 0.4rem;
  font-weight: 800;
}
.success-msg {
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.85rem;
}
.survey-ref-code {
  display: inline-block;
  background: var(--accent-gold-light);
  color: #92400e;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border: 1px dashed var(--accent-gold);
}
.sub-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.btn-primary {
  background: var(--primary-color);
  color: #fff;
  border: none;
  padding: 0.7rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

/* Admin Modal Header & Actions */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.modal-header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.modal-header h3 {
  font-size: 1.05rem;
  color: var(--primary-color);
  font-weight: 800;
}
.badge-staff-status {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.btn-logout {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-logout:hover {
  background: #fee2e2;
}
.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0.85rem 0;
  border-bottom: 2px solid var(--border-color);
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  margin-bottom: -2px;
}
.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--accent-red);
}

.tab-content {
  display: none;
  overflow-y: auto;
  flex: 1;
  padding-top: 0.35rem;
}
.tab-content.active {
  display: block;
}

/* QR Code & Poster Panel */
.qr-creator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: flex-start;
}
@media (max-width: 768px) {
  .qr-creator-grid { grid-template-columns: 1fr; }
}

.qr-config-panel {
  background: #f8fafc;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}
.qr-config-panel h4 {
  font-size: 0.95rem;
  color: var(--primary-color);
  margin-bottom: 0.85rem;
  font-weight: 700;
}
.help-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  display: block;
}
.action-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--primary-color);
  padding: 0.65rem 1rem;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-secondary:hover {
  background: #f1f5f9;
}

/* Printable Poster */
.poster-preview-panel {
  display: flex;
  justify-content: center;
}
.poster-card {
  width: 100%;
  max-width: 360px;
  background: #ffffff;
  border: 3px solid var(--primary-color);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  text-align: center;
}
.poster-banner-top {
  background: var(--primary-color);
  color: #ffffff;
  padding: 0.85rem 0.6rem;
}
.poster-star {
  color: var(--accent-gold);
  font-size: 1.2rem;
  line-height: 1;
  margin-bottom: 2px;
}
.poster-header-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 0.25rem 0 0.15rem;
}
.poster-dept-line {
  font-size: 0.825rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  line-height: 1.25;
}
.poster-unit-line {
  font-size: 1.15rem;
  font-weight: 900;
  color: #fbbf24; /* Vàng kim sang trọng */
  letter-spacing: 0.6px;
  text-transform: uppercase;
  line-height: 1.2;
}
.poster-agency-sub {
  font-size: 0.75rem;
  color: var(--accent-gold);
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-top: 3px;
}
.poster-banner-top h3 {
  font-size: 1rem;
  font-weight: 800;
}
.poster-body {
  padding: 1rem 0.85rem;
}
.poster-body h2 {
  font-size: 1.05rem;
  color: var(--accent-red);
  font-weight: 800;
  line-height: 1.3;
}
.poster-divider {
  height: 2px;
  background: var(--accent-gold);
  width: 50px;
  margin: 0.4rem auto;
}
.poster-guide {
  font-size: 0.8rem;
  color: var(--text-main);
  line-height: 1.35;
  margin-bottom: 0.85rem;
}

.qr-code-box {
  background: #ffffff;
  padding: 1.25rem;
  border: 3px dashed var(--primary-color);
  border-radius: 1.2rem;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2.5rem;
  position: relative;
}
#qrcodeCanvas canvas, #qrcodeCanvas img {
  width: 180px !important;
  height: 180px !important;
  display: block;
}
.qr-scan-badge {
  background: #dc2626;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 8px 20px;
  border-radius: 30px;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translate(-50%, -15%);
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}
.poster-footer-notes .note-highlight {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-color);
}
.poster-footer-notes .note-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Dashboard Panel Controls & Filters */
.dashboard-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.dash-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.table-responsive {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.data-table th, .data-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}
.data-table th {
  background: #f1f5f9;
  color: var(--primary-color);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 10;
}
.data-table tbody tr:hover {
  background: #f8fafc;
}
.data-table tbody tr.row-selected {
  background: #bae6fd !important;
}
.data-table tbody tr.row-selected td {
  border-bottom-color: #7dd3fc !important;
}
.badge-target {
  background: #e2e8f0;
  color: var(--primary-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.725rem;
  font-weight: 600;
}
.btn-sm-view {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-sm-view:hover { background: #bae6fd; }

/* Executive Theme Toggle Button */
.btn-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Executive KPI Grid Cards */
.stat-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 900px) {
  .stat-summary-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .stat-summary-grid { grid-template-columns: 1fr; }
}

.stat-kpi-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}
.stat-kpi-card:hover {
  transform: translateY(-2px);
}
.stat-kpi-card.border-navy { border-left: 4px solid var(--primary-color); }
.stat-kpi-card.border-gold { border-left: 4px solid var(--accent-gold); }
.stat-kpi-card.border-emerald { border-left: 4px solid var(--success-color); }
.stat-kpi-card.border-rose { border-left: 4px solid #f43f5e; }

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.bg-navy-light { background: #e0f2fe; color: #0369a1; }
.bg-gold-light { background: #fef3c7; color: #b45309; }
.bg-emerald-light { background: #d1fae5; color: #047857; }
.bg-rose-light { background: #ffe4e6; color: #be123c; }

.kpi-details {
  display: flex;
  flex-direction: column;
}
.kpi-title {
  font-size: 0.725rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.kpi-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary-color);
  line-height: 1.2;
}
.kpi-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Charts Wrapper & Cards */
.charts-wrapper {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 768px) {
  .charts-wrapper { grid-template-columns: 1fr; }
}

.chart-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #f1f5f9;
}
.chart-header h4 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary-color);
}
.chart-badge {
  font-size: 0.7rem;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.chart-body {
  position: relative;
  height: 220px;
  width: 100%;
}

/* Intelligent Analytics & Action Plan Cards */
.analytics-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
  flex-wrap: wrap;
  gap: 0.75rem;
}
.analytics-title-group h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-color);
}
.analytics-title-group p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.analytics-section-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
}
.card-title-icon {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}
.card-title-icon .icon { font-size: 1.25rem; }
.card-title-icon h4 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary-color);
}

.summary-paragraph {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-main);
}
.summary-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.highlight-chip {
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}
.chip-gold { background: #fef3c7; color: #92400e; }
.chip-emerald { background: #d1fae5; color: #065f46; }
.chip-navy { background: #e0f2fe; color: #0369a1; }

.bottlenecks-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}
@media (max-width: 768px) {
  .bottlenecks-grid { grid-template-columns: 1fr; }
}

.alert-card {
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.alert-red { background: #fef2f2; border-left: 4px solid #ef4444; color: #991b1b; }
.alert-amber { background: #fffbe6; border-left: 4px solid #f59e0b; color: #92400e; }
.alert-blue { background: #f0f9ff; border-left: 4px solid #0284c7; color: #075985; }

.alert-title { font-weight: 800; margin-bottom: 0.25rem; }
.alert-desc { font-size: 0.8rem; opacity: 0.9; line-height: 1.45; }

.recommendations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (max-width: 768px) {
  .recommendations-grid { grid-template-columns: 1fr; }
}

.rec-card {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
}
.rec-card.border-blue { border-top: 4px solid #3b82f6; }
.rec-card.border-gold { border-top: 4px solid #f59e0b; }
.rec-card.border-emerald { border-top: 4px solid #10b981; }
.rec-card.border-purple { border-top: 4px solid #8b5cf6; }

.rec-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.65rem;
}
.rec-badge {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--primary-color);
  letter-spacing: 0.5px;
  background: #e2e8f0;
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  align-self: flex-start;
}
.rec-header h5 {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--primary-color);
}
.rec-list {
  padding-left: 1.1rem;
  font-size: 0.825rem;
  color: var(--text-main);
  line-height: 1.5;
}
.rec-list li { margin-bottom: 0.4rem; }

.suggestions-list-box {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 280px;
  overflow-y: auto;
}
.suggestion-item {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
}
.sug-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}
.sug-time { color: var(--text-muted); font-weight: 400; }
.sug-content { font-size: 0.85rem; font-style: italic; color: #b91c1c; margin-bottom: 0.35rem; }
.sug-footer { display: flex; gap: 0.4rem; }
.badge-mini {
  font-size: 0.7rem;
  background: #e2e8f0;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* Filter Controls Bar */
.filter-controls-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1;
}
.search-box { min-width: 180px; flex: 1; }
.filter-dropdown select {
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
}
.form-control-sm {
  padding: 0.35rem 0.6rem !important;
  font-size: 0.8rem !important;
  height: 34px;
}
.btn-sm {
  padding: 0.35rem 0.65rem !important;
  font-size: 0.775rem !important;
}

/* Dark Mode Overrides */
#modalAdmin.dark-theme .modal-card {
  background-color: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
}
#modalAdmin.dark-theme .modal-header {
  border-bottom-color: #334155;
}
#modalAdmin.dark-theme .modal-header h3 {
  color: #f8fafc;
}
#modalAdmin.dark-theme .btn-theme-toggle {
  border-color: #475569;
  color: #f8fafc;
}
#modalAdmin.dark-theme .tab-btn {
  color: #94a3b8;
}
#modalAdmin.dark-theme .tab-btn.active {
  color: #38bdf8;
  border-bottom-color: var(--accent-red);
}
#modalAdmin.dark-theme .stat-kpi-card {
  background: #1e293b;
  border-color: #334155;
}
#modalAdmin.dark-theme .kpi-title, #modalAdmin.dark-theme .kpi-sub {
  color: #94a3b8;
}
#modalAdmin.dark-theme .kpi-value {
  color: #f8fafc;
}
#modalAdmin.dark-theme .chart-card {
  background: #1e293b;
  border-color: #334155;
}
#modalAdmin.dark-theme .chart-header {
  border-bottom-color: #334155;
}
#modalAdmin.dark-theme .chart-header h4 {
  color: #f8fafc;
}
#modalAdmin.dark-theme .chart-badge {
  background: #334155;
  color: #cbd5e1;
}
#modalAdmin.dark-theme .analytics-section-card {
  background: #1e293b;
  border-color: #334155;
}
#modalAdmin.dark-theme .card-title-icon {
  border-bottom-color: #334155;
}
#modalAdmin.dark-theme .card-title-icon h4 {
  color: #f8fafc;
}
#modalAdmin.dark-theme .summary-paragraph {
  color: #cbd5e1;
}
#modalAdmin.dark-theme .rec-card {
  background: #0f172a;
  border-color: #334155;
}
#modalAdmin.dark-theme .rec-header h5 {
  color: #f8fafc;
}
#modalAdmin.dark-theme .rec-list {
  color: #cbd5e1;
}
#modalAdmin.dark-theme .suggestion-item {
  background: #0f172a;
  border-color: #334155;
}
#modalAdmin.dark-theme .sug-header {
  color: #38bdf8;
}
#modalAdmin.dark-theme .data-table th {
  background: #1e293b;
  color: #f8fafc;
  border-bottom-color: #334155;
}
#modalAdmin.dark-theme .data-table td {
  border-bottom-color: #334155;
  color: #cbd5e1;
}
#modalAdmin.dark-theme .data-table tbody tr:hover {
  background: #334155;
}
#modalAdmin.dark-theme .qr-config-panel {
  background: #1e293b;
  border-color: #334155;
}
#modalAdmin.dark-theme .qr-config-panel h4 {
  color: #f8fafc;
}
#modalAdmin.dark-theme .form-control {
  background: #0f172a;
  color: #f8fafc;
  border-color: #334155;
}

/* Footer */
.footer {
  background: var(--primary-color);
  color: #cbd5e1;
  text-align: center;
  padding: 1.15rem 0;
  font-size: 0.8rem;
  border-top: 3px solid var(--accent-gold);
}

#citizenFooterSub {
  color: var(--accent-gold);
  font-weight: 800;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 0.4rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* MOBILE RESPONSIVE ENHANCEMENTS */
@media (max-width: 640px) {
  .container { padding: 0 0.6rem; }
  .hero-header { padding: 1rem 0 0.85rem; }
  .main-heading { font-size: 1.2rem; }
  .heading-desc { font-size: 0.8rem; }
  .card-section { padding: 0.9rem 0.85rem; margin-bottom: 0.9rem; }
  .section-title { font-size: 0.95rem; }

  /* Mobile Touch Targets */
  .card-box, .tthc-item, .btn-utility, .btn-submit, .btn-primary, .btn-secondary, .tab-btn {
    min-height: 46px;
  }
  
  .submit-actions { flex-direction: column; width: 100%; }
  .btn-submit, .btn-reset { width: 100%; text-align: center; }

  .modal-lg { padding: 0.85rem !important; }
  .modal-tabs { flex-wrap: wrap; }
  .tab-btn { flex: 1; min-width: 120px; justify-content: center; padding: 0.4rem 0.6rem; font-size: 0.775rem; }
  
  .filter-controls-bar { flex-direction: column; align-items: stretch; }
  .search-box, .filter-dropdown { width: 100%; }
}

/* ==========================================================================
   FULL-PAGE ADMINISTRATIVE EXECUTIVE DASHBOARD & SIDEBAR STYLES
   ========================================================================== */

/* Page View Visibility */
.app-page {
  width: 100%;
  min-height: 100vh;
  transition: opacity 0.25s ease;
}
.app-page.hidden {
  display: none !important;
}

/* Administrative Full Dashboard Layout */
.admin-dashboard-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background: #f8fafc;
  color: var(--text-main);
  font-family: 'Be Vietnam Pro', sans-serif;
}

/* Left Sidebar Navigation */
.admin-sidebar {
  width: 270px;
  flex-shrink: 0;
  background: #0f2942;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
}

.sidebar-top {
  padding: 1.25rem 1rem;
}

/* Sidebar Branding */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 1rem;
}
.brand-star {
  font-size: 1.5rem;
  color: var(--accent-gold);
  line-height: 1;
}
.brand-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.3px;
  line-height: 1.2;
}
.brand-sub {
  font-size: 0.7rem;
  color: #94a3b8;
  display: block;
  margin-top: 2px;
}

/* User Status Badge */
.sidebar-user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.4rem 0.75rem;
  border-radius: 20px;
  font-size: 0.725rem;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 1.25rem;
}
.badge-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

/* Sidebar Menu Navigation */
.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.menu-label {
  font-size: 0.675rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  padding-left: 0.5rem;
}

.sidebar-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}
.sidebar-nav-item.active {
  background: linear-gradient(135deg, #da251d 0%, #b91c1c 100%);
  color: #ffffff;
  font-weight: 700;
  border-color: #ef4444;
  box-shadow: 0 4px 14px rgba(218, 37, 29, 0.4);
}
.sidebar-nav-item svg {
  flex-shrink: 0;
}

.sidebar-nav-item.item-accent {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px dashed rgba(56, 189, 248, 0.45);
}
.sidebar-nav-item.item-accent:hover {
  background: rgba(56, 189, 248, 0.25);
  color: #ffffff;
  border-color: #38bdf8;
}

/* Sidebar Footer Controls */
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-sidebar-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.btn-sidebar-control:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn-sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.btn-sidebar-logout:hover {
  background: #ef4444;
  color: #ffffff;
}

/* Right Main Area */
.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  height: 54px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  white-space: nowrap;
  gap: 0.75rem;
}
.topbar-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}
.topbar-left h2 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-color);
  margin: 0;
  white-space: nowrap;
}
.topbar-clock {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  padding-left: 0.6rem;
  border-left: 1px solid #e2e8f0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 0;
}

.admin-content-body {
  flex: 1;
  padding: 1.5rem 1.75rem;
  background: #f8fafc;
}

/* Dark Theme Styles for Full Page Admin */
body.dark-theme .admin-dashboard-layout {
  background: #0f172a;
  color: #f8fafc;
}
body.dark-theme .admin-sidebar {
  background: #091322;
  border-right-color: #1e293b;
}
body.dark-theme .admin-topbar {
  background: #1e293b;
  border-bottom-color: #334155;
  color: #f8fafc;
}
body.dark-theme .topbar-left h2 {
  color: #f8fafc;
}
body.dark-theme .topbar-clock {
  color: #94a3b8;
}
body.dark-theme .admin-content-body {
  background: #0f172a;
}
body.dark-theme .stat-kpi-card {
  background: #1e293b;
  border-color: #334155;
}
body.dark-theme .stat-kpi-card .kpi-value {
  color: #f8fafc;
}
body.dark-theme .chart-card {
  background: #1e293b;
  border-color: #334155;
}
body.dark-theme .chart-header {
  border-bottom-color: #334155;
}
body.dark-theme .chart-header h4 {
  color: #f8fafc;
}
body.dark-theme .analytics-section-card {
  background: #1e293b;
  border-color: #334155;
}
body.dark-theme .card-title-icon h4 {
  color: #f8fafc;
}
body.dark-theme .summary-paragraph {
  color: #cbd5e1;
}
body.dark-theme .rec-card {
  background: #0f172a;
  border-color: #334155;
}
body.dark-theme .rec-header h5 {
  color: #f8fafc;
}
body.dark-theme .rec-list {
  color: #cbd5e1;
}
body.dark-theme .suggestion-item {
  background: #0f172a;
  border-color: #334155;
}
body.dark-theme .data-table th {
  background: #1e293b;
  color: #f8fafc;
  border-bottom-color: #334155;
}
body.dark-theme .data-table td {
  border-bottom-color: #334155;
  color: #cbd5e1;
}
body.dark-theme .data-table tbody tr:hover {
  background: #334155;
}

/* Mobile & Responsive Modern Sidebar Styling */
@media (max-width: 900px) {
  .admin-dashboard-layout {
    flex-direction: column;
  }
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 2px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 0.75rem;
  }
  .sidebar-top {
    padding: 1rem 0.85rem;
  }
  .sidebar-menu {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .menu-label {
    width: 100%;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
  }
  .sidebar-nav-item {
    width: auto;
    flex: 1 1 auto;
    justify-content: center;
    padding: 0.55rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 20px;
  }
  .sidebar-footer {
    flex-direction: row;
    padding: 0.5rem 0.85rem;
  }
  .btn-sidebar-control, .btn-sidebar-logout {
    flex: 1;
    border-radius: 20px;
  }
  .admin-topbar {
    padding: 0.85rem 1rem;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .admin-content-body {
    padding: 1rem 0.85rem;
  }
}

/* Validation Modal & Warning Styling */
.warning-icon {
  font-size: 3rem;
  line-height: 1;
}
.text-gold {
  color: #d97706;
}
.validation-missing-box {
  background: #fffbe6;
  border: 1.5px solid #fde047;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.1rem;
  max-height: 220px;
  overflow-y: auto;
}
.validation-missing-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0;
  font-size: 0.9rem;
  color: #92400e;
  font-weight: 600;
  border-bottom: 1px dashed #fef08a;
}
.validation-missing-item:last-child {
  border-bottom: none;
}
.validation-missing-item .bullet {
  color: #d97706;
  font-size: 1rem;
}

/* Highlight section animation when redirected */
@keyframes sectionPulse {
  0% { box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.7); }
  50% { box-shadow: 0 0 0 10px rgba(2, 132, 199, 0.25); }
  100% { box-shadow: 0 0 0 0 rgba(2, 132, 199, 0); }
}
.highlight-missing-section {
  animation: sectionPulse 1.2s ease 2;
  border-color: #0284c7 !important;
}

/* Cloud JSON Sync & Accent Buttons */
.cloud-sync-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.775rem;
  font-weight: 700;
  margin-right: 0.5rem;
}
.sync-dot {
  font-size: 0.85rem;
  color: #10b981;
  animation: pulseDot 1.5s infinite;
}
.sync-dot.syncing {
  color: #f59e0b;
}
.sync-dot.error {
  color: #ef4444;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.btn-xs-sync {
  background: transparent;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 2px;
  transition: transform 0.3s ease;
}
.btn-xs-sync:hover {
  transform: rotate(180deg);
}
.btn-accent-gold {
  background: #fef3c7 !important;
  color: #92400e !important;
  border-color: #fde68a !important;
}
.btn-accent-gold:hover {
  background: #fde68a !important;
}
/* ==========================================================================
   COMPREHENSIVE SMARTPHONE & MOBILE RESPONSIVE OPTIMIZATION SUITE
   ========================================================================== */

/* Universal Touch & Mobile Engine Fixes */
html, body {
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button, input, select, textarea, .card-box, .rating-opt-card {
  touch-action: manipulation;
}

@media (max-width: 768px) {
  /* Prevent iOS Safari from auto-zooming on input focus */
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="email"],
  select,
  textarea,
  .form-control {
    font-size: 16px !important;
  }
}

/* Tablets & Large Phones (max-width: 768px) */
@media (max-width: 768px) {
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .admin-dashboard-layout {
    flex-direction: column;
  }

  .stat-summary-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  .charts-wrapper,
  .bottlenecks-grid,
  .recommendations-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid var(--border-color);
  }
}

/* Smartphone & Standard Mobile View (max-width: 640px) */
@media (max-width: 640px) {
  .container {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
  }

  /* Utility Bar */
  .utility-bar {
    padding: 0.35rem 0;
  }
  .utility-container {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
  }
  .agency-badge {
    font-size: 0.72rem;
    line-height: 1.25;
    font-weight: 700;
    gap: 0.4rem;
    text-align: left;
    max-width: calc(100% - 135px);
  }
  .agency-logo-img {
    height: 38px;
    width: 38px;
    object-fit: contain;
    background: #ffffff;
    border-radius: 50%;
    padding: 1.5px;
    flex-shrink: 0;
  }
  .btn-utility {
    padding: 0.35rem 0.6rem;
    font-size: 0.74rem;
    white-space: nowrap;
    border-radius: 6px;
    flex-shrink: 0;
  }

  /* Hero Header */
  .hero-header {
    padding: 1.15rem 0.5rem 1rem;
  }
  .sub-heading {
    font-size: 0.75rem;
    letter-spacing: 0.8px;
  }
  .motto {
    font-size: 0.72rem;
    margin-top: 0.1rem;
  }
  .divider-gold {
    width: 45px;
    margin: 0.4rem auto;
  }
  .main-heading {
    font-size: 1.3rem;
  }
  .heading-desc {
    font-size: 0.8rem;
    line-height: 1.35;
    margin-top: 0.15rem;
    padding: 0 0.5rem;
  }

  /* Purpose Card */
  .purpose-card {
    padding: 0.75rem 0.85rem;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
    border-radius: 10px;
  }
  .purpose-icon {
    padding: 0.4rem;
  }
  .purpose-icon svg {
    width: 22px;
    height: 22px;
  }
  .purpose-text h3 {
    font-size: 0.85rem;
    margin-bottom: 0.1rem;
  }
  .purpose-text p {
    font-size: 0.78rem;
    line-height: 1.4;
  }

  /* Sticky Progress Bar */
  .sticky-progress {
    padding: 0.45rem 0.75rem;
    margin-bottom: 0.85rem;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  .progress-info {
    font-size: 0.74rem;
    margin-bottom: 0.25rem;
  }
  .progress-bar-bg {
    height: 5px;
  }

  /* Form Section Cards */
  .card-section {
    padding: 0.85rem 0.75rem;
    margin-bottom: 0.85rem;
    border-radius: 12px;
  }
  .section-title {
    font-size: 0.92rem;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
  }
  .step-num {
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
  }
  .badge-optional {
    font-size: 0.7rem;
  }

  /* Survey Group Banners */
  .survey-group-banner {
    padding: 0.55rem 0.75rem;
    font-size: 0.78rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    line-height: 1.35;
  }

  /* Question Cards */
  .question-card-box {
    padding: 0.85rem 0.7rem;
    margin-bottom: 0.75rem;
    border-radius: 10px;
  }
  .q-header-line {
    gap: 0.45rem;
    margin-bottom: 0.65rem;
  }
  .badge-q-tag {
    font-size: 0.68rem;
    padding: 2px 6px;
    margin-top: 1px;
  }
  .q-title-text {
    font-size: 0.84rem;
    line-height: 1.4;
  }

  /* 5-Level Rating Grid on Mobile: 5 compact buttons in 1 row */
  .rating-5-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 0.3rem !important;
  }
  .rating-opt-card {
    padding: 0.5rem 0.12rem !important;
    min-height: 56px !important;
    border-radius: 8px !important;
  }
  .rating-opt-card .emoji {
    font-size: 1.3rem !important;
    margin-bottom: 2px !important;
  }
  .rating-opt-card .label-txt {
    font-size: 0.64rem !important;
    line-height: 1.15 !important;
    font-weight: 700 !important;
    letter-spacing: -0.2px !important;
    word-break: break-word !important;
  }
  .rating-opt-card:active {
    transform: scale(0.95);
  }

  /* Radio & Checkbox Card Boxes */
  .options-grid.grid-2 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.45rem !important;
  }
  .card-box {
    padding: 0.6rem 0.5rem;
    min-height: 42px;
    font-size: 0.82rem;
    justify-content: center;
    text-align: center;
    border-radius: 8px;
  }
  .card-box:active {
    transform: scale(0.97);
  }

  /* Textarea & Inputs */
  .form-group label {
    font-size: 0.82rem;
    margin-bottom: 0.25rem;
  }
  .form-control {
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
  }

  /* Submit Buttons */
  .submit-actions {
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
    margin-top: 1.25rem;
  }
  .btn-submit {
    width: 100%;
    padding: 0.85rem 1.25rem;
    font-size: 0.95rem;
    justify-content: center;
    border-radius: 28px;
  }
  .btn-submit:active {
    transform: scale(0.98);
  }
  .btn-reset {
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.82rem;
    text-align: center;
    border-radius: 28px;
  }

  /* Thankyou Banner Box */
  .thankyou-banner-box {
    padding: 0.75rem 0.85rem;
    font-size: 0.84rem;
    border-radius: 10px;
    line-height: 1.4;
  }
  .thankyou-banner-box .thankyou-icon {
    font-size: 1.25rem;
  }

  /* Footer */
  .footer {
    padding: 0.85rem 0.25rem !important;
  }
  #citizenFooterAgency {
    font-size: clamp(0.48rem, 2.4vw, 0.65rem) !important;
    white-space: nowrap !important;
    letter-spacing: 0px !important;
    line-height: 1.25 !important;
  }
  #citizenFooterSub {
    font-size: clamp(0.7rem, 3.2vw, 0.84rem) !important;
    letter-spacing: 1px !important;
    margin-top: 0.25rem !important;
  }

  /* Modals on Mobile */
  .modal-backdrop {
    padding: 0.75rem !important;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom)) !important;
    align-items: flex-start !important;
  }
  .modal-card {
    width: 100% !important;
    max-width: 100% !important;
    padding: 1.35rem 1rem !important;
    border-radius: 16px !important;
    max-height: calc(100vh - 1.5rem) !important;
    max-height: calc(100dvh - 1.5rem) !important;
    overflow-y: auto !important;
    margin: auto 0 !important;
  }
  .modal-card.modal-lg {
    padding: 1rem 0.85rem !important;
  }
  .detail-grid {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }
  .detail-box.full-width {
    grid-column: span 1 !important;
  }
  .btn-close-modal {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.4rem !important;
    line-height: 1 !important;
  }

  /* Admin Sidebar on Mobile */
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 2px solid rgba(255, 255, 255, 0.12);
    padding: 0.65rem 0.75rem 0.75rem;
  }
  .sidebar-top {
    padding: 0;
  }
  .sidebar-brand {
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
  }
  .sidebar-menu {
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 0.35rem;
    padding-bottom: 0.35rem;
    scrollbar-width: none;
  }
  .sidebar-menu::-webkit-scrollbar {
    display: none;
  }
  .menu-label {
    display: none !important;
  }
  .sidebar-nav-item {
    width: auto;
    flex-shrink: 0;
    padding: 0.5rem 0.8rem;
    font-size: 0.78rem;
    border-radius: 20px;
  }
  .sidebar-footer {
    flex-direction: row;
    padding: 0.5rem 0 0;
    gap: 0.4rem;
  }
  .btn-sidebar-control, .btn-sidebar-logout {
    flex: 1;
    border-radius: 20px;
    padding: 0.45rem 0.55rem;
    font-size: 0.74rem;
  }

  .admin-topbar {
    padding: 0.65rem 0.85rem;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }
  .admin-content-body {
    padding: 0.85rem 0.65rem;
  }

  .filter-controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }
  .search-box, .filter-dropdown {
    width: 100%;
  }

  .qr-creator-grid {
    grid-template-columns: 1fr !important;
  }
  .poster-preview-panel {
    padding: 0.75rem;
  }
}

/* Extra Small Phones (max-width: 380px) */
@media (max-width: 380px) {
  .rating-5-grid {
    gap: 0.2rem !important;
  }
  .rating-opt-card {
    padding: 0.45rem 0.08rem !important;
    min-height: 52px !important;
  }
  .rating-opt-card .emoji {
    font-size: 1.15rem !important;
  }
  .rating-opt-card .label-txt {
    font-size: 0.58rem !important;
    line-height: 1.1 !important;
  }
  .agency-badge {
    font-size: 0.66rem !important;
  }
  .main-heading {
    font-size: 1.15rem !important;
  }
}

/* 14-Question Survey Specific Styling & Group Banners */
.survey-group-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}
.banner-group-a { background: linear-gradient(135deg, #0f2942 0%, #1e3a5f 100%); border-left: 5px solid #38bdf8; }
.banner-group-b { background: linear-gradient(135deg, #065f46 0%, #047857 100%); border-left: 5px solid #34d399; }
.banner-group-c { background: linear-gradient(135deg, #7c2d12 0%, #9a3412 100%); border-left: 5px solid #fb923c; }
.banner-group-d { background: linear-gradient(135deg, #581c87 0%, #6b21a8 100%); border-left: 5px solid #c084fc; }

.question-card-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.question-card-box:hover {
  border-color: #94a3b8;
  box-shadow: 0 4px 12px rgba(15, 41, 66, 0.08);
}
.question-card-box.is-answered {
  border-color: #a7f3d0;
  background: #f0fdf4;
}

.q-header-line {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}
.badge-q-tag {
  background: var(--primary-color);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.q-title-text {
  font-size: 0.925rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1.45;
}

/* 5 Rating Options Grid */
.rating-5-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.rating-opt-card {
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.35rem;
  background: #f8fafc;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-align: center;
  transition: all 0.2s ease;
  user-select: none;
}
.rating-opt-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.rating-opt-card .emoji {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 0.25rem;
  transition: transform 0.2s ease;
}
.rating-opt-card .label-txt {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.25;
}

.rating-opt-card:hover {
  background: #f1f5f9;
  border-color: #0284c7;
}
.rating-opt-card:hover .emoji {
  transform: scale(1.15);
}

/* Satisfaction Level Specific Active Colors */
.rating-opt-card:has(input:checked),
.rating-opt-card.is-selected {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
}

.rating-opt-card[data-val="1"]:has(input:checked),
.rating-opt-card[data-val="1"].is-selected {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
}
.rating-opt-card[data-val="1"]:has(input:checked) .label-txt { color: #991b1b !important; font-weight: 800; }

.rating-opt-card[data-val="2"]:has(input:checked),
.rating-opt-card[data-val="2"].is-selected {
  background: #fff7ed !important;
  border-color: #f97316 !important;
  color: #9a3412 !important;
}
.rating-opt-card[data-val="2"]:has(input:checked) .label-txt { color: #9a3412 !important; font-weight: 800; }

.rating-opt-card[data-val="3"]:has(input:checked),
.rating-opt-card[data-val="3"].is-selected {
  background: #fefce8 !important;
  border-color: #eab308 !important;
  color: #854d0e !important;
}
.rating-opt-card[data-val="3"]:has(input:checked) .label-txt { color: #854d0e !important; font-weight: 800; }

.rating-opt-card[data-val="4"]:has(input:checked),
.rating-opt-card[data-val="4"].is-selected {
  background: #f0f9ff !important;
  border-color: #0284c7 !important;
  color: #0369a1 !important;
}
.rating-opt-card[data-val="4"]:has(input:checked) .label-txt { color: #0369a1 !important; font-weight: 800; }

.rating-opt-card[data-val="5"]:has(input:checked),
.rating-opt-card[data-val="5"].is-selected {
  background: #ecfdf5 !important;
  border-color: #10b981 !important;
  color: #065f46 !important;
}
.rating-opt-card[data-val="5"]:has(input:checked) .label-txt { color: #065f46 !important; font-weight: 800; }

/* Status Badges for Responses Table & Detail Modal */
.badge-sat-5 { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; padding: 0.2rem 0.5rem; border-radius: 4px; font-weight: 700; font-size: 0.775rem; }
.badge-sat-4 { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; padding: 0.2rem 0.5rem; border-radius: 4px; font-weight: 700; font-size: 0.775rem; }
.badge-sat-3 { background: #fef9c3; color: #854d0e; border: 1px solid #fef08a; padding: 0.2rem 0.5rem; border-radius: 4px; font-weight: 700; font-size: 0.775rem; }
.badge-sat-2 { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; padding: 0.2rem 0.5rem; border-radius: 4px; font-weight: 700; font-size: 0.775rem; }
.badge-sat-1 { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; padding: 0.2rem 0.5rem; border-radius: 4px; font-weight: 700; font-size: 0.775rem; }

/* Thank You Banner Box */
.thankyou-banner-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.1rem 1.35rem;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1.5px solid #86efac;
  border-radius: var(--radius-md);
  color: #166534;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.12);
  line-height: 1.5;
}
.thankyou-banner-box .thankyou-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

/* ========================================================================== */
/* QR CODE CREATOR & A4 PRINTABLE POSTER STYLING (MODERN & MOBILE-OPTIMIZED)  */
/* ========================================================================== */

/* Mobile Segmented View Switcher (Visible only on mobile/tablet) */
.qr-mobile-switcher {
  display: none;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 1rem;
  gap: 4px;
}
@media (max-width: 900px) {
  .qr-mobile-switcher {
    display: flex;
  }
}
.qr-switcher-btn {
  flex: 1;
  padding: 0.65rem 0.75rem;
  font-size: 0.84rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: #475569;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}
.qr-switcher-btn.active {
  background: #ffffff;
  color: #0f2942;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.qr-creator-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 1.75rem;
  align-items: start;
}
@media (max-width: 900px) {
  .qr-creator-grid {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
  }
  .qr-config-panel {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
  }
  .poster-preview-panel {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
  }
}

.qr-config-panel {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(15, 41, 66, 0.04);
}
@media (max-width: 640px) {
  .qr-config-panel {
    padding: 1.15rem 1rem;
    border-radius: 14px;
  }
}

.panel-section-title h4 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}
.panel-subtitle {
  font-size: 0.8rem;
  color: #64748b;
  margin-bottom: 1rem;
}

/* Fast Action Download Toolbar */
.qr-action-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.btn-qr-action {
  border: none;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  border-radius: 10px;
}
.btn-qr-download-full {
  width: 100%;
  padding: 0.9rem 1.25rem;
  font-size: 0.95rem;
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
}
.btn-qr-download-full:hover {
  background: linear-gradient(135deg, #15803d 0%, #166534 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.4);
}
.btn-qr-download-full:active {
  transform: scale(0.98);
}

.qr-sub-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}
@media (max-width: 600px) {
  .qr-sub-actions-grid {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }
}

.btn-qr-download-only {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #86efac;
  padding: 0.6rem 0.5rem;
  font-size: 0.78rem;
}
.btn-qr-download-only:hover {
  background: #dcfce7;
}

.btn-qr-print {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
  padding: 0.6rem 0.5rem;
  font-size: 0.78rem;
}
.btn-qr-print:hover {
  background: #dbeafe;
}

.btn-qr-copy {
  background: #fdf4ff;
  color: #86198f;
  border: 1px solid #f0abfc;
  padding: 0.6rem 0.5rem;
  font-size: 0.78rem;
}
.btn-qr-copy:hover {
  background: #fae8ff;
}

.panel-divider {
  border: none;
  border-top: 1px dashed #cbd5e1;
  margin: 1rem 0 1.25rem;
}

/* Poster Preview Panel */
.poster-preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-radius: var(--radius-lg);
  border: 2px dashed #cbd5e1;
}
@media (max-width: 640px) {
  .poster-preview-panel {
    padding: 1rem 0.65rem;
    border-radius: 14px;
  }
}

.poster-preview-header-bar {
  width: 100%;
  max-width: 440px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}
.preview-badge {
  font-size: 0.78rem;
  font-weight: 800;
  color: #0369a1;
  background: #e0f2fe;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid #bae6fd;
}
.btn-xs-preview-download {
  background: #16a34a;
  color: #ffffff;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.poster-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border: 3px solid #0f2942;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 14px 35px rgba(15, 41, 66, 0.18);
  font-family: 'Be Vietnam Pro', sans-serif;
  text-align: center;
  position: relative;
  box-sizing: border-box;
}
@media (max-width: 480px) {
  .poster-card {
    max-width: 100%;
    border-width: 2.5px;
    border-radius: 14px;
  }
}

.poster-banner-top {
  background: linear-gradient(135deg, #0b1e33 0%, #0f2942 60%, #1e3a5f 100%);
  color: #ffffff;
  padding: 1.15rem 0.85rem 0.95rem;
  position: relative;
  border-bottom: 3px solid var(--accent-gold);
}
.poster-star {
  color: #f59e0b;
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
  letter-spacing: 2px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.poster-header-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0.25rem 0;
}
.poster-dept-line {
  font-size: clamp(0.72rem, 2.8vw, 0.9rem);
  font-weight: 700;
  color: #ffffff !important;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  display: block;
  line-height: 1.25;
}
.poster-unit-line {
  font-size: clamp(0.95rem, 4vw, 1.25rem);
  font-weight: 800;
  color: #ffffff !important;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: block;
  line-height: 1.25;
}
.poster-agency-sub, #prevPosterSlogan {
  font-size: clamp(0.75rem, 3vw, 0.9rem) !important;
  font-weight: 700 !important;
  color: #fbbf24 !important;
  letter-spacing: 1px !important;
  margin-top: 0.3rem !important;
  text-transform: uppercase !important;
  display: block;
}

.poster-body {
  padding: 1.15rem 0.85rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

#prevPosterSub {
  font-size: clamp(0.92rem, 3.8vw, 1.15rem) !important;
  font-weight: 800 !important;
  color: #b91c1c !important;
  line-height: 1.35 !important;
  margin: 0.2rem 0 0.4rem !important;
  text-transform: uppercase !important;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  width: 100% !important;
  text-align: center !important;
  box-sizing: border-box !important;
  padding: 0 0.35rem !important;
}

.poster-divider {
  width: 70px;
  height: 3px;
  background: linear-gradient(90deg, #dc2626 0%, #f59e0b 100%);
  border-radius: 4px;
  margin: 0.4rem auto 0.65rem;
}

.poster-guide {
  font-size: clamp(0.78rem, 3vw, 0.9rem);
  font-weight: 600;
  color: #1e293b;
  line-height: 1.4;
  margin: 0.2rem 0 0.85rem;
  padding: 0 0.35rem;
}

.qr-code-box {
  background: #ffffff;
  border: 2.5px dashed #0f2942;
  border-radius: 14px;
  padding: 0.95rem;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  margin-bottom: 0.5rem;
  position: relative;
}

#qrcodeCanvas {
  display: block;
  width: 100%;
  text-align: center;
  line-height: 0;
}
/* QRCode.js vẽ ra 1 <canvas> rồi tạo thêm 1 <img> và ẩn canvas đi.
   Không được ép display:block cho cả hai — sẽ hiện 2 mã QR chồng nhau.
   Chỉ định cỡ, còn việc ẩn/hiện để thư viện tự quyết. */
#qrcodeCanvas canvas,
#qrcodeCanvas img {
  max-width: 100%;
  width: 220px;
  height: auto;
  border-radius: 6px;
  margin: 0 auto;
}
@media (max-width: 420px) {
  #qrcodeCanvas canvas,
  #qrcodeCanvas img {
    width: 180px;
  }
}

.qr-scan-badge {
  background: #dc2626;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.3rem 0.85rem;
  border-radius: 20px;
  letter-spacing: 0.4px;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
  white-space: nowrap;
}

.poster-footer-notes {
  margin-top: 0.85rem;
  width: 100%;
}
.poster-footer-notes .note-highlight {
  font-size: clamp(0.75rem, 2.8vw, 0.88rem);
  font-weight: 800;
  color: #0284c7;
  margin-bottom: 0.2rem;
}
.poster-footer-notes .note-sub {
  font-size: clamp(0.68rem, 2.5vw, 0.78rem);
  font-weight: 600;
  color: #64748b;
  font-style: italic;
}

.poster-preview-mobile-footer {
  display: none;
  width: 100%;
  max-width: 420px;
  margin-top: 1rem;
}
@media (max-width: 900px) {
  .poster-preview-mobile-footer {
    display: block;
  }
}


/* ========================================================================== */
/* DYNAMIC QUESTION MANAGEMENT STYLING (ADMIN & SUPERADMIN)                   */
/* ========================================================================== */

.questions-management-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.q-group-admin-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.q-group-admin-header {
  background: linear-gradient(90deg, #0f2942 0%, #1e3a5f 100%);
  color: #ffffff;
  padding: 0.85rem 1.15rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
@media (max-width: 640px) {
  .q-group-admin-header {
    padding: 0.75rem 0.85rem;
  }
}

.q-group-header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}

.q-group-badge-circle {
  width: 28px;
  height: 28px;
  background: #f59e0b;
  color: #0f2942;
  font-weight: 800;
  font-size: 0.85rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.q-group-title-text {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.3px;
  display: block;
}
.q-group-desc-sub {
  font-size: 0.72rem;
  color: #cbd5e1;
  display: block;
  margin-top: 1px;
}

.q-admin-item-list {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
@media (max-width: 640px) {
  .q-admin-item-list {
    padding: 0.5rem;
    gap: 0.5rem;
  }
}

.q-admin-item-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #0284c7;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.q-admin-item-row:hover {
  border-color: #cbd5e1;
  border-left-color: #0284c7;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.q-admin-item-row.is-inactive {
  background: #f8fafc;
  opacity: 0.75;
  border-left-color: #94a3b8;
}

.q-admin-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.q-admin-tags-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.q-admin-id-tag {
  background: #0f2942;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.q-admin-type-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.type-rating5 { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.type-yesno { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }

.q-admin-status-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.status-active { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.status-hidden { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.q-admin-title-txt {
  font-size: 0.9rem;
  color: #0f172a;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}

.q-admin-item-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  border-top: 1px dashed #e2e8f0;
  padding-top: 0.5rem;
  margin-top: 0.15rem;
}
@media (max-width: 640px) {
  .q-admin-item-actions {
    justify-content: stretch;
  }
  .q-admin-item-actions .btn-q-action {
    flex: 1;
    justify-content: center;
    min-height: 38px;
    font-size: 0.8rem;
  }
}

.btn-q-action {
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-q-edit {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}
.btn-q-edit:hover {
  background: #0284c7;
  color: #ffffff;
}
.btn-q-delete {
  background: #ffe4e6;
  color: #be123c;
  border-color: #fecdd3;
}
.btn-q-delete:hover {
  background: #e11d48;
  color: #ffffff;
}
.btn-q-hide {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}
.btn-q-hide:hover {
  background: #f59e0b;
  color: #ffffff;
}
.btn-q-show {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}
.btn-q-show:hover {
  background: #16a34a;
  color: #ffffff;
}


/* ========================================================================== */
/* MODAL STYLING & RESPONSIVE FORM ELEMENTS                                   */
/* ========================================================================== */

.modal-question-card {
  max-width: 580px !important;
  padding: 1.75rem !important;
  border-radius: 18px !important;
}
@media (max-width: 640px) {
  .modal-question-card {
    padding: 1.25rem 0.9rem !important;
    border-radius: 14px !important;
    max-height: calc(100vh - 1.5rem) !important;
    max-height: calc(100dvh - 1.5rem) !important;
    overflow-y: auto !important;
  }
  /* Keep "Lưu Thay Đổi" / "Hủy Bỏ" reachable no matter how long the
     question text is — the row rides the bottom of the scroll area. */
  .modal-question-card .modal-actions-row {
    position: sticky;
    bottom: -1.25rem;
    background: var(--card-bg);
    padding: 0.7rem 0 calc(0.7rem + env(safe-area-inset-bottom));
    margin-top: 0.7rem;
    box-shadow: 0 -10px 14px -10px rgba(15, 23, 42, 0.28);
    z-index: 2;
  }
}

.modal-question-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
@media (max-width: 640px) {
  .modal-question-meta-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

.question-textarea {
  line-height: 1.45;
  font-size: 0.92rem;
  padding: 0.75rem;
  border-radius: 8px;
  width: 100%;
  box-sizing: border-box;
}

.modal-actions-row {
  display: flex;
  gap: 0.65rem;
  width: 100%;
}
.flex-1 {
  flex: 1;
}
.btn-success-theme {
  background: #10b981 !important;
  border-color: #059669 !important;
}
.btn-success-theme:hover {
  background: #059669 !important;
}


/* Trình duyệt đặt mặc định min-inline-size:min-content cho <fieldset>, nên
   các khối câu hỏi của trang người dân không chịu thu hẹp theo màn hình và
   đẩy cả trang tràn ngang trên máy 320–360px. Đây là cách sửa chuẩn. */
fieldset {
  min-inline-size: 0;
  min-width: 0;
}

/* Tiêu đề mỗi phần ("0 Thông tin đánh giá, phản ánh (Không bắt buộc)") dùng
   white-space:nowrap nên trên máy hẹp nó kéo dài quá bề ngang màn hình. */
@media (max-width: 700px) {
  .section-title {
    display: flex;
    flex-wrap: wrap;
    white-space: normal;
    max-width: 100%;
    min-width: 0;
    row-gap: 0.25rem;
    line-height: 1.35;
  }
  .section-title > span {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

/* ========================================================================== */
/* MOBILE LAYOUT HARDENING — KHÔNG CHO TRÀN NGANG / CHE MẤT NỘI DUNG          */
/* Nguyên nhân gốc: thanh topbar quản trị dùng white-space:nowrap nên chiều   */
/* rộng tối thiểu của nó (~720px) kéo giãn toàn bộ trang trên điện thoại,     */
/* làm poster QR và thẻ câu hỏi bị đẩy ra ngoài màn hình.                     */
/* ========================================================================== */

@media (max-width: 900px) {

  /* 1. Không một khối nào trong khung quản trị được rộng hơn màn hình */
  .admin-dashboard-layout,
  .admin-main,
  .admin-content-body,
  .tab-content {
    min-width: 0;
    max-width: 100%;
  }
  .admin-content-body > * {
    min-width: 0;
    max-width: 100%;
  }

  /* 2. Topbar xếp thành nhiều dòng thay vì kéo dài vô tận */
  .admin-topbar {
    white-space: normal;
    flex-wrap: wrap;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .topbar-left,
  .topbar-right {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex: 0 0 auto;
    flex-wrap: wrap;
    white-space: normal;
    overflow: visible;
    row-gap: 0.4rem;
  }
  .topbar-left h2 {
    flex: 1 1 100%;
    white-space: normal;
    font-size: 0.98rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  #adminUserBadge {
    white-space: normal !important;
    max-width: 100%;
  }
  .topbar-clock {
    border-left: none;
    padding-left: 0;
    white-space: normal;
  }

  /* 3. Hàng nút tác vụ: chia đều, luôn nằm trọn trong màn hình */
  .topbar-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    gap: 0.45rem;
  }
  .cloud-sync-status {
    grid-column: 1 / -1;
    margin-right: 0 !important;
    min-width: 0;
    max-width: 100%;
    justify-content: flex-start;
  }
  .cloud-sync-status .sync-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #btnTopChangePass,
  #btnTopSwitchCitizen {
    width: 100%;
    min-width: 0;
    justify-content: center;
    white-space: normal !important;
    text-align: center;
    line-height: 1.25;
  }

  /* 4. Bảng dữ liệu cuộn trong khung của nó, không kéo giãn cả trang */
  .table-responsive {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-responsive .data-table {
    min-width: 640px;
  }

  /* 4b. Biểu đồ: ô lưới mặc định có min-width:auto nên canvas Chart.js
         đẩy thẻ rộng hơn cột. Ép về 0 để biểu đồ co theo màn hình. */
  .charts-wrapper,
  .stat-summary-grid,
  .bottlenecks-grid,
  .recommendations-grid {
    min-width: 0;
  }
  .charts-wrapper > *,
  .stat-summary-grid > *,
  .bottlenecks-grid > *,
  .recommendations-grid > * {
    min-width: 0;
    max-width: 100%;
  }
  .chart-card {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }
  .chart-body {
    min-width: 0;
    max-width: 100%;
  }
  .chart-body canvas {
    max-width: 100% !important;
  }
  .chart-header {
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 0;
  }
  .chart-header h4 {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* 4c. Hàng nút thao tác trên Dashboard tự xuống dòng */
  .dash-actions {
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
  }
  .dash-actions > * {
    min-width: 0;
  }

  /* 5. Chuỗi dài (URL, mã hồ sơ) tự xuống dòng thay vì đẩy rộng khối cha */
  .q-admin-title-txt,
  .help-text,
  .panel-subtitle,
  .detail-box,
  .alert-card {
    overflow-wrap: anywhere;
  }
}

/* --- Tab Mã QR & Poster trên điện thoại --- */
@media (max-width: 900px) {
  .qr-mobile-switcher {
    gap: 4px;
  }
  .qr-switcher-btn {
    padding: 0.6rem 0.4rem;
    font-size: 0.78rem;
    line-height: 1.25;
    min-width: 0;
    text-align: center;
  }
  .qr-switcher-btn > span {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* Poster luôn căn giữa đúng khung nhìn, không bị lệch ra rìa phải */
  .poster-preview-panel,
  .poster-preview-header-bar,
  .poster-card,
  .poster-preview-mobile-footer {
    max-width: 100%;
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
  }
  .qr-config-panel,
  .qr-action-toolbar,
  .btn-qr-action {
    max-width: 100%;
    min-width: 0;
  }
  .btn-qr-action {
    white-space: normal;
    text-align: center;
    line-height: 1.25;
  }
}

/* Poster typography scales with the POSTER, not with the phone screen.
   Trước đây dùng đơn vị vw nên cỡ chữ đổi theo bề ngang máy, làm poster
   xem trước và ảnh xuất ra bị vỡ khung. cqw neo vào chính thẻ poster. */
.poster-card {
  container-type: inline-size;
}
@supports (width: 1cqw) {
  .poster-dept-line {
    font-size: clamp(0.72rem, 3.4cqw, 0.95rem);
  }
  .poster-unit-line {
    font-size: clamp(0.98rem, 5cqw, 1.35rem);
  }
  .poster-agency-sub,
  #prevPosterSlogan {
    font-size: clamp(0.75rem, 3.6cqw, 0.95rem) !important;
  }
  #prevPosterSub {
    font-size: clamp(0.95rem, 4.7cqw, 1.2rem) !important;
  }
  .poster-guide {
    font-size: clamp(0.8rem, 3.7cqw, 0.95rem);
  }
  .poster-footer-notes .note-highlight {
    font-size: clamp(0.76rem, 3.4cqw, 0.9rem);
  }
  .poster-footer-notes .note-sub {
    font-size: clamp(0.68rem, 3cqw, 0.8rem);
  }
  .qr-scan-badge {
    font-size: clamp(0.7rem, 3.2cqw, 0.82rem);
  }
}

/* ---------------------------------------------------------------------- */
/* NÚT ĐĂNG NHẬP CÁN BỘ TRÊN THANH ĐẦU TRANG NGƯỜI DÂN                     */
/* Lỗi: .btn-text-mobile có sẵn nhưng KHÔNG media query nào bật lên, nên    */
/* điện thoại vẫn hiện "Đăng nhập Cán bộ" — nút phình to đè mất tên xã.     */
/* ---------------------------------------------------------------------- */
@media (max-width: 640px) {
  .btn-text-desktop {
    display: none !important;
  }
  .btn-text-mobile {
    display: inline !important;
  }
  #btn-admin-modal {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0.4rem 0.62rem;
    font-size: 0.74rem;
    gap: 0.25rem;
  }
  /* Tên đơn vị co chữ theo màn hình, thừa thì cắt gọn bằng dấu ... chứ
     không chui xuống dưới nút bấm */
  .agency-badge {
    max-width: calc(100% - 104px);
    overflow: hidden;
  }
  .agency-badge-text {
    width: 100%;
    overflow: hidden;
  }
  /* Cả 3 dòng đều giữ MỘT DÒNG. Script fitAgencyBadge() tự co cỡ chữ cho
     dòng dài nhất vừa khung, nên đổi sang tên xã dài hơn vẫn không vỡ. */
  .badge-dept-line,
  .badge-unit-line,
  .badge-slogan-line {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.1px;
  }
  .badge-dept-line {
    font-size: clamp(0.56rem, 2.6vw, 0.72rem);
  }
  .badge-unit-line {
    font-size: clamp(0.68rem, 3.2vw, 0.86rem);
  }
  .badge-slogan-line {
    font-size: clamp(0.52rem, 2.4vw, 0.66rem);
  }
}

/* Tiêu đề phiếu khảo sát trên poster: ĐÚNG 2 DÒNG, mỗi vế một dòng liền.
   Script tự co cỡ chữ (fitPosterTitle) cho vế dài nhất vừa khung, nên
   nowrap ở đây an toàn kể cả khi đơn vị đổi sang tên khác dài hơn. */
#prevPosterSub .poster-sub-line {
  display: block;
  white-space: nowrap;
  width: 100%;
}

/* ---------------------------------------------------------------------- */
/* KHUNG MÃ QR TRÊN POSTER                                                 */
/* Thiết kế chuẩn: khung nét đứt ÔM SÁT mã QR (không kéo full chiều rộng), */
/* nhãn đỏ "QUÉT MÃ TRÊN ĐIỆN THOẠI" nằm ĐÈ LÊN CHÍNH GIỮA viền dưới.      */
/* Lỗi cũ: nhãn absolute nhưng khung chỉ chừa margin-bottom 0.5rem nên nhãn */
/* đè lên dòng "Rất đơn giản..." — nay chừa đủ chỗ cho nửa nhãn thò ra.     */
/* ---------------------------------------------------------------------- */

/* Không khối nào trong thân poster bị ép co lại */
.poster-body > * {
  flex-shrink: 0;
  max-width: 100%;
}

.qr-code-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  /* Đáy chừa rộng hơn để nhãn đỏ không áp sát mã QR — mã QR cần vùng trắng
     yên tĩnh (quiet zone) xung quanh thì máy quét mới đọc nhanh và chắc. */
  padding: 1.15rem 1.15rem 2.1rem;
  border: 3px dashed #0f2942;
  border-radius: 18px;
  background: #ffffff;
  position: relative;
  gap: 0;
  /* chỗ trống cho nửa dưới của nhãn đỏ + khoảng thở tới dòng chữ kế tiếp */
  margin-bottom: 1.75rem;
}
.qr-code-box > * {
  flex-shrink: 0;
}

.qr-scan-badge {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  background: #dc2626;
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 0.42rem 1.15rem;
  border-radius: 30px;
  line-height: 1.25;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
  z-index: 2;
}

/* Cỡ mã QR: ghi đè quy tắc 180px !important của khối CSS đời cũ.
   Mã QR chiếm gần trọn khung nét đứt, đúng như mẫu. */
#qrcodeCanvas canvas,
#qrcodeCanvas img {
  width: 240px !important;
  height: auto !important;
  max-width: 100% !important;
}
@media (max-width: 420px) {
  #qrcodeCanvas canvas,
  #qrcodeCanvas img {
    width: 200px !important;
  }
}
@media (max-width: 340px) {
  #qrcodeCanvas canvas,
  #qrcodeCanvas img {
    width: 168px !important;
  }
}


/* ========================================================================== */
/* PRINT STYLES FOR A4 REPORT & POSTER                                        */
/* ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 1.2cm;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .admin-sidebar, .admin-topbar, .analytics-header-bar, .qr-config-panel, .qr-mobile-switcher, .utility-bar, .hero-header, .submit-actions, .modal-backdrop, button, input, select {
    display: none !important;
  }
  .admin-dashboard-layout, .admin-main, .admin-content-body {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
  }
  .tab-content:not(.active) {
    display: none !important;
  }
  .tab-content.active {
    display: block !important;
  }
  /* When printing Poster */
  #tab-qr.active #printablePoster {
    display: block !important;
    visibility: visible !important;
    margin: 0 auto !important;
    box-shadow: none !important;
    border: 3px solid #0f2942 !important;
    max-width: 18cm !important;
  }
  /* When printing Report */
  #tab-analytics.active #printableReportArea {
    display: block !important;
    visibility: visible !important;
    width: 100% !important;
  }
  .analytics-section-card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    margin-bottom: 1rem !important;
  }
}

