:root {
  --crimson: #E22440;
  --crimson-dark: #BA1831;
  --crimson-bright: #EF3853;
  --crimson-soft: #FDF2F4;
  --gold: #C8942E;
  --gold-dark: #A6761B;
  --gold-light: #F6E2B8;
  --gold-soft: #FDF8EC;
  --bg: #F6F3F3;
  --surface: #FFFFFF;
  --surface-alt: #F9F6F6;
  --border: #E8DEDE;
  --border-strong: #CEBDBD;
  --text: #1F2937;
  --text-muted: #5B6472;
  --emerald: #0F766E;
  --emerald-bg: #ECFDF5;
  --amber: #B45309;
  --amber-bg: #FFFBEB;
  --rose: #BE123C;
  --rose-bg: #FFF1F2;
  --header-h: 70px;
  --sidebar-w: 256px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 2px 10px rgba(31, 41, 55, 0.05);
  --shadow-md: 0 10px 26px rgba(226, 36, 64, 0.12);
  --font-body: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-head: 'Prompt', 'Sarabun', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-head);
  margin: 0;
  color: #1F2937;
}

code {
  font-family: Consolas, Monaco, monospace;
  font-size: 0.9em;
  background: #F1E9E9;
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--crimson-dark);
}

.hidden {
  display: none !important;
}

.print-only {
  display: none;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== TOP WHITE HEADER ==================== */
.portal-header {
  position: sticky;
  top: 0;
  z-index: 45;
  height: var(--header-h);
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.app-shell:has(#view-home.active) .portal-header,
.app-shell.is-home .portal-header {
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.96) 0%,
      rgba(255, 255, 255, 0.86) 44%,
      rgba(255, 255, 255, 0) 64%,
      rgba(255, 255, 255, 0) 100%);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: none;
  box-shadow: none;
}

.app-shell:has(#view-home.active) .status-pill.status-connected,
.app-shell.is-home .status-pill.status-connected {
  background: rgba(236, 253, 245, 0.9);
  backdrop-filter: blur(4px);
}

.header-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 22px;
  height: 100%;
  min-height: 70px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  min-width: 0;
}

.mobile-menu-btn {
  display: none;
  background: var(--crimson-soft);
  color: var(--crimson);
  border: 1px solid #F0CBD0;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.header-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-divider {
  width: 1px;
  height: 34px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.header-org-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.header-org-text strong {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 600;
  color: #1F2937;
}

.header-org-text span {
  font-size: 12.5px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-header-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
  color: var(--crimson);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.16s ease;
}

.btn-header-pill:hover {
  background: var(--crimson-soft);
  border-color: var(--crimson);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.16s ease;
}

.status-pill.status-connected {
  background: var(--emerald-bg);
  border-color: #A7F3D0;
  color: var(--emerald);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #F59E0B;
}

.status-pill.status-connected .status-dot {
  background: #10B981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.status-pill.status-checking {
  background: #FFFBEB;
  border-color: #FDE68A;
  color: #92400E;
}

.status-pill.status-checking .status-dot {
  background: #F59E0B;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}

.status-pill.status-error {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #B91C1C;
}

.status-pill.status-error .status-dot {
  background: #DC2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.22);
}

.status-pill.is-static {
  cursor: default;
}

.user-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease;
}

.user-profile-chip:hover {
  border-color: var(--crimson);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--crimson) 0%, var(--crimson-dark) 100%);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-meta strong {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  max-width: 145px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta span {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ==================== PORTAL BODY & LEFT SIDEBAR ==================== */
.portal-body {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.portal-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(90deg, #E22440 0%, #BE1832 58%, #8F0D22 100%);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 4px 0 18px rgba(226, 36, 64, 0.18);
}

.side-nav {
  position: relative;
  z-index: 2;
  padding: 18px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-nav-btn {
  width: 100%;
  border: none;
  background: transparent;
  color: #FFFFFF;
  font-family: var(--font-head);
  font-size: 13.5px;
  font-weight: 500;
  padding: 11px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
}

.side-nav-btn:hover {
  background: rgba(255, 255, 255, 0.13);
  color: #FFFFFF;
}

.side-nav-btn.active {
  background: linear-gradient(90deg, #FFFFFF 0%, #F7DFB3 100%);
  color: var(--crimson-dark);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.side-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 1;
}

.side-nav-label {
  flex: 1;
  line-height: 1.45;
}

.nav-count {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
}

.side-nav-btn.active .nav-count {
  background: var(--crimson);
  color: #FFFFFF;
}

.side-nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
  margin: 8px 6px;
}

.side-nav-sub {
  font-size: 12.5px;
  opacity: 0.88;
  padding: 9px 14px;
}

.sidebar-admin-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-admin-title {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  padding: 2px 12px 0;
}

.side-nav-sso-btn {
  background: rgba(15, 23, 42, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.side-nav-sso-btn:hover {
  background: rgba(15, 23, 42, 0.38);
  border-color: rgba(255, 255, 255, 0.45);
}

.side-nav-sso-btn small {
  font-size: 11px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.82);
}

.sidebar-admin-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 2px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.admin-user-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
  flex-shrink: 0;
}

.admin-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.admin-user-text strong {
  font-family: var(--font-head);
  font-size: 12.5px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-text span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-nav-logout-btn {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.86);
  padding: 8px 14px;
  margin-top: 2px;
  border: 1px dashed rgba(255, 255, 255, 0.24);
}

.side-nav-logout-btn:hover {
  background: rgba(15, 23, 42, 0.35);
  border-color: rgba(255, 255, 255, 0.45);
}

.sidebar-quote {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 14px 18px 8px;
}

.sidebar-quote p {
  margin: 0;
  font-family: var(--font-head);
  font-size: 14.5px;
  font-style: italic;
  font-weight: 500;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.sidebar-quote-bar {
  display: inline-block;
  width: 44px;
  height: 3px;
  border-radius: 999px;
  background: var(--gold-light);
  margin-top: 8px;
}

.sidebar-art-wrap {
  position: relative;
  z-index: 1;
  margin-top: 6px;
  pointer-events: none;
}

.sidebar-building-art {
  display: block;
  width: 100%;
  height: auto;
  filter: brightness(0) invert(1);
  opacity: 0.45;
  transform: scale(1.06);
  transform-origin: bottom center;
}

/* ==================== MAIN WORKSPACE ==================== */
.portal-main {
  flex: 1;
  min-width: 0;
  padding: 22px 26px 42px;
}

.view-section {
  display: none;
}

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

#view-form.active {
  padding-bottom: 72px;
}

/* ==================== VIEW 0: HOME PORTAL ==================== */
.hero-banner {
  position: relative;
  margin: calc(-22px - var(--header-h)) -26px 0 -26px;
  min-height: clamp(580px, 68vh, 720px);
  border-radius: 0;
  overflow: hidden;
  border: none;
  border-bottom: 1px solid #EFE4E4;
  box-shadow: none;
  background-color: #FFFFFF;
  background-image:
    linear-gradient(93deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0.88) 38%, rgba(255, 255, 255, 0.45) 54%, rgba(255, 255, 255, 0.02) 70%),
    url('../img/herotef.jpg');
  background-size: cover;
  background-position: right bottom;
  display: flex;
  align-items: center;
  padding: calc(var(--header-h) + 42px) 48px 124px;
}

#localModeNotice:not(.hidden)~#view-home .hero-banner {
  margin-top: 0;
  padding-top: 48px;
}

.hero-content {
  max-width: 720px;
  position: relative;
  z-index: 2;
}

.hero-badge-org {
  display: inline-block;
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  color: var(--crimson);
  background: var(--crimson-soft);
  border: 1px solid #F3C4CC;
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.hero-content h1 {
  font-size: clamp(32px, 3.8vw, 48px);
  font-weight: 700;
  color: #111827;
  line-height: 1.18;
}

.hero-subtitle {
  margin: 6px 0 18px;
  font-family: var(--font-head);
  font-size: clamp(22px, 2.5vw, 32px);
  font-weight: 700;
  color: #9E0D24;
}

.hero-pill-tagline {
  display: inline-block;
  background: linear-gradient(90deg, #8F0D22 0%, #6A0817 100%);
  color: #FFFFFF;
  font-family: var(--font-head);
  font-size: 14.5px;
  font-weight: 500;
  padding: 8px 20px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(106, 8, 23, 0.28);
}

.hero-actions {
  margin-top: 22px;
}

.btn-hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 28px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #E22440 0%, #BD1831 100%);
  color: #FFFFFF;
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(226, 36, 64, 0.3);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.btn-hero-cta:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #D11D38 0%, #A8132A 100%);
  box-shadow: 0 8px 20px rgba(226, 36, 64, 0.38);
}

/* Domain Cards */
.domain-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-top: 22px;
}

.domain-card {
  position: relative;
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.domain-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.domain-card-crimson {
  border: 1.5px solid #F0B6BF;
  background: linear-gradient(135deg, #FFFFFF 45%, #FDF2F4 100%);
}

.domain-card-gold {
  border: 1.5px solid #ECC985;
  background: linear-gradient(135deg, #FFFFFF 45%, #FDF8EC 100%);
}

.domain-count-badge {
  position: absolute;
  top: 14px;
  right: 16px;
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  color: #FFFFFF;
}

.badge-crimson {
  background: #E22440;
}

.badge-gold {
  background: #C8942E;
}

.domain-card-inner {
  display: flex;
  align-items: center;
  gap: 18px;
}

.domain-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-crimson {
  background: #FCE8EC;
  color: #E22440;
}

.icon-gold {
  background: #FBF0D6;
  color: #C08319;
}

.domain-text h2 {
  font-size: 21px;
  font-weight: 700;
  color: #1F2937;
  padding-right: 84px;
}

.domain-text p {
  margin: 6px 0 10px;
  font-size: 14px;
  color: var(--text-muted);
}

.domain-live-stat {
  font-size: 13px;
  font-weight: 700;
  color: var(--crimson-dark);
  margin-bottom: 12px;
}

.domain-card-gold .domain-live-stat {
  color: var(--gold-dark);
}

.btn-domain {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border: none;
  border-radius: 999px;
  color: #FFFFFF;
  font-family: var(--font-head);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.16s ease;
}

.btn-domain:hover {
  opacity: 0.92;
}

.btn-domain-crimson {
  background: linear-gradient(90deg, #E22440 0%, #C21A33 100%);
}

.btn-domain-gold {
  background: linear-gradient(90deg, #C88C24 0%, #9E6A12 100%);
}

/* Bottom 3-Column Home Grid */
.home-bottom-grid {
  display: grid;
  grid-template-columns: 1.08fr 1.08fr 0.84fr;
  gap: 18px;
  margin-top: 18px;
}

.home-widget-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.widget-cream {
  background: #FCF9F4;
}

.widget-header {
  margin-bottom: 14px;
}

.widget-header.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.widget-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.widget-header h3.justify-center {
  justify-content: center;
}

.widget-icon {
  color: var(--crimson);
  display: inline-flex;
}

.widget-link-all {
  border: none;
  background: transparent;
  color: var(--crimson);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.progress-overview-body {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1;
}

.donut-box {
  position: relative;
  width: 112px;
  height: 112px;
  flex-shrink: 0;
}

.donut-svg {
  width: 112px;
  height: 112px;
  transform: rotate(-90deg);
}

.donut-track {
  fill: none;
  stroke: #EFE6E6;
  stroke-width: 10;
}

.donut-fill {
  fill: none;
  stroke: var(--crimson-bright);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s ease;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.donut-center strong {
  font-family: var(--font-head);
  font-size: 21px;
  color: #1F2937;
  line-height: 1.1;
}

.donut-center span {
  font-size: 11px;
  color: var(--text-muted);
}

.checklist-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}

.checklist-btn {
  width: 100%;
  border: none;
  background: transparent;
  padding: 4px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.checklist-btn:hover {
  background: var(--crimson-soft);
}

.chk-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #CBD5E1;
  background: #FFFFFF;
  flex-shrink: 0;
  position: relative;
}

.checklist-btn.is-done .chk-dot {
  border-color: var(--crimson);
  background: var(--crimson);
}

.checklist-btn.is-done .chk-dot::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checklist-btn.is-partial .chk-dot {
  border-color: var(--gold);
  background: var(--gold-soft);
}

/* Announcements */
.announce-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.announce-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #EFE7E7;
  background: #FDFBFB;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font-body);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.announce-item:hover {
  border-color: var(--crimson);
  background: var(--crimson-soft);
}

.announce-date-tile {
  min-width: 52px;
  padding: 5px 6px;
  border-radius: 8px;
  background: #FCE8EC;
  color: var(--crimson-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  flex-shrink: 0;
}

.announce-date-tile strong {
  font-family: var(--font-head);
  font-size: 13px;
}

.announce-date-tile span {
  font-size: 11px;
}

.announce-date-tile.tile-gold {
  background: var(--gold-soft);
  color: var(--gold-dark);
}

.announce-date-tile.tile-slate {
  background: #EEF2F7;
  color: #334155;
}

.announce-text {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
}

.announce-text small {
  display: block;
  color: var(--text-muted);
  font-weight: 400;
}

.announce-arrow {
  color: var(--text-muted);
  font-size: 18px;
}

/* 4 Rating Circles */
.rating-circles-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: auto 0;
  padding: 10px 0;
}

.rating-circle-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.rating-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  color: #FFFFFF;
  font-family: var(--font-head);
  font-size: 19px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.rc-1 {
  background: #E22440;
}

.rc-2 {
  background: #F97316;
}

.rc-3 {
  background: #0284C7;
}

.rc-4 {
  background: #16A34A;
}

.rating-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.rating-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ==================== BUTTONS & COMMON UI ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-primary {
  background: var(--crimson);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--crimson-dark);
}

.btn-success {
  background: var(--emerald);
  color: #FFFFFF;
}

.btn-success:hover:not(:disabled) {
  background: #0D625B;
}

.btn-gold {
  background: var(--gold);
  color: #FFFFFF;
  font-weight: 600;
}

.btn-gold:hover:not(:disabled) {
  background: var(--gold-dark);
}

.btn-outline {
  background: #FFFFFF;
  border-color: var(--border-strong);
  color: var(--crimson);
}

.btn-outline:hover:not(:disabled) {
  background: var(--crimson-soft);
  border-color: var(--crimson);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-alt);
  color: var(--crimson);
}

.btn-warning-solid {
  background: var(--amber);
  color: #FFFFFF;
}

/* ==================== CARDS & CONTAINERS ==================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card+.card {
  margin-top: 18px;
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.card-header.flex-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.card-header h2 {
  font-size: 19px;
  margin-top: 4px;
}

.card-desc {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.card-body {
  padding: 20px 22px;
}

.section-tag {
  display: inline-block;
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  color: var(--crimson);
  background: var(--crimson-soft);
  padding: 2px 10px;
  border-radius: 999px;
}

.mt-md {
  margin-top: 16px;
}

.mt-lg {
  margin-top: 24px;
}

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

.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  flex-wrap: wrap;
}

.alert-warning {
  background: var(--amber-bg);
  border: 1px solid #FCD34D;
  color: #78350F;
}

.alert-danger {
  background: #FEF2F2;
  border: 1.5px solid #FCA5A5;
  color: #991B1B;
}

.btn-danger-solid {
  background: #DC2626;
  color: #FFFFFF;
  border: none;
}

.btn-danger-solid:hover:not(:disabled) {
  background: #B91C1C;
}

.is-connection-blocked {
  opacity: 0.56 !important;
  cursor: not-allowed !important;
  filter: grayscale(0.25);
}

/* ==================== WIZARD PROGRESS BAR ==================== */
.wizard-top-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.wizard-progress-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  padding: 16px 20px 18px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  user-select: none;
}

.wizard-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.wizard-progress-current {
  font-family: var(--font-head);
  font-size: 14.5px;
  font-weight: 700;
  color: #1E293B;
}

.wizard-progress-percent {
  font-family: var(--font-head);
  font-size: 12.5px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 999px;
  background: #FFFFFF;
  color: #475569;
  border: 1px solid #CBD5E1;
  transition: all 0.2s ease;
}

.wizard-progress-card[data-current-step="2"] .wizard-progress-percent,
.wizard-progress-card[data-current-step="3"] .wizard-progress-percent {
  background: #FEF9C3;
  color: #A16207;
  border-color: #FACC15;
}

.wizard-progress-card[data-current-step="4"] .wizard-progress-percent,
.wizard-progress-card[data-current-step="5"] .wizard-progress-percent {
  background: #DCFCE7;
  color: #15803D;
  border-color: #86EFAC;
}

.wizard-stepper-wrap {
  position: relative;
}

.wizard-progress-track {
  position: absolute;
  top: 15px;
  left: 10%;
  right: 10%;
  height: 6px;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 999px;
  overflow: hidden;
  z-index: 1;
}

.wizard-progress-fill {
  height: 100%;
  width: 0%;
  background: #FFFFFF;
  border-radius: 999px;
  transition: width 0.28s ease, background 0.28s ease;
}

.wizard-progress-card[data-current-step="2"] .wizard-progress-fill {
  background: linear-gradient(90deg, #FFFFFF 0%, #FEF9C3 40%, #FDE047 100%);
}

.wizard-progress-card[data-current-step="3"] .wizard-progress-fill {
  background: linear-gradient(90deg, #FFFFFF 0%, #FEF08A 42%, #EAB308 100%);
}

.wizard-progress-card[data-current-step="4"] .wizard-progress-fill {
  background: linear-gradient(90deg, #FFFFFF 0%, #FEF08A 28%, #FACC15 56%, #4ADE80 100%);
}

.wizard-progress-card[data-current-step="5"] .wizard-progress-fill {
  background: linear-gradient(90deg, #FFFFFF 0%, #FEF08A 22%, #FACC15 48%, #4ADE80 76%, #16A34A 100%);
}

.wizard-stepper {
  position: relative;
  z-index: 2;
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  cursor: default;
  color: #94A3B8;
}

.step-item[data-step="1"] {
  --step-bg: #FFFFFF;
  --step-border: #94A3B8;
  --step-fg: #334155;
  --step-ring: rgba(148, 163, 184, 0.22);
  --step-label: #1E293B;
}

.step-item[data-step="2"] {
  --step-bg: #FEF08A;
  --step-border: #EAB308;
  --step-fg: #854D0E;
  --step-ring: rgba(234, 179, 8, 0.24);
  --step-label: #A16207;
}

.step-item[data-step="3"] {
  --step-bg: #FACC15;
  --step-border: #CA8A04;
  --step-fg: #713F12;
  --step-ring: rgba(202, 138, 4, 0.26);
  --step-label: #A16207;
}

.step-item[data-step="4"] {
  --step-bg: #4ADE80;
  --step-border: #16A34A;
  --step-fg: #14532D;
  --step-ring: rgba(34, 197, 94, 0.24);
  --step-label: #15803D;
}

.step-item[data-step="5"] {
  --step-bg: #16A34A;
  --step-border: #15803D;
  --step-fg: #FFFFFF;
  --step-ring: rgba(22, 163, 74, 0.26);
  --step-label: #15803D;
}

.step-node {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  color: #64748B;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.step-check {
  display: none;
  font-size: 15px;
  line-height: 1;
}

.step-label {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  color: #94A3B8;
  transition: color 0.2s ease;
}

.step-item.completed .step-node,
.step-item.active .step-node {
  background: var(--step-bg);
  border-color: var(--step-border);
  color: var(--step-fg);
}

.step-item.active .step-node {
  box-shadow: 0 0 0 4px var(--step-ring);
}

.step-item.completed .step-num {
  display: none;
}

.step-item.completed .step-check {
  display: inline;
}

.step-item.completed .step-label,
.step-item.active .step-label {
  color: var(--step-label);
}

.step-item.active .step-label {
  font-weight: 700;
}

.draft-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.wizard-step {
  display: none;
}

.wizard-step.active {
  display: block;
}

/* ==================== INSTRUCTIONS & FORMS ==================== */
.instructions-card {
  margin-bottom: 18px;
  overflow: hidden;
}

.home-instructions-card {
  position: relative;
  z-index: 6;
  margin-top: -88px;
  margin-bottom: 0;
  border: 2px solid #DDA43B;
  border-radius: 16px;
  background: linear-gradient(135deg, #FFFFFF 0%, #FFFDF8 60%, #FDF2DC 100%);
  box-shadow: 0 14px 32px rgba(200, 148, 46, 0.22), 0 4px 12px rgba(166, 118, 27, 0.14);
}

.home-instructions-card .instructions-summary {
  background: linear-gradient(90deg, #FDF3DC 0%, #FFFBF2 100%);
  color: #8F5609;
}

.home-instructions-card .instructions-body {
  border-top: 1px solid #F1D9A8;
}

.home-instructions-card .inst-block h4 {
  color: #9A5E0A;
}

.instructions-summary {
  padding: 14px 20px;
  background: var(--crimson-soft);
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--crimson-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.instructions-body {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.inst-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.inst-block h4 {
  font-size: 15px;
  margin-bottom: 6px;
  color: var(--crimson-dark);
}

.inst-block ul {
  margin: 0 0 12px;
  padding-left: 18px;
}

.inst-block li {
  margin-bottom: 4px;
}

.scale-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.scale-pill {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}

.scale-pill.level-1 {
  background: #FEE2E2;
  color: #B91C1C;
  border-color: #FCA5A5;
}

.scale-pill.level-2 {
  background: #FFEDD5;
  color: #C2410C;
  border-color: #FDBA74;
}

.scale-pill.level-3 {
  background: #E0F2FE;
  color: #0369A1;
  border-color: #7DD3FC;
}

.scale-pill.level-4 {
  background: #DCFCE7;
  color: #15803D;
  border-color: #86EFAC;
}

.form-grid {
  display: grid;
  gap: 14px 18px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

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

.col-span-2-md {
  grid-column: span 2;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group>label {
  font-weight: 600;
  font-size: 15px;
  color: #1F2937;
}

.req {
  color: var(--rose);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  background: #FFFFFF;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(226, 36, 64, 0.16);
}

.input-error {
  border-color: var(--rose) !important;
  box-shadow: 0 0 0 3px rgba(190, 18, 60, 0.14) !important;
}

.field-hint {
  font-size: 13px;
  color: var(--text-muted);
}

.form-divider {
  border: none;
  border-top: 1px dashed var(--border);
  margin: 20px 0;
}

.grouped-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.option-subgroup {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.option-subgroup-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 600;
  color: var(--crimson-dark);
  margin-bottom: 10px;
}

.option-grid {
  display: grid;
  gap: 10px;
}

.option-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-pill {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  cursor: pointer;
  transition: all 0.14s ease;
  font-size: 15px;
}

.choice-pill:hover {
  border-color: var(--crimson);
  background: var(--crimson-soft);
}

.choice-pill input[type="radio"] {
  margin-top: 4px;
  accent-color: var(--crimson);
  flex-shrink: 0;
}

.choice-pill:has(input:checked) {
  border-color: var(--crimson);
  background: var(--crimson-soft);
  box-shadow: inset 0 0 0 1px var(--crimson);
  font-weight: 500;
}

.conditional-box {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--gold-soft);
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.conditional-box>label {
  display: block;
  font-weight: 600;
  color: var(--crimson-dark);
  margin-bottom: 8px;
  font-size: 14px;
}

/* ==================== COMPETENCY RUBRIC CARDS ==================== */
.part-toolbar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.group-pills-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.group-pill {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--crimson-dark);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
}

.group-pill.complete {
  background: var(--emerald-bg);
  border-color: #6EE7B7;
  color: var(--emerald);
}

.competency-group-card {
  margin-bottom: 28px;
  border-radius: 14px;
  border: 1px solid #DCE3EC;
  background: #F1F5F9;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.05);
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 22px;
  background: linear-gradient(90deg, #C81D37 0%, #E22440 60%, #A6142A 100%);
  color: #FFFFFF;
  flex-wrap: wrap;
}

.group-header h3 {
  font-size: 17px;
  font-weight: 600;
  color: #FFFFFF;
}

.group-avg-badge {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.36);
}

.competency-items-list {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.competency-item {
  background: #FFFFFF;
  border: 1px solid #DDE5EE;
  border-left: 4px solid #CBD5E1;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.competency-item[data-selected-level="1"] { border-left-color: #DC2626; }
.competency-item[data-selected-level="2"] { border-left-color: #EA580C; }
.competency-item[data-selected-level="3"] { border-left-color: #0284C7; }
.competency-item[data-selected-level="4"] { border-left-color: #16A34A; }

.competency-item.unanswered-highlight {
  background: #FFF7F8;
  border-color: #FDA4AF;
  border-left-color: var(--rose);
  box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.12);
}

.competency-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  background: #F8FAFC;
  border-bottom: 1px solid #E9EEF5;
}

.competency-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 15.5px;
  font-weight: 600;
  color: #0F172A;
  line-height: 1.45;
}

.competency-code {
  display: inline-block;
  flex-shrink: 0;
  font-family: var(--font-head);
  font-size: 12.5px;
  font-weight: 700;
  color: #BE123C;
  background: #FFF1F2;
  border: 1px solid #FECDD3;
  padding: 3px 10px;
  border-radius: 999px;
}

.selected-score-chip {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.selected-score-chip[data-level="1"],
.rubric-option[data-level="1"],
.compact-radio-label[data-level="1"] {
  --lvl-solid: #DC2626;
  --lvl-hover: #EF4444;
  --lvl-dark: #B91C1C;
  --lvl-soft: #FEF2F2;
  --lvl-pill: #FEE2E2;
  --lvl-ring: rgba(220, 38, 38, 0.22);
}

.selected-score-chip[data-level="2"],
.rubric-option[data-level="2"],
.compact-radio-label[data-level="2"] {
  --lvl-solid: #EA580C;
  --lvl-hover: #F97316;
  --lvl-dark: #C2410C;
  --lvl-soft: #FFF7ED;
  --lvl-pill: #FFEDD5;
  --lvl-ring: rgba(234, 88, 12, 0.22);
}

.selected-score-chip[data-level="3"],
.rubric-option[data-level="3"],
.compact-radio-label[data-level="3"] {
  --lvl-solid: #0284C7;
  --lvl-hover: #0EA5E9;
  --lvl-dark: #0369A1;
  --lvl-soft: #F0F9FF;
  --lvl-pill: #E0F2FE;
  --lvl-ring: rgba(2, 132, 199, 0.24);
}

.selected-score-chip[data-level="4"],
.rubric-option[data-level="4"],
.compact-radio-label[data-level="4"] {
  --lvl-solid: #16A34A;
  --lvl-hover: #22C55E;
  --lvl-dark: #15803D;
  --lvl-soft: #F0FDF4;
  --lvl-pill: #DCFCE7;
  --lvl-ring: rgba(22, 163, 74, 0.22);
}

.selected-score-chip.has-score {
  background: var(--lvl-solid, var(--crimson));
  color: #FFFFFF;
}

.rubric-cards-grid {
  padding: 16px 18px 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: #FFFFFF;
}

.rubric-option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  background: #F8FAFC;
  cursor: pointer;
  transition: all 0.16s ease;
}

.rubric-option:hover {
  background: #FFFFFF;
  border-color: var(--lvl-hover, var(--crimson));
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.rubric-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rubric-option-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #E2E8F0;
  transition: border-color 0.16s ease;
}

.rubric-option-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
}

.rating-face-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  color: #94A3B8;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.rating-face-svg {
  width: 24px;
  height: 24px;
  display: block;
}

.rubric-score-badge {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: #E2E8F0;
  color: #475569;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.benchmark-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  transition: color 0.16s ease;
}

.rubric-desc {
  font-size: 13.5px;
  line-height: 1.65;
  color: #475569;
}

.rubric-cards-grid:has(input:checked) .rubric-option:not(:has(input:checked)) {
  opacity: 0.66;
  background: #FAFBFD;
}

.rubric-cards-grid:has(input:checked) .rubric-option:not(:has(input:checked)):hover {
  opacity: 1;
  background: #FFFFFF;
}

.rubric-option:hover .rating-face-circle {
  background: var(--lvl-pill);
  border-color: var(--lvl-solid);
  color: var(--lvl-solid);
  transform: scale(1.06);
}

.rubric-option:has(input:checked) {
  border-color: var(--lvl-solid, var(--crimson));
  background: var(--lvl-soft, var(--crimson-soft));
  box-shadow: 0 0 0 2px var(--lvl-ring, rgba(226, 36, 64, 0.2));
}

.rubric-option:has(input:checked) .rubric-option-head {
  border-bottom-color: var(--lvl-ring);
}

.rubric-option:has(input:checked) .rating-face-circle {
  background: var(--lvl-solid, var(--crimson));
  border-color: var(--lvl-solid, var(--crimson));
  color: #FFFFFF;
  box-shadow: 0 4px 10px var(--lvl-ring, rgba(226, 36, 64, 0.28));
  transform: scale(1.08);
}

.rubric-option:has(input:checked) .rubric-score-badge {
  background: var(--lvl-solid, var(--crimson));
  color: #FFFFFF;
}

.rubric-option:hover .benchmark-tag,
.rubric-option:has(input:checked) .benchmark-tag {
  color: var(--lvl-dark);
}

.rubric-option:has(input:checked) .rubric-desc {
  color: #0F172A;
  font-weight: 500;
}

/* Compact Table Mode */
.compact-table-wrap {
  padding: 16px 18px 18px;
  background: #FFFFFF;
  overflow-x: auto;
}

.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.compact-table th,
.compact-table td {
  border: 1px solid var(--border);
  padding: 12px 14px;
  vertical-align: middle;
}

.compact-table tbody tr:nth-child(even) {
  background: #FAFBFD;
}

.compact-table tbody tr:hover {
  background: #F1F5F9;
}

.compact-table th {
  background: var(--surface-alt);
  color: var(--crimson-dark);
  font-family: var(--font-head);
  font-size: 13px;
  text-align: center;
}

.compact-table th:first-child {
  text-align: left;
}

.compact-table tr.unanswered-highlight td {
  background: #FFF7F8;
}

.compact-radio-cell {
  text-align: center;
  width: 96px;
}

.compact-radio-label {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 56px;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.16s ease;
}

.compact-radio-label .rating-face-circle {
  width: 36px;
  height: 36px;
}

.compact-score-num {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}

.compact-score-text {
  display: none;
}

.compact-radio-label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.compact-radio-label:hover {
  background: var(--lvl-soft);
  border-color: var(--lvl-hover);
}

.compact-radio-label:hover .rating-face-circle {
  background: var(--lvl-pill);
  border-color: var(--lvl-solid);
  color: var(--lvl-solid);
  transform: scale(1.06);
}

.compact-radio-label:hover .compact-score-num {
  color: var(--lvl-dark);
}

.compact-radio-label:has(input:checked) {
  background: var(--lvl-soft, var(--crimson-soft));
  border-color: var(--lvl-solid, var(--crimson));
  box-shadow: 0 0 0 2px var(--lvl-ring, rgba(226, 36, 64, 0.2));
}

.compact-radio-label:has(input:checked) .rating-face-circle {
  background: var(--lvl-solid, var(--crimson));
  border-color: var(--lvl-solid, var(--crimson));
  color: #FFFFFF;
  box-shadow: 0 3px 8px var(--lvl-ring, rgba(226, 36, 64, 0.28));
  transform: scale(1.08);
}

.compact-radio-label:has(input:checked) .compact-score-num {
  color: var(--lvl-dark, var(--crimson-dark));
}

.rubric-option:has(input:focus-visible),
.compact-radio-label:has(input:focus-visible) {
  outline: 2px solid var(--lvl-solid, var(--crimson));
  outline-offset: 2px;
}

/* ==================== STICKY WIZARD FOOTER ==================== */
.wizard-footer {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  z-index: 35;
  box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.08);
}

.wizard-progress-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.progress-badge,
.avg-badge {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
}

.progress-badge {
  background: var(--crimson-soft);
  color: var(--crimson-dark);
}

.avg-badge {
  background: var(--gold-soft);
  color: var(--gold-dark);
}

.wizard-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==================== KPI, GUIDE, CONTACT & TABLES ==================== */
.kpi-grid {
  display: grid;
  gap: 14px;
}

.kpi-4 {
  grid-template-columns: repeat(4, 1fr);
}

.kpi-5 {
  grid-template-columns: repeat(5, 1fr);
}

.kpi-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-box.kpi-highlight {
  background: linear-gradient(135deg, var(--crimson-dark) 0%, var(--crimson) 100%);
  color: #FFFFFF;
  border-color: var(--crimson);
}

.kpi-box.kpi-highlight .kpi-label,
.kpi-box.kpi-highlight .kpi-value,
.kpi-box.kpi-highlight .kpi-sub {
  color: #FFFFFF;
}

.kpi-box.kpi-pass {
  background: var(--emerald-bg);
  border-color: #6EE7B7;
}

.kpi-box.kpi-pass .kpi-value {
  color: var(--emerald);
}

.kpi-box.kpi-fail {
  background: var(--rose-bg);
  border-color: #FECDD3;
}

.kpi-box.kpi-fail .kpi-value {
  color: var(--rose);
}

.kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-family: var(--font-head);
  font-size: 22px;
  color: var(--crimson-dark);
}

.kpi-sub {
  font-size: 13px;
  color: var(--text-muted);
}

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

.summary-table,
.rubric-ref-table,
.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.summary-table th,
.summary-table td,
.rubric-ref-table th,
.rubric-ref-table td,
.records-table th,
.records-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  vertical-align: top;
}

.summary-table th,
.rubric-ref-table th,
.records-table th {
  background: var(--crimson);
  color: #FFFFFF;
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 13px;
}

.rubric-ref-table th.col-benchmark {
  background: #0284C7;
}

.rubric-ref-table td.col-benchmark {
  background: #F0F9FF;
}

.summary-table tr.row-subtotal td {
  background: var(--crimson-soft);
  font-weight: 700;
  color: var(--crimson-dark);
}

.summary-table tr.row-grandtotal td {
  background: var(--crimson-dark);
  color: #FFFFFF;
  font-weight: 700;
}

.rubric-group-row td {
  background: var(--gold-soft);
  color: var(--crimson-dark);
  font-family: var(--font-head);
  font-weight: 600;
}

.badge-level {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-level.pass {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid #6EE7B7;
}

.badge-level.fail {
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px solid #FECDD3;
}

.badge-level.neutral {
  background: var(--surface-alt);
  color: var(--text-muted);
}

.certification-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--crimson-soft);
  border: 1.5px solid var(--crimson);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.certification-box input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 3px;
  accent-color: var(--crimson);
  flex-shrink: 0;
}

.signature-widget {
  padding: 16px;
  background: #F8FAFC;
  border: 1px solid #DDE5EE;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sig-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sig-widget-header label {
  font-family: var(--font-head);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--crimson-dark);
  margin: 0;
}

.sig-mode-tabs {
  display: inline-flex;
  padding: 3px;
  background: #E2E8F0;
  border-radius: 8px;
  gap: 4px;
}

.sig-tab-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-head);
  font-size: 12.5px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sig-tab-btn.active {
  background: #FFFFFF;
  color: var(--crimson);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.sig-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 16px;
  border: 2px dashed #CBD5E1;
  border-radius: 10px;
  background: #FFFFFF;
  text-align: center;
  cursor: pointer;
  transition: all 0.16s ease;
}

.sig-dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.sig-dropzone:hover,
.sig-dropzone.is-dragover {
  border-color: var(--crimson);
  background: var(--crimson-soft);
}

.sig-dropzone.has-error {
  border-color: var(--rose);
  background: #FFF7F8;
}

.sig-drop-icon {
  color: var(--crimson);
  display: inline-flex;
}

.sig-drop-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
}

.sig-drop-hint {
  font-size: 12.5px;
  color: var(--text-muted);
}

.sig-canvas-wrap {
  position: relative;
  background: #FFFFFF;
  border: 1.5px solid #CBD5E1;
  border-radius: 10px;
  overflow: hidden;
}

.sig-canvas-wrap.has-error {
  border-color: var(--rose);
  box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.12);
}

#signatureCanvas {
  display: block;
  width: 100%;
  max-width: 560px;
  height: 170px;
  margin: 0 auto;
  cursor: crosshair;
  touch-action: none;
}

.sig-canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  color: #94A3B8;
  pointer-events: none;
}

.sig-canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.sig-preview-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: #FFFFFF;
  border: 1.5px solid #86EFAC;
  border-radius: 10px;
  flex-wrap: wrap;
}

.sig-preview-img {
  max-height: 76px;
  max-width: 240px;
  object-fit: contain;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  background: #FFFFFF;
  padding: 4px 8px;
}

.sig-preview-info {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--text-muted);
}

.sig-preview-info strong {
  color: #15803D;
  font-size: 13.5px;
}

.sig-error-msg {
  color: var(--rose);
  font-size: 13px;
  font-weight: 600;
}

.submitted-lock-banner {
  border: 2px solid #16A34A;
  background: linear-gradient(135deg, #F0FDF4 0%, #DCFCE7 100%);
  padding: 18px 20px;
}

.submitted-lock-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.submitted-lock-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #16A34A;
  color: #FFFFFF;
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(22, 163, 74, 0.25);
}

.submitted-lock-head h3 {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 700;
  color: #14532D;
  margin: 0 0 4px;
}

.submitted-lock-head p {
  margin: 0;
  font-size: 14px;
  color: #166534;
}

.submitted-lock-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-left: 52px;
}

.btn.is-submitted-locked,
.btn.is-submitted-locked:disabled {
  background: #15803D;
  border-color: #15803D;
  color: #FFFFFF;
  opacity: 0.92;
  cursor: not-allowed;
}

.guide-steps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.guide-step-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.guide-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--crimson);
  color: #FFFFFF;
  font-family: var(--font-head);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-step-box p {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.contact-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
}

.contact-logo-wrap {
  margin-bottom: 16px;
}

.contact-logo {
  height: 48px;
  width: auto;
}

.contact-info-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contact-info-list li {
  display: flex;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}

.contact-info-list strong {
  min-width: 90px;
  color: var(--crimson-dark);
}

.contact-info-list a {
  color: var(--crimson);
  font-weight: 600;
}

.contact-sketch-box {
  margin-top: 16px;
  background: var(--crimson-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.contact-building-sketch {
  max-width: 100%;
  max-height: 230px;
  object-fit: contain;
}

/* ==================== FILTER BAR & SETTINGS ==================== */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1 1 280px;
}

.filter-select {
  flex: 0 1 240px;
}

.badge-inline {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 13px;
  color: var(--crimson-dark);
}

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

.settings-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
}

.setup-steps {
  margin: 0;
  padding-left: 20px;
}

.setup-steps li {
  margin-bottom: 10px;
}

.test-output-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.test-output-box.ok {
  background: var(--emerald-bg);
  border-color: #6EE7B7;
  color: #065F46;
}

.test-output-box.err {
  background: var(--rose-bg);
  border-color: #FECDD3;
  color: #9F1239;
}

.resource-links h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

.resource-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==================== CRIMSON FOOTER ==================== */
.portal-footer {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, #C71B35 0%, #E22440 50%, #C71B35 100%);
  color: #FFFFFF;
  padding: 16px 26px;
}

.footer-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-logo {
  height: 30px;
  width: auto;
  filter: brightness(0) invert(1);
}

.footer-org {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  font-size: 12.5px;
}

.footer-org strong {
  font-family: var(--font-head);
  font-size: 13.5px;
}

.footer-contacts {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
}

.footer-contacts span,
.footer-contacts a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
}

.footer-contacts a:hover {
  text-decoration: underline;
  color: var(--gold-light);
}

.footer-copy {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.85);
}

/* ==================== DRAWER & MODALS ==================== */
.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 60;
}

.rubric-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 94vw);
  background: #FFFFFF;
  z-index: 65;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.2);
}

.drawer-header,
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.drawer-search {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.drawer-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.drawer-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}

.drawer-item h4 {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--crimson-dark);
}

.drawer-levels {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.drawer-level-row {
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
}

.drawer-level-row.lvl3 {
  background: #F0F9FF;
  border-left: 3px solid #0284C7;
}

.modal-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-dialog {
  background: #FFFFFF;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-md {
  max-width: 580px;
}

.modal-lg {
  max-width: 960px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==================== CONFIRM SUBMIT & LOADING MODAL ==================== */
.confirm-warning-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: #FFFBEB;
  border: 1.5px solid #FCD34D;
  color: #92400E;
  font-size: 14px;
  line-height: 1.5;
}

.confirm-warning-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.confirm-warning-banner strong {
  color: #78350F;
  display: block;
  margin-bottom: 3px;
  font-size: 14.5px;
}

.confirm-warning-banner p {
  margin: 0;
}

.submit-loading-panel {
  text-align: center;
  padding: 26px 16px 20px;
}

.submit-spinner-wrap {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.submit-spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 5px solid #F1F5F9;
  border-top-color: var(--crimson);
  border-right-color: #F59E0B;
  animation: submitSpin 0.95s linear infinite;
}

.submit-spinner-doc {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFF1F2 0%, #FFE4E6 100%);
  color: var(--crimson-dark);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1.5px #FECDD3;
  animation: submitPulse 1.5s ease-in-out infinite;
}

.submit-loading-title {
  font-size: 17px;
  color: #0F172A;
  margin: 0 0 6px;
}

.submit-loading-step {
  font-size: 14px;
  font-weight: 600;
  color: var(--crimson-dark);
  margin: 0 0 16px;
  min-height: 21px;
}

.submit-loading-bar-track {
  width: 100%;
  max-width: 420px;
  height: 12px;
  margin: 0 auto 12px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.12);
}

.submit-loading-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FACC15 0%, #22C55E 55%, #16A34A 100%);
  background-size: 200% 100%;
  transition: width 0.35s ease;
  animation: submitBarShimmer 1.6s linear infinite;
}

.submit-loading-hint {
  font-size: 12.5px;
  color: #64748B;
  margin: 0;
}

@keyframes submitSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes submitPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.07);
  }
}

@keyframes submitBarShimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* ==================== TOASTS ==================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  background: #1F2937;
  color: #FFFFFF;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  font-weight: 500;
  border-left: 4px solid var(--gold);
}

.toast.toast-success {
  border-left-color: #34D399;
}

.toast.toast-error {
  border-left-color: #FB7185;
  background: #881337;
}

.toast.toast-warning {
  border-left-color: #FBBF24;
}

/* ==================== REPORT / PRINT DOCUMENT ==================== */
.report-doc {
  font-family: 'Sarabun', sans-serif;
  color: #111827;
  font-size: 13px;
  line-height: 1.42;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.report-page {
  background: #FFFFFF;
  box-sizing: border-box;
}

#reportModalBody .report-page + .report-page {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px dashed #CBD5E1;
}

.report-doc-header {
  text-align: center;
  border-bottom: 2px solid var(--crimson);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.report-doc-header h2 {
  font-size: 16.5px;
  margin: 2px 0 4px;
  color: var(--crimson-dark);
}

.report-doc-org {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  margin-bottom: 2px;
}

.report-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px 16px;
  margin-bottom: 10px;
  padding: 9px 12px;
  background: #FDFBFA;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 12.2px;
  line-height: 1.35;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  font-size: 12.2px;
  line-height: 1.35;
}

.report-table th,
.report-table td {
  border: 1px solid #94A3B8;
  padding: 4.5px 7px;
  vertical-align: middle;
}

.report-table th {
  background-color: #F1E9EA !important;
  color: #111827 !important;
  font-weight: 700;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.report-row-group td {
  background-color: #EFF4FA !important;
  color: #111827 !important;
  font-weight: 700;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.report-row-avg td {
  background-color: #F8FAFC !important;
  color: #111827 !important;
  font-weight: 700;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.report-row-part-total td {
  background-color: #E2E8F0 !important;
  color: #111827 !important;
  font-weight: 700;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.report-grand-total-table {
  margin-top: 2px;
  margin-bottom: 10px;
}

.report-row-grand-total,
.report-row-grand-total td {
  background-color: #E22440 !important;
  color: #FFFFFF !important;
  font-weight: 700;
  border-color: #94A3B8;
  padding: 7px 10px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.report-note-box {
  border: 1px solid #CBD5E1;
  background: #F8FAFC;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 12.2px;
}

.report-cert-box {
  border: 1px solid #94A3B8;
  padding: 12px 16px;
  margin-top: 10px;
  border-radius: 6px;
  background: #FFFFFF;
  page-break-inside: avoid;
  break-inside: avoid;
}

.report-sign-block {
  margin-top: 14px;
  text-align: right;
  page-break-inside: avoid;
  break-inside: avoid;
}

.report-sign-image-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.report-sign-img {
  max-height: 62px;
  max-width: 220px;
  object-fit: contain;
  display: block;
}

/* Offscreen A4 PDF Capture Stage (Exact 794x1123 A4 Pages) */
.report-a4-capture-root {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 794px;
  background: #FFFFFF;
  z-index: -1;
  pointer-events: none;
}

.report-a4-capture-root .report-page {
  width: 794px;
  min-height: 1123px;
  padding: 36px 42px;
  background: #FFFFFF;
  box-sizing: border-box;
  margin: 0 !important;
  border: none !important;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1180px) {
  .home-bottom-grid {
    grid-template-columns: 1fr 1fr;
  }

  .widget-cream {
    grid-column: span 2;
  }

  .guide-steps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 960px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .portal-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 62;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  .portal-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 60;
  }

  .wizard-footer {
    left: 0;
  }

  .rubric-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi-5 {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .portal-header {
    height: auto;
  }

  .header-inner {
    padding: 8px 12px;
    gap: 8px;
    height: auto;
  }

  .header-logo {
    height: 36px;
  }

  .status-pill {
    font-size: 11.5px;
    padding: 5px 10px;
    gap: 5px;
    max-width: 205px;
  }

  #connectionBadgeText {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-shell:has(#view-home.active) .portal-header,
  .app-shell.is-home .portal-header {
    background: rgba(255, 255, 255, 0.95);
  }

  .portal-main {
    padding: 14px 12px 136px;
  }

  .header-org-text,
  .brand-divider {
    display: none;
  }

  .hero-banner {
    margin: -14px -12px 0 -12px;
    min-height: 360px;
    padding: 28px 16px 64px;
    background-image:
      linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(255, 255, 255, 0.88) 70%, rgba(255, 255, 255, 0.72) 100%),
      url('../img/herotef.jpg');
  }

  .home-instructions-card {
    margin-top: -42px;
  }

  .domain-cards-grid,
  .home-bottom-grid,
  .inst-grid,
  .grid-2,
  .grid-3,
  .grouped-options,
  .kpi-4,
  .kpi-5,
  .rubric-cards-grid,
  .report-meta-grid,
  .guide-steps-grid {
    grid-template-columns: 1fr;
  }

  .card-header,
  .card-body {
    padding: 14px;
  }

  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="date"],
  input[type="url"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px;
  }

  .wizard-progress-card {
    padding: 12px 12px 14px;
  }

  .step-node {
    width: 30px;
    height: 30px;
    font-size: 12.5px;
  }

  .wizard-progress-track {
    top: 12px;
  }

  .step-label {
    font-size: 11px;
  }

  .widget-cream,
  .col-span-2-md {
    grid-column: span 1;
  }

  .part-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
  }

  .part-toolbar .toolbar-controls,
  .part-toolbar .view-mode-toggle {
    width: 100%;
  }

  .group-header {
    padding: 12px 14px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .group-header h3 {
    font-size: 14.5px;
  }

  .competency-items-list {
    padding: 12px;
    gap: 14px;
  }

  .competency-item-header {
    padding: 12px 14px;
    flex-wrap: wrap;
  }

  .rubric-cards-grid {
    padding: 12px 14px 14px;
  }

  /* Compact Table -> 2-Row Mobile Cards (Question on row 1, 4 scores on row 2) */
  .compact-table-wrap {
    padding: 10px;
    overflow-x: visible;
    background: #F1F5F9;
  }

  .compact-table,
  .compact-table tbody {
    display: block;
    width: 100%;
  }

  .compact-table thead {
    display: none;
  }

  .compact-table tbody tr {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: #FFFFFF;
    border: 1.5px solid #CBD5E1;
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
  }

  .compact-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .compact-table tbody tr:nth-child(even),
  .compact-table tbody tr:hover {
    background: #FFFFFF;
  }

  .compact-table tbody tr.unanswered-highlight {
    border-color: var(--crimson);
    box-shadow: 0 0 0 3px rgba(226, 36, 64, 0.16);
  }

  .compact-table tbody tr[data-selected-level="1"] {
    border-color: #DC2626;
    border-top-width: 3px;
  }

  .compact-table tbody tr[data-selected-level="2"] {
    border-color: #EA580C;
    border-top-width: 3px;
  }

  .compact-table tbody tr[data-selected-level="3"] {
    border-color: #0284C7;
    border-top-width: 3px;
  }

  .compact-table tbody tr[data-selected-level="4"] {
    border-color: #16A34A;
    border-top-width: 3px;
  }

  .compact-table td.compact-question-cell {
    grid-column: 1 / -1;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 11px 12px;
    background: #F8FAFC;
    border: none;
    border-bottom: 1px solid #E2E8F0;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.45;
    color: #0F172A;
    text-align: left;
  }

  .compact-table td.compact-question-cell .competency-code {
    flex-shrink: 0;
    margin-top: 1px;
  }

  .compact-table td.compact-radio-cell {
    width: auto;
    padding: 0;
    border: none;
    border-right: 1px solid #E2E8F0;
    background: #FFFFFF;
  }

  .compact-table td.compact-radio-cell:last-child {
    border-right: none;
  }

  .compact-radio-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 0 0 10px;
    gap: 6px;
    border: none;
    border-radius: 0;
  }

  .compact-score-text {
    display: block;
    width: 100%;
    padding: 7px 2px;
    background: #FFF6F7;
    border-bottom: 1px solid #F1E9EA;
    color: var(--crimson-dark);
    font-family: var(--font-head);
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
    line-height: 1.25;
    white-space: nowrap;
  }

  .compact-radio-label .rating-face-circle {
    width: 34px;
    height: 34px;
    margin-top: 2px;
  }

  .compact-radio-label:has(input:checked) {
    background: var(--lvl-soft, var(--crimson-soft));
    box-shadow: inset 0 0 0 2px var(--lvl-solid, var(--crimson));
  }

  .compact-radio-label:has(input:checked) .compact-score-text {
    background: var(--lvl-pill, #FFE4E6);
    color: var(--lvl-dark, var(--crimson-dark));
    border-bottom-color: var(--lvl-hover, #FDA4AF);
  }

  .progress-overview-body {
    flex-direction: column;
  }

  .wizard-footer {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
    gap: 8px;
  }

  .wizard-progress-inline {
    justify-content: space-between;
    font-size: 12.5px;
  }

  .wizard-buttons {
    justify-content: space-between;
    gap: 8px;
  }

  .wizard-buttons .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
    font-size: 14px;
  }

  .sig-widget-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .sig-mode-tabs {
    width: 100%;
  }

  .sig-tab-btn {
    flex: 1;
    text-align: center;
  }

  #signatureCanvas {
    width: 100%;
    height: 150px;
  }

  .modal-dialog {
    max-height: 92vh;
  }

  .modal-body {
    padding: 14px;
  }

  .modal-footer {
    padding: 12px 14px;
  }
}

@media (max-width: 420px) {
  .compact-score-text {
    font-size: 10.5px;
    padding: 6px 1px;
  }

  .compact-radio-label .rating-face-circle {
    width: 30px;
    height: 30px;
  }

  .step-label {
    font-size: 10px;
  }

  .hero-content h1 {
    font-size: 24px;
  }

  .btn-hero-cta {
    width: 100%;
    justify-content: center;
  }
}

/* ==================== PRINT MEDIA ==================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 11mm;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: #FFFFFF !important;
    margin: 0;
    padding: 0;
  }

  .no-print {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  .report-page {
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .report-page-break {
    page-break-before: always;
    break-before: page;
  }

  .report-cert-box,
  .report-sign-block,
  .report-grand-total-table,
  .report-table tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}