
:root {
  --bg: #eef3f7;
  --surface: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0ea5e9;
  --primary2: #0284c7;
  --success: #059669;
  --danger: #dc2626;
  --warn: #f59e0b;
  --sidebar: #0f172a;
  --sidebar2: #082f49;
  --shadow: 0 10px 30px rgba(15,23,42,.08);
  --radius: 22px;
  --sidebar-w: 260px;
}

/* ═══ DARK MODE ═══ */
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: #334155;
  --primary: #38bdf8;
  --primary2: #0ea5e9;
  --success: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --sidebar: #020617;
  --sidebar2: #0c1a35;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
[data-theme="dark"] .auth-card,
[data-theme="dark"] .panel,
[data-theme="dark"] .card { background: var(--surface); border-color: var(--line); color: var(--text); }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: #0f172a; border-color: var(--line); color: var(--text); }
[data-theme="dark"] input::placeholder,
[data-theme="dark"] select::placeholder,
[data-theme="dark"] textarea::placeholder { color: #64748b; }
[data-theme="dark"] .btn.light, [data-theme="dark"] .btn-light { background: var(--surface); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .drawer { background: var(--surface); color: var(--text); }
[data-theme="dark"] .drawer-header { border-color: var(--line); }
[data-theme="dark"] table th { background: #1e293b; color: #cbd5e1; }
[data-theme="dark"] table td { border-color: var(--line); color: var(--text); }
[data-theme="dark"] .toast { background: #334155; color: #f1f5f9; }
[data-theme="dark"] hr { border-color: var(--line); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", sans-serif; overflow-x: hidden; max-width: 100vw; }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* ═══ AUTH ═══ */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(480px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 28px; padding: 28px; box-shadow: var(--shadow); }
.auth-logo { width: 90px; height: 90px; border-radius: 22px; background: linear-gradient(135deg, #38bdf8, #0284c7); display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 900; text-align: center; line-height: 1.2; margin: 0 auto 18px; box-shadow: 0 12px 30px rgba(2,132,199,.3); }
.auth-logo-img { width: 100px; height: 100px; border-radius: 24px; margin: 0 auto 18px; display: block; box-shadow: 0 12px 30px rgba(2,132,199,.3); }
.brand-row { display: flex; gap: 12px; align-items: center; }
.brand-badge { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, #38bdf8, #0284c7); color: #fff; font-size: 24px; }
.brand-badge.small { width: 44px; height: 44px; font-size: 20px; }
.brand-title { font-size: 24px; font-weight: 900; color: var(--primary2); }
.brand-sub, .muted, .sku { color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 10px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mt16 { margin-top: 16px; }

/* ═══ BUTTONS ═══ */
.btn { border: none; border-radius: 999px; padding: 11px 16px; font-weight: 900; cursor: pointer; font-size: 14px; white-space: nowrap; }
.btn.primary, .btn-primary { background: var(--primary2); color: #fff; }
.btn.light, .btn-light { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.dark { background: #111827; color: #fff; }
.btn.success { background: var(--success); color: #fff; }
.btn.warn { background: #fff7ed; color: #b45309; border: 1px solid #fdba74; }
.btn.danger-fill { background: var(--danger); color: #fff; }

/* ═══ PANEL / CARDS ═══ */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; background: #fff; font-size: 15px; }

/* ═══ APP LAYOUT ═══ */
.app-shell { display: flex; min-height: 100vh; }

/* ─── SIDEBAR (Desktop) ─── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar2), var(--sidebar));
  color: #fff; padding: 20px 16px; overflow-y: auto; overflow-x: hidden; z-index: 30;
}
.sidebar-head { display: flex; gap: 12px; align-items: center; }
.sidebar-logo { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, #38bdf8, #0284c7); display: grid; place-items: center; color: #fff; font-size: 9px; font-weight: 900; text-align: center; line-height: 1.15; flex-shrink: 0; }
.sidebar-logo-img { width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0; }
.sidebar-title { font-size: 20px; font-weight: 900; }
.sidebar-sub { color: #cbd5e1; font-size: 12px; }
.user-box { margin-top: 16px; padding: 12px; border-radius: 16px; background: rgba(255,255,255,.08); }
.user-name { font-weight: 900; font-size: 14px; }
.user-role { margin-top: 4px; color: #bae6fd; font-size: 12px; }
.nav-group-label { margin-top: 16px; color: #cbd5e1; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.nav-btn { width: 100%; margin-top: 6px; border: none; border-radius: 14px; padding: 11px 12px; background: transparent; color: #e2e8f0; text-align: left; cursor: pointer; font-size: 14px; font-weight: 600; transition: .15s; }
.nav-btn:hover, .nav-btn.active { background: rgba(14,165,233,.18); color: #fff; font-weight: 800; }
.nav-btn.danger { color: #fecaca; }
.nav-btn.sub { padding-left: 28px; font-size: 13px; font-weight: 500; color: #94a3b8; }
.nav-btn.sub:hover, .nav-btn.sub.active { color: #fff; background: rgba(14,165,233,.14); font-weight: 700; }

/* ─── Collapsible Nav Groups ─── */
.nav-group { margin-top: 4px; }
.nav-group-toggle {
  width: 100%; border: none; border-radius: 14px; padding: 11px 12px;
  background: transparent; color: #e2e8f0; text-align: left;
  cursor: pointer; font-size: 14px; font-weight: 700; transition: .15s;
  display: flex; justify-content: space-between; align-items: center;
}
.nav-group-toggle:hover { background: rgba(14,165,233,.12); color: #fff; }
.nav-group.open > .nav-group-toggle { background: rgba(14,165,233,.1); color: #38bdf8; }
.nav-arrow { font-size: 10px; transition: transform .2s ease; display: inline-block; }
.nav-group.open .nav-arrow { transform: rotate(90deg); }
.nav-group-items {
  max-height: 0; overflow: hidden; transition: max-height .25s ease;
}
.nav-group.open > .nav-group-items { max-height: 300px; }

/* ─── MAIN CONTENT ─── */
.content { flex: 1; padding-left: var(--sidebar-w); min-width: 0; overflow-x: hidden; max-width: 100vw; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(238,243,247,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 22px;
}
.topbar-left, .topbar-right { display: flex; gap: 10px; align-items: center; }
.desktop-search { width: 300px; max-width: 36vw; }
.icon-btn { width: 42px; height: 42px; border: none; border-radius: 14px; background: #fff; box-shadow: var(--shadow); cursor: pointer; font-size: 18px; }
.page-title { font-size: 24px; font-weight: 900; color: var(--primary2); }
.page-sub { font-size: 12px; color: var(--muted); }
.page { padding: 20px; display: grid; gap: 16px; }

/* ═══ HERO (Dashboard) ═══ */
.hero { background: linear-gradient(135deg, #38bdf8, #0284c7); color: #fff; border-radius: 26px; padding: 22px; box-shadow: 0 14px 30px rgba(2,132,199,.25); }
.hero-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
.hero-title-row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.shop-bubble { width: 80px; height: 80px; border-radius: 999px; background: rgba(255,255,255,.88); color: #92400e; display: grid; place-items: center; text-align: center; font-size: 11px; font-weight: 900; padding: 8px; flex-shrink: 0; }
.hero-amount { font-size: 48px; font-weight: 900; line-height: 1; margin-top: 6px; }
.hero-sub { font-size: 18px; margin-top: 8px; }
.hero-status { margin-top: 12px; border-radius: 14px; background: rgba(255,255,255,.18); padding: 10px 12px; font-size: 13px; }

/* ═══ STATS ═══ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 16px; box-shadow: var(--shadow); }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 900; margin-top: 6px; word-break: break-all; }

/* ═══ GRID / LIST ═══ */
.two-col { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.list, .card-list { display: grid; gap: 10px; }
.card, .item-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); }
.item-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item-name { font-size: 18px; font-weight: 900; }
.item-price { font-size: 20px; font-weight: 900; color: var(--primary2); }
.item-stock { margin-top: 8px; }

/* ═══ BADGES ═══ */
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.low { background: #fee2e2; color: #991b1b; }
.badge.warn { background: #fff7ed; color: #b45309; }

/* ═══ BACKDROP / DRAWER ═══ */
.backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; width: min(520px, 100vw); height: 100vh; background: #fff; z-index: 60; padding: 18px; box-shadow: -8px 0 28px rgba(15,23,42,.18); overflow-y: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ═══ MOBILE NAV ═══ */
.mobile-nav { display: none; }
.mobile-only { display: none; }

/* ═══ TOAST ═══ */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; z-index: 100; background: #111827; color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; font-size: 14px; white-space: nowrap; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; }

/* ═══ TABLE ═══ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: 13px; }
th { color: var(--muted); font-size: 12px; }

/* ═══ CHART ═══ */
.chart-wrap { height: 280px; }

/* ═══ MISC ═══ */
.kpi-red { color: #b91c1c; }
.kpi-green { color: #166534; }
.quick-pay { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

/* ═══════════════════════════════════════════════════════════
   TABLET (< 1100px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .hero-grid { grid-template-columns: 1fr; }
  .desktop-search { display: none; }
  .stat-value { font-size: 24px; }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE (< 768px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Hide sidebar, show mobile nav ── */
  .sidebar { transform: translateX(-105%); transition: .25s; }
  .sidebar.open { transform: translateX(0); }

  .content { padding-left: 0; padding-bottom: 80px; max-width: 100vw; overflow-x: hidden; }
  .page { max-width: 100vw; overflow-x: hidden; word-break: break-word; }
  .row { flex-wrap: wrap; }
  .panel, .card, .hero { max-width: 100%; overflow-x: hidden; }
  table { width: 100%; table-layout: auto; }
  .auth-card { max-width: 100%; }
  .mobile-only { display: inline-flex; }

  /* ── Topbar ── */
  .topbar { padding: 10px 14px; gap: 8px; }
  .page-title { font-size: 18px; }
  .page-sub { font-size: 11px; }
  .icon-btn { width: 38px; height: 38px; font-size: 16px; }

  /* ── Page content ── */
  .page { padding: 12px; gap: 12px; }
  .panel { padding: 14px; border-radius: 18px; }
  .card { padding: 12px; border-radius: 16px; }

  /* ── Hero ── */
  .hero { padding: 16px; border-radius: 22px; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-amount { font-size: 36px; }
  .hero-sub { font-size: 15px; }
  .shop-bubble { width: 64px; height: 64px; font-size: 10px; }

  /* ── Stats ── */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px; border-radius: 16px; }
  .stat-label { font-size: 11px; }
  .stat-value { font-size: 20px; }

  /* ── Two column → single ── */
  .two-col { grid-template-columns: 1fr; }

  /* ── Buttons ── */
  .btn { padding: 10px 14px; font-size: 13px; }

  /* ── Inputs ── */
  input, select, textarea { padding: 10px 12px; font-size: 14px; border-radius: 14px; }

  /* ── Drawer (bottom sheet style) ── */
  .drawer {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100%; height: 88vh;
    border-top-left-radius: 24px; border-top-right-radius: 24px;
    border-radius: 24px 24px 0 0;
  }

  /* ── Quick pay ── */
  .quick-pay { grid-template-columns: repeat(4, 1fr); gap: 6px; }

  /* ── Chart ── */
  .chart-wrap { height: 220px; }

  /* ── Table ── */
  th, td { padding: 8px 6px; font-size: 12px; }

  /* ══════════════════════════════════════
     MOBILE BOTTOM NAV BAR
     ══════════════════════════════════════ */
  .mobile-nav {
    display: flex;
    justify-content: space-around;
    position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    z-index: 40;
    padding: 6px 4px env(safe-area-inset-bottom, 6px);
    box-shadow: 0 -4px 16px rgba(15,23,42,.06);
  }
  .mobile-nav-btn {
    flex: 1;
    border: none; background: transparent;
    color: #94a3b8;
    border-radius: 12px;
    padding: 6px 2px;
    font-weight: 800;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    font-size: 10px;
    cursor: pointer;
    min-width: 0;
  }
  .mobile-nav-btn span { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56px; }
  .mobile-nav-btn.active { color: var(--primary2); }
}

/* ═══════════════════════════════════════════════════════════
   SMALL PHONES (< 400px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .hero-amount { font-size: 30px; }
  .hero-sub { font-size: 13px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-value { font-size: 18px; }
  .mobile-nav-btn { font-size: 9px; padding: 5px 1px; }
  .mobile-nav-btn span { font-size: 9px; max-width: 48px; }
  .page { padding: 10px; gap: 10px; }
  .topbar { padding: 8px 10px; }
  .page-title { font-size: 16px; }
}

/* ═══════════════════════════════════════════════════════════
   SETTINGS — Field Labels & QR Upload
   ═══════════════════════════════════════════════════════════ */
.field-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: -4px; }
.qr-preview-box { text-align: center; padding: 12px; background: var(--bg); border-radius: 16px; border: 1px dashed var(--line); }
.qr-preview-img { max-width: 200px; max-height: 200px; border-radius: 12px; }
.qr-upload-area { margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════
   POS — FlowAccount Style
   ═══════════════════════════════════════════════════════════ */

/* ─── Sales Banner ─── */
.pos-banner {
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  color: #fff; border-radius: 22px; padding: 24px 20px; text-align: center;
  box-shadow: 0 12px 30px rgba(2,132,199,.25);
}
.pos-banner-label { font-size: 14px; opacity: .85; }
.pos-banner-amount { font-size: 42px; font-weight: 900; line-height: 1.2; margin: 4px 0; }
.pos-banner-count { font-size: 13px; opacity: .8; }

/* ─── Action Grid ─── */
.pos-action-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px;
}
.pos-action-btn {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 18px 8px; text-align: center; cursor: pointer;
  box-shadow: var(--shadow); transition: .15s;
}
.pos-action-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15,23,42,.12); }
.pos-action-btn:active { transform: scale(.97); }
.pos-action-icon { font-size: 32px; margin-bottom: 6px; }
.pos-action-label { font-size: 12px; font-weight: 700; color: var(--primary2); }

/* ─── Sub-page Header ─── */
.pos-subpage-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.pos-back-btn { border-radius: 14px !important; padding: 8px 14px !important; font-size: 18px !important; }

/* ─── Product Grid ─── */
.pos-sort-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; }
.pos-product-grid { display: grid; gap: 8px; }
.pos-product-card {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.pos-product-info { flex: 1; min-width: 0; }
.pos-add-btn { width: 42px; height: 42px; border-radius: 14px !important; font-size: 20px !important; padding: 0 !important; display: grid; place-items: center; flex-shrink: 0; }

/* ─── Sticky Cart Bar ─── */
.pos-sticky-cart {
  position: sticky; bottom: 0; left: 0; right: 0;
  display: flex; gap: 8px; padding: 12px 0; margin-top: 12px;
  background: var(--bg); z-index: 10;
}
.pos-sticky-pay-btn {
  flex: 1; border: none; border-radius: 16px;
  background: var(--primary2); color: #fff;
  padding: 14px 16px; font-size: 16px; font-weight: 900; cursor: pointer;
}
.pos-sticky-pay-btn:disabled { opacity: .5; }

/* ─── Payment Select ─── */
.pos-pay-amount-box {
  text-align: center; padding: 40px 20px 32px;
  background: var(--bg); border-radius: 22px; margin-bottom: 16px;
}
.pos-pay-label { font-size: 14px; color: var(--muted); font-weight: 700; }
.pos-pay-total { font-size: 48px; font-weight: 900; color: var(--primary2); line-height: 1.2; margin: 8px 0; }

.pos-pay-methods { display: grid; gap: 1px; background: var(--line); border-radius: 20px; overflow: hidden; }
.pos-pay-method-btn {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: none; padding: 18px 20px; cursor: pointer;
  font-size: 16px; font-weight: 600; text-align: left; transition: .1s;
}
.pos-pay-method-btn:hover { background: #f0f9ff; }
.pos-pay-method-btn:active { background: #e0f2fe; }
.pos-pay-method-icon { font-size: 24px; width: 36px; text-align: center; flex-shrink: 0; }
.pos-pay-arrow { margin-left: auto; color: var(--muted); font-size: 20px; }

/* ─── Numpad ─── */
.pos-numpad-display {
  text-align: center; padding: 32px 20px 24px;
  background: var(--bg); border-radius: 22px; margin-bottom: 12px;
}
.pos-numpad-value { font-size: 52px; font-weight: 900; color: var(--primary2); line-height: 1.15; margin: 4px 0; }
.pos-change-display { font-size: 16px; font-weight: 700; color: var(--success); margin-top: 8px; }

.pos-numpad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 16px; margin-bottom: 10px;
}
.pos-numpad-btn {
  border: none; background: #fff; border-radius: 16px;
  padding: 18px; font-size: 24px; font-weight: 700; color: var(--primary2);
  cursor: pointer; box-shadow: 0 2px 8px rgba(15,23,42,.06); transition: .1s;
}
.pos-numpad-btn:hover { background: #f0f9ff; }
.pos-numpad-btn:active { background: #e0f2fe; transform: scale(.95); }

.pos-quick-amounts { display: flex; gap: 8px; padding: 0 16px; margin-bottom: 12px; flex-wrap: wrap; }
.pos-quick-amounts .btn { flex: 1; text-align: center; }

/* ─── Collect Button ─── */
.pos-collect-btn {
  display: block; width: 100%; border: none; border-radius: 16px;
  background: var(--primary2); color: #fff;
  padding: 16px; font-size: 18px; font-weight: 900; cursor: pointer;
  transition: .15s;
}
.pos-collect-btn.disabled, .pos-collect-btn:disabled {
  background: #cbd5e1; color: #94a3b8; cursor: not-allowed;
}

/* ─── History Button ─── */
.pos-history-btn {
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.3);
  color: #fff; border-radius: 999px; padding: 6px 14px; font-size: 13px;
  font-weight: 700; cursor: pointer; backdrop-filter: blur(4px);
}

/* ─── Transfer / QR Screen ─── */
.pos-transfer-card {
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  padding: 24px; box-shadow: var(--shadow); text-align: center;
}
.pos-transfer-qr-wrap {
  background: #f0f9ff; border-radius: 16px; padding: 16px; display: inline-block;
}
.pos-transfer-qr-img { max-width: 240px; width: 100%; border-radius: 12px; }
.pos-transfer-amount {
  font-size: 36px; font-weight: 900; color: var(--primary2); margin: 16px 0 8px;
}
.pos-transfer-bank-info {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  background: var(--bg); border-radius: 16px; padding: 14px 18px; margin-top: 12px;
  text-align: left;
}
.pos-transfer-bank-icon { font-size: 28px; }

/* ─── Proof Section ─── */
.pos-proof-section { margin-top: 16px; display: grid; gap: 1px; background: var(--line); border-radius: 20px; overflow: hidden; }
.pos-proof-btn {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: none; padding: 16px 20px; cursor: pointer;
  font-size: 15px; font-weight: 600; text-align: left; transition: .1s;
}
.pos-proof-btn:hover { background: #f8fafc; }
.pos-proof-btn:active { background: #f1f5f9; }

/* ─── QR Placeholder ─── */
.pos-qr-placeholder { padding: 40px 20px; color: var(--muted); text-align: center; }

/* ─── Scanner ─── */
.pos-scanner-info { text-align: center; font-weight: 700; color: var(--text); padding: 8px; font-size: 15px; }
.pos-scanner-area { width: 100%; max-width: 400px; margin: 0 auto; border-radius: 16px; overflow: hidden; background: #000; min-height: 300px; }
.pos-scanner-result { text-align: center; padding: 12px; }

/* ─── Cart Summary ─── */
.pos-cart-summary { margin-top: 16px; }
.pos-cart-items { max-height: 200px; overflow-y: auto; }
.pos-cart-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.pos-cart-item:last-child { border-bottom: none; }
.pos-cart-item-info { min-width: 0; flex: 1; }

/* ─── POS Mobile Responsive ─── */
@media (max-width: 768px) {
  .pos-action-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .pos-action-btn { padding: 14px 8px; }
  .pos-action-icon { font-size: 28px; }
  .pos-action-label { font-size: 11px; }
  .pos-banner-amount { font-size: 34px; }
  .pos-pay-total { font-size: 40px; }
  .pos-numpad-value { font-size: 42px; }
  .pos-numpad-btn { padding: 14px; font-size: 22px; }
  .pos-transfer-qr-img { max-width: 200px; }
  .pos-transfer-amount { font-size: 30px; }
  .pos-sticky-cart { bottom: 70px; padding: 10px 0; }
}

@media (max-width: 400px) {
  .pos-action-grid { gap: 8px; }
  .pos-action-btn { padding: 12px 6px; border-radius: 16px; }
  .pos-action-icon { font-size: 24px; }
  .pos-action-label { font-size: 10px; }
  .pos-banner { padding: 18px 14px; }
  .pos-banner-amount { font-size: 28px; }
  .pos-pay-total { font-size: 32px; }
  .pos-numpad-value { font-size: 36px; }
  .pos-numpad-btn { padding: 12px; font-size: 20px; }
}

/* ═══════════════════════════════════════════════════════════
   CONTACT BOOK — สมุดรายชื่อ
   ═══════════════════════════════════════════════════════════ */

/* ─── Filter Tabs ─── */
.contact-filter-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  background: var(--bg); border-radius: 14px; padding: 4px;
}
.contact-tab {
  border: none; background: transparent; border-radius: 10px;
  padding: 8px 14px; font-size: 13px; font-weight: 700;
  color: var(--muted); cursor: pointer; transition: .15s;
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.contact-tab:hover { background: #fff; }
.contact-tab.active { background: #fff; color: var(--primary2); box-shadow: 0 2px 8px rgba(15,23,42,.08); }
.contact-tab-count { font-size: 11px; opacity: .7; }
.contact-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ─── Contact Table ─── */
.contact-table { width: 100%; border-collapse: collapse; }
.contact-table thead th {
  background: var(--primary2); color: #fff;
  padding: 12px 10px; font-size: 13px; font-weight: 700; text-align: left; white-space: nowrap;
}
.contact-table thead th:first-child { border-radius: 10px 0 0 0; }
.contact-table thead th:last-child { border-radius: 0 10px 0 0; }
.contact-table tbody td {
  padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top;
}
.contact-table tbody tr:hover { background: #f8fafc; }

/* ─── Pagination ─── */
.contact-pagination { display: flex; align-items: center; justify-content: center; gap: 4px; }
.contact-page-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 6px 12px; font-size: 14px; font-weight: 700; cursor: pointer;
  color: var(--primary2); transition: .1s; min-width: 36px; text-align: center;
}
.contact-page-btn.active { background: var(--primary2); color: #fff; border-color: var(--primary2); }
.contact-page-btn:hover:not(.active):not(:disabled) { background: #f0f9ff; }
.contact-page-btn:disabled { opacity: .4; cursor: default; }

/* ─── Mobile: hide some columns ─── */
@media (max-width: 768px) {
  .desktop-col { display: none; }
  .contact-filter-tabs { gap: 2px; }
  .contact-tab { padding: 6px 10px; font-size: 12px; }
  .contact-table thead th { padding: 10px 6px; font-size: 12px; }
  .contact-table tbody td { padding: 10px 6px; font-size: 13px; }
  .contact-page-btn { padding: 5px 8px; font-size: 13px; min-width: 30px; }
}

/* ═══════════════════════════════════════════════════════════
   PRODUCTS PAGE — FlowAccount Style
   ═══════════════════════════════════════════════════════════ */

/* ─── Header ─── */
.prod-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap;
}
.prod-title { margin: 0; font-size: 22px; color: var(--primary2); }

/* ─── Filter Tabs ─── */
.prod-filter-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  background: var(--bg); border-radius: 14px; padding: 4px;
}
.prod-tab {
  border: none; background: transparent; border-radius: 10px;
  padding: 8px 14px; font-size: 13px; font-weight: 700;
  color: var(--muted); cursor: pointer; transition: .15s;
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.prod-tab:hover { background: #fff; }
.prod-tab.active { background: #fff; color: var(--primary2); box-shadow: 0 2px 8px rgba(15,23,42,.08); }
.prod-tab-count { font-size: 11px; opacity: .7; }
.prod-status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ─── Toolbar: Search + Sort ─── */
.prod-toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.prod-search-wrap {
  flex: 1; min-width: 200px; position: relative; display: flex; align-items: center;
}
.prod-search-icon {
  position: absolute; left: 14px; font-size: 16px; pointer-events: none; z-index: 1;
}
.prod-search-input {
  width: 100%; padding-left: 40px !important; padding-right: 48px !important;
}
.prod-scan-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: none; background: transparent;
  font-size: 20px; cursor: pointer; border-radius: 12px; transition: .1s;
}
.prod-scan-btn:hover { background: var(--bg); }

.prod-sort-wrap { display: flex; gap: 8px; align-items: center; }
.prod-sort-select {
  width: auto; min-width: 160px; padding: 10px 14px; font-size: 13px; font-weight: 700;
  border-radius: 14px; border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.prod-view-toggle {
  width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; font-size: 20px; cursor: pointer; display: grid; place-items: center;
  transition: .1s;
}
.prod-view-toggle:hover { background: var(--bg); }

/* ─── Letter Avatar ─── */
.prod-avatar {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  color: #fff; font-size: 20px; font-weight: 900;
  flex-shrink: 0;
}
.prod-avatar-wrap { position: relative; flex-shrink: 0; }
.prod-stock-indicator {
  position: absolute; bottom: -2px; right: -2px;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2.5px solid #fff;
}

/* ─── List Mode ─── */
.prod-list { display: grid; gap: 1px; background: var(--line); border-radius: 20px; overflow: hidden; }
.prod-list-item {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; padding: 14px 16px; gap: 12px;
  cursor: pointer; transition: .1s;
}
.prod-list-item:hover { background: #f8fafc; }
.prod-list-left { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.prod-list-info { min-width: 0; flex: 1; }
.prod-list-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod-list-sku { font-size: 12px; color: var(--muted); margin-top: 2px; }
.prod-list-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.prod-list-price { font-size: 16px; font-weight: 900; color: var(--primary2); white-space: nowrap; }
.prod-list-stock { font-size: 12px; color: var(--muted); white-space: nowrap; }
.prod-list-actions { display: flex; gap: 6px; }

/* ─── Grid Mode ─── */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.prod-grid-card {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 16px; text-align: center; box-shadow: var(--shadow);
  transition: .15s; cursor: pointer;
}
.prod-grid-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15,23,42,.12); }
.prod-grid-avatar-wrap { position: relative; display: inline-block; margin-bottom: 10px; }
.prod-grid-avatar-wrap .prod-avatar { width: 56px; height: 56px; font-size: 24px; border-radius: 16px; }
.prod-grid-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod-grid-price { font-size: 18px; font-weight: 900; color: var(--primary2); margin-top: 6px; }
.prod-grid-stock { font-size: 12px; color: var(--muted); margin-top: 2px; }
.prod-grid-actions { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }

/* ─── Empty State ─── */
.prod-empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
  background: #fff; border-radius: 20px;
}

/* ─── Pagination ─── */
.prod-pagination { display: flex; align-items: center; justify-content: center; gap: 4px; }

/* ─── Scanner Modal ─── */
.prod-scanner-modal {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(15,23,42,.5); display: grid; place-items: center; padding: 20px;
}
.prod-scanner-card {
  background: #fff; border-radius: 22px; padding: 20px;
  width: min(480px, 100%); max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15,23,42,.25);
}
.prod-scanner-head { display: flex; justify-content: space-between; align-items: center; }

/* ─── Products Mobile ─── */
@media (max-width: 768px) {
  .prod-header { flex-direction: column; gap: 8px; }
  .prod-header > div:last-child { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
  .prod-header > div:last-child .btn { flex: 1; min-width: 0; font-size: 11px; padding: 8px 6px; white-space: nowrap; }
  .prod-type-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; scrollbar-width: none; }
  .prod-type-tabs::-webkit-scrollbar { display: none; }
  .prod-type-tab { padding: 8px 12px !important; font-size: 12px !important; white-space: nowrap; flex-shrink: 0; }
  .prod-toolbar { flex-direction: column; }
  .prod-search-wrap { min-width: 100%; }
  .prod-sort-wrap { width: 100%; }
  .prod-sort-select { flex: 1; }
  .prod-list-right { flex-direction: column; align-items: flex-end; gap: 4px; }
  .prod-list-actions { margin-top: 4px; }
  .prod-list-item { padding: 10px; gap: 8px; }
  .prod-avatar { width: 40px; height: 40px; font-size: 18px; border-radius: 12px; }
  .prod-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .prod-grid-card { padding: 12px; border-radius: 16px; }
  .prod-grid-avatar-wrap .prod-avatar { width: 48px; height: 48px; }
  .prod-filter-tabs { gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; scrollbar-width: none; }
  .prod-filter-tabs::-webkit-scrollbar { display: none; }
  .prod-tab { padding: 6px 10px; font-size: 12px; flex-shrink: 0; }
  .prod-scanner-card { border-radius: 18px; padding: 16px; }
  .wh-selector { margin-top: 8px; }
}

@media (max-width: 400px) {
  .prod-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .prod-grid-card { padding: 10px; }
  .prod-list-name { font-size: 13px; }
  .prod-list-price { font-size: 13px; }
  .prod-list-item { padding: 8px; }
}

/* ═══════════════════════════════════════════════════════════
   SETTINGS — FlowAccount Drill-Down Style
   ═══════════════════════════════════════════════════════════ */

/* ─── Profile Card ─── */
.set-profile-card {
  display: flex; gap: 16px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  padding: 20px; box-shadow: var(--shadow);
}
.set-profile-avatar { flex-shrink: 0; }
.set-profile-logo {
  width: 64px; height: 64px; border-radius: 50%;
  object-fit: contain; border: 2px solid var(--line);
}
.set-profile-info { min-width: 0; }
.set-profile-name { font-size: 18px; font-weight: 900; color: var(--primary2); }
.set-profile-detail { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ─── Menu List ─── */
.set-menu-list {
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  overflow: hidden; box-shadow: var(--shadow); margin-top: 12px;
}
.set-menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  border: none; background: #fff; padding: 18px 20px;
  cursor: pointer; text-align: left; font-size: 15px; font-weight: 600;
  color: var(--text); transition: .1s;
  border-bottom: 1px solid var(--line);
}
.set-menu-item:last-child { border-bottom: none; }
.set-menu-item:hover { background: #f8fafc; }
.set-menu-item:active { background: #f0f9ff; }
.set-menu-icon { font-size: 22px; width: 32px; text-align: center; flex-shrink: 0; }
.set-menu-label { flex: 1; }
.set-menu-arrow { color: var(--primary2); font-size: 22px; font-weight: 300; flex-shrink: 0; }

/* ─── Footer ─── */
.set-footer { margin-top: 16px; padding: 0 4px; }
.set-footer-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; font-size: 14px; color: var(--muted);
}

/* ─── Sub-page ─── */
.set-subpage { animation: setSlideIn .2s ease; }
@keyframes setSlideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.set-subpage-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.set-back-btn {
  width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; font-size: 20px; cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--shadow); transition: .1s; flex-shrink: 0;
}
.set-back-btn:hover { background: var(--bg); }
.set-subpage-title { font-size: 20px; font-weight: 900; color: var(--primary2); margin: 0; }

/* ─── Form Card ─── */
.set-form-card {
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.set-section-title { font-size: 16px; font-weight: 900; color: var(--primary2); margin-bottom: 12px; }
.set-field-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: -4px; }

/* ─── Save Button ─── */
.set-save-btn {
  display: block; width: 100%; border: none; border-radius: 16px;
  background: linear-gradient(135deg, #38bdf8, #0284c7); color: #fff;
  padding: 16px; font-size: 17px; font-weight: 900; cursor: pointer;
  box-shadow: 0 8px 24px rgba(2,132,199,.25); transition: .15s;
  margin-top: 4px;
}
.set-save-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(2,132,199,.3); }
.set-save-btn:active { transform: scale(.98); }

/* ─── Toggle Switch ─── */
.set-toggle-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 4px 0;
}
.set-toggle {
  position: relative; display: inline-block; width: 52px; height: 28px; flex-shrink: 0;
}
.set-toggle input { opacity: 0; width: 0; height: 0; }
.set-toggle-slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 28px;
  cursor: pointer; transition: .25s;
}
.set-toggle-slider::before {
  content: ""; position: absolute; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; left: 3px; bottom: 3px;
  transition: .25s; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.set-toggle input:checked + .set-toggle-slider { background: var(--primary2); }
.set-toggle input:checked + .set-toggle-slider::before { transform: translateX(24px); }

/* ─── Radio Card ─── */
.set-radio-group { display: grid; gap: 8px; }
.set-radio-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px; border: 2px solid var(--line); border-radius: 16px;
  cursor: pointer; transition: .15s; min-width: 0;
}
.set-radio-card > div { min-width: 0; flex: 1; }
.set-radio-card.selected { border-color: var(--primary2); background: #f0f9ff; }
.set-radio-card input[type="radio"] { margin-top: 3px; accent-color: var(--primary2); flex-shrink: 0; }

/* ─── Logo Page ─── */
.set-logo-preview {
  text-align: center; padding: 20px; background: var(--bg);
  border-radius: 16px; margin-bottom: 16px;
}
.set-logo-img {
  max-width: 200px; max-height: 200px; border-radius: 16px;
  border: 2px solid var(--line); object-fit: contain;
}
.set-logo-doc-preview { margin-top: 12px; }
.set-doc-mockup {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.set-doc-header { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.set-doc-body { display: grid; gap: 6px; }
.set-doc-line { height: 8px; background: var(--line); border-radius: 4px; }

/* ─── User List ─── */
.set-user-list { display: grid; gap: 8px; }
.set-user-card {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.set-user-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-size: 18px; font-weight: 900; flex-shrink: 0;
}
.set-user-info { flex: 1; min-width: 0; }
.set-user-name { font-size: 15px; font-weight: 700; }
.set-user-role { font-size: 13px; font-weight: 700; }
.set-role-select {
  font-size: 13px; padding: 6px 10px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; flex-shrink: 0;
}

/* ─── Settings Mobile ─── */
@media (max-width: 768px) {
  .set-profile-card { padding: 16px; }
  .set-profile-logo { width: 52px; height: 52px; }
  .set-profile-name { font-size: 16px; }
  .set-menu-item { padding: 16px; font-size: 14px; gap: 12px; }
  .set-menu-icon { font-size: 20px; width: 28px; }
  .set-form-card { padding: 14px; border-radius: 18px; max-width: 100%; overflow-x: hidden; }
  .set-save-btn { padding: 14px; font-size: 16px; }
  .set-back-btn { width: 38px; height: 38px; font-size: 18px; }
  .set-subpage-title { font-size: 18px; }
  .set-user-card { padding: 12px; }
  .set-toggle-row { gap: 12px; }
  .set-radio-card { padding: 12px; gap: 10px; }
  .set-radio-group { gap: 6px; }
}

@media (max-width: 400px) {
  .set-profile-card { flex-direction: column; text-align: center; }
  .set-menu-item { padding: 14px 12px; font-size: 13px; }
}

/* ═══════════════════════════════════════════════════════════
   Warehouse / คลังสินค้า
   ═══════════════════════════════════════════════════════════ */
.wh-selector {
  display: flex; align-items: center; gap: 8px;
}
.wh-select {
  width: 100%; padding: 10px 14px; font-size: 14px; font-weight: 600;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--text);
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  cursor: pointer; transition: border-color .2s, box-shadow .2s;
}
.wh-select:focus {
  outline: none; border-color: var(--primary2);
  box-shadow: 0 0 0 3px rgba(2,132,199,.12);
}

/* ─── Warehouse stock inputs in product drawer ─── */
.wh-stock-section { margin-top: 8px; }
.wh-stock-row {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px; background: var(--bg);
  border-radius: 12px; margin-bottom: 6px;
  border: 1px solid var(--line);
}
.wh-stock-label {
  font-size: 13px; font-weight: 700; color: var(--text);
}
.wh-stock-input, .wh-min-stock-input {
  padding: 8px 10px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; width: 100%;
}
.wh-stock-input:focus, .wh-min-stock-input:focus {
  outline: none; border-color: var(--primary2);
  box-shadow: 0 0 0 3px rgba(2,132,199,.12);
}

@media (max-width: 768px) {
  .wh-select { font-size: 13px; padding: 9px 12px; }
  .wh-stock-row { padding: 8px 10px; }
  .wh-stock-label { font-size: 12px; }
}

/* ═══════════════════════════════════════════════════════════
   Payment — Multi-bank cards
   ═══════════════════════════════════════════════════════════ */
.pay-bank-card {
  background: var(--bg); border: 1.5px solid var(--line);
  border-radius: 16px; padding: 16px; margin-bottom: 10px;
  transition: border-color .2s;
}
.pay-bank-card:hover { border-color: var(--primary2); }
.pay-bank-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.pay-bank-num {
  font-size: 14px; font-weight: 800; color: var(--primary2);
}
.pay-bank-remove {
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: #fee2e2; color: #dc2626;
  font-size: 14px; cursor: pointer; display: grid; place-items: center;
  transition: background .2s;
}
.pay-bank-remove:hover { background: #fca5a5; }
.custom-bank-row { margin-bottom: 4px; }
.custom-bank-row.hidden { display: none; }
.qr-preview-box { text-align: center; margin-bottom: 8px; }
.qr-preview-img { max-width: 200px; border-radius: 12px; border: 2px solid var(--line); }

/* ═══════════════════════════════════════════════════════════
   QUOTATION / INVOICE — Document Preview & Form
   ═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   DOCUMENT PREVIEW V3 — Professional A4 Government-Ready
   ═══════════════════════════════════════════════════════════ */
.doc-preview { background: #e2e8f0; padding: 24px; }

/* ─── A4 Page ─── */
.doc-page {
  width: 210mm; max-width: 100%; margin: 0 auto 24px;
  background: #fff; padding: 20mm 18mm 15mm;
  box-shadow: 0 2px 16px rgba(15,23,42,.12);
  font-family: "Sarabun", "Noto Sans Thai", system-ui, sans-serif;
  font-size: 14px; color: #1a1a1a; line-height: 1.6;
  position: relative; min-height: 270mm;
  display: flex; flex-direction: column;
}
.doc-page-inner { flex: 1; display: flex; flex-direction: column; }

/* ─── Page Number Badge (top-right corner) ─── */
.doc-page-badge {
  position: absolute; top: 0; right: 0;
  width: 40px; height: 40px; display: flex;
  align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: #fff;
}
.doc-page-badge.inv { background: #0284c7; }
.doc-page-badge.re  { background: #16a34a; }

/* ─── Copy Label (ต้นฉบับ / สำเนา) ─── */
.doc-copy-label {
  font-size: 13px; font-weight: 600; color: #64748b;
  text-align: center; margin-top: -2px;
}

/* ─── Color Accent ─── */
.doc-accent { height: 5px; width: 100%; position: absolute; top: 0; left: 0; }
.doc-accent.qt  { background: linear-gradient(90deg, #ea580c, #f97316, #fdba74); }
.doc-accent.inv { background: linear-gradient(90deg, #0369a1, #0284c7, #38bdf8); }
.doc-accent.re  { background: linear-gradient(90deg, #15803d, #16a34a, #4ade80); }

/* ─── Doc Header ─── */
.doc-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px;
}
.doc-header-left { display: flex; align-items: flex-start; gap: 12px; max-width: 55%; }
.doc-logo {
  width: 64px; height: 64px; border-radius: 8px; object-fit: contain;
  flex-shrink: 0;
}
.doc-company-name { font-size: 16px; font-weight: 900; color: #1a1a1a; margin-bottom: 4px; }
.doc-company-detail { font-size: 12px; color: #555; line-height: 1.7; }
.doc-header-right { text-align: right; }
.doc-title { font-size: 26px; font-weight: 900; }
.doc-title.qt  { color: #ea580c; }
.doc-title.inv { color: #0369a1; }
.doc-title.re  { color: #15803d; }

/* ─── Doc Detail Box (right side info) ─── */
.doc-detail-table {
  margin-left: auto; border-collapse: collapse;
  font-size: 13px; margin-top: 8px;
}
.doc-detail-table td {
  padding: 3px 10px; border: 1px solid #d1d5db;
}
.doc-detail-table td:first-child {
  font-weight: 700; color: #555; background: #f9fafb;
  white-space: nowrap;
}
.doc-detail-table td:last-child { min-width: 140px; }

/* ─── Customer Section ─── */
.doc-customer-section { margin: 12px 0 16px; }
.doc-customer-label {
  font-weight: 800; font-size: 12px; text-decoration: underline;
  margin-bottom: 4px;
}
.doc-customer-label.qt  { color: #ea580c; }
.doc-customer-label.inv { color: #0369a1; }
.doc-customer-label.re  { color: #15803d; }
.doc-customer-name { font-weight: 700; font-size: 14px; }
.doc-customer-detail { font-size: 13px; color: #333; line-height: 1.6; }

/* ─── Doc Table ─── */
.doc-table { width: 100%; border-collapse: collapse; margin: 12px 0 8px; }
.doc-table th {
  padding: 8px 10px; font-size: 12px; font-weight: 700;
  text-align: center; border: 1px solid #d1d5db;
  background: #f3f4f6; color: #333;
}
.doc-table td {
  padding: 8px 10px; font-size: 13px;
  border: 1px solid #d1d5db; vertical-align: top;
}
.doc-table td.item-desc { font-size: 12px; color: #555; padding-top: 2px; }

/* ─── Doc Totals ─── */
.doc-totals { margin-left: auto; width: 280px; margin-top: 4px; }
.doc-total-row {
  display: flex; justify-content: space-between;
  padding: 4px 0; font-size: 13px; color: #333;
}
.doc-total-row.grand {
  font-size: 14px; font-weight: 900; padding-top: 8px;
  margin-top: 4px;
}
.doc-total-row.grand.qt  { color: #ea580c; border-top: 2px solid #ea580c; }
.doc-total-row.grand.inv { color: #0369a1; border-top: 2px solid #0369a1; }
.doc-total-row.grand.re  { color: #15803d; border-top: 2px solid #15803d; }

/* ─── Thai Baht Text ─── */
.doc-baht-text { font-size: 13px; color: #555; margin-top: 2px; }

/* ─── Doc Note ─── */
.doc-note-section {
  margin-top: 16px; font-size: 12.5px; line-height: 1.7;
}
.doc-note-title { font-weight: 800; text-decoration: underline; margin-bottom: 2px; }
.doc-note-title.qt  { color: #ea580c; }
.doc-note-title.inv { color: #0369a1; }
.doc-note-title.re  { color: #15803d; }

/* ─── Payment Checkbox (Receipt) ─── */
.doc-payment-check {
  margin-top: auto; padding-top: 20px; font-size: 12.5px;
}
.doc-payment-check-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.doc-checkbox {
  display: inline-flex; align-items: center; gap: 4px; margin-right: 12px;
}
.doc-checkbox-box {
  width: 14px; height: 14px; border: 1.5px solid #555;
  display: inline-block; border-radius: 2px;
}
.doc-bank-line {
  display: flex; gap: 16px; margin-top: 6px; font-size: 12px;
}
.doc-bank-field {
  display: flex; gap: 4px; align-items: baseline;
}
.doc-bank-field .underline {
  border-bottom: 1px solid #333; min-width: 100px; display: inline-block; height: 16px;
}

/* ─── Doc Signatures (FlowAccount style) ─── */
.doc-signatures {
  display: flex; justify-content: space-between;
  margin-top: auto; padding-top: 24px;
  font-size: 13px;
}
.doc-sig-col { text-align: center; width: 42%; }
.doc-sig-behalf { font-weight: 600; margin-bottom: 28px; font-size: 12.5px; }
.doc-sig-line {
  width: 200px; border-bottom: 1px solid #333;
  margin: 0 auto 6px; height: 0;
}
.doc-sig-label { font-size: 12px; color: #333; }
.doc-sig-label-row {
  display: flex; justify-content: center; gap: 40px; font-size: 12px;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .doc-preview { padding: 8px; }
  .doc-page { padding: 12mm 10mm 10mm; min-height: auto; width: auto; font-size: 12px; }
  .doc-header { flex-direction: column; gap: 8px; }
  .doc-header-left { max-width: 100%; }
  .doc-header-right { text-align: left; }
  .doc-logo { width: 48px; height: 48px; }
  .doc-title { font-size: 20px; }
  .doc-detail-table { margin-left: 0; }
  .doc-totals { width: 100%; }
  .doc-signatures { flex-direction: column; gap: 24px; align-items: center; }
  .doc-sig-col { width: 80%; }
  .doc-page-badge { width: 30px; height: 30px; font-size: 14px; }
}

/* ─── Print Styles ─── */
@media print {
  .doc-preview { background: none; padding: 0; }
  .doc-page { box-shadow: none; margin: 0; page-break-after: always; }
  .doc-page:last-child { page-break-after: avoid; }
}

/* ─── Quotation Dropdown (customer/product search) ─── */
.qt-dropdown {
  position: absolute; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15,23,42,.12);
  max-height: 240px; overflow-y: auto; z-index: 20;
  margin-top: 4px;
}
.qt-dd-item {
  padding: 10px 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  border-bottom: 1px solid #f1f5f9;
  transition: background .15s;
}
.qt-dd-item:last-child { border-bottom: none; }
.qt-dd-item:hover { background: #f0f9ff; }

/* ─── Quotation Card ─── */
.qt-card { transition: box-shadow .2s; }
.qt-card:hover { box-shadow: 0 8px 24px rgba(15,23,42,.1); }

/* ─── Responsive adjustments for doc preview V2 ─── */
@media (max-width: 768px) {
  .doc-preview { padding: 10px; }
  .doc-page-inner { padding: 20px 16px 20px; }
  .doc-header { flex-direction: column; gap: 10px; }
  .doc-header-right { text-align: left; }
  .doc-company { font-size: 17px; }
  .doc-title { font-size: 22px; }
  .doc-logo { width: 44px; height: 44px; }
  .doc-info-grid { grid-template-columns: 1fr; gap: 14px; }
  .doc-detail-box { margin-top: 4px; }
  .doc-info-box[style*="text-align:right"] { text-align: left !important; }
  .doc-signatures { grid-template-columns: 1fr; gap: 28px; }
  .doc-sig-line { width: 160px; }
  .doc-totals { max-width: 100%; width: 100%; margin-left: 0; }
  .qt-dropdown { border-radius: 12px; }

  /* ─── ฟอร์ม: ตาราง scroll + input พอดีจอ ─── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  .table-wrap table { min-width: 520px; }
  .table-wrap th { font-size: 11px !important; padding: 6px 4px !important; }
  .table-wrap td { padding: 6px 4px !important; font-size: 12px !important; }
  .table-wrap td input {
    font-size: 12px !important; padding: 4px !important;
  }

  /* ─── ฟอร์ม: grid 2 คอลัมน์ → 1 คอลัมน์ ─── */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ─── ฟอร์ม: summary เต็มจอ ─── */
  [style*="max-width:420px"] {
    max-width: 100% !important;
    margin-left: 0 !important;
  }

  /* ─── ปุ่ม toolbar ─── */
  .panel > .row { gap: 6px; }
  .panel > .row .btn { font-size: 12px; padding: 7px 10px; }

  /* ─── Field labels ─── */
  .field-label { font-size: 12px; font-weight: 700; color: var(--muted); }
}

/* ═══════════════════════════════════════════════════════════
   Phase 5: Accessibility & Cleanup (2/4/2569)
   ═══════════════════════════════════════════════════════════ */

/* ─── Screen Reader Only ─── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ─── Loading Overlay ─── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  transition: opacity .4s ease;
}
.loading-overlay.fade-out { opacity: 0; pointer-events: none; }
.loading-spinner {
  position: relative; width: 80px; height: 80px;
}
.spinner-ring {
  position: absolute; inset: 0;
  border: 4px solid var(--line);
  border-top-color: var(--primary2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner-logo {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 12px;
}
.loading-text { font-size: 14px; color: var(--muted); font-weight: 600; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Auth Page (moved from inline) ─── */
.auth-title { text-align: center; color: var(--primary2); }
.auth-subtitle { text-align: center; margin-bottom: 16px; }
.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 20px 0;
}
.auth-divider-line { flex: 1; height: 1px; background: var(--line); }
.auth-divider-text { font-size: 13px; }
.customer-auth-title {
  text-align: center; color: var(--success);
  margin-bottom: 12px; font-size: 15px;
}

/* ─── Password Toggle (moved from inline) ─── */
.password-wrap { position: relative; }
.password-wrap .form-input { padding-right: 40px; }
.password-toggle {
  position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 18px; padding: 4px; color: #888;
}

/* ─── OTP Inputs (moved from inline) ─── */
.otp-phone-input { font-size: 18px; letter-spacing: 2px; text-align: center; }
.otp-code-input { font-size: 28px; letter-spacing: 12px; text-align: center; font-weight: 900; }
.otp-display-section { text-align: center; margin-bottom: 12px; }
.otp-phone-number { font-size: 20px; font-weight: 900; color: var(--primary2); margin-top: 4px; }
.otp-actions { text-align: center; margin-top: 10px; }
.otp-actions-sep { margin: 0 8px; }
.btn-success-full { background: var(--success); width: 100%; }

/* ─── Link Buttons (moved from inline) ─── */
.link-btn { background: none; border: none; cursor: pointer; font-size: 13px; }
.link-btn-muted { color: var(--muted); }
.link-btn-primary { color: var(--primary2); font-weight: 700; }

/* ─── Dark Mode Toggle (moved from inline) ─── */
.dark-mode-row {
  margin-top: 16px; padding: 8px 12px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.06); border-radius: 14px;
}
.dark-mode-label { font-size: 13px; color: #cbd5e1; }
.toggle-switch {
  position: relative; width: 44px; height: 24px; cursor: pointer;
  display: inline-block;
}
.toggle-input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: #475569; border-radius: 99px; transition: .3s;
}
.toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; background: #fff;
  border-radius: 50%; transition: .3s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle-input:checked ~ .toggle-track { background: var(--primary); }
.toggle-input:checked ~ .toggle-knob { left: 22px; }

/* ─── Sidebar Bottom Shortcut ─── */
.nav-group-label--bottom { margin-top: auto; padding-top: 16px; }
.nav-btn--logout { margin-top: 8px; }

/* ─── Product Drawer (moved from inline) ─── */
.barcode-row { display: flex; gap: 8px; align-items: center; }
.barcode-input { flex: 1; }
.btn-sm-action { white-space: nowrap; padding: 10px 12px; font-size: 12px; }
.btn-sm-icon { white-space: nowrap; padding: 10px 14px; font-size: 18px; }
.barcode-preview {
  margin-top: 8px; text-align: center; padding: 8px;
  border: 1px solid #e2e8f0; border-radius: 8px; background: #fafafa;
}
.scanner-area { margin-top: 8px; }
.scanner-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.scanner-label { font-weight: 600; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.scanner-video { width: 100%; border-radius: 8px; overflow: hidden; }
.scanner-result { margin-top: 6px; font-size: 13px; text-align: center; }
.wh-stock-title { margin-top: 8px; }
.wh-stock-inputs { display: flex; gap: 8px; }
.wh-stock-inputs input { flex: 1; }

/* ─── Drawer as <aside> ─── */
aside.drawer { position: fixed; top: 0; right: 0; }

/* ─── Form Validation Error ─── */
.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 2px rgba(220,38,38,.15);
  animation: shake .3s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ─── Confirm Modal ─── */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeInOverlay .2s ease;
}
@keyframes fadeInOverlay { from { opacity: 0; } to { opacity: 1; } }
.confirm-card {
  background: var(--surface); border-radius: 20px;
  padding: 24px; max-width: 380px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: scaleIn .2s ease;
}
@keyframes scaleIn { from { transform: scale(.9); opacity:0; } to { transform: scale(1); opacity:1; } }
.confirm-msg { font-size: 16px; font-weight: 600; margin-bottom: 20px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
[data-theme="dark"] .confirm-card { background: var(--surface); color: var(--text); }

