/* ================================================================
     KMUTT Visitor System — Premium Design System v3.0
     Brand Palette  : Yellow #FFC72C · Orange #FA4616 · Blue-Grey #7B8189
     Typography     : Prompt (Thai) + Inter (EN/Number)
     Style          : Professional · Formal · Motion-Driven
     Skill          : ui-ux-pro-max
  ================================================================ */

  /* ----------------------------------------------------------------
     DESIGN TOKENS
  ---------------------------------------------------------------- */
  :root {
    /* ── Brand Core ── */
    --yellow:        #FFC72C;   /* PANTONE 123 C */
    --yellow-light:  #FFD966;
    --yellow-deep:   #F0A500;
    --orange:        #FA4616;   /* PANTONE 172 C */
    --orange-light:  #FF6B3D;
    --orange-deep:   #D63808;
    --grey:          #7B8189;   /* PANTONE 415 C */
    --grey-light:    #A0A7AF;
    --grey-deep:     #565C63;

    /* ── Derived Semantic ── */
    --primary:       var(--orange);
    --primary-hover: var(--orange-deep);
    --accent:        var(--yellow);
    --accent-hover:  var(--yellow-deep);
    --neutral:       var(--grey);

    /* ── Surfaces ── */
    --bg-base:       #FFF9F0;          /* warm off-white */
    --bg-surface:    #FFFDF8;
    --bg-dark:       #1C1A18;
    --card-bg:       #FFFFFF;
    --card-glass:    rgba(255, 255, 255, 0.82);
    --card-glass-h:  rgba(255, 255, 255, 0.97);

    /* ── Text ── */
    --text-heading:  #1A1714;
    --text-main:     #2D2A26;
    --text-muted:    #5C5C60;
    --text-subtle:   #9CA3AF;
    --text-inverse:  #FFFFFF;

    /* ── Borders ── */
    --border:        #EDE8DF;
    --border-strong: #D9D0C2;
    --border-focus:  var(--orange);
    --border-accent: rgba(255, 199, 44, 0.5);

    /* ── Shadows ── */
    --shadow-xs:  0 1px 3px  rgba(26, 23, 20, 0.06);
    --shadow-sm:  0 2px 8px  rgba(26, 23, 20, 0.08);
    --shadow-md:  0 4px 18px rgba(26, 23, 20, 0.11);
    --shadow-lg:  0 10px 36px rgba(26, 23, 20, 0.14);
    --shadow-xl:  0 20px 60px rgba(26, 23, 20, 0.18);
    --shadow-orange: 0 8px 28px rgba(250, 70, 22, 0.30);
    --shadow-yellow: 0 8px 28px rgba(255, 199, 44, 0.38);
    --shadow-grey:   0 8px 22px rgba(123, 129, 137, 0.25);

    /* ── Input ── */
    --input-bg:      #FAFAF8;

    /* ── Radius ── */
    --r-xs:  6px;
    --r-sm:  10px;
    --r-md:  16px;
    --r-lg:  22px;
    --r-xl:  32px;
    --r-full: 9999px;

    /* ── Glass ── */
    --glass-bg:     rgba(255, 255, 255, 0.80);
    --glass-border: rgba(255, 255, 255, 0.70);

    /* ── Transitions ── */
    --t-fast:   all 0.15s ease;
    --t-base:   all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --t-spring: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    --t-slow:   all 0.50s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* ----------------------------------------------------------------
     RESET & BASE
  ---------------------------------------------------------------- */
  *, *::before, *::after { box-sizing: border-box; }

  body {
    font-family: 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-base);
    /* Layered warm background */
    background-image:
      radial-gradient(ellipse 70% 40% at 15% 0%,   rgba(250, 70, 22, 0.06) 0%, transparent 55%),
      radial-gradient(ellipse 55% 35% at 85% 100%, rgba(255, 199, 44, 0.08) 0%, transparent 55%),
      radial-gradient(ellipse 50% 60% at 50% 50%,  rgba(123, 129, 137, 0.03) 0%, transparent 70%),
      linear-gradient(160deg, #FFF8EE 0%, #FFFBF5 45%, #FFF9F0 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    margin: 0; padding: 0;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* Numbers & Latin text → Inter for crispness */
  .kpi-value,
  .kpi-mini-value,
  .badge-custom,
  td,
  .inter { font-family: 'Inter', sans-serif; }

  /* ================================================================
     KEYFRAME LIBRARY
  ================================================================ */
  @keyframes fadeInUp {
    from { opacity: 0; transform: translateY(22px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-14px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes slideInScale {
    from { opacity: 0; transform: translateY(28px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
  }
  @keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
  }
  @keyframes shine-sweep {
    0%   { left: -120%; }
    22%  { left:  210%; }
    100% { left:  210%; }
  }
  @keyframes float-gentle {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50%       { transform: translateY(-6px) rotate(1deg); }
  }
  @keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40%            { transform: scale(1); opacity: 1; }
  }
  @keyframes ripple-anim {
    to { transform: scale(5); opacity: 0; }
  }
  @keyframes gradient-flow {
    0%, 100% { background-position: 0%   50%; }
    50%       { background-position: 100% 50%; }
  }
  @keyframes border-glow {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
  }
  @keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0   rgba(250, 70, 22, 0.38); }
    70%  { box-shadow: 0 0 0 12px rgba(250, 70, 22, 0); }
    100% { box-shadow: 0 0 0 0   rgba(250, 70, 22, 0); }
  }
  @keyframes count-in {
    from { opacity: 0; transform: translateY(10px) scale(0.88); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
  }
  @keyframes header-line {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
  }
  @keyframes auth-bg-drift {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
  }
  @keyframes auth-card-enter {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  @keyframes auth-item-enter {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes auth-button-breathe {
    0%, 100% { box-shadow: 0 10px 24px rgba(250, 70, 22, 0.26); }
    50%      { box-shadow: 0 14px 32px rgba(250, 70, 22, 0.40); }
  }
  @keyframes auth-logo-shine {
    from { transform: translateX(-135%) skewX(-18deg); }
    to   { transform: translateX(180%) skewX(-18deg); }
  }
  @keyframes auth-orbit {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }
  @keyframes auth-login-content-in {
    from { opacity: 0; transform: translateX(22px); }
    to   { opacity: 1; transform: translateX(0); }
  }

  /* ── Page Transition Animations ── */
  @keyframes tab-slide-in-right {
    from { opacity: 0; transform: translateX(32px) scale(0.98); }
    to   { opacity: 1; transform: translateX(0)    scale(1); }
  }
  @keyframes tab-slide-in-left {
    from { opacity: 0; transform: translateX(-32px) scale(0.98); }
    to   { opacity: 1; transform: translateX(0)     scale(1); }
  }
  @keyframes tab-slide-in-up {
    from { opacity: 0; transform: translateY(24px) scale(0.975); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
  }
  @keyframes app-reveal-header {
    from { opacity: 0; transform: translateY(-18px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes app-reveal-content {
    from { opacity: 0; transform: translateY(28px) scale(0.975); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
  }

  /* ── Animation utility classes ── */
  .animate-fade-in-up   { animation: fadeInUp    0.48s cubic-bezier(0.4,0,0.2,1) forwards; opacity: 0; }
  .animate-fade-in      { animation: fadeInUp    0.38s cubic-bezier(0.4,0,0.2,1) forwards; }
  .animate-slide-scale  { animation: slideInScale 0.48s cubic-bezier(0.4,0,0.2,1) forwards; opacity: 0; }

  .animate-delay-1 { animation-delay: 0.08s; }
  .animate-delay-2 { animation-delay: 0.16s; }
  .animate-delay-3 { animation-delay: 0.24s; }
  .animate-delay-4 { animation-delay: 0.32s; }
  .animate-delay-5 { animation-delay: 0.40s; }

  /* ================================================================
     LAYOUT
  ================================================================ */
  .main-container {
    max-width: 96%;
    margin: 36px auto;
    padding: 0 24px;
    width: 100%;
  }

  .form-container-limit {
    width: 100%;
    max-width: min(1680px, calc(100vw - 32px));
    margin-left: auto;
    margin-right: auto;
  }

  body.auth-required .app-shell-header,
  body.auth-required .main-container { visibility: hidden; }

  /* ================================================================
     APP HEADER — Dark hero header matching site contact footer
  ================================================================ */
  .app-shell-header {
    width: 100%;
    margin: 0 0 2rem 0;
    padding: 2.2rem 1rem 2rem;
    background: linear-gradient(135deg, #211d1a 0%, #2d2925 55%, #1c1a18 100%);
    border-bottom: 4px solid var(--yellow, #ffc72c);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
  }

  .app-shell-header::before {
    content: '';
    position: absolute;
    width: 480px;
    height: 240px;
    top: -120px;
    right: -100px;
    border-radius: 50%;
    background: rgba(255, 199, 44, 0.12);
    filter: blur(20px);
    pointer-events: none;
  }

  .app-header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
  }

  .app-header > * { position: relative; z-index: 1; }

  .header-logo-badge {
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 24px;
    border-radius: 999px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .app-title {
    font-family: 'Prompt', sans-serif;
    font-weight: 700;
    font-size: clamp(1.65rem, 3.2vw, 2.15rem);
    letter-spacing: 0;
    line-height: 1.25;
    margin-bottom: 0.45rem;
    color: #ff6b35;
    background: linear-gradient(130deg, #ffa07a 0%, #ff6b35 40%, #fa4616 80%, #e03e10 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.4));
  }

  .app-subtitle {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.93rem;
    font-weight: 400;
    letter-spacing: 0.015em;
  }

  .app-header .btn-outline-primary {
    border-color: rgba(255, 199, 44, 0.6) !important;
    color: var(--yellow, #ffc72c) !important;
    background: rgba(255, 199, 44, 0.06);
  }
  .app-header .btn-outline-primary:hover {
    background: rgba(255, 199, 44, 0.2) !important;
    color: #fff !important;
    border-color: var(--yellow, #ffc72c) !important;
  }

  .app-header .btn-outline-dark {
    border-color: rgba(255, 255, 255, 0.35) !important;
    color: rgba(255, 255, 255, 0.9) !important;
    background: rgba(255, 255, 255, 0.08);
  }
  .app-header .btn-outline-dark:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
  }

  .app-header .btn-outline-danger {
    border-color: rgba(255, 107, 107, 0.6) !important;
    color: #ff8585 !important;
    background: rgba(255, 107, 107, 0.08);
  }
  .app-header .btn-outline-danger:hover {
    background: #e11d48 !important;
    color: #fff !important;
    border-color: #e11d48 !important;
  }

  .app-header .btn-outline-secondary {
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    background: rgba(255, 255, 255, 0.06);
  }
  .app-header .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.18) !important;
    color: #fff !important;
  }

  /* ================================================================
     GOOGLE LOGIN / AUTH CHIPS
  ================================================================ */
  .google-login-btn { max-width: min(100%, 300px); transition: var(--t-base); }

  .google-logo-img {
    width: 18px;
    height: 18px;
    display: inline-block;
    object-fit: contain;
  }

  .swal2-confirm.swal-google-login-button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 18px !important;
    border-radius: 999px !important;
    border: 1px solid #dadce0 !important;
    background: #fff !important;
    color: #3c4043 !important;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.18) !important;
    font-weight: 600 !important;
  }

  .swal2-confirm.swal-google-login-button:hover {
    background: #f8fafd !important;
  }

  /* ── Animation utility classes ── */
  .animate-fade-in-up   { animation: fadeInUp    0.48s cubic-bezier(0.4,0,0.2,1) forwards; opacity: 0; }
  .animate-fade-in      { animation: fadeInUp    0.38s cubic-bezier(0.4,0,0.2,1) forwards; }
  .animate-slide-scale  { animation: slideInScale 0.48s cubic-bezier(0.4,0,0.2,1) forwards; opacity: 0; }

  .animate-delay-1 { animation-delay: 0.08s; }
  .animate-delay-2 { animation-delay: 0.16s; }
  .animate-delay-3 { animation-delay: 0.24s; }
  .animate-delay-4 { animation-delay: 0.32s; }
  .animate-delay-5 { animation-delay: 0.40s; }

  /* ================================================================
     LAYOUT
  ================================================================ */
  .main-container {
    max-width: 96%;
    margin: 36px auto;
    padding: 0 24px;
    width: 100%;
  }

  .form-container-limit {
    width: 100%;
    max-width: min(1680px, calc(100vw - 32px));
    margin-left: auto;
    margin-right: auto;
  }

  body.auth-required .app-shell-header,
  body.auth-required .main-container { visibility: hidden; }

  /* ================================================================
     APP HEADER — Dark hero header matching site contact footer
  ================================================================ */
  .app-shell-header {
    width: 100%;
    margin: 0 0 2rem 0;
    padding: 2.2rem 1rem 2rem;
    background: linear-gradient(135deg, #211d1a 0%, #2d2925 55%, #1c1a18 100%);
    border-bottom: 4px solid var(--yellow, #ffc72c);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
  }

  .app-shell-header::before {
    content: '';
    position: absolute;
    width: 480px;
    height: 240px;
    top: -120px;
    right: -100px;
    border-radius: 50%;
    background: rgba(255, 199, 44, 0.12);
    filter: blur(20px);
    pointer-events: none;
  }

  .app-header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
  }

  .app-header > * { position: relative; z-index: 1; }

  .header-logo-badge {
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 24px;
    border-radius: 999px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .app-title {
    font-family: 'Prompt', sans-serif;
    font-weight: 700;
    font-size: clamp(1.65rem, 3.2vw, 2.15rem);
    letter-spacing: 0;
    line-height: 1.25;
    margin-bottom: 0.45rem;
    color: #ff6b35;
    background: linear-gradient(130deg, #ffa07a 0%, #ff6b35 40%, #fa4616 80%, #e03e10 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.4));
  }

  .app-subtitle {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.93rem;
    font-weight: 400;
    letter-spacing: 0.015em;
  }

  .app-header .btn-outline-primary {
    border-color: rgba(255, 199, 44, 0.6) !important;
    color: var(--yellow, #ffc72c) !important;
    background: rgba(255, 199, 44, 0.06);
  }
  .app-header .btn-outline-primary:hover {
    background: rgba(255, 199, 44, 0.2) !important;
    color: #fff !important;
    border-color: var(--yellow, #ffc72c) !important;
  }

  .app-header .btn-outline-dark {
    border-color: rgba(255, 255, 255, 0.35) !important;
    color: rgba(255, 255, 255, 0.9) !important;
    background: rgba(255, 255, 255, 0.08);
  }
  .app-header .btn-outline-dark:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
  }

  .app-header .btn-outline-danger {
    border-color: rgba(255, 107, 107, 0.6) !important;
    color: #ff8585 !important;
    background: rgba(255, 107, 107, 0.08);
  }
  .app-header .btn-outline-danger:hover {
    background: #e11d48 !important;
    color: #fff !important;
    border-color: #e11d48 !important;
  }

  .app-header .btn-outline-secondary {
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    background: rgba(255, 255, 255, 0.06);
  }
  .app-header .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.18) !important;
    color: #fff !important;
  }

  /* ================================================================
     GOOGLE LOGIN / AUTH CHIPS
  ================================================================ */
  .google-login-btn { max-width: min(100%, 300px); transition: var(--t-base); }

  .google-logo-img {
    width: 18px;
    height: 18px;
    display: inline-block;
    object-fit: contain;
  }

  .swal2-confirm.swal-google-login-button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 18px !important;
    border-radius: 999px !important;
    border: 1px solid #dadce0 !important;
    background: #fff !important;
    color: #3c4043 !important;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.18) !important;
    font-weight: 600 !important;
  }

  .swal2-confirm.swal-google-login-button:hover {
    background: #f8fafd !important;
    border-color: #cfd4dc !important;
    box-shadow: 0 2px 5px rgba(60, 64, 67, 0.22) !important;
  }

  .google-login-btn.is-signed-in {
    border-color: rgba(5, 150, 105, 0.40);
    color: #064E3B;
    background: rgba(209, 250, 229, 0.80);
  }

  .google-account-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 240px;
  }

  .google-account-avatar {
    width: 22px; height: 22px;
    border-radius: 999px;
    object-fit: cover;
    border: 1.5px solid rgba(26, 23, 20, 0.14);
    background: #fff;
  }

  .google-account-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ================================================================
     AUTH GATE — Welcome screen shown before the app is unlocked
  ================================================================ */
  body.auth-required { overflow: hidden; }

  .auth-gate {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 24px 16px;
    background: radial-gradient(circle at 50% 45%, #1e2c40 0%, #131d2b 55%, #0a111a 100%);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  }

  body:not(.auth-required) .auth-gate {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(1.05);
    filter: blur(8px);
  }

  .auth-gate-card {
    position: relative;
    width: min(500px, 100%);
    background: #ffffff;
    border-radius: 24px;
    padding: 48px 42px 38px 42px;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 255, 255, 0.08);
    overflow: hidden;
    text-align: center;
    animation: auth-card-pop 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  @keyframes auth-card-pop {
    from {
      opacity: 0;
      transform: scale(0.92) translateY(12px);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  .auth-card-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, #ea580c 0%, #f97316 42%, #0284c7 60%, #2563eb 100%);
  }

  .auth-card-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 28px;
  }

  .auth-card-logo {
    width: auto;
    max-width: 255px;
    height: 66px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.04));
  }

  .auth-card-logo-divider {
    width: 2px;
    height: 42px;
    background: rgba(0, 0, 0, 0.16);
    border-radius: 2px;
    flex-shrink: 0;
  }

  .auth-card-system-logo {
    width: auto;
    max-width: 115px;
    height: 68px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.06));
    transition: transform 0.25s ease;
  }

  .auth-card-system-logo:hover {
    transform: scale(1.06);
  }

  .auth-card-header {
    margin-bottom: 28px;
  }

  .auth-card-title {
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.52rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 8px 0;
    letter-spacing: -0.01em;
    line-height: 1.3;
  }

  .auth-card-system {
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.98rem;
    font-weight: 600;
    color: #334155;
    margin: 0 0 5px 0;
    line-height: 1.4;
  }

  .auth-card-dept {
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.86rem;
    font-weight: 400;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
  }

  .auth-provider-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
  }

  .auth-provider-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px 22px;
    min-height: 56px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    outline: none;
  }

  .auth-provider-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
  }

  .auth-provider-btn:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 2px;
    border-color: #f97316;
  }

  .auth-provider-btn:active {
    background: #f1f5f9;
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }

  .auth-provider-btn:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
    pointer-events: none;
  }

  .auth-provider-main {
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
  }

  .auth-provider-icon {
    display: block;
    flex-shrink: 0;
  }

  .auth-provider-label {
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.96rem;
    font-weight: 600;
    color: #1e293b;
    letter-spacing: -0.01em;
  }

  .auth-provider-arrow {
    font-size: 0.82rem;
    color: #94a3b8;
    transition: transform 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
  }

  .auth-provider-btn:hover .auth-provider-arrow {
    color: #475569;
    transform: translateX(3px);
  }

  .auth-gate-status {
    min-height: 24px;
    margin: 16px 0 0;
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.84rem;
    color: #ea580c;
    text-align: center;
    font-weight: 500;
  }

  @media (max-width: 480px) {
    .auth-gate {
      padding: 16px 12px;
    }
    .auth-gate-card {
      padding: 32px 20px 26px 20px;
      border-radius: 16px;
    }
    .auth-card-logo-wrap {
      gap: 8px;
    }
    .auth-card-logo {
      max-width: 170px;
      height: 42px;
    }
    .auth-card-logo-divider {
      height: 26px;
    }
    .auth-card-system-logo {
      max-width: 65px;
      height: 40px;
    }
    .auth-card-title {
      font-size: 1.22rem;
    }
    .auth-card-system {
      font-size: 0.82rem;
    }
    .auth-card-dept {
      font-size: 0.74rem;
    }
    .auth-provider-btn {
      padding: 11px 14px;
    }
    .auth-provider-label {
      font-size: 0.82rem;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .auth-gate, .auth-gate-card, .auth-provider-btn, .auth-provider-arrow {
      animation: none !important;
      transition: none !important;
    }
    .auth-provider-btn:hover {
      transform: none !important;
    }
    .auth-provider-btn:hover .auth-provider-arrow {
      transform: none !important;
    }
  }

  /* ================================================================
     CARD SYSTEM — Glassmorphism + Glow Accent
  ================================================================ */
  .card-custom {
    background: var(--glass-bg);
    backdrop-filter: blur(22px) saturate(1.7);
    -webkit-backdrop-filter: blur(22px) saturate(1.7);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(250, 70, 22, 0.05);
    padding: 36px 42px;
    margin-bottom: 32px;
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
    transition:
      transform   0.30s cubic-bezier(0.4, 0, 0.2, 1),
      box-shadow  0.30s cubic-bezier(0.4, 0, 0.2, 1),
      background  0.25s ease;
  }

  /* Top-right decorative orb */
  .card-custom::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 140px; height: 140px;
    background: radial-gradient(circle,
      rgba(255, 199, 44, 0.10) 0%,
      transparent 65%
    );
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  /* Animated bottom accent bar (revealed on hover) */
  .card-custom::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 0; height: 3px;
    background: linear-gradient(90deg, var(--orange), var(--yellow));
    border-radius: 0 0 var(--r-lg) 0;
    transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .card-custom:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(250, 70, 22, 0.10);
    background: var(--card-glass-h);
  }

  .card-custom:hover::after { width: 100%; }

  /* ================================================================
     NAVIGATION TABS — Floating Glassmorphism Pill
  ================================================================ */
  .nav-pills-custom {
    background: rgba(255, 255, 255, 0.90);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    padding: 6px;
    border-radius: var(--r-full);
    box-shadow:
      0 2px 18px rgba(26, 23, 20, 0.09),
      0 0 0 1px rgba(250, 70, 22, 0.08),
      inset 0 1px 0 rgba(255,255,255,0.9);
    display: inline-flex;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.95);
    position: relative;
  }

  .app-shell-header .nav-pills-custom {
    margin-bottom: 0;
  }

  .nav-pills-custom .nav-link {
    border-radius: var(--r-full);
    color: var(--grey);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 9px 26px;
    transition:
      color            0.20s ease,
      background-color 0.20s ease,
      box-shadow       0.20s ease;
    white-space: nowrap;
    position: relative;
    cursor: pointer;
    overflow: hidden;
  }

  .nav-pills-custom .nav-link:hover {
    color: var(--orange);
    background-color: rgba(250, 70, 22, 0.06);
  }

  .nav-pills-custom .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--orange-deep) 0%, var(--orange) 55%, var(--orange-light) 100%);
    background-size: 200% auto;
    animation: gradient-flow 5s ease infinite;
    box-shadow:
      0 4px 16px rgba(250, 70, 22, 0.40),
      inset 0 1px 0 rgba(255,255,255,0.20);
    font-weight: 600;
  }

  /* Shine sweep on active tab */
  .nav-pills-custom .nav-link.active::before {
    content: '';
    position: absolute;
    top: 0; left: -120%;
    width: 60%; height: 100%;
    background: linear-gradient(to right,
      rgba(255,255,255,0)   0%,
      rgba(255,255,255,0.28) 50%,
      rgba(255,255,255,0)   100%
    );
    transform: skewX(-22deg);
    animation: shine-sweep 4.5s ease-in-out infinite;
  }

  /* ================================================================
     FORM ELEMENTS
  ================================================================ */
  .section-title {
    color: var(--text-heading);
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 1.4rem;
    margin-top: 0.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    position: relative;
  }

  /* Animated gradient underline */
  .section-title::after {
    content: '';
    position: absolute;
    bottom: -2px; left: 0;
    width: 52px; height: 2px;
    background: linear-gradient(90deg, var(--orange), var(--yellow));
    border-radius: var(--r-full);
    transition: width 0.3s ease;
  }

  .section-title:hover::after { width: 100%; }

  .section-title i {
    background: linear-gradient(135deg,
      rgba(250, 70, 22, 0.12) 0%,
      rgba(255, 199, 44, 0.10) 100%
    );
    padding: 8px;
    border-radius: var(--r-sm);
    color: var(--orange);
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    border: 1px solid rgba(250, 70, 22, 0.14);
    transition: var(--t-base);
  }

  .section-title:hover i {
    background: linear-gradient(135deg, rgba(250,70,22,0.18), rgba(255,199,44,0.16));
    transform: rotate(-5deg) scale(1.08);
  }

  .form-label {
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 7px;
    font-size: 0.91rem;
    letter-spacing: 0.01em;
  }

  .form-control,
  .form-select {
    border-radius: var(--r-sm);
    border: 1.5px solid var(--border);
    padding: 11px 14px;
    background-color: var(--input-bg);
    font-family: 'Prompt', 'Inter', sans-serif;
    font-size: 0.92rem;
    color: var(--text-main);
    transition:
      border-color     0.20s ease,
      box-shadow       0.20s ease,
      background-color 0.20s ease;
  }

  .form-control:focus,
  .form-select:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(250, 70, 22, 0.14);
    background-color: #fff;
    outline: none;
  }

  .form-control::placeholder { color: var(--text-subtle); }

  #visitorForm .row.g-4 {
    --bs-gutter-x: 1.45rem;
    --bs-gutter-y: 1.15rem;
  }

  #visitorForm .section-title.mt-5 {
    margin-top: 2rem !important;
  }

  #visitorForm textarea.form-control {
    min-height: 72px;
  }

  #objective {
    min-height: 88px;
  }

  @media (min-width: 1200px) {
    .form-container-limit.card-custom {
      padding: 34px 42px;
    }

    #visitorForm .section-title {
      margin-bottom: 1rem;
    }

    #visitorForm .section-title.mt-5 {
      margin-top: 1.65rem !important;
    }

    #visitorForm .form-label {
      margin-bottom: 5px;
    }

    #visitorForm .form-control,
    #visitorForm .form-select {
      padding-top: 10px;
      padding-bottom: 10px;
    }

    #visitorForm .upload-area {
      padding: 22px 28px;
    }
  }

  /* Upload Area */
  .upload-area {
    border: 2px dashed var(--border-strong);
    border-radius: var(--r-lg);
    padding: 32px;
    text-align: center;
    background: linear-gradient(135deg, #FFF8EE 0%, #FFF5E0 100%);
    transition:
      border-color 0.25s ease,
      background   0.25s ease,
      transform    0.20s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }

  .upload-area::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg,
      rgba(250, 70, 22, 0.04) 0%,
      rgba(255, 199, 44, 0.04) 100%
    );
    opacity: 0;
    transition: opacity 0.25s ease;
  }

  .upload-area:hover,
  .upload-area.dragover {
    border-color: var(--orange);
    background: linear-gradient(135deg, #FFF0E6 0%, #FFFBE8 100%);
    transform: scale(1.006);
  }

  .upload-area:hover::before,
  .upload-area.dragover::before { opacity: 1; }

  .upload-area * {
    pointer-events: none;
  }

  /* ================================================================
     BUTTONS — Micro-animation + Ripple System
  ================================================================ */

  /* Ripple layer (injected by JS) */
  .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.38);
    transform: scale(0);
    animation: ripple-anim 0.58s linear;
    pointer-events: none;
  }

  /* Primary Submit Button */
  .btn-submit {
    background: linear-gradient(135deg,
      var(--orange-deep) 0%,
      var(--orange)      50%,
      var(--orange-light) 100%
    );
    background-size: 200% auto;
    border: none;
    border-radius: var(--r-full);
    padding: 13px 46px;
    font-family: 'Prompt', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.03em;
    color: #fff;
    box-shadow: var(--shadow-orange);
    transition:
      background-position 0.40s ease,
      transform           0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
      box-shadow          0.25s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
  }

  .btn-submit::before {
    content: '';
    position: absolute;
    top: 0; left: -120%;
    width: 55%; height: 100%;
    background: linear-gradient(to right,
      rgba(255,255,255,0)   0%,
      rgba(255,255,255,0.30) 50%,
      rgba(255,255,255,0)   100%
    );
    transform: skewX(-22deg);
    transition: left 0.65s ease;
  }

  .btn-submit:hover::before { left: 210%; }

  .btn-submit:hover {
    background-position: right center;
    transform: translateY(-3px) scale(1.025);
    box-shadow: 0 14px 32px rgba(250, 70, 22, 0.42);
    color: #fff;
  }

  .btn-submit:active {
    transform: translateY(-1px) scale(0.985);
  }

  /* Yellow / accent update variant */
  .btn-update {
    background: linear-gradient(135deg,
      var(--yellow-deep) 0%,
      var(--yellow)      60%,
      var(--yellow-light) 100%
    );
    background-size: 200% auto;
    color: var(--text-heading) !important;
    box-shadow: var(--shadow-yellow);
  }

  .btn-update:hover {
    box-shadow: 0 14px 32px rgba(255, 199, 44, 0.48);
    color: var(--text-heading) !important;
  }

  /* Bootstrap .btn-primary override */
  .btn-primary {
    background: linear-gradient(135deg, var(--orange-deep), var(--orange));
    border: none;
    box-shadow: 0 4px 16px rgba(250, 70, 22, 0.28);
    transition: var(--t-base);
    position: relative;
    overflow: hidden;
    cursor: pointer;
  }

  .btn-primary:hover {
    background: linear-gradient(135deg, var(--orange), var(--orange-light));
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(250, 70, 22, 0.40);
    filter: brightness(1.04);
  }

  .btn-primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(250, 70, 22, 0.36);
  }

  /* ================================================================
     IMAGE PREVIEW
  ================================================================ */
  .img-preview {
    width: 80px; height: 80px;
    object-fit: cover;
    border-radius: var(--r-sm);
    margin: 5px;
    border: 2px solid #fff;
    box-shadow: var(--shadow-md);
    transition:
      transform   0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
      box-shadow  0.22s ease;
    cursor: pointer;
  }

  .img-preview:hover {
    transform: scale(1.14);
    z-index: 2;
    box-shadow: var(--shadow-orange);
  }

  .schedule-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(79, 70, 229, 0.18);
    border-radius: var(--r-sm);
    background: #fff;
    box-shadow: var(--shadow-sm);
  }

  .schedule-file-chip .schedule-file-name {
    max-width: min(340px, 68vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ================================================================
     TABLE SYSTEM — Hover Glow Effects
  ================================================================ */
  .table-custom {
    border-collapse: separate;
    border-spacing: 0 8px;
    table-layout: fixed;
    width: 100%;
  }

  .table-container {
    contain: layout;
    overflow: hidden;
  }

  .table-custom thead th {
    border: none;
    background: transparent;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.70rem;
    letter-spacing: 0.10em;
    padding: 8px 15px;
  }

  .history-col-date { width: 12%; }
  .history-col-org { width: 38%; }
  .history-col-visitors { width: 10%; }
  .history-col-image { width: 8%; }
  .history-col-follow { width: 18%; }
  .history-col-actions { width: 14%; }

  .history-table thead th:nth-child(3),
  .history-table thead th:nth-child(4),
  .history-table thead th:nth-child(6) {
    text-align: center;
  }

  .table-custom tbody tr {
    background-color: #fff;
    box-shadow: var(--shadow-xs), 0 0 0 1px rgba(26,23,20,0.04);
    content-visibility: auto;
    contain-intrinsic-size: 92px;
    transition:
      transform    0.22s cubic-bezier(0.4, 0, 0.2, 1),
      box-shadow   0.22s ease;
    cursor: pointer;
  }

  .table-custom td:first-child {
    border-top-left-radius: var(--r-sm);
    border-bottom-left-radius: var(--r-sm);
    position: relative;
  }

  /* Glow on hover — orange left border reveal */
  .table-custom tbody tr td:first-child::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    background: linear-gradient(180deg, var(--orange), var(--yellow));
    border-radius: var(--r-xs) 0 0 var(--r-xs);
    opacity: 0;
    transition: opacity 0.20s ease;
    z-index: 1;
  }

  .table-custom tbody tr:hover {
    transform: translateY(-2px) translateX(3px);
    box-shadow:
      var(--shadow-md),
      0 0 0 1px rgba(250, 70, 22, 0.12),
      0 0 20px rgba(250, 70, 22, 0.06);
  }

  .table-custom tbody tr:hover td:first-child::before { opacity: 1; }

  .table-custom td {
    border: none;
    padding: 14px 12px;
    vertical-align: middle;
    color: var(--text-main);
    font-size: 0.90rem;
    min-width: 0;
    overflow: hidden;
  }

  .history-cell-org,
  .history-cell-follow {
    min-width: 0;
    overflow: hidden;
  }

  .history-cell-org .fw-bold {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
  }

  .history-cell-visitors,
  .history-cell-image,
  .history-cell-actions {
    text-align: center;
  }

  .history-follow-text {
    max-width: 100%;
  }

  .history-actions {
    justify-content: center;
    min-width: 0;
    flex-wrap: nowrap;
  }

  .history-detail-button {
    flex: 0 1 auto;
    min-width: 0 !important;
    max-width: 100%;
  }

  /* ================================================================
     HISTORY VIEW SWITCHER + GRID CARDS
  ================================================================ */
  .history-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .history-view-switch {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow-xs);
  }

  .history-view-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 34px;
    padding: 6px 12px;
    border: 0;
    border-radius: var(--r-full);
    color: var(--text-muted);
    background: transparent;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  }

  .history-view-button:hover {
    color: var(--orange-deep);
    background: rgba(250, 70, 22, 0.08);
  }

  .history-view-button:focus-visible {
    outline: 3px solid rgba(250, 70, 22, 0.24);
    outline-offset: 2px;
  }

  .history-view-button.is-active {
    color: #fff;
    background: var(--orange);
    box-shadow: 0 4px 12px rgba(250, 70, 22, 0.22);
  }

  .history-grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
    gap: 1rem;
    contain: layout;
  }

  .history-grid-empty {
    grid-column: 1 / -1;
    padding: 3rem 1rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text-muted);
    text-align: center;
    background: rgba(255, 255, 255, 0.58);
  }

  .history-card {
    position: relative;
    display: flex;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(26, 23, 20, 0.07);
    border-radius: var(--r-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  }

  .history-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, var(--orange), var(--yellow));
  }

  .history-card:hover {
    border-color: rgba(250, 70, 22, 0.18);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(250, 70, 22, 0.06);
  }

  .history-card-main {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: 0.8rem;
    padding: 1.1rem 1.1rem 0.9rem;
  }

  .history-card-meta,
  .history-card-org-row,
  .history-card-footer,
  .history-card-actions {
    display: flex;
    align-items: center;
  }

  .history-card-meta,
  .history-card-org-row,
  .history-card-footer {
    justify-content: space-between;
    gap: 0.75rem;
  }

  .history-card-date {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
  }

  .history-card-org-row {
    align-items: flex-start;
  }

  .history-card-org {
    min-width: 0;
    color: var(--text-heading);
    font-size: 1rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .history-card-org .new-record-label {
    display: inline-flex;
    vertical-align: middle;
    margin: 0 0 0.15rem 0.35rem !important;
    font-size: 0.65rem;
  }

  .history-card-status {
    flex: 0 0 auto;
  }

  .history-card-info {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.6rem;
  }

  .history-card-image {
    position: relative;
    display: flex;
    width: 100%;
    height: 170px;
    align-items: center;
    justify-content: center;
    min-height: 0;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, #fff8ee, #f8fafc);
    overflow: hidden;
  }

  .history-card-image > .position-relative {
    display: block !important;
    width: 100%;
    height: 100%;
  }

  .history-card-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border: 0;
    border-radius: inherit;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .history-card-image img:hover {
    transform: scale(1.04);
    box-shadow: var(--shadow-orange);
  }

  .history-card-image > .position-relative > .badge {
    top: 0.65rem !important;
    right: 0.65rem !important;
    left: auto !important;
    transform: none !important;
    z-index: 2;
  }

  .history-card-image-placeholder {
    color: var(--text-subtle);
    font-size: 0.75rem;
  }

  .history-card-stats {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: #fafaf8;
  }

  .history-card-stat-label {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
  }

  .history-card-follow {
    min-height: 2.8rem;
    padding: 0.7rem 0.8rem;
    border-radius: var(--r-sm);
    color: var(--text-main);
    background: #fafaf8;
    font-size: 0.8rem;
    line-height: 1.5;
  }

  .history-card-follow-label {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
  }

  .history-card-actions {
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.1rem 1rem;
    border-top: 1px solid var(--border);
  }

  .history-card-action {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border: 0;
  }

  @media (max-width: 1200px) {
    .history-grid-view {
      grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
    }
  }

  @media (max-width: 767.98px) {
    .history-header-actions {
      width: 100%;
      justify-content: space-between;
    }

    .history-view-switch { flex: 1 1 auto; }
    .history-view-button { flex: 1 1 0; }
    .history-grid-view { grid-template-columns: minmax(0, 1fr); }
    .history-card-image { height: 150px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .history-card,
    .history-card-image img,
    .history-view-button { transition: none; }
  }

  @media (max-width: 1280px) {
    .table-custom thead th {
      padding-left: 10px;
      padding-right: 10px;
      font-size: 0.66rem;
      letter-spacing: 0.06em;
    }

    .history-col-date { width: 12%; }
    .history-col-org { width: 39%; }
    .history-col-visitors { width: 10%; }
    .history-col-image { width: 8%; }
    .history-col-follow { width: 19%; }
    .history-col-actions { width: 12%; }

    .history-detail-button {
      width: 44px;
      height: 44px;
      padding: 0 !important;
      border-radius: 999px !important;
    }

    .history-detail-button span {
      display: none;
    }
  }

  .table-custom td:first-child {
    border-top-left-radius: var(--r-sm);
    border-bottom-left-radius: var(--r-sm);
  }

  .table-custom td:last-child {
    border-top-right-radius: var(--r-sm);
    border-bottom-right-radius: var(--r-sm);
  }

  .badge-custom {
    font-family: 'Inter', sans-serif;
    padding: 5px 11px;
    border-radius: var(--r-full);
    font-weight: 600;
    font-size: 0.73rem;
    letter-spacing: 0.02em;
  }

  .badge-primary {
    background: rgba(250, 70, 22, 0.10);
    color: var(--orange-deep);
    border: 1px solid rgba(250, 70, 22, 0.18);
  }

  .badge-secondary {
    background: rgba(123, 129, 137, 0.10);
    color: var(--grey-deep);
    border: 1px solid rgba(123, 129, 137, 0.18);
  }

  .new-record-label {
    display: inline-block;
    font-size: 0.68rem;
    line-height: 1.2;
    font-weight: 600;
    padding: 3px 7px;
    vertical-align: middle;
    white-space: nowrap;
  }

  .visit-status-label {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.68rem;
    line-height: 1.2;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 999px;
    white-space: nowrap;
  }

  .visit-status-active {
    color: #842029;
    background: #f8d7da;
    border: 1px solid #f1aeb5;
  }

  .visit-status-upcoming {
    color: #664d03;
    background: #fff3cd;
    border: 1px solid #ffecb5;
  }

  /* Thin scrollbar for table wrapper */
  .table-responsive {
    scrollbar-width: thin;
    scrollbar-color: rgba(250, 70, 22, 0.25) transparent;
  }
  .table-responsive::-webkit-scrollbar { height: 4px; }
  .table-responsive::-webkit-scrollbar-track { background: transparent; }
  .table-responsive::-webkit-scrollbar-thumb {
    background: rgba(250, 70, 22, 0.28);
    border-radius: var(--r-full);
  }

  /* ================================================================
     LOADING OVERLAY — 3-dot loader
  ================================================================ */
  .loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255, 249, 240, 0.90);
    backdrop-filter: blur(10px) saturate(1.4);
    -webkit-backdrop-filter: blur(10px) saturate(1.4);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 1.2rem;
  }

  .dot-loader {
    display: flex;
    gap: 9px;
    align-items: center;
  }

  .dot-loader span {
    width: 13px; height: 13px;
    border-radius: 50%;
    display: block;
    animation: dot-bounce 1.4s ease-in-out infinite;
  }

  .dot-loader span:nth-child(1) { animation-delay: 0s;    background: var(--orange); }
  .dot-loader span:nth-child(2) { animation-delay: 0.18s; background: var(--yellow); }
  .dot-loader span:nth-child(3) { animation-delay: 0.36s; background: var(--grey);   }

  .spinner-grow {
    width: 3rem; height: 3rem;
    color: var(--orange);
  }

  /* ================================================================
     DASHBOARD — KPI CARDS (Animated Counters + Gradient)
  ================================================================ */
  .kpi-card {
    background: linear-gradient(135deg,
      var(--orange-deep) 0%,
      var(--orange)      45%,
      var(--yellow-deep) 75%,
      var(--yellow)      100%
    );
    background-size: 220% 220%;
    animation: gradient-flow 8s ease infinite;
    border-radius: var(--r-lg);
    padding: 22px;
    color: #fff;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-orange);
    transition:
      transform   0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
      box-shadow  0.35s ease;
    cursor: pointer;
  }

  /* Decorative orb */
  .kpi-card::before {
    content: '';
    position: absolute;
    top: -35px; right: -35px;
    width: 120px; height: 120px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    pointer-events: none;
  }

  /* Shine sweep */
  .kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: -120%;
    width: 55%; height: 100%;
    background: linear-gradient(to right,
      rgba(255,255,255,0)   0%,
      rgba(255,255,255,0.20) 50%,
      rgba(255,255,255,0)   100%
    );
    transform: skewX(-22deg);
    animation: shine-sweep 6.5s ease-in-out infinite;
  }

  .kpi-card:hover {
    transform: translateY(-7px) scale(1.025);
    box-shadow: 0 20px 48px rgba(250, 70, 22, 0.40);
    animation-play-state: paused;
  }

  .kpi-icon {
    font-size: 1.25rem;
    opacity: 0.90;
    margin-bottom: 6px;
  }

  .kpi-value {
    font-family: 'Inter', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.15;
    animation: count-in 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    letter-spacing: -0.03em;
  }

  .kpi-label {
    font-size: 0.72rem;
    opacity: 0.88;
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  /* Mini KPI Cards */
  .kpi-card-mini {
    background: #fff;
    border-radius: var(--r-md);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(26,23,20,0.04);
    transition:
      transform    0.22s ease,
      box-shadow   0.22s ease,
      border-color 0.22s ease;
    border-left: 3px solid transparent;
    position: relative;
    overflow: hidden;
  }

  .kpi-card-mini::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--orange), var(--yellow));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.30s ease;
  }

  .kpi-card-mini:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-left-color: var(--orange);
  }

  .kpi-card-mini:hover::before { transform: scaleX(1); }

  .kpi-mini-icon {
    width: 44px; height: 44px;
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem;
    margin-right: 14px;
    flex-shrink: 0;
  }

  .kpi-mini-value {
    font-family: 'Inter', sans-serif;
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text-heading);
    line-height: 1.15;
    letter-spacing: -0.03em;
    animation: count-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .kpi-mini-label {
    font-size: 0.72rem;
    color: var(--grey);
    font-weight: 500;
    letter-spacing: 0.025em;
  }

  /* Top Org Banner */
  .top-org-banner {
    padding: 20px 24px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, #FFFBEE 0%, #FFF8E0 100%);
    border: 1px solid rgba(255, 199, 44, 0.28);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--t-base);
  }

  .top-org-banner:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(255, 199, 44, 0.50);
  }

  .top-org-trophy {
    width: 54px; height: 54px;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, var(--yellow), var(--yellow-deep));
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    margin-right: 16px;
    flex-shrink: 0;
    box-shadow: var(--shadow-yellow);
    animation: float-gentle 3.5s ease-in-out infinite;
  }

  /* ================================================================
     CHART CARDS
  ================================================================ */
  .chart-card {
    padding: 24px;
    border-radius: var(--r-lg);
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    contain: layout paint;
    transition: var(--t-base);
    position: relative;
    overflow: hidden;
  }

  /* Animated top accent line (hidden → reveal on hover) */
  .chart-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg,
      var(--orange) 0%,
      var(--yellow) 50%,
      var(--orange) 100%
    );
    background-size: 200% auto;
    animation: border-glow 4s linear infinite;
    opacity: 0;
    transition: opacity 0.30s ease;
  }

  .chart-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(250, 70, 22, 0.14);
  }

  .chart-card:hover::before { opacity: 1; }

  .chart-card-header {
    display: flex; align-items: center;
    gap: 12px;
    margin-bottom: 20px;
  }

  .chart-icon {
    width: 40px; height: 40px;
    border-radius: var(--r-xs);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; flex-shrink: 0;
  }

  .chart-title {
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 2px;
    font-size: 0.92rem;
    letter-spacing: -0.01em;
  }

  .chart-subtitle {
    font-size: 0.72rem;
    color: var(--text-subtle);
    font-weight: 400;
  }

  /* Progress bar with shimmer */
  .progress-bar-custom {
    height: 7px;
    border-radius: var(--r-full);
    background: #EDE8DF;
    overflow: hidden;
  }

  .progress-bar-custom .bar {
    height: 100%;
    border-radius: var(--r-full);
    background: linear-gradient(90deg, var(--orange), var(--yellow));
    transition: width 0.85s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
  }

  .progress-bar-custom .bar::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg,
      transparent,
      rgba(255,255,255,0.45),
      transparent
    );
    animation: shimmer 2.2s ease-in-out infinite;
    background-size: 200% 100%;
  }

  /* ================================================================
     BENTO-BOX GRID (Dashboard supplemental utility)
  ================================================================ */
  .bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .bento-card {
    background: #fff;
    border-radius: var(--r-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(26,23,20,0.04);
    transition: var(--t-base);
    position: relative;
    overflow: hidden;
    cursor: pointer;
  }

  .bento-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(250,70,22,0.10);
  }

  /* Span variants */
  .bento-span-2 { grid-column: span 2; }
  .bento-span-3 { grid-column: span 3; }
  .bento-span-4 { grid-column: span 4; }
  .bento-row-2  { grid-row: span 2; }

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

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

  /* ================================================================
     SCROLL REVEAL (Intersection Observer hook)
  ================================================================ */
  .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition:
      opacity   0.55s cubic-bezier(0.4, 0, 0.2, 1),
      transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .reveal.visible {
    opacity: 1;
    transform: translateY(0);
  }

  /* Stagger children inside reveal container */
  .reveal-stagger > * {
    opacity: 0;
    transform: translateY(18px);
    transition:
      opacity   0.45s cubic-bezier(0.4,0,0.2,1),
      transform 0.45s cubic-bezier(0.4,0,0.2,1);
  }

  .reveal-stagger.visible > *:nth-child(1) { opacity:1; transform:none; transition-delay: 0.05s; }
  .reveal-stagger.visible > *:nth-child(2) { opacity:1; transform:none; transition-delay: 0.12s; }
  .reveal-stagger.visible > *:nth-child(3) { opacity:1; transform:none; transition-delay: 0.19s; }
  .reveal-stagger.visible > *:nth-child(4) { opacity:1; transform:none; transition-delay: 0.26s; }
  .reveal-stagger.visible > *:nth-child(5) { opacity:1; transform:none; transition-delay: 0.33s; }

  /* ================================================================
     SKELETON SHIMMER PLACEHOLDER
  ================================================================ */
  .skeleton {
    background: linear-gradient(
      90deg,
      #F5EFE6 25%,
      #EDE4D8 50%,
      #F5EFE6 75%
    );
    background-size: 400% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
    border-radius: var(--r-sm);
  }

  /* ================================================================
     DIVIDER
  ================================================================ */
  .divider-gradient {
    height: 1px;
    background: linear-gradient(90deg,
      transparent 0%,
      var(--border) 25%,
      var(--border-strong) 50%,
      var(--border) 75%,
      transparent 100%
    );
    margin: 1.5rem 0;
  }

  /* ================================================================
     AI ASSISTANT MODAL
  ================================================================ */
  .ai-assistant-launch-btn {
    background: linear-gradient(135deg, #0369A1 0%, #0284C7 60%, #06B6D4 100%);
    background-size: 200% auto;
    border: none;
    font-size: 0.91rem;
    font-weight: 600;
    transition: background-position 0.40s ease, transform 0.20s ease, box-shadow 0.20s ease;
    position: relative;
    overflow: hidden;
  }

  .ai-assistant-launch-btn:hover {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(2, 132, 199, 0.36);
    filter: brightness(1.04);
  }

  .ai-assistant-modal .modal-dialog {
    width: min(97vw, 1680px) !important;
    max-width: min(97vw, 1680px) !important;
  }

  .ai-assistant-modal { --bs-modal-width: min(97vw, 1680px); }

  .ai-assistant-modal .ai-assistant-dialog {
    width: var(--bs-modal-width) !important;
    max-width: var(--bs-modal-width) !important;
  }

  .ai-assistant-modal .modal-content {
    border-radius: var(--r-lg);
    overflow: hidden;
    border: none;
    box-shadow: var(--shadow-xl);
  }

  .ai-assistant-header {
    padding: 1.5rem 1.7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #FAFBFF 0%, #FFF8F0 100%);
  }

  .ai-assistant-title {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.025em;
  }

  .ai-assistant-title-icon {
    width: 36px; height: 36px;
    border-radius: var(--r-xs);
    display: inline-flex; align-items: center; justify-content: center;
    color: #0284C7;
    background: linear-gradient(135deg, #E0F2FE, #BAE6FD);
    font-size: 1.05rem;
    box-shadow: 0 3px 10px rgba(2,132,199,0.22);
  }

  .ai-assistant-close-btn {
    width: 42px; height: 42px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: #fff;
    color: var(--grey);
    display: inline-flex; align-items: center; justify-content: center;
    transition: var(--t-fast);
    cursor: pointer;
  }

  .ai-assistant-close-btn:hover {
    background: #F5F0E8;
    color: var(--text-heading);
  }

  .ai-assistant-body {
    padding: 1.35rem 1.7rem 1.7rem;
    background: #fff;
  }

  .ai-assistant-options-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.95rem;
    font-size: 0.92rem;
    color: var(--text-main);
  }

  .ai-summary-action-btn {
    background: linear-gradient(135deg, #0369A1, #0284C7);
    color: #fff;
    border: none;
    border-radius: var(--r-sm);
    padding: 0.6rem 1rem;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(2,132,199,0.24);
    transition: var(--t-base);
    cursor: pointer;
  }

  .ai-summary-action-btn:hover {
    color: #fff;
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(2,132,199,0.32);
  }

  .ai-assistant-options-row .form-check-input:checked {
    background-color: var(--orange);
    border-color: var(--orange);
  }

  .ai-chat-stage {
    min-height: 250px;
    max-height: 370px;
    overflow-y: auto;
    background: linear-gradient(135deg, #FFF8EE 0%, #FFFBF5 100%);
    border: 1px solid #F0E8D8;
    border-radius: var(--r-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(250, 70, 22, 0.28) transparent;
  }

  .ai-chat-stage::-webkit-scrollbar { width: 5px; }
  .ai-chat-stage::-webkit-scrollbar-track { background: transparent; }
  .ai-chat-stage::-webkit-scrollbar-thumb {
    background: rgba(250, 70, 22, 0.28);
    border-radius: var(--r-full);
  }

  .ai-message-card {
    width: min(100%, 500px);
    border-radius: var(--r-md);
    border: 1px solid #EAE0D0;
    background: #fff;
    box-shadow: 0 2px 10px rgba(26,23,20,0.07);
    padding: 0.75rem 0.9rem 0.85rem;
    animation: fadeInUp 0.32s ease-out forwards;
  }

  .ai-message-assistant { align-self: flex-start; }

  .ai-message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #FFF8EE, #FFF5E5);
    border-color: rgba(250, 70, 22, 0.18);
  }

  .ai-message-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    color: var(--grey);
    margin-bottom: 0.28rem;
    text-transform: uppercase;
  }

  .ai-message-text {
    white-space: pre-line;
    line-height: 1.58;
    color: var(--text-main);
    font-size: 0.91rem;
  }

  .ai-input-wrap { margin-top: 0.8rem; }

  .ai-prompt-input {
    border: 1.5px solid rgba(250, 70, 22, 0.45);
    background: #fff;
    border-radius: var(--r-md);
    padding: 0.85rem 0.9rem;
    min-height: 102px;
    resize: vertical;
    font-family: 'Prompt', 'Inter', sans-serif;
    transition: border-color 0.20s ease, box-shadow 0.20s ease;
  }

  .ai-prompt-input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(250, 70, 22, 0.13);
    outline: none;
  }

  .ai-action-row {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
  }

  .ai-chat-clear-btn {
    border-radius: var(--r-sm);
    border: 1px solid var(--border-strong);
    background: #F9F5EE;
    color: var(--grey-deep);
    font-weight: 600;
    padding: 0.55rem 1.1rem;
    transition: var(--t-fast);
    cursor: pointer;
  }

  .ai-chat-clear-btn:hover {
    background: #F0E8DC;
    color: var(--text-main);
  }

  .ai-chat-send-btn {
    border-radius: var(--r-sm);
    border: none;
    background: linear-gradient(135deg, var(--orange-deep), var(--orange));
    color: #fff;
    font-weight: 700;
    padding: 0.55rem 1.4rem;
    transition: var(--t-base);
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }

  .ai-chat-send-btn:hover {
    color: #fff;
    filter: brightness(1.07);
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(250, 70, 22, 0.34);
  }

  /* ================================================================
     EXTRA DATA MODAL — Premium Redesign
  ================================================================ */
  #extraDataModal .modal-dialog {
    width: min(98vw, 1760px);
    max-width: min(98vw, 1760px) !important;
    min-width: 0 !important;
    margin: 0.75rem auto;
  }

  #extraDataModal .modal-content {
    border-radius: 16px !important;
    overflow: hidden;
    border: none !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18) !important;
  }

  /* --- Header --- */
  #extraDataModal .modal-header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 55%, #6366f1 100%) !important;
    padding: 1.4rem 1.75rem 1.2rem !important;
    border-bottom: none !important;
    border-radius: 0 !important;
    position: relative;
  }
  #extraDataModal .modal-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
  }
  #extraDataModal .modal-title {
    font-size: 1.3rem !important;
    font-weight: 700 !important;
    color: #fff !important;
    letter-spacing: 0.01em;
    position: relative;
    z-index: 1;
  }
  #extraDataModal .modal-title .modal-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.18);
    border-radius: 9px;
    margin-right: 0.65rem;
    font-size: 1rem;
    flex-shrink: 0;
  }
  #extraDataModal .btn-close {
    filter: invert(1) brightness(2) !important;
    opacity: 0.85;
    position: relative;
    z-index: 1;
  }

  /* --- Body --- */
  #extraDataModal .modal-body {
    padding: 1.25rem 1.5rem 1rem !important;
    background: #f0f4f8 !important;
  }

  /* --- Main Grid --- */
  #extraDataModal .extra-data-shell {
    background: transparent !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  #extraDataModal .extra-data-grid {
    display: grid !important;
    grid-template-columns: 300px 1fr 280px;
    gap: 1rem;
    align-items: start;
  }

  #extraDataModal .extra-data-primary,
  #extraDataModal .extra-data-secondary {
    min-width: 0;
    width: auto !important;
    max-width: none !important;
    flex: none !important;
  }

  /* --- Section Card base --- */
  #extraDataModal .ed-section {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  #extraDataModal .ed-section-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }
  #extraDataModal .ed-section-header .ed-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    font-size: 0.78rem;
    flex-shrink: 0;
  }
  #extraDataModal .ed-section-body {
    padding: 0.9rem 1rem;
    flex: 1;
  }

  /* --- Color themes per section --- */
  #extraDataModal .ed-theme-blue  .ed-section-header { background: #eff6ff; color: #1d4ed8; }
  #extraDataModal .ed-theme-blue  .ed-icon           { background: #dbeafe; color: #1d4ed8; }
  #extraDataModal .ed-theme-violet .ed-section-header { background: #f5f3ff; color: #6d28d9; }
  #extraDataModal .ed-theme-violet .ed-icon           { background: #ede9fe; color: #6d28d9; }
  #extraDataModal .ed-theme-green .ed-section-header  { background: #f0fdf4; color: #166534; }
  #extraDataModal .ed-theme-green .ed-icon            { background: #dcfce7; color: #166534; }
  #extraDataModal .ed-theme-amber .ed-section-header  { background: #fffbeb; color: #92400e; }
  #extraDataModal .ed-theme-amber .ed-icon            { background: #fef3c7; color: #92400e; }
  #extraDataModal .ed-theme-rose  .ed-section-header  { background: #fff1f2; color: #9f1239; }
  #extraDataModal .ed-theme-rose  .ed-icon            { background: #ffe4e6; color: #9f1239; }
  #extraDataModal .ed-theme-teal  .ed-section-header  { background: #f0fdfa; color: #115e59; }
  #extraDataModal .ed-theme-teal  .ed-icon            { background: #ccfbf1; color: #0f766e; }

  /* --- Left column (primary) stack --- */
  #extraDataModal .extra-data-primary {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
  }
  #extraDataModal .extra-data-primary > .mb-2 {
    margin: 0 !important;
  }
  #extraDataModal .extra-data-primary .extra-data-wide {
    grid-column: unset;
  }

  /* --- Middle column (checklist area) --- */
  #extraDataModal .extra-data-secondary {
    border-left: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
  }
  #extraDataModal .extra-data-secondary > .mb-2 {
    margin: 0 !important;
    min-width: 0;
  }

  /* --- Right column (note + news) --- */
  #extraDataModal .extra-data-tertiary {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
  }

  /* --- Checklist styling --- */
  #extraDataModal .extra-data-checklist {
    background: #f8fafc !important;
    border-radius: 8px;
    max-height: none;
    padding: 0.6rem 0.75rem !important;
  }
  #extraDataModal .extra-data-checklist .form-check {
    margin-bottom: 0.35rem !important;
    min-height: 24px;
    padding-left: 1.6rem;
  }
  #extraDataModal .extra-data-checklist .form-check-input {
    margin-top: 0.2rem;
  }
  #extraDataModal .form-check-label {
    font-size: 0.875rem;
  }

  /* --- Org list grid --- */
  #extraDataModal .visited-org-list {
    max-height: 220px !important;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 0.5rem;
    align-content: start;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
  }

  /* --- Textarea sizing --- */
  #extraDataModal .extra-data-note textarea {
    min-height: 100px;
    font-size: 0.875rem;
  }
  #extraDataModal .extra-data-news textarea {
    min-height: 110px;
    font-size: 0.875rem;
  }
  #extraDataModal .extra-data-news {
    grid-column: unset;
  }

  /* --- Form controls inside modal --- */
  #extraDataModal .form-control,
  #extraDataModal .form-select {
    font-size: 0.875rem;
    border-color: #e2e8f0;
    border-radius: 8px;
  }
  #extraDataModal .form-control:focus,
  #extraDataModal .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  }

  /* --- Footer --- */
  #extraDataModal .modal-footer {
    background: #f0f4f8 !important;
    border-top: 1px solid #e2e8f0 !important;
    padding: 0.9rem 1.5rem !important;
    border-radius: 0 !important;
    gap: 0.75rem;
  }

  /* ---- Responsive ---- */
  @media (max-width: 1199.98px) {
    #extraDataModal .extra-data-grid {
      grid-template-columns: 1fr 1fr !important;
    }
    #extraDataModal .extra-data-tertiary {
      grid-column: 1 / -1;
    }
  }

  @media (max-width: 767.98px) {
    #extraDataModal .modal-dialog {
      width: 100vw;
      max-width: 100vw !important;
      margin: 0;
    }
    #extraDataModal .modal-body {
      padding: 0.75rem !important;
    }
    #extraDataModal .extra-data-grid {
      grid-template-columns: 1fr !important;
    }
    #extraDataModal .visited-org-list {
      grid-template-columns: 1fr;
      max-height: 220px !important;
    }
  }

  /* ================================================================
     UTILITY CLASSES
  ================================================================ */
  .text-brand-orange { color: var(--orange) !important; }
  .text-brand-yellow { color: var(--yellow-deep) !important; }
  .text-brand-grey   { color: var(--grey) !important; }
  .bg-brand-orange   { background: rgba(250, 70, 22, 0.09) !important; }
  .bg-brand-yellow   { background: rgba(255, 199, 44, 0.12) !important; }
  .bg-brand-grey     { background: rgba(123, 129, 137, 0.10) !important; }

  /* Focus ring — accessibility */
  :focus-visible {
    outline: 3px solid rgba(250, 70, 22, 0.50);
    outline-offset: 2px;
    border-radius: var(--r-xs);
  }

  /* ================================================================
     RESPONSIVE
  ================================================================ */
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  img,
  canvas,
  video,
  svg {
    max-width: 100%;
  }

  .form-control,
  .form-select,
  .btn,
  .page-link {
    min-height: 44px;
  }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .input-group-text {
    min-height: 44px;
  }

  @media (max-width: 1024px) {
    .main-container { margin: 24px auto; padding: 0 16px; }
    .card-custom { padding: 28px 24px; }
  }

  @media (max-width: 992px) {
    .ai-assistant-title { font-size: 1.5rem; }
  }

  @media (max-width: 768px) {
    .main-container {
      max-width: 100%;
      margin: 12px auto;
      padding: 0 10px;
    }
    .form-container-limit {
      max-width: 100%;
    }
    .card-custom {
      padding: 18px 14px;
      margin-bottom: 18px;
      border-radius: var(--r-md);
    }
    .app-shell-header {
      margin-bottom: 1.15rem;
      padding-bottom: 1.05rem;
    }
    .app-header {
      margin-bottom: 1.35rem;
      padding: 0 6px;
    }
    .app-header::before {
      width: calc(100% - 34px);
    }
    .app-header::after {
      width: min(420px, 100%);
      height: 170px;
    }
    .app-title { font-size: 1.5rem; }

    .nav-pills-custom {
      width: 100%;
      overflow-x: auto;
      justify-content: flex-start;
      scrollbar-width: none;
    }
    .nav-pills-custom::-webkit-scrollbar { display: none; }
    .nav-pills-custom .nav-link {
      flex: 1 0 auto;
      min-height: 44px;
      padding: 10px 14px;
      font-size: 0.82rem;
      text-align: center;
    }

    .section-title {
      align-items: flex-start;
      line-height: 1.35;
    }

    .form-container-limit .row.g-4,
    #pills-history .row.g-3 {
      --bs-gutter-y: 0.95rem;
    }

    #pills-history .border-bottom {
      align-items: flex-start !important;
      gap: 0.75rem;
      flex-direction: column;
    }

    #pills-history .border-bottom .btn {
      width: 100%;
    }

    #pills-history .history-header-actions {
      width: 100%;
      flex-direction: row;
      justify-content: space-between;
    }

    #pills-history .history-header-actions > .btn {
      width: auto;
      flex: 0 0 auto;
    }

    #pills-history .input-group {
      flex-wrap: nowrap;
    }

    #pills-history .input-group:has(input[type="date"]) {
      display: grid;
      grid-template-columns: 1fr auto 1fr;
    }

    .table-container {
      overflow: visible;
      contain: layout;
    }

    .history-table {
      display: block;
      width: 100%;
      border-spacing: 0;
    }

    .history-table colgroup,
    .history-table thead {
      display: none;
    }

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

    .history-table tbody tr {
      margin-bottom: 12px;
      padding: 12px;
      border-radius: var(--r-md);
      box-shadow: var(--shadow-sm), 0 0 0 1px rgba(26,23,20,0.06);
      transform: none !important;
    }

    .history-table td {
      position: relative;
      padding: 8px 0 8px 118px;
      min-height: 40px;
      text-align: left !important;
      overflow: visible;
      word-break: break-word;
    }

    .history-table td::before {
      position: absolute;
      left: 0;
      top: 8px;
      width: 98px;
      color: var(--text-muted);
      font-size: 0.74rem;
      font-weight: 700;
      line-height: 1.3;
    }

    .history-cell-date::before { content: "วันที่"; }
    .history-cell-org::before { content: "หน่วยงาน"; }
    .history-cell-visitors::before { content: "จำนวน"; }
    .history-cell-image::before { content: "รูปภาพ"; }
    .history-cell-follow::before { content: "ติดตาม"; }
    .history-cell-actions::before { content: "จัดการ"; }

    .history-cell-actions {
      padding-left: 0 !important;
      padding-top: 12px !important;
      border-top: 1px solid var(--border);
    }

    .history-cell-actions::before {
      content: none;
    }

    .history-actions {
      justify-content: stretch;
      width: 100%;
      flex-wrap: wrap;
    }

    .history-detail-button {
      flex: 1 1 150px;
      min-width: 150px !important;
      width: auto;
      height: 44px;
      border-radius: var(--r-full) !important;
    }

    .history-detail-button span {
      display: inline;
    }

    #paginationControls {
      flex-direction: column;
      gap: 0.75rem;
      align-items: stretch !important;
    }

    #paginationControls .pagination {
      width: 100%;
      justify-content: space-between;
    }

    #paginationControls .page-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .ai-assistant-modal .modal-dialog {
      width: calc(100vw - 1rem) !important;
      max-width: none !important;
      margin: 0.5rem;
    }
    .ai-assistant-header { padding: 1rem 1rem 0.85rem; }
    .ai-assistant-body   { padding: 1rem; }
    .ai-assistant-title  { font-size: 1.28rem; }
    .ai-chat-stage       { min-height: 220px; max-height: 300px; }
    .ai-message-card     { width: 100%; }
    .kpi-value           { font-size: 1.8rem; }
  }

  @media (max-width: 480px) {
    .app-shell-header {
      padding-bottom: 0.9rem;
    }
    .nav-pills-custom {
      border-radius: var(--r-lg);
    }
    .nav-pills-custom .nav-link { padding: 9px 12px; }

    .app-title { font-size: 1.25rem; }

    .form-container-limit .d-flex.flex-wrap.gap-2.mt-4 > .btn {
      width: 100%;
      justify-content: center;
    }

    .history-table td {
      padding-left: 96px;
    }

    .history-table td::before {
      width: 82px;
    }
  }

  /* ================================================================
     REDUCED MOTION — Accessibility
  ================================================================ */
  @media (prefers-reduced-motion: reduce) {
    html:focus-within, body { scroll-behavior: auto; }

    *, *::before, *::after {
      animation-duration:       0.01ms !important;
      animation-iteration-count: 1     !important;
      transition-duration:      0.01ms !important;
    }

    .reveal, .reveal-stagger > * {
      opacity: 1;
      transform: none;
    }
  }

  @media (max-width: 768px), (pointer: coarse) {
    body { background-attachment: scroll; }

    .card-custom,
    .nav-pills-custom,
    .modal-content {
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
    }

    .app-title,
    .app-header::before,
    .nav-pills-custom .nav-link.active,
    .nav-pills-custom .nav-link.active::before {
      animation: none;
    }
  }


/* ---- extracted inline style block ---- */

/* ── Hero Header ─────────────────────────────── */
  .db-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
  }
  .db-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    background: linear-gradient(135deg,var(--orange-deep),var(--orange));
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: .28rem .75rem;
    border-radius: 999px;
    margin-bottom: .6rem;
  }
  .db-hero-title {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-heading);
    margin: 0 0 .25rem;
    letter-spacing: -.02em;
  }
  .db-hero-sub {
    color: var(--text-muted);
    font-size: .88rem;
    margin: 0;
  }

  /* Filter controls */
  .db-filter-group   { display:flex; flex-wrap:wrap; gap:.6rem; align-items:center; }
  .db-filter-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .45rem .85rem;
  }
  .db-date-input {
    border: none;
    background: transparent;
    font-size: .875rem;
    color: var(--text-body);
    outline: none;
    min-width: 120px;
  }
  .db-filter-sep { color: var(--text-muted); font-size: .8rem; }
  .db-select {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .45rem .9rem;
    font-size: .875rem;
    background: var(--surface);
    color: var(--text-body);
    outline: none;
    cursor: pointer;
  }
  .db-icon-btn {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display:inline-flex; align-items:center; justify-content:center;
    cursor: pointer;
    transition: all .2s;
  }
  .db-icon-btn:hover { background:var(--orange-light);color:#fff;border-color:var(--orange-light); }
  .db-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    background: linear-gradient(135deg,var(--orange-deep),var(--orange));
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: .45rem 1rem;
    font-weight: 600;
    font-size: .875rem;
    cursor: pointer;
    transition: all .25s;
    box-shadow: 0 4px 14px rgba(250,70,22,.28);
  }
  .db-refresh-btn:hover { filter:brightness(1.08); transform:translateY(-1px); }
  .db-refresh-btn i { transition: transform .4s; }
  .db-refresh-btn:active i { transform: rotate(360deg); }

  
  /* ── Executive Analytics & Insights Container ── */
  .db-insights-container {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.95));
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
  }
  .db-insights-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4F46E5, #06B6D4, #10B981, #F59E0B);
  }
  .db-insights-badge {
    background: rgba(79, 70, 229, 0.1);
    color: #4F46E5;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
  }
  .db-insight-stat-card {
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  .db-insight-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.06);
  }
  .db-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(241, 245, 249, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
  }
  .db-stat-label {
    display: block;
    font-size: 0.75rem;
    color: #64748B;
    font-weight: 600;
    line-height: 1.2;
  }
  .db-stat-value {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.3;
  }
  .db-stat-sub {
    font-size: 0.7rem;
    display: block;
  }
  .db-takeaway-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.65rem 0.9rem;
    background: rgba(248, 250, 252, 0.85);
    border-left: 3.5px solid #4F46E5;
    border-radius: 0 8px 8px 0;
    margin-bottom: 0.5rem;
    font-size: 0.86rem;
    color: #334155;
    line-height: 1.45;
  }
  .db-takeaway-item:last-child {
    margin-bottom: 0;
  }
  @media print {
    body * { visibility: hidden !important; }
    #pills-dashboard, #pills-dashboard * { visibility: visible !important; }
    #pills-dashboard { position: absolute !important; left: 0 !important; top: 0 !important; width: 100% !important; }
    .db-hero-controls, .db-refresh-btn, .db-icon-btn, .navbar, footer, .btn { display: none !important; }
    .db-chart-card, .db-insights-container { break-inside: avoid !important; page-break-inside: avoid !important; box-shadow: none !important; border: 1px solid #ccc !important; }
  }

  /* ── Bento KPI Grid ──────────────────────────── */
  .db-bento {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
  }
  @media (max-width: 900px) { .db-bento { grid-template-columns: repeat(2,1fr); } }
  @media (max-width: 520px) { .db-bento { grid-template-columns: 1fr 1fr; } }

  /* Big KPI cards */
  .db-kpi-card {
    position: relative;
    border-radius: 20px;
    padding: 1.5rem 1.25rem 1.25rem;
    color: #fff;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,.14);
    transition: transform .25s, box-shadow .25s;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }
  .db-kpi-card:hover { transform: translateY(-5px); box-shadow: 0 18px 36px rgba(0,0,0,.18); }
  .db-kpi-bg-orb {
    position: absolute;
    top: -28px; right: -28px;
    width: 110px; height: 110px;
    background: rgba(255,255,255,.14);
    border-radius: 50%;
    pointer-events: none;
  }
  .db-kpi-icon-wrap {
    position: absolute;
    top: 1.1rem; right: 1.1rem;
    width: 40px; height: 40px;
    background: rgba(255,255,255,.2);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
  }
  .db-kpi-val {
    font-family: 'Inter', sans-serif;
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1;
    position: relative;
    z-index: 1;
  }
  .db-kpi-lbl {
    font-size: .72rem;
    font-weight: 600;
    opacity: .85;
    margin-top: .35rem;
    letter-spacing: .01em;
    position: relative;
    z-index: 1;
  }
  .db-kpi-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg,transparent 40%,rgba(255,255,255,.18) 50%,transparent 60%);
    background-size: 200% 100%;
    animation: shimmer-sweep 3.5s linear infinite;
    pointer-events: none;
    border-radius: inherit;
  }
  /* Palette variants */
  .db-kpi-primary { background: linear-gradient(135deg,#5B8DEF 0%,#7C5CBF 100%); }
  .db-kpi-rose    { background: linear-gradient(135deg,#f093fb 0%,#f5576c 100%); }
  .db-kpi-teal    { background: linear-gradient(135deg,#43e97b 0%,#12b886 100%); }
  .db-kpi-amber   { background: linear-gradient(135deg,#FFC72C 0%,#FA4616 100%); }

  /* Mini KPI row (spans full bento width) */
  .db-mini-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
  @media (max-width: 520px) { .db-mini-row { grid-template-columns: 1fr; } }
  .db-mini-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: .85rem;
    transition: all .25s;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
  }
  .db-mini-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.08); }
  .db-mini-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
  }
  .db-mini-val {
    font-family: 'Inter', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-heading);
    line-height: 1;
  }
  .db-mini-lbl {
    font-size: .72rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: .2rem;
  }

  /* ── Trophy Banner ───────────────────────────── */
  .db-trophy-banner {
    background: linear-gradient(135deg, rgba(255,199,44,.08) 0%, rgba(250,70,22,.06) 100%);
    border: 1px solid rgba(255,199,44,.3);
    border-radius: 20px;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    backdrop-filter: blur(8px);
  }
  .db-trophy-left { display:flex; align-items:center; gap:1rem; flex:1; min-width:0; }
  .db-trophy-icon {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg,#FFD700,#FFA000);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    flex-shrink: 0;
    box-shadow: 0 6px 20px rgba(255,160,0,.35);
  }
  .db-trophy-eyebrow { font-size:.72rem; font-weight:700; color:var(--text-muted); margin-bottom:.3rem; }
  .db-trophy-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-heading);
    word-break: break-word;
  }
  .db-trophy-count-wrap { text-align:right; flex-shrink:0; }
  .db-trophy-count {
    font-family: 'Inter', sans-serif;
    font-size: 2.4rem;
    font-weight: 900;
    background: linear-gradient(135deg,var(--orange),var(--yellow));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
  }
  .db-trophy-unit { font-size:.7rem; font-weight:700; color:var(--text-muted); margin-top:.15rem; }

  /* ── Chart Cards ─────────────────────────────── */
  .db-chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,.04);
    transition: box-shadow .25s;
  }
  .db-chart-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.08); }
  .db-chart-head {
    display: flex;
    align-items: center;
    gap: .85rem;
    margin-bottom: 1.25rem;
  }
  .db-chart-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
  }
  .db-chart-title {
    font-size: .92rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: .18rem;
    line-height: 1.3;
  }
  .db-chart-sub {
    font-size: .72rem;
    color: var(--text-muted);
    font-weight: 400;
    line-height: 1.4;
  }
  .db-canvas-wrap { position: relative; }
  .db-mb { margin-bottom: 1.5rem; }
  .db-loading-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-size: .875rem;
  }

  /* ── Summary Table ────────────────────────────── */
  .db-summary-table thead th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 2px solid var(--border);
    padding: .65rem 1rem;
    background: transparent;
  }
  .db-summary-table tbody td {
    padding: .75rem 1rem;
    font-size: .875rem;
    border-color: var(--border);
  }
  .db-summary-table tbody tr:hover { background: rgba(250,70,22,.03); }

  /* ── Top Orgs Grid ────────────────────────────── */
  .db-orgs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: .55rem;
  }

  .db-org-row {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem .85rem;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all .2s;
  }
  .db-org-row:hover {
    background: rgba(250,70,22,.03);
    border-color: rgba(250,70,22,.2);
    transform: translateX(3px);
  }
  .db-org-rank {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-weight: 800;
    font-size: .75rem;
  }
  .db-org-medal { font-size: 1.1rem; line-height: 1; }
  .db-org-num   { font-family: 'Inter', sans-serif; }
  .db-org-name  {
    flex: 1;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-heading);
    line-height: 1.35;
    word-break: break-word;
  }
  .db-org-badge {
    display: flex;
    align-items: baseline;
    gap: .25rem;
    border-radius: 8px;
    padding: .25rem .6rem;
    flex-shrink: 0;
    white-space: nowrap;
  }
  .db-org-count { font-family: 'Inter', sans-serif; font-size: .95rem; font-weight: 800; }
  .db-org-unit  { font-size: .65rem; font-weight: 600; opacity: .75; }

  /* Advanced analytics */
  .db-section-label {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin: 2rem 0 1rem;
  }

  .db-section-eyebrow {
    display: inline-block;
    font-size: .68rem;
    font-weight: 800;
    color: var(--orange);
    text-transform: uppercase;
    letter-spacing: 0;
    margin-bottom: .25rem;
  }

  .db-section-title {
    margin: 0;
    color: var(--text-heading);
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.25;
  }

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

  .db-compare-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.2rem;
    min-height: 160px;
    box-shadow: 0 2px 10px rgba(0,0,0,.04);
  }

  .db-compare-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .db-compare-title {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 700;
    line-height: 1.35;
  }

  .db-compare-sub {
    margin-top: .25rem;
    color: var(--text-heading);
    font-size: .92rem;
    font-weight: 800;
    line-height: 1.3;
  }

  .db-compare-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .db-compare-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 1rem;
  }

  .db-compare-value {
    color: var(--text-heading);
    font-family: 'Inter', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
  }

  .db-compare-meta {
    color: var(--text-muted);
    font-size: .76rem;
    font-weight: 600;
    line-height: 1.45;
    margin-top: .4rem;
  }

  .db-change-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border-radius: 999px;
    padding: .38rem .7rem;
    font-size: .78rem;
    font-weight: 800;
    white-space: nowrap;
  }

  .db-change-up {
    background: rgba(76,175,80,.12);
    color: #2E7D32;
  }

  .db-change-down {
    background: rgba(229,57,53,.12);
    color: #C62828;
  }

  .db-change-same {
    background: rgba(96,125,139,.12);
    color: #455A64;
  }

  .db-top-months-list {
    display: grid;
    gap: .55rem;
  }

  .db-top-month-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: .7rem;
    padding: .65rem .75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,.72);
  }

  .db-rank-pill {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,152,0,.12);
    color: #D97706;
    font-family: 'Inter', sans-serif;
    font-size: .8rem;
    font-weight: 900;
  }

  .db-top-month-name {
    color: var(--text-heading);
    font-size: .9rem;
    font-weight: 800;
    line-height: 1.25;
  }

  .db-top-month-meta {
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 600;
    margin-top: .18rem;
  }

  .db-top-month-visitors {
    color: var(--orange);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 900;
    white-space: nowrap;
  }

  .db-insights-container {
    padding: 0;
  }

  .db-insights-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .85rem;
  }

  .db-insight-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: .75rem;
    align-items: flex-start;
    min-height: 106px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: .9rem;
    background: rgba(255,255,255,.78);
  }

  .db-insight-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .db-insight-title {
    color: var(--text-heading);
    font-size: .86rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: .25rem;
  }

  .db-insight-text {
    color: var(--text-muted);
    font-size: .78rem;
    line-height: 1.55;
    margin: 0;
  }

  @media (max-width: 768px) {
    .db-hero {
      align-items: stretch;
      gap: 1rem;
      margin-bottom: 1.25rem;
      padding-bottom: 1rem;
    }

    .db-hero-left,
    .db-hero-controls,
    .db-filter-group,
    .db-filter-chip,
    .db-select,
    .db-refresh-btn {
      width: 100%;
    }

    .db-hero-title {
      font-size: 1.38rem;
      line-height: 1.25;
    }

    .db-hero-sub {
      font-size: .8rem;
    }

    .db-filter-group {
      align-items: stretch;
    }

    .db-filter-chip {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
      gap: .45rem;
      padding: .55rem .65rem;
    }

    .db-date-input {
      min-width: 0;
      width: 100%;
      font-size: .82rem;
    }

    .db-icon-btn {
      width: 44px;
      height: 44px;
      flex: 0 0 44px;
    }

    .db-refresh-btn {
      min-height: 44px;
      justify-content: center;
    }

    .db-bento {
      grid-template-columns: 1fr 1fr;
      gap: .75rem;
    }

    .db-kpi-card {
      min-height: 128px;
      padding: 1.1rem .9rem .95rem;
      border-radius: 16px;
    }

    .db-kpi-icon-wrap {
      top: .8rem;
      right: .8rem;
      width: 34px;
      height: 34px;
      border-radius: 10px;
      font-size: .95rem;
    }

    .db-kpi-val {
      font-size: 1.65rem;
    }

    .db-kpi-lbl {
      font-size: .68rem;
      line-height: 1.35;
    }

    .db-trophy-banner {
      align-items: flex-start;
      flex-direction: column;
      padding: 1rem;
      border-radius: 16px;
    }

    .db-trophy-left {
      width: 100%;
    }

    .db-trophy-name {
      max-width: 100%;
      white-space: normal;
    }

    .db-trophy-count-wrap {
      width: 100%;
      text-align: left;
    }

    .db-chart-card {
      padding: 1rem;
      border-radius: 16px;
      overflow: hidden;
    }

    .db-chart-head {
      align-items: flex-start;
      gap: .65rem;
      margin-bottom: 1rem;
    }

    .db-chart-title {
      font-size: .86rem;
    }

    .db-chart-sub {
      font-size: .68rem;
    }

    .db-canvas-wrap {
      min-height: 240px;
    }

    .db-canvas-wrap[style] {
      height: 260px !important;
    }

    .db-orgs-grid {
      grid-template-columns: 1fr;
    }

    .db-org-row {
      align-items: flex-start;
    }

    .db-org-badge {
      align-self: center;
    }

    .db-summary-table {
      min-width: 620px;
    }

    .db-comparison-grid,
    .db-insights-grid {
      grid-template-columns: 1fr;
    }

    .db-section-label {
      margin-top: 1.35rem;
    }

    .db-compare-card,
    .db-insights-container {
      border-radius: 16px;
    }

    .db-compare-body {
      grid-template-columns: 1fr;
      align-items: start;
      gap: .75rem;
    }

    .db-change-badge {
      width: max-content;
      max-width: 100%;
    }

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

    .db-top-month-visitors {
      grid-column: 2;
      justify-self: start;
    }
  }

  @media (max-width: 420px) {
    .db-bento {
      grid-template-columns: 1fr;
    }

    .db-filter-chip {
      grid-template-columns: auto minmax(0, 1fr);
    }

    .db-filter-sep {
      display: none;
    }

    .db-kpi-card {
      min-height: 118px;
    }
  }

  /* Shimmer animation (shared with Styles.html) */
  @keyframes shimmer-sweep {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }


/* ---- extracted inline style block ---- */

/* ================================================================
   PREMIUM CALENDAR STYLING (KMUTT Visitor System)
================================================================ */
#calendar {
  --fc-border-color: var(--border-strong, #D9D0C2);
  --fc-button-text-color: var(--text-main, #2D2A26);
  --fc-button-bg-color: #ffffff;
  --fc-button-border-color: var(--border-strong, #D9D0C2);
  --fc-button-hover-bg-color: #FFF0E6;
  --fc-button-hover-border-color: var(--orange, #FA4616);
  --fc-button-active-bg-color: var(--orange, #FA4616);
  --fc-button-active-border-color: var(--orange-deep, #D63808);
  --fc-today-bg-color: rgba(255, 199, 44, 0.15);
  --fc-neutral-bg-color: rgba(123, 129, 137, 0.05);
  --fc-page-bg-color: transparent;
  
  font-family: 'Prompt', 'Inter', sans-serif;
  padding: 10px;
  background: var(--card-bg, #ffffff);
  border-radius: var(--r-md, 16px);
}

/* Header Toolbar */
.fc .fc-toolbar.fc-header-toolbar {
  margin-bottom: 24px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #FAFAF8 0%, #FFFFFF 100%);
  border-radius: var(--r-md, 16px);
  border: 1px solid var(--border, #EDE8DF);
  box-shadow: var(--shadow-xs);
}

.fc .fc-toolbar-title {
  font-family: 'Prompt', sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--text-heading, #1A1714);
  text-shadow: 0 1px 2px rgba(0,0,0,0.05);
  background: linear-gradient(130deg, var(--orange-deep) 0%, var(--orange) 30%, var(--yellow-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Mobile Responsiveness for Calendar */
@media (max-width: 768px) {
  .fc .fc-toolbar.fc-header-toolbar {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
  }
  .fc .fc-toolbar-title {
    font-size: 1.25rem;
    text-align: center;
  }
  .fc .fc-button {
    padding: 6px 10px;
    font-size: 0.85rem;
  }
  .fc-theme-standard .fc-scrollgrid {
    font-size: 0.85rem;
  }
}

/* Buttons */
.fc .fc-button {
  border-radius: var(--r-sm, 10px) !important;
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  text-transform: capitalize;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-xs);
  padding: 8px 16px;
}

.fc .fc-button-primary {
  background-color: var(--fc-button-bg-color) !important;
  border-color: var(--fc-button-border-color) !important;
  color: var(--fc-button-text-color) !important;
}

.fc .fc-button-primary:hover {
  background-color: var(--fc-button-hover-bg-color) !important;
  border-color: var(--fc-button-hover-border-color) !important;
  color: var(--orange, #FA4616) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background-color: var(--orange, #FA4616) !important;
  border-color: var(--orange-deep, #D63808) !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(250, 70, 22, 0.35) !important;
  transform: translateY(0);
}

/* Button Groups */
.fc .fc-button-group > .fc-button {
  border-radius: 0 !important;
  margin-left: -1px;
}
.fc .fc-button-group > .fc-button:first-child {
  border-top-left-radius: var(--r-sm, 10px) !important;
  border-bottom-left-radius: var(--r-sm, 10px) !important;
}
.fc .fc-button-group > .fc-button:last-child {
  border-top-right-radius: var(--r-sm, 10px) !important;
  border-bottom-right-radius: var(--r-sm, 10px) !important;
}

/* Grid & Cells */
.fc-theme-standard .fc-scrollgrid,
.fc-theme-bootstrap5 .fc-scrollgrid {
  border-radius: var(--r-md, 16px);
  overflow: hidden;
  border: 1px solid var(--border-strong, #D9D0C2) !important;
  box-shadow: var(--shadow-sm);
}

.fc-theme-standard th,
.fc-theme-bootstrap5 th {
  background: var(--bg-surface, #FFFDF8);
  padding: 14px 0;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  color: var(--text-muted, #5C5C60);
  border-bottom: 2px solid var(--border-strong, #D9D0C2) !important;
  border-right: 1px solid var(--border, #EDE8DF);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
}

.fc-theme-standard td, .fc-theme-standard th,
.fc-theme-bootstrap5 td, .fc-theme-bootstrap5 th {
  border: 1px solid var(--border, #EDE8DF);
}

.fc .fc-daygrid-day-number {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  color: var(--text-main, #2D2A26);
  padding: 10px 14px;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.fc .fc-daygrid-day-number:hover {
  color: var(--orange, #FA4616);
  text-decoration: none;
}

/* Today */
.fc .fc-day-today {
  background-color: var(--fc-today-bg-color) !important;
}
.fc .fc-day-today .fc-daygrid-day-number {
  color: var(--orange-deep, #D63808);
  background: #fff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px;
  box-shadow: var(--shadow-xs);
}

/* Event Styling */
.fc-event {
  border-radius: 6px;
  border: none !important;
  padding: 4px 8px;
  margin: 2px 6px 4px 6px;
  font-size: 0.85rem;
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
  transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
  cursor: pointer;
  overflow: hidden;
}

.fc-event:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 6px 12px rgba(0,0,0,0.12);
  filter: brightness(1.08);
  z-index: 5;
}

.fc-h-event .fc-event-main {
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.fc-daygrid-dot-event .fc-event-title {
  font-weight: 600;
}

.fc-daygrid-event-dot {
  border-color: rgba(255,255,255,0.7);
}

.fc .fc-daygrid-day.fc-day-today {
  background-color: var(--fc-today-bg-color) !important;
}


/* ---- extracted inline style block ---- */

body.modal-open-noscroll {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
  }


/* ---- extracted inline style block ---- */

/* Support Chat CSS */

  .chat-tab-buttons .btn.active {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #fff !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }
  .chat-tab-buttons {
    max-width: 100%;
    min-width: 0;
  }
  .chat-tab-buttons .btn {
    white-space: nowrap;
  }

  .support-chat-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1050;
    font-family: 'Prompt', 'Inter', sans-serif;
  }
  html.support-chat-scroll-locked,
  body.support-chat-scroll-locked {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
  }
  body.support-chat-scroll-locked {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
  }
  .support-chat-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
    border: none;
    outline: none;
    box-shadow: 0 4px 16px rgba(250, 70, 22, 0.4);
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }
  .support-chat-trigger:hover {
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 6px 20px rgba(250, 70, 22, 0.5);
  }
  .support-chat-trigger:active {
    transform: scale(0.95);
  }
  .support-chat-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }
  .support-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 140px);
    max-width: calc(100vw - 48px);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
    touch-action: auto;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  .support-chat-panel.show {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  .support-chat-header {
    padding: 16px;
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-deep) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    flex-shrink: 0;
  }
  .support-chat-header .header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  .support-chat-title {
    font-weight: 600;
    font-size: 16px;
  }
  .support-chat-back-btn, .support-chat-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: background 0.2s;
  }
  .support-chat-back-btn {
    display: none;
  }
  .support-chat-back-btn:hover, .support-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
  }
  .support-chat-body {
    flex: 1;
    overflow: hidden;
    overscroll-behavior: contain;
    position: relative;
    background: rgba(248, 249, 250, 0.6);
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .chat-subview {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    overflow: hidden;
  }
  #support-chat-auth-view,
  #support-chat-user-view,
  #support-chat-admin-list-view {
    display: none;
  }
  .chat-messages-container {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    max-height: 100%;
  }
  .chat-rooms-container {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    max-height: 100%;
  }
  .chat-room-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    cursor: pointer;
    transition: background 0.2s;
  }
  .chat-room-item:hover {
    background: rgba(0,0,0,0.03);
  }
  .chat-room-item.unread {
    background: rgba(250, 70, 22, 0.04);
  }
  .chat-room-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--grey-light);
    border: 1px solid rgba(0,0,0,0.05);
  }
  .chat-room-info {
    flex: 1;
    min-width: 0;
  }
  .chat-room-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
  }
  .chat-room-name {
    font-weight: 600;
    font-size: 14px;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .chat-room-time {
    font-size: 11px;
    color: #6c757d;
  }
  .chat-room-last-msg {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .chat-room-badge-col {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .chat-room-unread-badge {
    background: var(--orange);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
  }
  
  /* Message Bubbles */
  .delete-msg-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .chat-message-row.sent:hover .delete-msg-btn {
    opacity: 0.5;
  }
  .chat-message-row.sent .delete-msg-btn:hover {
    opacity: 1;
  }

  .chat-message-row {
    display: flex;
    gap: 8px;
    max-width: 85%;
    min-width: 0;
  }
  .chat-message-row.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
  }
  .chat-message-row.received {
    align-self: flex-start;
  }
  .chat-message-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    object-fit: cover;
  }
  .chat-message-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .chat-message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: anywhere;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  }
  .chat-message-row.sent .chat-message-bubble {
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
    color: white;
    border-bottom-right-radius: 4px;
  }
  .chat-message-row.received .chat-message-bubble {
    background: white;
    color: #212529;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0,0,0,0.06);
  }
  .chat-message-time {
    font-size: 10px;
    color: #6c757d;
    margin-top: 3px;
    margin-left: 4px;
  }
  .chat-message-row.sent .chat-message-time {
    align-self: flex-end;
    margin-right: 4px;
  }
  
  #support-chat-attach-btn {
    background: #f1f5f9;
    border: 1px solid rgba(0,0,0,0.08);
    color: #64748b;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
  }
  #support-chat-attach-btn:hover {
    background: #e2e8f0;
    color: var(--orange);
  }
  .chat-attached-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
    margin-bottom: 4px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s;
  }
  .chat-attached-img:hover {
    transform: scale(1.02);
  }
  .chat-file-link {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.9);
    padding: 8px 12px;
    border-radius: 10px;
    color: #1e293b;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 500;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 4px;
    word-break: break-all;
    transition: background 0.2s;
  }
  .chat-file-link:hover {
    background: #f8fafc;
    color: var(--orange-deep);
  }
  .chat-message-row.sent .chat-file-link {
    background: rgba(255,255,255,0.25);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
  }
  .chat-message-row.sent .chat-file-link:hover {
    background: rgba(255,255,255,0.35);
    color: white;
  }
  .uploading-loader-item {
    font-size: 12px;
    color: #64748b;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(250, 70, 22, 0.08);
    border-radius: 12px;
    align-self: center;
    margin: 4px 0;
  }

  /* Footer */
  .support-chat-footer {
    padding: 12px;
    background: white;
    border-top: 1px solid rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-height: 60px;
  }
  #support-chat-input {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
  }
  #support-chat-input:focus {
    border-color: var(--orange-light);
  }
  #support-chat-send-btn {
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(250, 70, 22, 0.25);
    transition: transform 0.2s;
  }
  #support-chat-send-btn:hover {
    transform: scale(1.05);
  }
  #support-chat-send-btn:active {
    transform: scale(0.95);
  }
  
  /* Mobile adaptation */
  @media (max-width: 768px) {
    .support-chat-wrapper {
      right: 14px;
      bottom: 14px;
    }
    .support-chat-trigger {
      width: 56px;
      height: 56px;
      font-size: 22px;
    }
    .support-chat-panel {
      left: 8px;
      right: 8px;
      bottom: 78px;
      width: auto;
      height: min(620px, calc(100dvh - 94px));
      max-height: calc(100dvh - 94px);
      max-width: none;
      border-radius: 14px;
    }
    .support-chat-header {
      padding: 12px;
      min-height: 64px;
    }
    .support-chat-header .header-left {
      gap: 6px;
      max-width: calc(100vw - 72px);
    }
    .chat-tab-buttons {
      overflow-x: auto;
      scrollbar-width: none;
    }
    .chat-tab-buttons::-webkit-scrollbar {
      display: none;
    }
    .chat-tab-buttons .btn {
      padding-left: 12px !important;
      padding-right: 12px !important;
      font-size: 13px !important;
    }
    .support-chat-close-btn {
      width: 34px;
      height: 34px;
      flex: 0 0 34px;
      font-size: 17px;
    }
    .chat-messages-container {
      padding: 12px 14px 12px 12px;
      gap: 10px;
      scrollbar-gutter: stable;
    }
    .chat-message-row {
      max-width: 92%;
    }
    .chat-message-avatar {
      width: 28px;
      height: 28px;
      min-width: 28px;
    }
    .chat-message-bubble {
      max-width: calc(100vw - 104px);
      padding: 9px 12px;
      font-size: 13px;
      line-height: 1.45;
    }
    .chat-message-row.sent .chat-message-bubble {
      max-width: calc(100vw - 76px);
    }
    .support-chat-footer {
      padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
      min-height: 62px;
    }
    #support-chat-input {
      height: 40px;
      padding: 8px 14px;
      font-size: 13px;
    }
    #support-chat-send-btn,
    #support-chat-attach-btn {
      width: 40px;
      height: 40px;
      flex: 0 0 40px;
    }
  }

  @media (max-width: 576px) {
    .support-chat-panel {
      top: 0;
      bottom: 0;
      right: 0;
      left: 0;
      width: auto;
      height: 100dvh;
      max-height: 100dvh;
      max-width: none;
      border-radius: 0;
    }
    .support-chat-header {
      border-radius: 0;
    }
    .chat-message-row {
      max-width: 94%;
    }
    .chat-message-bubble {
      max-width: calc(100vw - 96px);
    }
    .chat-message-row.sent .chat-message-bubble {
      max-width: calc(100vw - 70px);
    }
  }


/* ---- extracted inline style block ---- */

/* ================================================================
     SITE CONTACT FOOTER
  ================================================================ */
  body {
    min-height: 0;
  }

  body > .main-container {
    flex: 0 0 auto;
  }

  .site-contact-footer {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    margin-top: 0;
    background: linear-gradient(135deg, #211d1a 0%, #2d2925 55%, #1c1a18 100%);
    border-top: 4px solid var(--yellow, #ffc72c);
    color: rgba(255, 255, 255, 0.88);
  }

  .site-contact-footer::before {
    content: '';
    position: absolute;
    width: 420px;
    height: 220px;
    top: -150px;
    right: -80px;
    border-radius: 50%;
    background: rgba(255, 199, 44, 0.1);
    filter: blur(8px);
    pointer-events: none;
  }

  .site-contact-footer__inner {
    position: relative;
    z-index: 1;
    width: min(1320px, 100%);
    margin: 0 auto;
    padding: 2.8rem 24px 1.5rem;
  }

  .site-contact-footer__grid {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.35fr) minmax(220px, 0.85fr);
    gap: clamp(1.75rem, 4vw, 4.5rem);
  }

  .site-contact-footer__eyebrow {
    margin: 0 0 0.35rem;
    color: var(--yellow, #ffc72c);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
  }

  .site-contact-footer h2,
  .site-contact-footer h3 {
    margin: 0;
    color: #fff;
    font-family: 'Prompt', sans-serif;
    font-weight: 600;
    line-height: 1.35;
  }

  .site-contact-footer h2 { font-size: clamp(1.35rem, 2.4vw, 1.75rem); }
  .site-contact-footer h3 { font-size: 1.05rem; }

  .site-contact-footer__contact-list {
    display: grid;
    gap: 0.85rem;
    margin-top: 1.5rem;
  }

  .site-contact-footer__contact-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.92rem;
    line-height: 1.55;
  }

  .site-contact-footer__contact-item > span:first-child {
    color: rgba(255, 255, 255, 0.62);
  }

  .site-contact-footer a {
    color: #fff;
    text-decoration: none;
    transition: color 0.2s ease, transform 0.2s ease;
  }

  .site-contact-footer a:hover {
    color: var(--yellow, #ffc72c);
  }

  .site-contact-footer__address {
    margin: 1rem 0 1.25rem;
    font-size: 0.92rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.78);
  }

  .site-contact-footer__address strong {
    color: #fff;
    font-weight: 600;
  }

  .site-contact-footer__map-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.9rem;
    border: 1px solid rgba(255, 199, 44, 0.55);
    border-radius: 999px;
    color: var(--yellow, #ffc72c) !important;
    font-size: 0.88rem;
  }

  .site-contact-footer__map-link:hover {
    background: rgba(255, 199, 44, 0.12);
    transform: translateY(-1px);
  }

  .site-contact-footer__map-container {
    margin-top: 0.85rem;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 199, 44, 0.4);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    background: #1e1e1e;
    line-height: 0;
  }

  .site-contact-footer__map-placeholder {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 1rem;
    color: rgba(255, 255, 255, 0.72);
    text-align: center;
    line-height: 1.5;
  }
  .site-contact-footer__map-placeholder > i {
    color: var(--yellow, #ffc72c);
    font-size: 1.5rem;
  }
  .site-contact-footer__map-load {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0.5rem 0.9rem;
    border: 1px solid rgba(255, 199, 44, 0.55);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--yellow, #ffc72c);
    font: inherit;
    cursor: pointer;
  }
  .site-contact-footer__map-load:hover {
    background: rgba(255, 199, 44, 0.12);
  }
  .site-contact-footer__map-container iframe[hidden] {
    display: none !important;
  }
  .site-contact-footer__map-container iframe {
    width: 100%;
    height: 200px;
    border: 0;
    display: block;
  }

  .site-contact-footer__links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 1rem;
  }

  .site-contact-footer__links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 199, 44, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
  }

  .site-contact-footer__links a:hover {
    background: rgba(255, 199, 44, 0.12);
    transform: translateY(-1px);
  }

  .site-contact-footer__links i {
    color: var(--yellow, #ffc72c);
    font-size: 1.18rem;
    text-align: center;
  }

  .site-contact-footer__social-logo {
    width: 1.45rem;
    height: 1.45rem;
    flex: 0 0 1.45rem;
    object-fit: contain;
  }

  @media (max-width: 800px) {
    .site-contact-footer__grid {
      grid-template-columns: 1fr 1fr;
      gap: 2rem 1.5rem;
    }

    .site-contact-footer__grid > :first-child {
      grid-column: 1 / -1;
    }
  }

  @media (max-width: 560px) {
    .site-contact-footer__inner { padding: 2.25rem 18px 1.25rem; }
    .site-contact-footer__grid { grid-template-columns: 1fr; gap: 1.75rem; }
    .site-contact-footer__grid > :first-child { grid-column: auto; }
  }

  /* ========================================================
     [ACCESSIBILITY] WCAG AA Compliant Contrast Ratio (>= 4.5:1)
     ======================================================== */
  .text-muted,
  .form-text,
  .small.text-muted,
  p.text-muted,
  span.text-muted,
  div.text-muted {
    color: #525d69 !important;
  }

  .text-white-50,
  .support-chat-header .btn.text-white-50 {
    color: rgba(255, 255, 255, 0.92) !important;
  }

  .text-secondary {
    color: #4b5563 !important;
  }


/* Lighthouse v27: returning-session first-paint stability */
html { scrollbar-gutter: stable; }
html.kmutt-returning-session .auth-gate {
  opacity: 0 !important; visibility: hidden !important; pointer-events: none !important;
  transform: none !important; filter: none !important;
}
html.kmutt-returning-session body.auth-required { overflow-y: auto !important; }
html.kmutt-returning-session body.auth-required .app-shell-header,
html.kmutt-returning-session body.auth-required .main-container { visibility: visible !important; }
