/* ================================================================
     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%; }
  }

  /* ── 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 {
    max-width: 940px;
    margin-left: auto;
    margin-right: auto;
  }

  body.auth-required .main-container { visibility: hidden; }

  /* ================================================================
     APP HEADER — Parallax-like decorative header
  ================================================================ */
  .app-header {
    text-align: center;
    margin-bottom: 2.8rem;
    position: relative;
    padding: 2.2rem 1rem 1.6rem;
  }

  /* Animated top accent line */
  .app-header::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: min(640px, 88%);
    height: 3px;
    background: linear-gradient(90deg,
      transparent       0%,
      var(--orange)    20%,
      var(--yellow)    50%,
      var(--orange)    80%,
      transparent      100%
    );
    background-size: 200% auto;
    animation: header-line 4s linear infinite;
    border-radius: var(--r-full);
  }

  /* Soft halo behind header */
  .app-header::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 600px; height: 200px;
    background: radial-gradient(ellipse,
      rgba(255, 199, 44, 0.08) 0%,
      rgba(250, 70, 22, 0.05) 45%,
      transparent 70%
    );
    pointer-events: none;
    z-index: 0;
  }

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

  .app-title {
    font-family: 'Prompt', sans-serif;
    font-weight: 700;
    font-size: clamp(1.65rem, 3.2vw, 2.15rem);
    letter-spacing: -0.025em;
    line-height: 1.25;
    margin-bottom: 0.45rem;
    /* Brand gradient text */
    background: linear-gradient(130deg,
      var(--orange-deep) 0%,
      var(--orange)      30%,
      var(--yellow-deep) 60%,
      var(--yellow)      100%
    );
    background-size: 200% auto;
    animation: gradient-flow 6s ease infinite;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .app-subtitle {
    color: var(--grey);
    font-size: 0.93rem;
    font-weight: 400;
    letter-spacing: 0.015em;
  }

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

  .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;
  }

  /* ================================================================
     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;
  }

  .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); }

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

  @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);
  }

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

  /* ================================================================
     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;
    }
    .card-custom {
      padding: 18px 14px;
      margin-bottom: 18px;
      border-radius: var(--r-md);
    }
    .app-header {
      margin-bottom: 1.35rem;
      padding: 0 6px;
    }
    .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 .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) {
    .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 ---- */

body {
            background-color: #f8f9fa;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        .report-wrapper {
            flex: 1 0 auto;
            width: 100%;
            padding: 2rem 1rem;
        }

        .report-container {
            max-width: 100%;
            width: 100%;
            margin: 0;
        }

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

        /* New List Item Styles (Matching Screenshot) */
        .list-item-row {
            background-color: #ffffff;
            border: 1px solid #f0f0f0;
            border-radius: 8px;
            padding: 16px 20px;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            content-visibility: auto;
            contain-intrinsic-size: 96px;
            transition: box-shadow 0.2s ease, transform 0.2s ease;
        }

        .list-item-row:hover {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            transform: translateY(-2px);
        }

        .date-col {
            width: 120px;
            min-width: 120px;
            font-weight: 500;
            color: #333;
            font-size: 0.95rem;
        }

        .org-col {
            flex-grow: 1;
            padding-right: 20px;
            min-width: 0;
        }

        .org-name {
            font-weight: 600;
            color: #212529;
            font-size: 1rem;
            margin-bottom: 4px;
            overflow-wrap: anywhere;
        }

        .org-type-badge {
            background-color: #f1f3f5;
            color: #495057;
            font-size: 0.75rem;
            padding: 4px 10px;
            border-radius: 4px;
            display: inline-block;
            font-weight: 500;
        }

        .stats-col {
            display: flex;
            align-items: center;
            gap: 24px;
        }

        .visitor-count {
            font-size: 0.85rem;
            font-weight: 700;
            color: #212529;
            background-color: #fff;
            border: 1px solid #dee2e6;
            border-radius: 20px;
            padding: 4px 12px;
            white-space: nowrap;
        }

        .responsibility-text {
            color: #495057;
            font-size: 0.9rem;
            width: 300px;
            /* Increased from 180px since we have more room */
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            text-align: right;
        }

        .action-btn {
            min-width: 48px;
            height: 48px;
            border-radius: 12px;
            background-color: #e7f1ff;
            color: #0d6efd;
            border: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
            font-size: 0.85rem;
            font-weight: 600;
            padding: 0 14px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
        }

        .action-btn i {
            font-size: 1.1rem;
        }

        .action-btn:hover {
            background-color: #cfe2ff;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
            transform: translateY(-1px);
        }

        @media print {
            body {
                margin: 0;
                padding: 0;
                background-color: white;
            }

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

            .report-container {
                max-width: 100%;
                margin: 0;
                padding: 0;
                box-shadow: none !important;
            }

            .list-item-row {
                border-color: #ddd;
                box-shadow: none !important;
                transform: none !important;
                page-break-inside: avoid;
            }
        }

        /* Responsive Adjustments */
        @media (max-width: 768px) {
            .list-item-row {
                flex-direction: column;
                align-items: flex-start;
                gap: 10px;
                padding: 14px;
            }

            .date-col,
            .org-col {
                width: 100%;
                min-width: 0;
                padding-right: 0;
            }

            .stats-col {
                margin-top: 12px;
                width: 100%;
                justify-content: space-between;
                flex-wrap: wrap;
                gap: 10px;
            }

            .responsibility-text {
                width: 100%;
                text-align: left;
                white-space: normal;
                overflow: visible;
                text-overflow: clip;
                order: 3;
            }

            .action-btn {
                min-height: 44px;
            }
        }

        @media (max-width: 576px) {
            body {
                padding: 0.75rem 0.5rem;
            }

            .report-container {
                padding: 1rem !important;
                border-radius: 12px !important;
            }

            .report-container > .d-flex.justify-content-between {
                align-items: flex-start !important;
                flex-direction: column;
                gap: 0.75rem;
            }

            .report-container > .d-flex.justify-content-between .btn {
                width: 100%;
                min-height: 44px;
            }

            .no-print.bg-light {
                margin-left: 0 !important;
                margin-right: 0 !important;
            }

            .visitor-count {
                flex: 1 1 100%;
                text-align: center;
            }

            .action-btn {
                flex: 1 1 150px;
                min-width: 0;
            }

            .modal-dialog {
                margin: 0.5rem;
            }

            .modal-content {
                border-radius: 12px;
            }
        }

        /* --- New Unread Notification Effects --- */
        @keyframes subtlePulse {
            0% {
                background-color: rgba(255, 109, 0, 0.05);
            }

            50% {
                background-color: rgba(255, 109, 0, 0.15);
                box-shadow: inset 4px 0 0 #ff6d00;
            }

            100% {
                background-color: rgba(255, 109, 0, 0.05);
            }
        }

        .unread-row {
            animation: subtlePulse 0.9s ease-out 1;
            border-left: 4px solid #ff6d00 !important;
            transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
        }

        .unread-row:hover {
            background-color: rgba(255, 109, 0, 0.2);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        .badge-glow {
            box-shadow: 0 0 8px rgba(220, 53, 69, 0.6);
        }

        .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;
        }

        @keyframes glowPulse {
            from {
                box-shadow: 0 0 4px rgba(220, 53, 69, 0.4);
            }

            to {
                box-shadow: 0 0 12px rgba(220, 53, 69, 0.8), 0 0 4px rgba(255, 255, 255, 0.8) inset;
            }
        }

        /* ================================================================
           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 ---- */

/* ================================================================
     SITE CONTACT FOOTER
  ================================================================ */
  .site-contact-footer {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    width: 100%;
    margin-top: auto;
    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; }
  }
