﻿  /* ซ่อนข้อความที่แสดงผิดพลาดจาก template processing (เช่น <?!= include('Styles'); ?>) */
  body > text,
  body > comment,
  body > *:not(script):not(style):not(header):not(main):not(footer):not(div):not(section):not(nav):not(article):not(aside) {
    display: none !important;
    visibility: hidden !important;
  }
  
  /* ป้องกันการแสดงข้อความ template ที่ไม่ถูกประมวลผล */
  body {
    position: relative;
  }
  
  /* ซ่อนข้อความ "Loading..." ที่แสดงผิดพลาด */
  body > small:not(#current-date),
  body > span:not(.user-status):not(.badge-accent):not(.shimmer-text) {
    display: none !important;
  }
  
  :root {
    --primary: #0F172A;
    --accent: #FFB24A;
    --accent-dark: #E69D35;
    --success: #10B981;
    --danger: #EF4444;
    --bg: #F8FAFC;
    --line: rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.1);
    --card-bg: #FFFFFF;
  }

  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  
  html, body { 
    height: 100%; margin: 0; padding: 0; 
    background-color: var(--bg); font-family: 'Anuphan', sans-serif;
    color: var(--primary);
    overflow-x: hidden;
  }

  /* --- VIEW CONTROLLER --- */
  .view { display: none; width: 100%; }
  .view.active { 
    display: block; 
    animation: fadeIn 0.3s ease-out; 
  }
  @keyframes fadeIn { 
    from { opacity: 0; transform: translateY(8px); } 
    to { opacity: 1; transform: translateY(0); } 
  }

  /* --- HEADER & SHIMMER --- (ขนาดกะทัดรัดเพื่อให้เห็นเนื้อหามากขึ้น) */
  .header {
    position: sticky; top: 0; z-index: 1000;
    background: var(--primary); 
    padding: 6px 14px 10px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    border-bottom-left-radius: 16px; border-bottom-right-radius: 16px;
    color: #fff; overflow: hidden;
    width: 100%;
    box-sizing: border-box;
  }
  
  /* ป้องกัน header ซ้ำ */
  body > header:not(#header),
  body > .header:not(#header) {
    display: none !important;
  }
  
  /* ตรวจสอบว่า header มีเพียงตัวเดียว */
  #header {
    position: sticky;
    top: 0;
    z-index: 1000;
  }
  .header-inner { position: relative; z-index: 2; }
  .top-row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 6px; gap: 6px; }
  .header-user-wrap { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

  .title-with-logo { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .title-header-minimal { display: flex; align-items: center; min-width: 0; }
  .title-header-minimal .title-text { min-width: 0; }
  .title-header-minimal #current-date { display: block; font-weight: 600; }
  /* กรอบโลโก้สีทองแบบวิ่ง (เข้ากับ accent / shimmer) */
  .logo-frame {
    display: inline-flex;
    padding: 3px;
    border-radius: 10px;
    background: linear-gradient(90deg, #FFD700, #FFF8DC, #FFB24A, #B8860B, #FFD700);
    background-size: 300% 100%;
    animation: logoGoldBorder 3s linear infinite;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
  }
  .logo-frame-header { border-radius: 10px; }
  .logo-frame-header .header-logo {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
  }
  .logo-frame-hero { border-radius: 12px; padding: 4px; }
  .logo-frame-hero .hero-logo {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 10px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
  }
  @keyframes logoGoldBorder {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
  }
  .header-logo {
    width: 40px; height: 40px; object-fit: contain; flex-shrink: 0;
    border-radius: 8px; background: rgba(255,255,255,0.08);
  }
  .title-text { min-width: 0; }
  .company-name { display: block; font-size: 0.6rem; font-weight: 600; opacity: 0.9; letter-spacing: 0.02em; margin-top: 2px; }
  
  .shimmer-text {
    margin: 0; font-size: 1.1rem; font-weight: 700;
    background: linear-gradient(90deg, #fff, var(--accent), #fff);
    background-size: 200% auto; -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; animation: shine 3s linear infinite;
  }
  @keyframes shine { to { background-position: 200% center; } }

  .user-status { font-size: 0.75rem; background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 20px; }

  /* --- ข่าวสารวิ่ง (News Ticker) --- */
  .news-ticker {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: #fff; padding: 8px 12px; border-radius: 12px; margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(255, 178, 74, 0.3); overflow: hidden;
  }
  .news-ticker-content {
    display: flex; align-items: center; gap: 10px;
  }
  .news-icon { font-size: 1.1rem; flex-shrink: 0; }
  .news-marquee {
    flex: 1; overflow: hidden; white-space: nowrap;
  }
  .news-text {
    display: inline-block; padding-left: 100%;
    animation: newsScroll 30s linear infinite;
    font-size: 0.85rem; font-weight: 500;
  }
  @keyframes newsScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
  }
  .news-ticker:hover .news-text { animation-play-state: paused; }

  /* --- รายการล่าสุดวิ่งผ่านจอ (Recent Items Ticker) --- */
  .recent-ticker {
    background: #0f172a;
    color: #e5e7eb;
    padding: 6px 10px;
    border-radius: 10px;
    margin-bottom: 10px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
    overflow: hidden;
  }
  .recent-ticker-inner {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .recent-label {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.6);
    color: #e5e7eb;
    white-space: nowrap;
  }
  .recent-marquee {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto;
    cursor: grab;
  }
  .recent-marquee:active {
    cursor: grabbing;
  }
  .recent-marquee::-webkit-scrollbar {
    height: 4px;
  }
  .recent-marquee::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 4px;
  }
  .recent-marquee::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 4px;
  }
  .recent-track {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }
  .recent-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.85);
    color: inherit;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
  }
  .recent-item:hover {
    background: rgba(30, 64, 175, 0.9);
    border-color: rgba(191, 219, 254, 0.9);
  }
  .recent-item-account {
    font-weight: 500;
    color: #e0e7ff;
  }
  .recent-item-company {
    font-weight: 600;
    color: var(--accent);
  }
  .recent-item-type {
    font-weight: 600;
    color: #bfdbfe;
  }
  .recent-item-qty-in {
    color: #4ade80;
    font-weight: 600;
  }
  .recent-item-qty-out {
    color: #f97373;
    font-weight: 600;
  }
  .recent-item-date {
    opacity: 0.8;
  }
  .recent-sep {
    opacity: 0.35;
    font-size: 0.7rem;
  }

  /* --- SEARCH BAR --- */
  .search-wrap {
    background: rgba(255, 255, 255, 0.12); border-radius: 10px;
    padding: 6px 12px; height: 34px; display: flex; align-items: center; gap: 8px;
    border: 1px solid rgba(255,255,255,0.05);
  }
  .search-wrap input { background: transparent; border: none; outline: none; width: 100%; font-size: 14px; color: #fff; }
  .search-wrap svg { width: 16px; height: 16px; opacity: 0.6; color: #fff; }

  /* --- APP CONTAINER (Responsive) - เต็มหน้าจอมือถือ --- */
  .app { 
    width: 100%; max-width: 500px; margin: 0 auto; 
    padding: 0 max(10px, env(safe-area-inset-right)) 76px max(10px, env(safe-area-inset-left)); 
    min-height: 100vh; 
  }
  @media (min-width: 768px) {
    .app { max-width: 560px; padding: 0 24px 76px; }
    .header { padding: 10px 20px 12px; }
    .shimmer-text { font-size: 1.25rem; }
  }
  /* --- Desktop: ใช้พื้นที่จอใหญ่ ไม่กระทบมือถือ (ใช้เฉพาะ min-width) --- */
  @media (min-width: 1024px) {
    .app {
      max-width: 900px;
      padding: 0 32px 80px;
    }
    .header {
      padding: 12px 24px 14px;
      border-bottom-left-radius: 20px;
      border-bottom-right-radius: 20px;
    }
    .dash-kpi-grid {
      grid-template-columns: repeat(4, 1fr);
      gap: 14px;
      margin-bottom: 18px;
    }
    .dash-chart-body {
      height: 280px;
    }
    .dash-filter-row {
      flex-wrap: nowrap;
      gap: 12px;
      margin-bottom: 12px;
    }
    .dash-filter-group {
      min-width: 0;
      max-width: none;
      flex: 1;
    }
    .dash-filter-actions {
      flex-wrap: nowrap;
      align-items: flex-end;
    }
    .dash-company-body {
      max-height: 320px;
    }
    .shelf-layout-dimensional .shelf-box {
      max-width: 44px;
    }
    .shelf-layout-full.shelf-layout-dimensional .shelf-box {
      max-width: 48px;
    }
    .history-container {
      max-height: calc(100vh - 260px);
    }
    .stock-filters {
      grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
      gap: 12px;
    }
    .form-card {
      max-width: 640px;
      margin-left: auto;
      margin-right: auto;
    }
    .card {
      padding: 20px;
      margin-bottom: 20px;
    }
  }
  @media (min-width: 1280px) {
    .app {
      max-width: 1100px;
      padding: 0 40px 80px;
    }
    .dash-kpi-grid {
      grid-template-columns: repeat(4, 1fr);
    }
  }
  @media (max-width: 600px) {
    .app { padding: 0 max(8px, env(safe-area-inset-right)) 72px max(8px, env(safe-area-inset-left)); }
    .header { padding: 10px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)); border-radius: 0 0 14px 14px; }
    .hero-card { margin-bottom: 12px; border-radius: 16px; }
    .hero-card[style*="margin-top"] { margin-top: 8px !important; }
    .hero-body { bottom: 12px; left: 12px; }
    .stats-grid { gap: 8px; margin-bottom: 12px; }
    .stat-card { padding: 12px; border-radius: 14px; }
    .card { padding: 12px; margin-bottom: 12px; border-radius: 16px; }
    .shelf-layout-dimensional { padding: 10px 8px; border-radius: 12px; }
  }
  @media (max-width: 480px) {
    .app { padding: 0 max(6px, env(safe-area-inset-right)) 70px max(6px, env(safe-area-inset-left)); }
    .header { padding: 6px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); border-radius: 0 0 12px 12px; }
    .bottom-nav { height: 56px; }
    .nav-item-fab { width: 40px; height: 40px; }
    .nav-item-fab svg { width: 18px; height: 18px; }
    .nav-item { padding: 5px 4px; }
    .nav-item svg { width: 20px; height: 20px; }
    .nav-item span { font-size: 0.6rem; }
  }


  /* --- STAT CARDS & HERO --- */
  .hero-card {
    position: relative; border-radius: 20px; overflow: hidden; margin-bottom: 16px;
    box-shadow: var(--shadow-lg);
  }
  .hero-img { width: 100%; height: 100%; object-fit: cover; }
  .hero-overlay { position: absolute; inset: 0; background: linear-gradient(to right, rgba(15,23,42,0.9), transparent); }
  .hero-body { position: absolute; bottom: 16px; left: 16px; color: #fff; }

  .hero-body-b2c { display: flex; align-items: center; gap: 14px; right: 16px; }
  .hero-logo {
    width: 56px; height: 56px; object-fit: contain; flex-shrink: 0;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
  }
  /* ขนาดโลโก้ใน hero ใช้จาก .logo-frame-hero .hero-logo ด้านบนแล้ว */
  .hero-copy { min-width: 0; }
  .hero-copy h2 { margin: 0 0 4px 0; }
  .hero-company { margin: 0 0 4px 0; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; opacity: 0.95; }
  .hero-accent { color: var(--accent); }

  .stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
  .stat-card { background: #fff; border-radius: 16px; padding: 16px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); display: flex; align-items: center; gap: 12px; }
  .stat-icon { background: var(--bg); border-radius: 12px; display: grid; place-items: center; }

  /* --- หน้าหลัก: สรุป KPI + ฟิลเตอร์ + พับได้ --- */
  .dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
  }
  .dash-kpi-card {
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid var(--line);
  }
  .dash-kpi-in { border-left-color: #22c55e; }
  .dash-kpi-out { border-left-color: #ef4444; }
  .dash-kpi-net { border-left-color: #6366f1; }
  .dash-kpi-companies { border-left-color: #f59e0b; }
  .dash-kpi-clickable { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
  .dash-kpi-clickable:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); }
  .dash-kpi-rows { border-left-color: #64748b; }
  .dash-kpi-months { border-left-color: #0ea5e9; }
  .dash-kpi-avg-in { border-left-color: #22c55e; }
  .dash-kpi-avg-out { border-left-color: #ef4444; }
  .dash-kpi-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; font-weight: 700;
    flex-shrink: 0;
  }
  .dash-kpi-in .dash-kpi-icon { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
  .dash-kpi-out .dash-kpi-icon { background: rgba(239, 68, 68, 0.15); color: #dc2626; }
  .dash-kpi-net .dash-kpi-icon { background: rgba(99, 102, 241, 0.15); color: #4f46e5; }
  .dash-kpi-companies .dash-kpi-icon { background: rgba(245, 158, 11, 0.15); color: #d97706; }
  .dash-kpi-rows .dash-kpi-icon { background: rgba(100, 116, 139, 0.15); color: #475569; }
  .dash-kpi-months .dash-kpi-icon { background: rgba(14, 165, 233, 0.15); color: #0284c7; }
  .dash-kpi-avg-in .dash-kpi-icon { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
  .dash-kpi-avg-out .dash-kpi-icon { background: rgba(239, 68, 68, 0.12); color: #dc2626; }

  .dash-chart-card {
    margin-bottom: 12px;
  }
  .dash-chart-header {
    padding: 10px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .dash-chart-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
  }
  .dash-chart-subtitle {
    font-size: 0.72rem;
    color: #64748b;
  }
  .dash-chart-body {
    margin: 0 10px 12px;
    border-radius: 16px;
    background: radial-gradient(circle at top, #1d283a 0%, #020617 55%, #020617 100%);
    box-shadow:
      0 18px 40px rgba(15, 23, 42, 0.75),
      inset 0 0 0 1px rgba(148, 163, 184, 0.25);
    height: 220px;
    position: relative;
    overflow: hidden;
  }
  .dash-chart-body canvas {
    width: 100%;
    height: 100%;
    display: block;
  }
  .dash-chart-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 0.8rem;
    color: #94a3b8;
    pointer-events: none;
  }
  .dash-kpi-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; overflow: hidden; }
  .dash-kpi-label { font-size: 0.7rem; color: #64748b; line-height: 1.2; }
  .dash-kpi-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-all;
    line-height: 1.25;
  }
  .dash-kpi-net .dash-kpi-value.negative { color: #dc2626; }
  .dash-kpi-net .dash-kpi-value.positive { color: #16a34a; }
  /* การ์ด KPI ทุกกล่องกดได้ → เปิดการสรุป */
  .dash-kpi-card {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
  }
  .dash-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  }

  .dash-filter-card { margin-bottom: 12px; }
  .dash-filter-bar { padding: 0 14px 14px; }
  .dash-filter-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
  .dash-filter-group { flex: 1; min-width: 90px; max-width: 160px; }
  .dash-filter-group label { display: block; font-size: 0.72rem; color: #64748b; margin-bottom: 4px; }
  .dash-filter-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.85rem;
    background: #fff;
  }
  .dash-filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .dash-summary-card { margin-bottom: 12px; }
  .dashboard-summary-body { padding: 12px 14px; min-height: 80px; }
  .dashboard-summary-placeholder { color: #94a3b8; font-size: 0.9rem; margin: 0; }
  .dash-month-block {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
  }
  .dash-month-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
  }
  .dash-month-line {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: baseline;
  }
  .dash-month-label {
    font-weight: 700;
  }
  .dash-month-stat {
    font-weight: 500;
  }
  .dash-month-in {
    color: #16a34a;
  }
  .dash-month-out {
    color: #dc2626;
  }
  .dash-month-net.positive {
    color: #16a34a;
  }
  .dash-month-net.negative {
    color: #dc2626;
  }
  .dash-month-comp {
    color: #64748b;
  }
  .dash-month-head:hover { background: #e2e8f0; }
  .dash-month-head .dash-toggle { font-size: 0.8rem; color: #64748b; margin-left: 8px; }
  .dash-month-body { padding: 0 10px 10px; }
  .dash-month-block.dash-collapsed .dash-month-body { display: none; }
  .dash-company-block {
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
  }
  .dash-company-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px;
    background: #fafafa;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
  }
  .dash-company-title {
    max-width: 55%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .dash-company-meta {
    font-size: 0.78rem;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
  }
  .dash-company-head:hover { background: #f1f5f9; }
  .dash-company-head .dash-toggle { font-size: 0.75rem; color: #64748b; }
  .dash-company-body {
    padding: 0 8px 8px;
    max-height: 260px;
    overflow-y: auto;
  }
  .dash-company-block.dash-collapsed .dash-company-body { display: none; }
  .dash-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
  }
  .dash-summary-header-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .dash-summary-header-text {
    white-space: nowrap;
  }
  .dash-summary-icon {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
  }
  .dash-summary-icon-in {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
  }
  .dash-summary-icon-out {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
  }
  .dash-summary-icon-net {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
  }
  .dash-summary-table th,
  .dash-summary-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #f1f5f9; }
  .dash-summary-table th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
  }
  .dash-summary-table tbody tr:nth-child(odd) {
    background: #f9fafb;
  }
  .dash-summary-table tbody tr:hover {
    background: #eff6ff;
  }
  .dash-summary-row-clickable { cursor: pointer; }
  .dash-summary-row-clickable:hover { background: #dbeafe !important; }
  .dash-summary-table tr:last-child td { border-bottom: none; }
  .dash-summary-table .num { text-align: right; }
  .dash-summary-table .in { color: #16a34a; }
  .dash-summary-table .out { color: #dc2626; }
  .dash-summary-table .net { font-weight: 600; }
  .dash-summary-empty { padding: 20px; text-align: center; color: #94a3b8; font-size: 0.9rem; }

  /* --- CARD HEAD --- */
  .card-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; padding: 0 0 8px; border-bottom: 1px solid var(--line);
  }
  .card-head h2 { margin: 0; font-size: 0.95rem; font-weight: 600; color: var(--primary); }
  .card-head-form .btn-scan-ai {
    padding: 6px 12px; font-size: 0.8rem; background: var(--accent); color: #fff;
    border-radius: 20px; border: none; cursor: pointer; font-weight: 600;
  }
  .card-head-form .btn-scan-ai:hover { opacity: 0.9; }
  .badge-heatmap, .badge-accent {
    font-size: 0.7rem; padding: 4px 10px; border-radius: 999px;
    background: rgba(255, 178, 74, 0.2); color: var(--accent-dark);
  }
  .dot-live { display: inline-block; width: 6px; height: 6px; background: var(--success); border-radius: 50%; margin-right: 6px; animation: pulse 2s ease-in-out infinite; }
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
  .pulse-animation { animation: pulse 2s ease-in-out infinite; }

  /* --- HEATMAP แบบมีมิติ ROOM1 (แถว A 7 ช่อง, B-I ละ 6 ช่อง) --- */
  .shelf-layout-dimensional {
    display: flex; flex-direction: column; gap: 8px; padding: 12px 10px;
    background: linear-gradient(180deg, rgba(248,250,252,0.8) 0%, rgba(241,245,249,0.5) 100%);
    border-radius: 12px; border: 1px solid var(--line);
  }
  .shelf-row-wrapper { margin-bottom: 6px; }
  .shelf-row-head {
    display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
  }
  .shelf-row-thumb {
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  }
  .shelf-row-head .shelf-row-label {
    width: 24px; min-width: 24px; height: 28px; display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, #1e293b 100%);
    border-radius: 10px;
    box-shadow: 
      0 3px 6px rgba(0, 0, 0, 0.15),
      0 1px 3px rgba(0, 0, 0, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
  }
  .shelf-row-head .shelf-row-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
    pointer-events: none;
  }
  .shelf-row-toggle {
    width: 28px; height: 28px; padding: 0;
    border: 1.5px solid var(--line); border-radius: 8px;
    background: linear-gradient(135deg, #fff 0%, #F8FAFC 100%);
    color: var(--primary); font-size: 1rem; font-weight: 700; line-height: 1; cursor: pointer;
    box-shadow: 
      0 2px 4px rgba(0, 0, 0, 0.08),
      inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: all 0.2s;
  }
  .shelf-row-toggle:hover {
    background: linear-gradient(135deg, var(--bg) 0%, #F1F5F9 100%);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 
      0 3px 6px rgba(0, 0, 0, 0.12),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
  }
  .shelf-row-toggle:active {
    transform: translateY(0);
    box-shadow: 
      0 1px 2px rgba(0, 0, 0, 0.1),
      inset 0 1px 2px rgba(0, 0, 0, 0.1);
  }
  .shelf-row {
    display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
  }
  .shelf-row-collapsed { display: none !important; }
  .shelf-row-summary-container {
    display: block !important;
    padding: 12px;
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.95) 0%, rgba(241, 245, 249, 0.9) 100%);
    border-radius: 10px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    margin-top: 6px;
  }
  .shelf-row-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
  }
  .shelf-row-summary-empty {
    text-align: center;
    color: #94A3B8;
    padding: 8px;
    font-style: italic;
  }
  .shelf-row-summary-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }
  .shelf-row-summary-qty {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
  }
  .shelf-row-summary-pct {
    font-weight: 600;
    color: var(--accent-dark);
    background: rgba(255, 178, 74, 0.15);
    padding: 4px 10px;
    border-radius: 12px;
  }
  .shelf-row-summary-slots {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.8rem;
  }
  .shelf-row-summary-slots-used {
    color: var(--success);
    font-weight: 600;
  }
  .shelf-row-summary-slots-empty {
    color: #94A3B8;
  }
  .shelf-row-summary-slots-pct {
    color: #64748B;
    font-size: 0.75rem;
  }
  .shelf-row-summary-types,
  .shelf-row-summary-accounts {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.8rem;
    flex-wrap: wrap;
  }
  .shelf-row-summary-label {
    font-weight: 600;
    color: #64748B;
    flex-shrink: 0;
  }
  .shelf-row-summary-values {
    color: var(--primary);
    flex: 1;
  }
  .shelf-row-summary-more {
    color: #94A3B8;
    font-style: italic;
  }
  .shelf-row-summary-other {
    background: linear-gradient(135deg, rgba(241, 245, 249, 0.95) 0%, rgba(226, 232, 240, 0.9) 100%);
    border-color: rgba(148, 163, 184, 0.4);
  }

  /* ปุ่มเปิด/ปิดทั้งหมด */
  .btn-expand-all,
  .btn-collapse-all {
    font-weight: 600;
    transition: all 0.2s;
  }
  .btn-expand-all:hover {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border-color: var(--success);
  }
  .btn-collapse-all:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: var(--danger);
  }
  .btn-expand-all:active,
  .btn-collapse-all:active {
    transform: scale(0.95);
  }
  .shelf-box {
    width: 100%; max-width: 36px; aspect-ratio: 1; border-radius: 8px;
    font-size: 0.6rem; display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); cursor: pointer; flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
      0 2px 4px rgba(0, 0, 0, 0.08),
      0 1px 2px rgba(0, 0, 0, 0.04),
      inset 0 1px 0 rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
  }
  .shelf-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.4), transparent);
    pointer-events: none;
    border-radius: 8px 8px 0 0;
  }
  .shelf-box:hover {
    transform: translateY(-2px) scale(1.08);
    box-shadow: 
      0 8px 16px rgba(0, 0, 0, 0.15),
      0 4px 8px rgba(0, 0, 0, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border-color: rgba(255, 255, 255, 0.5);
  }
  .shelf-box:active {
    transform: translateY(0) scale(1.02);
    box-shadow: 
      0 2px 4px rgba(0, 0, 0, 0.12),
      inset 0 1px 2px rgba(0, 0, 0, 0.1);
  }
  .shelf-zone-label { 
    font-size: 0.65rem; 
    font-weight: 700; 
    opacity: 0.95; 
    line-height: 1.2; 
    margin-bottom: 2px;
    color: inherit;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  }
  .shelf-qty-mini, .shelf-qty-full { 
    font-size: 0.7rem; 
    margin-top: 1px; 
    font-weight: 600;
    line-height: 1.1;
  }
  .shelf-qty-full { font-size: 0.75rem; }
  .shelf-pct { 
    font-size: 0.5rem; 
    opacity: 0.85; 
    font-weight: normal; 
    margin-top: 0; 
    line-height: 1;
  }
  .shelf-map-legend { margin: 10px 0 0; padding: 0 4px; font-size: 0.7rem; color: #64748B; line-height: 1.35; }
  .shelf-box.level-0 {
    background: linear-gradient(135deg, #E2E8F0 0%, #CBD5E1 100%);
    color: #64748B;
    box-shadow: 
      0 2px 4px rgba(0, 0, 0, 0.08),
      0 1px 2px rgba(0, 0, 0, 0.04),
      inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }
  .shelf-box.level-1 {
    background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
    color: #1E40AF;
    box-shadow: 
      0 3px 6px rgba(59, 130, 246, 0.2),
      0 1px 3px rgba(59, 130, 246, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.5);
  }
  .shelf-box.level-2 {
    background: linear-gradient(135deg, #93C5FD 0%, #60A5FA 100%);
    color: #1E3A8A;
    box-shadow: 
      0 4px 8px rgba(59, 130, 246, 0.25),
      0 2px 4px rgba(59, 130, 246, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.6);
  }
  .shelf-box.level-3 {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    color: #fff;
    font-weight: bold;
    box-shadow: 
      0 6px 12px rgba(59, 130, 246, 0.35),
      0 3px 6px rgba(59, 130, 246, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.7),
      inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  }
  .shelf-box.level-3:hover {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    box-shadow: 
      0 10px 20px rgba(59, 130, 246, 0.4),
      0 5px 10px rgba(59, 130, 246, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.8);
  }
  /* แถว "อื่นๆ" พื้นที่ที่ไม่ตรงกำหนด / ว่าง - สีต่างออกไป */
  .shelf-row-label-other {
    background: linear-gradient(135deg, #64748B 0%, #475569 100%) !important;
    box-shadow: 0 2px 4px rgba(100, 116, 139, 0.2);
  }
  .shelf-box.shelf-box-other {
    border: 1px dashed rgba(148, 163, 184, 0.4);
    background: linear-gradient(135deg, #F1F5F9 0%, #E2E8F0 100%) !important;
    color: #475569;
    box-shadow: 
      0 2px 4px rgba(0, 0, 0, 0.06),
      inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }
  .shelf-box.shelf-box-other.level-0 {
    background: linear-gradient(135deg, #F1F5F9 0%, #E2E8F0 100%) !important;
  }
  .shelf-box.shelf-box-other.level-1 {
    background: linear-gradient(135deg, #E2E8F0 0%, #CBD5E1 100%) !important;
  }
  .shelf-box.shelf-box-other.level-2 {
    background: linear-gradient(135deg, #CBD5E1 0%, #94A3B8 100%) !important;
  }
  .shelf-box.shelf-box-other.level-3 {
    background: linear-gradient(135deg, #94A3B8 0%, #64748B 100%) !important;
    color: #fff;
    box-shadow: 
      0 4px 8px rgba(100, 116, 139, 0.25),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
  /* แผนผังเต็ม (Warehouse) ช่องใหญ่ขึ้นเล็กน้อย */
  .shelf-layout-full.shelf-layout-dimensional .shelf-box { max-width: 42px; }
  .shelf-layout-full.shelf-layout-dimensional .shelf-row-label { width: 26px; min-width: 26px; height: 32px; font-size: 0.8rem; }

  /* มือถือ: ให้แถวชั้นวาง (เช่น Room2 ที่มีช่องมาก) ขึ้นบรรทัดล่างแทนล้นออกด้านขวา */
  @media (max-width: 600px) {
    .shelf-row {
      flex-wrap: wrap;
    }
    .shelf-layout-dimensional .shelf-box {
      max-width: 40px;
    }
    .shelf-layout-full.shelf-layout-dimensional .shelf-box {
      max-width: 38px;
    }
  }

  /* สถานะแผนผัง: กำลังโหลด / ไม่มีข้อมูล / โหลดไม่สำเร็จ */
  .shelf-map-loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 32px 16px; gap: 12px;
  }
  .shelf-map-loading .shelf-map-spinner {
    width: 32px; height: 32px; border-width: 3px;
  }
  .shelf-map-message {
    margin: 0; padding: 24px 16px; text-align: center; font-size: 0.9rem; color: #64748B;
  }
  .shelf-map-loading .shelf-map-message { padding: 0; }
  .shelf-map-empty { color: #94A3B8; }
  .shelf-map-error { color: var(--danger); }
  .shelf-map-error-detail { font-size: 0.75rem; color: #94A3B8; margin-top: 8px; word-break: break-all; }

  /* --- FORM STYLING --- */
  .card { background: #fff; border-radius: 20px; padding: 16px; margin-bottom: 16px; border: 1px solid var(--line); }
  /* ฟอร์มคีย์ข้อมูล - กะทัดรัดเพื่อเห็นข้อมูลได้มากขึ้น */
  .form-card { padding: 12px; margin-bottom: 12px; }
  .form-card .card-head { margin-bottom: 8px; padding-bottom: 6px; }
  .form-card .form { gap: 8px !important; padding: 10px !important; }
  .form-card .input-group { margin-bottom: 8px; gap: 4px; }
  .form-card .input-group label { font-size: 0.75rem; }
  .form-card .input-group input,
  .form-card .input-group select {
    padding: 9px 10px; border-radius: 10px; font-size: 0.9rem;
  }
  .form-card .row2 { gap: 10px; }
  .form-card .btn-main, .form-card .btn-sub { padding: 12px; font-size: 0.95rem; }
  .form-card .input-group[style*="background"] { padding: 8px 10px !important; }
  .form-card .input-group[style*="background"] label { margin-bottom: 2px !important; }
  .form-card .photo-upload-area { margin: 8px 0 !important; }
  .form-card .btn-group-stacked { gap: 6px !important; margin-top: 6px !important; }
  .input-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
  .input-group label { font-size: 0.8rem; font-weight: 600; color: #64748B; padding-left: 4px; }
  .input-group input, .input-group select {
    padding: 12px; border-radius: 12px; border: 1.5px solid #E2E8F0;
    font-size: 0.95rem; font-family: inherit; transition: border-color 0.2s;
    width: 100%; max-width: 100%; box-sizing: border-box;
  }
  .input-group input:focus, .input-group select:focus { border-color: var(--accent); outline: none; }
  .input-group .input-other { width: 100%; box-sizing: border-box; }
  .input-group select {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

  /* --- BUTTONS --- */
  .btn-main {
    background: var(--primary); color: #fff; border: none; padding: 16px;
    border-radius: 14px; font-weight: 700; font-size: 1rem; cursor: pointer;
    transition: transform 0.1s;
  }
  .btn-main:active { transform: scale(0.98); }
  .btn-sub { background: #F1F5F9; color: #475569; border: none; padding: 10px; border-radius: 10px; font-weight: 500; }

  /* --- NAVIGATION & FAB --- (แบบ Minimal Clean) เมนูด้านล่างพื้นหลังดำ - กะทัดรัด */
  .bottom-nav {
    position: fixed; bottom: 0; left: 0; width: 100%; height: 60px;
    background: var(--primary);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    display: grid; grid-template-columns: repeat(5, 1fr);
    z-index: 1000; 
    padding: 0 max(6px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    align-items: center;
  }
  .nav-item {
    border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: rgba(255, 255, 255, 0.5); transition: color 0.2s, transform 0.2s; position: relative; gap: 2px;
    padding: 6px 4px;
    margin: 0 2px;
  }
  .nav-item:hover {
    color: rgba(255, 255, 255, 0.8);
  }
  .nav-item.active {
    color: var(--accent);
    font-weight: 600;
    border: 2px solid var(--accent);
    border-radius: 12px;
  }
  .nav-item.active::after {
    display: none;
  }
  .nav-item svg {
    width: 22px; height: 22px;
    transition: color 0.2s;
    position: relative; z-index: 1;
  }
  .nav-item svg path,
  .nav-item svg circle {
    stroke-width: 1.5;
  }
  .nav-item:hover:not(.active) svg {
    transform: scale(1.05);
  }
  .nav-item span {
    position: relative; z-index: 1;
    font-size: 0.65rem; font-weight: 500;
    letter-spacing: 0.02em;
  }
  .nav-item.active span {
    color: var(--accent);
  }
  
  /* ปุ่ม + แบบ Minimal */
  .nav-item-fab {
    width: 44px; height: 44px;
    background: var(--accent);
    border-radius: 50%;
    border: none;
    box-shadow: 0 2px 8px rgba(255, 178, 74, 0.35);
    margin: 0 auto;
    color: white;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
  }
  .nav-item-fab:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 12px rgba(255, 178, 74, 0.4);
  }
  .nav-item-fab:active {
    transform: scale(1.02);
  }
  .nav-item-fab svg {
    width: 22px; height: 22px;
    stroke: white;
    stroke-width: 2.5;
    position: relative;
    z-index: 1;
    transition: transform 0.2s;
  }
  .nav-item-fab:hover svg {
    transform: rotate(90deg);
  }
  .nav-item-fab span { display: none; }
  .nav-item-fab.active::before,
  .nav-item-fab.active::after { display: none; }
  .nav-item-fab.active svg { transform: none; }
  
  .btn-logout-header {
    padding: 4px 10px; font-size: 0.7rem; border-radius: 8px; border: 1px solid rgba(255,255,255,0.4);
    background: transparent; color: #fff; cursor: pointer;
  }
  .btn-logout-header:hover { background: rgba(255,255,255,0.15); }

  .fab-wrapper { display: none; }
  .fab-options-container {
    position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%);
    z-index: 1999; display: none; flex-direction: column; gap: 8px; align-items: center;
  }
  .fab-options-container[style*="flex"] {
    display: flex !important;
  }
  .fab-option-item {
    padding: 10px 18px; border-radius: 24px; border: none; font-size: 0.85rem;
    font-weight: 500; cursor: pointer; white-space: nowrap;
    background: #fff; color: var(--primary); box-shadow: var(--shadow-lg);
    transition: transform 0.15s, background 0.15s;
  }
  .fab-option-item:hover { transform: scale(1.03); background: var(--bg); }
  .fab-option-item.ai { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; }

  /* --- TABS (Warehouse) --- */
  .tab-header-modern { display: flex; gap: 6px; margin-bottom: 12px; }
  .tab-btn {
    flex: 1; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 12px;
    background: #fff; color: #64748B; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.2s;
  }
  .tab-btn:hover { border-color: var(--accent); color: var(--accent); }
  .tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .map-room-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
  .admin-shelf-room-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

  /* --- HISTORY LIST --- */
  /* พื้นที่รายการสต๊อก/บันทึกการนำออก: ให้เลื่อนได้เมื่อมีหลายการ์ด */
  .history-container {
    display: flex; flex-direction: column; gap: 10px; padding-bottom: 20px;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    max-height: calc(100vh - 280px); min-height: 120px;
  }
  .history-card {
    background: #fff; border-radius: 14px; padding: 12px 14px; border: 1px solid var(--line);
    transition: box-shadow 0.2s;
  }
  .history-card:hover { box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08); }
  .history-card-grouped {
    border-left: 3px solid var(--accent);
    background: linear-gradient(to right, rgba(255, 178, 74, 0.03), #fff);
  }
  .history-card-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .hc-zone { font-weight: 700; color: var(--primary); font-size: 0.9rem; }
  .hc-type { font-size: 0.75rem; color: #64748B; }
  .hc-item { font-weight: 600; color: var(--primary); margin-bottom: 4px; }
  .hc-meta { font-size: 0.78rem; color: #64748B; margin-bottom: 4px; }
  .hc-qty { font-size: 0.8rem; color: var(--accent-dark); }
  .hc-balance { font-size: 0.85rem; font-weight: 600; color: var(--primary); margin-top: 4px; }
  .hc-qty-grouped { margin: 8px 0; padding: 8px; background: rgba(255, 178, 74, 0.08); border-radius: 8px; }
  .hc-qty-total { font-size: 0.9rem; color: var(--primary); display: flex; gap: 12px; flex-wrap: wrap; }
  .hc-qty-total strong { color: var(--accent-dark); font-weight: 700; }
  .hc-balance-grouped {
    font-size: 1rem; font-weight: 700; color: var(--primary);
    margin: 8px 0; padding: 10px; background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border-radius: 8px; border-left: 3px solid var(--success);
  }
  .hc-balance-grouped strong { color: var(--success); font-size: 1.1rem; }
  .hc-history-toggle {
    margin: 10px 0 6px; padding: 8px 12px; background: rgba(15, 23, 42, 0.04);
    border-radius: 6px; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 6px; transition: all 0.2s;
    position: relative; z-index: 2;
  }
  .hc-history-toggle:hover {
    background: rgba(15, 23, 42, 0.08); transform: translateX(2px);
  }
  .hc-history-toggle-icon {
    font-size: 0.75rem; color: var(--accent-dark); transition: transform 0.2s;
  }
  .hc-history-toggle-text {
    font-size: 0.85rem; color: var(--primary); font-weight: 500;
  }
  .hc-history-details {
    margin: 8px 0; padding: 10px; background: rgba(15, 23, 42, 0.02);
    border-radius: 6px; border-left: 2px solid var(--accent);
  }
  .hc-history-item {
    padding: 6px 0; border-bottom: 1px solid rgba(15, 23, 42, 0.05);
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  }
  .hc-history-item:last-child { border-bottom: none; }
  .hc-history-date {
    font-size: 0.8rem; color: #64748B; font-weight: 500; min-width: 100px;
  }
  .hc-history-qty {
    font-size: 0.85rem; color: var(--accent-dark); font-weight: 600;
  }
  .hc-history-meta {
    font-size: 0.8rem; color: #475569; font-style: normal;
  }
  /* ข้อความผู้คีย์ในการ์ดประวัติ: ให้อ่านชัด ไม่เลือน */
  .hc-history-item .hc-history-meta { font-size: 0.82rem; color: var(--primary); font-weight: 500; }
  .history-img-wrapper { margin: 8px 0; text-align: center; }
  .history-img { 
    max-width: 100%; max-height: 200px; border-radius: 8px; 
    cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
  }
  .history-img:hover { transform: scale(1.02); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
  .history-img-icon { font-size: 1.5rem; opacity: 0.6; }
  .history-img-link { margin-left: auto; text-decoration: none; font-size: 1rem; }
  .image-modal { 
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; 
    background: rgba(0, 0, 0, 0.9); z-index: 10000; 
    display: flex; align-items: center; justify-content: center; 
    cursor: pointer; animation: fadeIn 0.2s;
  }
  .image-modal img { 
    max-width: 90%; max-height: 90%; 
    object-fit: contain; border-radius: 8px; 
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  }
  .history-empty { text-align: center; color: #94A3B8; padding: 24px; font-size: 0.9rem; }
  .btn-take-out {
    margin-top: 10px; padding: 8px 14px; font-size: 0.8rem; font-weight: 600;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
    border: none; border-radius: 10px; cursor: pointer; width: 100%;
  }
  .btn-take-out:hover { opacity: 0.95; transform: translateY(-1px); }

  /* --- Stock filters (Account, ประเภท, งานรอบ, รายการ) --- */
  .stock-filters-card { margin-bottom: 12px; }
  .stock-filters-card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    cursor: pointer; padding: 12px 14px; border-radius: 10px; transition: background 0.2s;
  }
  .stock-filters-card-head:hover { background: rgba(0,0,0,0.03); }
  .stock-filters-card-head-inner { flex: 1; min-width: 0; }
  .stock-filters-card-head h2 { margin: 0 0 4px 0; font-size: 0.95rem; font-weight: 600; }
  .stock-filters-hint {
    margin: 0; font-size: 0.75rem; color: #64748b; font-weight: 400;
  }
  .stock-filters-toggle-btn { flex-shrink: 0; font-size: 0.8rem; padding: 6px 12px; }
  /* แถบเมื่อพับ: โหลดข้อมูลใหม่ + ขยายฟิลเตอร์ ค้างไว้ให้กดได้ */
  .stock-filters-card-bar {
    display: none; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 14px; border-top: 1px solid var(--line); background: var(--bg);
  }
  .stock-filters-card-body { padding: 12px 14px 14px; }
  .stock-filters-card.stock-filters-card--collapsed .stock-filters-card-body { display: none; }
  .stock-filters-card.stock-filters-card--collapsed .stock-filters-card-bar { display: flex; }
  .stock-filters-card:not(.stock-filters-card--collapsed) .stock-filters-card-bar { display: none !important; }
  .stock-filters {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end;
  }
  .stock-filters .input-group { margin-bottom: 0; }
  .stock-filters .input-group select {
    font-size: 0.85rem; color: #64748b;
  }
  .stock-filters .btn-sub { margin-bottom: 0; }
  .btn-sub.searching { opacity: 0.8; cursor: wait; pointer-events: none; }
  .stock-search-status {
    margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; font-size: 0.85rem; font-weight: 500;
    min-height: 20px; opacity: 0; transition: opacity 0.25s ease;
  }
  .stock-search-status.stock-search-status-visible {
    opacity: 1; background: rgba(255, 178, 74, 0.15); color: var(--accent-dark);
  }
  @media (max-width: 520px) {
    .stock-filters { grid-template-columns: 1fr 1fr; }
    .stock-filters .btn-sub { grid-column: 1 / -1; }
  }

  /* --- SEARCH RESULTS (Dashboard) --- */
  .search-results-card { margin-top: 8px; }
  .search-results-list { display: flex; flex-direction: column; gap: 6px; }
  .history-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    background: var(--bg); border-radius: 10px; cursor: pointer; transition: background 0.2s;
  }
  .history-item:hover { background: #E2E8F0; }
  .hi-zone { font-weight: 600; font-size: 0.85rem; min-width: 44px; }
  .hi-item { flex: 1; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hi-qty { font-size: 0.75rem; color: #64748B; }
  .search-empty { padding: 12px; text-align: center; color: #94A3B8; font-size: 0.85rem; }

  /* --- PHOTO UPLOAD --- */
  .photo-upload-area {
    padding: 12px; border: 2px dashed #cbd5e1; border-radius: 12px; text-align: center; margin-bottom: 12px;
  }
  .hidden-file { display: none !important; }
  .btn-upload-photo { width: 100%; font-size: 0.85rem; cursor: pointer; }
  .photo-preview-wrap { margin-top: 10px; }
  .photo-preview-wrap img { max-width: 100%; max-height: 180px; border-radius: 10px; display: block; margin: 0 auto; }

  /* --- ADMIN --- */
  .admin-pass-input {
    width: 100%; padding: 12px; margin-bottom: 15px; text-align: center;
    border: 1.5px solid #E2E8F0; border-radius: 10px; font-size: 1rem;
  }
  .admin-pass-input:focus { border-color: var(--accent); outline: none; }
  .btn-full { width: 100%; cursor: pointer; }

  /* --- FORM HIGHLIGHTS --- */
  .input-group.highlight-in input:focus { border-color: var(--success); }
  .input-group.highlight-out input:focus { border-color: var(--danger); }

  /* --- LOADER --- */
  /* Loader - ซ่อนโดย default และแสดงเมื่อมี class loader-visible */
  .loader-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.92); z-index: 9999;
    display: none; align-items: center; justify-content: center; text-align: center;
    visibility: hidden; opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .loader-overlay.loader-visible {
    display: flex !important; visibility: visible !important;
    opacity: 1 !important; pointer-events: auto !important;
  }
  .loader-content { display: flex; flex-direction: column; align-items: center; }
  .loader-text { margin-top: 16px; font-size: 0.9rem; color: var(--primary); font-weight: 500; }
  .spinner-modern {
    width: 48px; height: 48px; border: 4px solid #E2E8F0;
    border-top: 4px solid var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* --- Modal ลงชื่อก่อนคีย์ --- */
  .signin-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.75); z-index: 9000;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0.25s;
  }
  .signin-overlay.signin-open { opacity: 1; visibility: visible; }
  .signin-modal-card {
    background: #fff; border-radius: 20px; max-width: 400px; width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2); overflow: hidden;
    max-height: 90vh; display: flex; flex-direction: column;
  }
  .signin-modal-card #edit-request-form {
    overflow-y: auto; overflow-x: hidden; flex: 1;
    max-height: calc(90vh - 120px); padding-right: 8px;
  }
  .signin-modal-card #edit-request-form::-webkit-scrollbar {
    width: 6px;
  }
  .signin-modal-card #edit-request-form::-webkit-scrollbar-track {
    background: #f1f5f9; border-radius: 3px;
  }
  .signin-modal-card #edit-request-form::-webkit-scrollbar-thumb {
    background: #cbd5e1; border-radius: 3px;
  }
  .signin-modal-card #edit-request-form::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
  }
  .signin-header {
    padding: 24px 20px; text-align: center; background: linear-gradient(180deg, var(--primary) 0%, #1e293b 100%);
    color: #fff;
  }
  .modal-close-btn {
    position: absolute; top: 12px; right: 12px;
    width: 32px; height: 32px; border: none; border-radius: 50%;
    background: rgba(255,255,255,0.2); color: #fff; font-size: 1.1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; line-height: 1;
    transition: background 0.2s; z-index: 10001;
  }
  .modal-close-btn:hover { background: rgba(255,255,255,0.35); }
  .signin-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
  .signin-header h3 { margin: 0 0 8px; font-size: 1.1rem; }
  .signin-header p { margin: 0; font-size: 0.8rem; opacity: 0.9; }
  .signin-logo-wrap { text-align: center; padding: 20px 20px 0; background: linear-gradient(180deg, #f8fafc 0%, var(--primary) 20%); }
  .signin-logo { max-width: 120px; max-height: 80px; object-fit: contain; display: inline-block; }
  .signin-role-row { display: flex; gap: 20px; margin-top: 6px; }
  .signin-role-option { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
  .signin-password-wrap { display: flex; flex-direction: column; gap: 8px; }
  .signin-show-pw { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.85rem; color: #64748b; }
  .signin-body { padding: 20px; }
  .signin-body .input-group { margin-bottom: 14px; }
  .signin-body .btn-main { margin-bottom: 10px; }
  .signin-body .btn-sub { margin-top: 4px; }

  .signin-hint { font-size: 0.75rem; color: #94A3B8; margin: 0 0 12px; }

  /* --- ปุ่มอัพเดทใน Header --- */
  .btn-updates-header {
    display: flex; align-items: center; gap: 6px; padding: 6px 12px;
    background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px; color: #fff; font-size: 0.8rem; cursor: pointer;
    transition: background 0.2s, transform 0.15s; position: relative;
  }
  .btn-updates-header:hover { background: rgba(255, 255, 255, 0.25); transform: scale(1.02); }
  .btn-updates-icon { font-size: 1rem; }
  .btn-updates-badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--accent); color: var(--primary); font-size: 0.6rem;
    font-weight: 700; padding: 1px 5px; border-radius: 10px;
  }

  /* --- Modal อัพเดทระบบ --- */
  .updates-overlay.updates-open { opacity: 1; visibility: visible; }
  .updates-header { background: linear-gradient(180deg, var(--accent-dark) 0%, var(--accent) 100%); }
  .updates-body { padding: 20px; max-height: 50vh; overflow-y: auto; }
  .updates-list { margin-bottom: 16px; }
  .updates-item {
    padding: 12px 14px; margin-bottom: 10px; border-radius: 12px;
    background: #F8FAFC; border-left: 4px solid var(--accent);
  }
  .updates-item-date { font-size: 0.7rem; color: #64748B; margin-bottom: 4px; }
  .updates-item-title { font-weight: 600; font-size: 0.9rem; color: var(--primary); margin-bottom: 4px; }
  .updates-item-detail { font-size: 0.82rem; color: #475569; line-height: 1.5; white-space: pre-wrap; }
  .updates-empty { color: #94A3B8; font-size: 0.9rem; text-align: center; padding: 24px; margin: 0; }

  /* --- Modal การสรุป (กดจากการ์ด KPI) --- */
  .kpi-summary-overlay {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
  }
  .kpi-summary-overlay.kpi-summary-modal-open {
    opacity: 1;
    visibility: visible;
  }
  .kpi-summary-modal-card {
    max-width: 96%;
    width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
  }
  .kpi-summary-header {
    flex-shrink: 0;
    position: relative;
  }
  .kpi-summary-header .modal-close-btn {
    left: auto;
    right: auto;
    top: 10px;
    left: 12px;
    font-size: 0.9rem;
    padding: 6px 12px;
    width: auto;
    height: auto;
    border-radius: 8px;
  }
  .kpi-summary-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
  }
  .kpi-summary-body .dash-month-block {
    margin-bottom: 10px;
  }
  .kpi-summary-body .dash-month-body {
    padding: 0 8px 8px;
  }
  .kpi-summary-body .dash-summary-table {
    font-size: 0.78rem;
  }
  .kpi-summary-body .kpi-summary-months-list {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  .kpi-summary-body .kpi-summary-months-list li {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    font-size: 0.9rem;
  }
  .kpi-summary-body .kpi-summary-single {
    padding: 16px;
    background: #f1f5f9;
    border-radius: 10px;
    font-size: 1rem;
    margin: 0;
  }

  /* --- Modal นำออก (สต๊อก → รายการ) --- */
  #takeout-modal { opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0.25s; }
  #takeout-modal.takeout-open { opacity: 1; visibility: visible; }
  /* ให้การ์ดโมดอลบันทึกการนำออกเลื่อนได้ เมื่อเนื้อหายาว (ส่วน body เป็น scroll) */
  .takeout-modal-card .signin-body {
    overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0;
    max-height: calc(90vh - 140px); -webkit-overflow-scrolling: touch;
    padding-right: 8px;
  }
  .takeout-modal-card .signin-body::-webkit-scrollbar { width: 6px; }
  .takeout-modal-card .signin-body::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
  .takeout-modal-card .signin-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
  /* ช่องกรอกในโมดอลนำออก: ให้กด/โฟกัสได้ชัด ไม่ถูกบัง */
  #takeout-modal .input-group input { position: relative; z-index: 1; }
  .takeout-balance { margin-top: 8px; padding: 8px 0; border-top: 1px solid #E2E8F0; font-size: 1rem; color: var(--primary); }
  .takeout-history-block { margin-top: 10px; padding-top: 8px; border-top: 1px solid #E2E8F0; font-size: 0.9rem; }
  .takeout-history-list { margin: 6px 0 0; padding-left: 20px; color: #475569; font-size: 0.9rem; line-height: 1.5; }
  /* ผู้คีย์ใน Modal นำออก: ให้ชัด อ่านง่าย */
  #takeout-key-user-display { font-size: 0.95rem !important; font-weight: 600 !important; color: var(--primary) !important; }
  .takeout-item-summary {
    background: #F1F5F9; border-radius: 10px; padding: 12px; margin-bottom: 14px;
    font-size: 0.85rem; color: var(--primary);
  }
  .takeout-item-summary div { margin-bottom: 4px; }
  .takeout-item-summary div:last-child { margin-bottom: 0; }

  /* --- Modal สแกนบิล (ถ่ายรูป → แก้ข้อมูล → เลือกพื้นที่) --- */
  .scanbill-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.85); z-index: 9000;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s;
  }
  .scanbill-overlay.scanbill-open { opacity: 1; visibility: visible; }
  .scanbill-card {
    background: #fff; border-radius: 24px; max-width: 420px; width: 100%; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  }
  .scanbill-card.slide-up { animation: slideUp 0.35s ease-out; }
  @keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .scanbill-step { padding: 24px 20px; }
  .scanbill-header { text-align: center; margin-bottom: 20px; }
  .scanbill-icon { font-size: 2.5rem; display: block; margin-bottom: 8px; }
  .scanbill-header h2 { margin: 0 0 8px; font-size: 1.1rem; color: var(--primary); }
  .scanbill-header p { margin: 0; font-size: 0.82rem; color: #64748B; }
  .scanbill-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
  }
  .scanbill-actions-row .scanbill-camera-area {
    flex: 1;
    min-width: 120px;
  }
  .scanbill-gallery-area { border-color: var(--accent); background: rgba(255, 178, 74, 0.08); }
  .scanbill-gallery-area:hover { background: rgba(255, 178, 74, 0.15); }
  .scanbill-camera-area {
    border: 3px dashed var(--accent); border-radius: 20px; padding: 40px 24px;
    text-align: center; cursor: pointer; margin-bottom: 16px;
    background: rgba(255, 178, 74, 0.08); transition: background 0.2s, transform 0.15s;
  }
  .scanbill-camera-area:hover { background: rgba(255, 178, 74, 0.15); transform: scale(1.02); }
  .scanbill-camera-icon { font-size: 3rem; display: block; margin-bottom: 8px; }
  .scanbill-camera-text { display: block; font-weight: 700; font-size: 1.1rem; color: var(--primary); }
  .scanbill-camera-area small { font-size: 0.8rem; color: #64748B; }
  /* Step 1: แสดงรูปที่แนบ + ข้อความกำลังอ่าน */
  .scanbill-step1-preview {
    margin-top: 16px; padding: 12px; background: #F1F5F9; border-radius: 12px; text-align: center;
  }
  .scanbill-step1-preview-img-wrap {
    border-radius: 10px; overflow: hidden; max-height: 160px; margin-bottom: 10px;
    border: 2px solid var(--accent); background: #fff;
  }
  .scanbill-step1-thumb { width: 100%; height: auto; max-height: 160px; object-fit: contain; display: block; }
  .scanbill-step1-status {
    margin: 0; font-size: 0.9rem; font-weight: 600; color: var(--primary);
  }
  .scanbill-step1-status.reading { color: var(--accent-dark); }
  .scanbill-retry-wrap { margin-top: 12px; }
  .scanbill-retry-wrap .btn-main { margin: 0; }
  .scanbill-preview-img-wrap { margin-bottom: 16px; border-radius: 12px; overflow: hidden; max-height: 140px; }
  .scanbill-preview-img { width: 100%; height: auto; display: block; }
  .scanbill-edit-form .input-group { margin-bottom: 12px; }
  .scanbill-edit-form .btn-full { margin-top: 8px; }
  
  /* รายการสินค้าที่เลือกได้ */
  .scanbill-items-list { margin-bottom: 20px; }
  .scanbill-bill-info {
    background: #F1F5F9;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
  }
  .scanbill-bill-info div {
    margin-bottom: 4px;
  }
  .scanbill-bill-info div:last-child {
    margin-bottom: 0;
  }
  .scanbill-bill-edit {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
  }
  .scanbill-bill-edit-title,
  .scanbill-save-form-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 0.95rem;
  }
  .scanbill-bill-edit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
  }
  .scanbill-bill-edit-row label { min-width: 80px; font-size: 0.85rem; color: #64748B; }
  .scanbill-bill-edit-row input { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid #E2E8F0; }
  .scanbill-save-form {
    background: #F1F5F9;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
    border: 1px solid #E2E8F0;
  }
  .scanbill-save-form .input-group { margin-bottom: 10px; }
  .scanbill-save-form .input-group:last-child { margin-bottom: 0; }
  .scanbill-item-editable .scanbill-item-details { margin-left: 8px; flex: 1; }
  .scanbill-item-edit-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
  .scanbill-item-edit-row label { font-size: 0.75rem; color: #64748B; min-width: 50px; }
  .scanbill-item-edit-row input { padding: 6px 8px; border-radius: 6px; border: 1px solid #E2E8F0; font-size: 0.85rem; }
  .scanbill-item-edit-row .scan-edit-item-name { flex: 1; min-width: 120px; }
  .scanbill-item-edit-row .scan-edit-item-qty { width: 56px; }
  .scanbill-item-edit-row .scan-edit-item-unitprice,
  .scanbill-item-edit-row .scan-edit-item-total { width: 70px; }
  .scanbill-items-header {
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--primary);
    font-size: 0.95rem;
  }
  .scanbill-items-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .scanbill-item-checkbox {
    background: var(--card-bg);
    border: 2px solid #E2E8F0;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s;
  }
  .scanbill-item-checkbox:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(255, 178, 74, 0.15);
  }
  .scanbill-item-checkbox label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    margin: 0;
  }
  .scanbill-item-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .scanbill-item-details {
    flex: 1;
  }
  .scanbill-item-name {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 6px;
    font-size: 0.95rem;
  }
  .scanbill-item-info {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
    color: #64748B;
  }
  .scanbill-item-info span {
    display: inline-block;
  }
  .scanbill-no-items {
    text-align: center;
    padding: 20px;
    color: #64748B;
    font-size: 0.9rem;
  }

  /* --- Admin: ผู้ใช้คีย์ + รหัสผ่าน --- */
  .admin-key-users { margin: 16px 0; padding-top: 16px; border-top: 1px solid var(--line); }
  .admin-section-title { margin: 0 0 6px; font-size: 1.05rem; font-weight: 600; color: #0f172a; }
  .admin-section-desc { font-size: 0.875rem; color: #64748b; margin: 0 0 16px; line-height: 1.45; max-width: 520px; }
  .admin-user-list, .admin-list-items { list-style: none; padding: 0; margin: 0 0 20px; font-size: 0.9rem; }
  .admin-user-list li, .admin-list-items li { 
    padding: 12px 14px; background: #f8fafc; border-radius: 10px; margin-bottom: 8px; 
    display: flex; justify-content: space-between; align-items: center;
    border: 1px solid #e2e8f0; font-size: 0.9rem;
  }
  .admin-user-list li:hover, .admin-list-items li:hover { background: #f1f5f9; border-color: #cbd5e1; }
  .admin-user-item .admin-user-info { flex: 1; min-width: 0; }
  .admin-user-name { font-weight: 600; color: #0f172a; font-size: 0.95rem; }
  .admin-user-role-badge { font-size: 0.8rem; color: #64748b; font-weight: 500; margin-left: 4px; }
  .admin-user-meta { font-size: 0.825rem; color: #64748b; margin-top: 4px; display: block; }
  .admin-user-actions { display: flex; gap: 8px; flex-shrink: 0; }
  .admin-btn-edit { padding: 6px 12px; font-size: 0.85rem; }
  .admin-btn-delete { padding: 6px 12px; font-size: 0.85rem; background: var(--danger); color: #fff; border-color: var(--danger); }
  .admin-btn-delete:hover { background: #b91c1c; color: #fff; }
  .admin-user-empty { color: #94a3b8; font-style: italic; padding: 12px 0; }
  .admin-add-user-card {
    max-width: 400px; padding: 20px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; margin-top: 8px;
  }
  .admin-form-title { margin: 0 0 16px; font-size: 0.95rem; font-weight: 600; color: #334155; }
  .admin-add-user { display: flex; flex-direction: column; gap: 16px; }
  .admin-add-user .admin-field-input, .admin-add-item input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 0.9rem; }
  .admin-field { display: flex; flex-direction: column; gap: 6px; }
  .admin-field-label { font-size: 0.9rem; font-weight: 600; color: #475569; }
  .admin-field-hint { font-size: 0.8rem; color: #64748b; margin: 0 0 2px; }
  .admin-role-options { display: flex; flex-direction: column; gap: 8px; }
  .admin-role-option {
    display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
    padding: 10px 12px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
    transition: background 0.15s, border-color 0.15s;
  }
  .admin-role-option:hover { background: #f1f5f9; border-color: #cbd5e1; }
  .admin-role-option input { margin: 3px 0 0; flex-shrink: 0; }
  .admin-role-option .admin-role-title { font-weight: 600; color: #334155; font-size: 0.9rem; display: block; }
  .admin-role-option .admin-role-desc { font-size: 0.8rem; color: #64748b; margin-top: 2px; display: block; }
  .admin-submit-btn { margin-top: 4px; }
  .admin-companies-wrap .admin-field-label { margin-bottom: 2px; }
  .admin-companies-checkboxes { max-height: 160px; overflow-y: auto; padding: 12px; border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; background: #fff; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 12px; }
  .admin-company-cb { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.875rem; white-space: nowrap; }
  .admin-company-cb input { margin: 0; }
  .edit-user-body .admin-field-option { padding: 8px 0; }
  .edit-user-body .admin-role-options { gap: 8px; }
  .edit-user-companies-wrap .admin-field-hint { margin-bottom: 4px; }
  .admin-add-item { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .admin-delete-btn { 
    padding: 4px 10px; font-size: 0.75rem; background: #FEE2E2; color: #DC2626; 
    border: 1px solid #FECACA; border-radius: 6px; cursor: pointer;
  }
  .admin-delete-btn:hover { background: #DC2626; color: #fff; }
  .admin-pending-list { max-height: 300px; overflow-y: auto; }

  /* --- Admin: พับเก็บได้ (จัดการพื้นที่ Room + รอการอนุมัติ) --- */
  .admin-collapse-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    background: #FAFBFC;
    border-radius: 12px;
    padding: 12px 14px;
  }
  .admin-collapse-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    cursor: pointer;
    padding: 6px 4px;
    margin: -4px -4px 0;
    border-radius: 8px;
    user-select: none;
  }
  .admin-collapse-head:hover { background: rgba(15, 23, 42, 0.04); }
  .admin-collapse-head h4 { margin: 0; font-size: 0.95rem; }
  .admin-collapse-icon {
    font-size: 0.85rem;
    color: #64748B;
    transition: transform 0.2s ease;
  }
  .admin-collapse-section--collapsed .admin-collapse-icon { transform: rotate(-90deg); }
  .admin-collapse-body { margin-top: 12px; }
  .admin-collapse-section--collapsed .admin-collapse-body { display: none; }

  .admin-room-block {
    margin-bottom: 16px;
    padding: 10px 12px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--line);
  }
  .admin-room-block:last-of-type { margin-bottom: 0; }
  .admin-room-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 4px 0;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
  }
  .admin-room-head:hover { color: var(--accent-dark); }
  .admin-room-head .admin-room-toggle { font-size: 0.75rem; color: #64748B; font-weight: normal; }
  .admin-room-list-wrap { margin-top: 10px; }
  .admin-room-block--collapsed .admin-room-list-wrap { display: none; }
  .admin-room-block .admin-list-items { max-height: 200px; overflow-y: auto; margin-bottom: 10px; }

  /* --- ลูกเล่น: สไลด์/ขยับ view --- */
  .view.active { animation: viewSlideIn 0.3s ease-out; }
  @keyframes viewSlideIn {
    from { opacity: 0; transform: translateX(8px); }
    to { opacity: 1; transform: translateX(0); }
  }
  .signin-modal-card { animation: slideUp 0.3s ease-out; }
