/* ============================================================
   FlowBiz ERP — app.css
   Palette: indigo primary, slate neutrals, emerald/amber/rose states
   ============================================================ */

:root{
  --indigo-50:#eef2ff; --indigo-100:#e0e7ff; --indigo-500:#6366f1;
  --indigo-600:#4f46e5; --indigo-700:#4338ca;
  --emerald:#10b981; --emerald-bg:#ecfdf5;
  --amber:#f59e0b;  --amber-bg:#fffbeb;
  --rose:#ef4444;   --rose-bg:#fef2f2;
  --sky:#0ea5e9;    --sky-bg:#f0f9ff;

  /* light theme tokens */
  --bg:#f4f6fb;
  --surface:#ffffff;
  --surface-2:#f8fafc;
  --ink:#0f172a;
  --ink-2:#475569;
  --muted:#94a3b8;
  --border:#e8ecf3;
  --border-strong:#dbe2ea;
  --shadow:0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.05);
  --shadow-lg:0 12px 40px rgba(15,23,42,.12);
  --primary:var(--indigo-600);
  --primary-soft:var(--indigo-50);
  --ring:rgba(99,102,241,.35);

  --radius:14px; --radius-sm:10px; --radius-lg:20px;
  --sidebar-w:264px;
  font-family:"IBM Plex Sans Thai","Sarabun",-apple-system,"Segoe UI",Tahoma,sans-serif;
}

[data-theme="dark"]{
  --bg:#0b1020;
  --surface:#121a2e;
  --surface-2:#0f1626;
  --ink:#e8edf6;
  --ink-2:#9fb0c9;
  --muted:#64748b;
  --border:#1e2942;
  --border-strong:#27324d;
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
  --shadow-lg:0 16px 50px rgba(0,0,0,.55);
  --primary:var(--indigo-500);
  --primary-soft:rgba(99,102,241,.14);
  --indigo-50:rgba(99,102,241,.12);
  --emerald-bg:rgba(16,185,129,.13);
  --amber-bg:rgba(245,158,11,.13);
  --rose-bg:rgba(239,68,68,.13);
  --sky-bg:rgba(14,165,233,.13);
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{background:var(--bg);color:var(--ink);font-size:14px;line-height:1.55;-webkit-font-smoothing:antialiased}
a{color:inherit;text-decoration:none}
svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
h1,h2,h3{margin:0;font-weight:700}
.num{font-variant-numeric:tabular-nums}

/* ---------- Layout ---------- */
.app{display:flex;min-height:100vh}
.main{flex:1;min-width:0;display:flex;flex-direction:column}

/* ---------- Sidebar ---------- */
.sidebar{
  width:var(--sidebar-w);flex-shrink:0;background:var(--surface);
  border-right:1px solid var(--border);display:flex;flex-direction:column;
  position:sticky;top:0;height:100vh;overflow-y:auto;z-index:40;
}
.brand{display:flex;align-items:center;gap:11px;padding:20px 20px 16px;flex-shrink:0}
.brand-mark{width:38px;height:38px;border-radius:11px;display:grid;place-items:center;
  background:linear-gradient(135deg,var(--indigo-500),var(--indigo-700));box-shadow:0 6px 16px var(--ring)}
.brand-mark svg{stroke:#fff;width:21px;height:21px;stroke-width:2}
.brand-text{display:flex;flex-direction:column;line-height:1.2}
.brand-text strong{font-family:"Sora",sans-serif;font-size:18px;letter-spacing:-.3px}
.brand-text span{font-size:11px;color:var(--muted)}

.company-pill{display:flex;align-items:center;gap:10px;margin:0 14px 8px;padding:10px 12px;flex-shrink:0;
  background:var(--surface-2);border:1px solid var(--border);border-radius:var(--radius-sm)}
.company-pill .ci{width:30px;height:30px;border-radius:8px;background:var(--primary);color:#fff;
  display:grid;place-items:center;font-weight:700;font-size:12px}
.cinfo{display:flex;flex-direction:column;line-height:1.25}
.cinfo strong{font-size:13px}
.cinfo span{font-size:11px;color:var(--muted)}

.nav{flex:1;padding:6px 12px 12px}
.nav-group{font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;
  color:var(--muted);padding:14px 12px 6px}
.nav-item{display:flex;align-items:center;gap:11px;padding:9px 12px;border-radius:10px;
  color:var(--ink-2);font-weight:500;margin-bottom:2px;position:relative;transition:.16s}
.nav-item svg{width:19px;height:19px;color:var(--muted);transition:.16s}
.nav-item:hover{background:var(--surface-2);color:var(--ink)}
.nav-item:hover svg{color:var(--ink-2)}
.nav-item.active{background:var(--primary-soft);color:var(--primary);font-weight:600}
.nav-item.active svg{color:var(--primary)}
.nav-item.active::before{content:"";position:absolute;left:-12px;top:8px;bottom:8px;width:3px;
  border-radius:0 3px 3px 0;background:var(--primary)}

.theme-toggle{display:flex;align-items:center;gap:10px;margin:8px 14px 16px;padding:10px 12px;flex-shrink:0;
  border:1px solid var(--border);background:var(--surface-2);border-radius:var(--radius-sm);
  color:var(--ink-2);font:inherit;font-weight:500;cursor:pointer;transition:.16s}
.theme-toggle:hover{border-color:var(--border-strong);color:var(--ink)}
.theme-toggle .i-sun{display:none}
[data-theme="dark"] .i-moon{display:none}
[data-theme="dark"] .i-sun{display:block}

/* ---------- Topbar ---------- */
.topbar{position:sticky;top:0;z-index:30;display:flex;align-items:center;gap:14px;
  padding:14px 26px;background:color-mix(in srgb,var(--bg) 78%,transparent);
  backdrop-filter:blur(10px);border-bottom:1px solid var(--border)}
.topbar-title{flex:1;min-width:0}
.topbar-title h1{font-size:20px;letter-spacing:-.3px}
.topbar-title p{margin:1px 0 0;font-size:12.5px;color:var(--muted)}
.topbar-user{display:flex;align-items:center;gap:10px}
.avatar{width:38px;height:38px;border-radius:50%;background:linear-gradient(135deg,#34d399,var(--emerald));
  color:#fff;display:grid;place-items:center;font-weight:700;font-size:13px}
.who{display:flex;flex-direction:column;line-height:1.25;text-align:right}
.who strong{font-size:13px}
.who span{font-size:11px;color:var(--muted)}
.burger{display:none}

.content{padding:24px 26px 56px;max-width:1500px;width:100%;margin:0 auto}

/* ---------- Buttons ---------- */
.btn{display:inline-flex;align-items:center;gap:7px;padding:9px 15px;border-radius:10px;
  font:inherit;font-weight:600;font-size:13.5px;cursor:pointer;border:1px solid transparent;transition:.16s;white-space:nowrap}
.btn svg{width:17px;height:17px}
.btn-primary{background:var(--primary);color:#fff;box-shadow:0 6px 16px var(--ring)}
.btn-primary:hover{background:var(--indigo-700);transform:translateY(-1px)}
.btn-ghost{background:var(--surface);color:var(--ink-2);border-color:var(--border-strong)}
.btn-ghost:hover{background:var(--surface-2);color:var(--ink)}
.btn-danger{background:var(--rose-bg);color:var(--rose);border-color:transparent}
.btn-danger:hover{background:var(--rose);color:#fff}
.btn-sm{padding:6px 11px;font-size:12.5px;border-radius:8px}
.btn-block{width:100%;justify-content:center}
.icon-btn{display:grid;place-items:center;width:34px;height:34px;border-radius:9px;border:1px solid var(--border);
  background:var(--surface);color:var(--ink-2);cursor:pointer;transition:.16s}
.icon-btn:hover{background:var(--surface-2);color:var(--ink);border-color:var(--border-strong)}
.icon-btn svg{width:16px;height:16px}

/* ---------- Cards ---------- */
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow)}
.card-pad{padding:20px}
.card-head{display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:16px 20px;border-bottom:1px solid var(--border)}
.card-head h2{font-size:15.5px;display:flex;align-items:center;gap:8px}
.card-head .link{font-size:12.5px;color:var(--primary);font-weight:600}

/* ---------- Stat cards ---------- */
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:16px;margin-bottom:22px}
.stat{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  padding:18px;box-shadow:var(--shadow);transition:.18s;position:relative;overflow:hidden}
.stat:hover{transform:translateY(-2px);box-shadow:var(--shadow-lg)}
.stat .row{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
.stat .label{font-size:12.5px;color:var(--ink-2);font-weight:500}
.stat .chip{width:38px;height:38px;border-radius:11px;display:grid;place-items:center}
.stat .chip svg{width:19px;height:19px}
.stat .value{font-size:25px;font-weight:700;letter-spacing:-.6px}
.stat .foot{font-size:11.5px;color:var(--muted);margin-top:3px}
.chip-indigo{background:var(--indigo-50);color:var(--indigo-600)}
.chip-emerald{background:var(--emerald-bg);color:var(--emerald)}
.chip-amber{background:var(--amber-bg);color:var(--amber)}
.chip-rose{background:var(--rose-bg);color:var(--rose)}
.chip-sky{background:var(--sky-bg);color:var(--sky)}
.stat.danger{border-color:color-mix(in srgb,var(--rose) 35%,var(--border))}

/* ---------- Welcome banner ---------- */
.banner{position:relative;overflow:hidden;border-radius:var(--radius-lg);padding:26px 28px;margin-bottom:22px;
  background:linear-gradient(120deg,var(--indigo-600),var(--indigo-500) 55%,#7c83f5);color:#fff;
  box-shadow:0 14px 38px var(--ring)}
.banner h2{font-size:23px;letter-spacing:-.4px}
.banner p{margin:6px 0 0;opacity:.9;font-size:13.5px}
.banner::after{content:"";position:absolute;right:-60px;top:-60px;width:220px;height:220px;border-radius:50%;
  background:rgba(255,255,255,.10)}
.banner::before{content:"";position:absolute;right:60px;bottom:-90px;width:180px;height:180px;border-radius:50%;
  background:rgba(255,255,255,.08)}
.banner .plan{position:absolute;right:24px;top:22px;display:flex;align-items:center;gap:8px;
  background:rgba(255,255,255,.16);padding:8px 14px;border-radius:12px;font-size:12.5px;font-weight:600;backdrop-filter:blur(4px)}

/* ---------- Grid helpers ---------- */
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:18px;margin-bottom:18px}
.grid-2.wide{grid-template-columns:1.4fr 1fr}

/* ---------- Tables ---------- */
.table-wrap{overflow-x:auto}
table{width:100%;border-collapse:collapse;font-size:13.5px}
thead th{text-align:left;font-weight:600;color:var(--muted);font-size:11.5px;text-transform:uppercase;
  letter-spacing:.04em;padding:11px 16px;border-bottom:1px solid var(--border);white-space:nowrap}
tbody td{padding:13px 16px;border-bottom:1px solid var(--border);vertical-align:middle}
tbody tr:last-child td{border-bottom:none}
tbody tr{transition:.12s}
tbody tr:hover{background:var(--surface-2)}
td.right,th.right{text-align:right}
td.center,th.center{text-align:center}
.t-strong{font-weight:600}
.t-sub{font-size:12px;color:var(--muted)}
.code-link{color:var(--primary);font-weight:600}

/* ---------- Badges ---------- */
.badge{display:inline-flex;align-items:center;gap:5px;padding:3px 10px;border-radius:999px;
  font-size:12px;font-weight:600;line-height:1.6}
.badge svg{width:13px;height:13px}
.b-emerald{background:var(--emerald-bg);color:var(--emerald)}
.b-amber{background:var(--amber-bg);color:var(--amber)}
.b-rose{background:var(--rose-bg);color:var(--rose)}
.b-sky{background:var(--sky-bg);color:var(--sky)}
.b-indigo{background:var(--indigo-50);color:var(--indigo-600)}
.b-gray{background:var(--surface-2);color:var(--ink-2);border:1px solid var(--border)}

/* ---------- Toolbar / filters ---------- */
.toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:16px}
.toolbar .spacer{flex:1}
.search{position:relative;flex:1;min-width:220px;max-width:420px}
.search svg{position:absolute;left:12px;top:50%;transform:translateY(-50%);width:17px;height:17px;color:var(--muted)}
.search input{width:100%;padding:10px 12px 10px 38px}
.chips{display:flex;gap:7px;flex-wrap:wrap}
.chip-btn{padding:6px 13px;border-radius:999px;border:1px solid var(--border-strong);background:var(--surface);
  color:var(--ink-2);font:inherit;font-size:12.5px;font-weight:500;cursor:pointer;transition:.14s}
.chip-btn:hover{border-color:var(--primary);color:var(--primary)}
.chip-btn.on{background:var(--primary);color:#fff;border-color:var(--primary)}

/* ---------- Forms ---------- */
input,select,textarea{width:100%;padding:10px 12px;border:1px solid var(--border-strong);border-radius:10px;
  background:var(--surface);color:var(--ink);font:inherit;font-size:13.5px;transition:.14s}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--ring)}
input::placeholder{color:var(--muted)}
label.field{display:block;margin-bottom:13px}
label.field>span{display:block;font-size:12.5px;font-weight:600;color:var(--ink-2);margin-bottom:5px}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:13px}
.help{font-size:11.5px;color:var(--muted);margin-top:4px}

/* ---------- Modal ---------- */
.modal{border:none;padding:0;background:transparent;max-width:560px;width:92%;border-radius:var(--radius-lg)}
.modal::backdrop{background:rgba(15,23,42,.5);backdrop-filter:blur(3px)}
.modal-card{background:var(--surface);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);overflow:hidden}
.modal-head{display:flex;align-items:center;justify-content:space-between;padding:18px 22px;border-bottom:1px solid var(--border)}
.modal-head h3{font-size:17px}
.modal-body{padding:22px;max-height:72vh;overflow-y:auto}
.modal-foot{display:flex;gap:10px;justify-content:flex-end;margin-top:8px}
.modal[open]{animation:pop .2s ease}
@keyframes pop{from{transform:scale(.96);opacity:0}to{transform:scale(1);opacity:1}}

/* ---------- Toast ---------- */
.toast{padding:12px 16px;border-radius:12px;font-weight:500;font-size:13.5px;margin-bottom:14px;
  border:1px solid var(--border);animation:slidein .3s ease;display:flex;align-items:center;gap:9px}
.toast::before{content:"";width:8px;height:8px;border-radius:50%;flex-shrink:0}
.toast-success{background:var(--emerald-bg);color:#047857;border-color:transparent}
.toast-success::before{background:var(--emerald)}
.toast-warn{background:var(--amber-bg);color:#b45309;border-color:transparent}
.toast-warn::before{background:var(--amber)}
.toast-danger{background:var(--rose-bg);color:#b91c1c;border-color:transparent}
.toast-danger::before{background:var(--rose)}
@keyframes slidein{from{transform:translateY(-8px);opacity:0}to{transform:translateY(0);opacity:1}}

/* ---------- Empty state ---------- */
.empty{text-align:center;padding:50px 20px;color:var(--muted)}
.empty svg{width:42px;height:42px;color:var(--border-strong);margin-bottom:10px}

/* ---------- Progress bars (customer dashboard style) ---------- */
.pbar{display:flex;align-items:center;gap:12px;margin-bottom:11px}
.pbar .pl{width:130px;font-size:13px;color:var(--ink-2)}
.pbar .pt{flex:1;height:26px;background:var(--surface-2);border-radius:8px;overflow:hidden;position:relative}
.pbar .pf{height:100%;border-radius:8px;display:flex;align-items:center;justify-content:flex-end;padding-right:9px;
  color:#fff;font-size:12px;font-weight:700;min-width:26px;transition:width .6s ease}

/* ---------- POS ---------- */
.pos{display:grid;grid-template-columns:1fr 380px;gap:18px;align-items:start}
.pos-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px;margin-top:14px}
.pcard{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:14px;
  cursor:pointer;transition:.16s;text-align:center;box-shadow:var(--shadow)}
.pcard:hover{transform:translateY(-3px);border-color:var(--primary);box-shadow:var(--shadow-lg)}
.pcard .pic{width:48px;height:48px;border-radius:12px;background:var(--indigo-50);color:var(--indigo-600);
  display:grid;place-items:center;margin:0 auto 10px}
.pcard .pn{font-size:13px;font-weight:600;line-height:1.35;min-height:35px;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.pcard .psku{font-size:11px;color:var(--muted);margin:2px 0 6px}
.pcard .pp{font-size:16px;font-weight:700;color:var(--primary)}
.pcard.oos{opacity:.5;pointer-events:none}

.cart{position:sticky;top:84px}
.cart-items{max-height:46vh;overflow-y:auto;padding:4px}
.cart-row{display:flex;align-items:center;gap:10px;padding:10px;border-radius:10px;transition:.12s}
.cart-row:hover{background:var(--surface-2)}
.cart-row .ci-name{flex:1;min-width:0}
.cart-row .ci-name strong{font-size:13px;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cart-row .ci-name span{font-size:11.5px;color:var(--muted)}
.qty{display:flex;align-items:center;gap:6px}
.qty button{width:26px;height:26px;border-radius:7px;border:1px solid var(--border-strong);background:var(--surface);
  cursor:pointer;font-size:15px;color:var(--ink-2);display:grid;place-items:center}
.qty button:hover{background:var(--surface-2)}
.qty input{width:42px;text-align:center;padding:5px}
.cart-empty{text-align:center;color:var(--muted);padding:40px 10px}
.summary{border-top:1px solid var(--border);margin-top:8px;padding-top:14px}
.sline{display:flex;justify-content:space-between;font-size:13.5px;color:var(--ink-2);margin-bottom:7px}
.sline.total{font-size:19px;font-weight:700;color:var(--ink);margin-top:8px}

/* ---------- Section title ---------- */
.section-head{display:flex;align-items:center;justify-content:space-between;margin:0 0 14px}
.section-head h2{font-size:16px}

@media (max-width:1024px){
  .grid-2,.grid-2.wide{grid-template-columns:1fr}
  .pos{grid-template-columns:1fr}
  .cart{position:static}
}
@media (max-width:820px){
  .sidebar{position:fixed;left:0;top:0;transform:translateX(-100%);transition:transform .25s ease;box-shadow:var(--shadow-lg)}
  .sidebar.open{transform:translateX(0)}
  .scrim{display:none;position:fixed;inset:0;background:rgba(15,23,42,.45);z-index:35}
  .scrim.show{display:block}
  .burger{display:grid;place-items:center;width:38px;height:38px;border-radius:10px;border:1px solid var(--border);
    background:var(--surface);color:var(--ink-2);cursor:pointer}
  .content{padding:18px 16px 48px}
  .topbar{padding:12px 16px}
  .form-row{grid-template-columns:1fr}
  .who{display:none}
}

/* ---------- Company switcher dropdown ---------- */
.co-drop{display:none;flex-shrink:0;margin:0 14px 8px;background:var(--surface-2);border:1px solid var(--border);
  border-radius:var(--radius-sm);overflow:hidden}
.co-drop.show{display:block}
.co-drop form{margin:0}
.co-item{width:100%;display:flex;align-items:center;gap:9px;padding:9px 12px;border:none;background:none;
  cursor:pointer;font:inherit;font-size:12.5px;text-align:left;color:var(--ink-2);transition:.12s}
.co-item:hover{background:var(--surface)}
.co-item.on{color:var(--primary);font-weight:600}
.co-item .d{width:22px;height:22px;border-radius:6px;background:var(--primary);color:#fff;display:grid;place-items:center;font-size:10px;font-weight:700;flex-shrink:0}
.co-item .n{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.co-item .chk{color:var(--emerald);font-weight:700}
.co-item .sw{font-size:11px;color:var(--muted)}
.co-add{width:100%;padding:10px;border:none;border-top:1px dashed var(--border-strong);background:none;
  cursor:pointer;font:inherit;font-size:12.5px;font-weight:600;color:var(--primary)}
.co-add:hover{background:var(--primary-soft)}

/* ---------- User menu ---------- */
.user-menu{display:none;position:absolute;right:0;top:48px;min-width:180px;background:var(--surface);
  border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow-lg);overflow:hidden;z-index:50}
.user-menu.show{display:block}
.user-menu a{display:block;padding:11px 16px;font-size:13.5px;color:var(--ink-2);transition:.12s}
.user-menu a:hover{background:var(--surface-2);color:var(--ink)}
.user-menu a.danger{color:var(--rose);border-top:1px solid var(--border)}
.user-menu a.danger:hover{background:var(--rose-bg)}

/* ---------- Print ---------- */
@media print{ .sidebar,.topbar,.no-print{display:none!important} .content{padding:0!important;max-width:none!important} body{background:#fff} }

/* ---------- Empty company CTA ---------- */
.empty-cta{display:flex;gap:18px;align-items:center;padding:22px 24px;margin-bottom:18px;
  background:linear-gradient(135deg,var(--indigo-50),var(--surface));border:1px dashed var(--indigo-300,#a5b4fc);
  border-radius:var(--radius-lg)}
.empty-cta-icon{font-size:40px;line-height:1;flex-shrink:0}
.empty-cta-body h2{font-size:17px;margin-bottom:4px}
.empty-cta-body p{color:var(--muted);font-size:13.5px;line-height:1.6;margin-bottom:14px;max-width:640px}
.empty-cta-actions{display:flex;gap:10px;flex-wrap:wrap}

/* ---------- PJAX: แถบโหลด + fade เนื้อหา (สลับหน้าแบบลื่น) ---------- */
#pjaxBar{position:fixed;top:0;left:0;height:3px;width:0;z-index:9999;opacity:0;
  background:linear-gradient(90deg,var(--indigo-600,#4f46e5),var(--indigo-400,#818cf8));
  box-shadow:0 0 8px rgba(99,102,241,.6)}
#pjaxBar.run{width:78%;opacity:1;transition:width 8s cubic-bezier(.1,.7,.1,1),opacity .2s}
#pjaxBar.done{width:100%;opacity:1;transition:width .2s ease}
.content{transition:opacity .22s ease, transform .22s ease}
.content.swapping{opacity:0;transform:translateY(8px)}

/* ---------- โลโก้บริษัท ---------- */
.logo-box{display:flex;gap:16px;align-items:center;padding:14px;margin-bottom:18px;
  background:var(--surface-2);border:1px solid var(--border);border-radius:var(--radius)}
.logo-preview{width:84px;height:84px;flex-shrink:0;border-radius:12px;overflow:hidden;background:#fff;
  border:1px solid var(--border);display:grid;place-items:center}
.logo-preview img{width:100%;height:100%;object-fit:contain}
.logo-ph{width:100%;height:100%;display:grid;place-items:center;font-weight:800;font-size:32px;
  color:#fff;background:linear-gradient(135deg,var(--indigo-600,#4f46e5),var(--indigo-400,#818cf8))}
.logo-actions{flex:1;min-width:0}
.logo-actions input[type=file]{font-size:12.5px;max-width:100%}
/* โลโก้ในแถบเมนู */
.company-pill .ci img{width:100%;height:100%;object-fit:contain;border-radius:8px;background:#fff}

/* ---------- เมนูที่ถูกล็อกตามแพ็คเกจ ---------- */
.nav-item.locked{opacity:.5}
.nav-item.locked:hover{opacity:.8}
.nav-item .navlock{width:14px!important;height:14px!important;margin-left:auto;opacity:.7}

/* ---------- หน้าแพ็คเกจ ---------- */
.plan-intro{background:var(--surface-2);border:1px solid var(--border);border-radius:var(--radius);
  padding:14px 18px;margin-bottom:18px;color:var(--ink-2);font-size:14px}
.plan-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}
@media(max-width:900px){.plan-grid{grid-template-columns:1fr}}
.plan-card{position:relative;background:var(--surface);border:1.5px solid var(--border);border-radius:var(--radius-lg);
  padding:24px 22px;display:flex;flex-direction:column}
.plan-card.featured{border-color:var(--accent);box-shadow:0 10px 30px -12px color-mix(in srgb,var(--accent) 55%,transparent)}
.plan-card.current{border-color:var(--emerald)}
.plan-ribbon{position:absolute;top:-11px;left:50%;transform:translateX(-50%);background:var(--accent);color:#fff;
  font-size:11.5px;font-weight:700;padding:4px 14px;border-radius:999px;white-space:nowrap}
.plan-name{font-family:"Sora",sans-serif;font-weight:800;font-size:22px;color:var(--accent)}
.plan-tag{color:var(--muted);font-size:13px;line-height:1.5;margin:6px 0 14px;min-height:40px}
.plan-price{font-family:"Sora",sans-serif;font-weight:800;font-size:30px;color:var(--ink);margin-bottom:16px}
.plan-price span{font-family:inherit;font-size:14px;font-weight:500;color:var(--muted)}
.plan-feats{list-style:none;margin:0 0 20px;padding:0;display:flex;flex-direction:column;gap:10px;flex:1}
.plan-feats li{display:flex;gap:9px;align-items:flex-start;font-size:13.5px;color:var(--ink-2);line-height:1.45}
.plan-feats svg{width:17px;height:17px;flex-shrink:0;margin-top:1px;stroke:var(--accent);fill:none;stroke-width:3}
.plan-note{margin-top:18px;color:var(--muted);font-size:13px;text-align:center}

/* ---------- หน้าเลือกบริษัท ---------- */
.pick-body{background:linear-gradient(160deg,var(--bg),var(--surface-2));min-height:100vh;margin:0}
.pick-wrap{max-width:760px;margin:0 auto;padding:48px 20px 60px}
.pick-head{text-align:center;margin-bottom:28px}
.pick-head h1{font-family:"Sora",sans-serif;font-size:26px;margin:14px 0 6px;color:var(--ink)}
.pick-head p{color:var(--muted)}
.pick-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:14px}
@media(max-width:620px){.pick-grid{grid-template-columns:1fr}}
.pick-card{margin:0}
.pick-card>button{width:100%;display:flex;align-items:center;gap:14px;text-align:left;cursor:pointer;
  background:var(--surface);border:1.5px solid var(--border);border-radius:var(--radius-lg);padding:16px;transition:.15s}
.pick-card>button:hover{border-color:var(--primary);transform:translateY(-2px);box-shadow:0 10px 26px -14px var(--primary)}
.pick-logo{width:52px;height:52px;flex-shrink:0;border-radius:13px;overflow:hidden;background:#fff;border:1px solid var(--border);
  display:grid;place-items:center;font-weight:800;font-size:22px;color:var(--primary)}
.pick-logo img{width:100%;height:100%;object-fit:contain}
.pick-logo.plus{background:var(--primary-soft);color:var(--primary);font-size:28px;border-style:dashed}
.pick-info{flex:1;min-width:0}
.pick-info strong{display:block;font-size:15px;color:var(--ink);margin-bottom:4px}
.pick-plan{display:inline-block;font-size:11.5px;font-weight:700;padding:2px 10px;border-radius:999px;
  background:color-mix(in srgb,var(--a) 14%,transparent);color:var(--a)}
.pick-arr{width:20px;height:20px;stroke:var(--muted);fill:none;stroke-width:2;flex-shrink:0}
.pick-add>button{border-style:dashed}
.pick-foot{text-align:center;margin-top:26px}
.pick-foot a{color:var(--muted);text-decoration:none;font-size:14px}
.pick-foot a:hover{color:var(--rose,#e11d48)}

/* ---------- ตั้งค่า VAT ---------- */
.vat-check{display:flex;gap:12px;align-items:flex-start;padding:14px;background:var(--surface-2);
  border:1px solid var(--border);border-radius:var(--radius);cursor:pointer}
.vat-check input{width:20px;height:20px;margin-top:2px;flex-shrink:0;accent-color:var(--primary)}
.vat-note{margin-top:12px;font-size:13px;color:var(--muted);background:var(--primary-soft);padding:10px 14px;border-radius:10px}

/* ---------- จัดการหมวดหมู่ ---------- */
.cat-list{display:flex;flex-direction:column;gap:6px;max-height:280px;overflow:auto}
.cat-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 12px;
  background:var(--surface-2);border:1px solid var(--border);border-radius:10px;font-size:14px}

/* ---------- รูปย่อสินค้าในตาราง ---------- */
.prod-cell{display:flex;align-items:center;gap:11px}
.prod-thumb{width:40px;height:40px;border-radius:9px;object-fit:cover;background:#fff;border:1px solid var(--border);flex-shrink:0}
.prod-thumb.ph{display:grid;place-items:center;font-weight:800;color:#fff;font-size:15px;
  background:linear-gradient(135deg,var(--indigo-600,#4f46e5),var(--indigo-400,#818cf8))}

/* ---------- หน้าแก้ไขสินค้า ---------- */
.pe-top{display:flex;align-items:center;gap:10px;margin-bottom:16px}
.pe-imgbox{display:flex;gap:16px;align-items:flex-start;flex-wrap:wrap}
.pe-img{width:120px;height:120px;flex-shrink:0;border-radius:14px;overflow:hidden;background:#fff;border:1px solid var(--border);display:grid;place-items:center}
.pe-img img{width:100%;height:100%;object-fit:cover}
.pe-img-ph{color:var(--muted);font-size:13px}
.pe-codes{display:flex;gap:18px;flex-wrap:wrap;justify-content:center}
.pe-code{text-align:center;background:var(--surface-2);border:1px solid var(--border);border-radius:12px;padding:16px 20px;flex:1;min-width:170px}
.pe-code-h{font-size:12px;font-weight:700;color:var(--muted);margin-bottom:10px;text-transform:uppercase;letter-spacing:.5px}
.pe-bc svg{max-width:100%;height:60px}
.pe-qr{display:grid;place-items:center}.pe-qr img,.pe-qr canvas{width:150px;height:150px}
.pe-code-v{margin-top:10px;font-size:13px;font-weight:600;color:var(--ink-2)}

/* ---------- Admin Console ---------- */
.adm-plans{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
@media(max-width:900px){.adm-plans{grid-template-columns:1fr}}
.adm-plan{background:var(--surface-2);border:1.5px solid var(--border);border-top:3px solid var(--accent);
  border-radius:var(--radius);padding:16px}
.adm-plan-name{font-family:"Sora",sans-serif;font-weight:800;font-size:18px;color:var(--accent);margin-bottom:12px}
.adm-plan-sel{padding:5px 10px;border:1px solid var(--border);border-radius:8px;background:var(--surface);
  font-family:inherit;font-size:13px;font-weight:600;cursor:pointer;color:var(--ink)}

/* ---------- รูปสินค้า: คลิกดูเต็ม + ชี้พรีวิว + ตัวเลือกรูป ---------- */
img.zoomable{cursor:zoom-in;transition:transform .12s}
img.zoomable:hover{transform:scale(1.05)}
#fbLightbox{position:fixed;inset:0;z-index:10000;background:rgba(15,23,42,.86);display:none;
  align-items:center;justify-content:center;padding:30px;cursor:zoom-out;backdrop-filter:blur(3px)}
#fbLightbox.show{display:flex;animation:fbIn .15s ease}
#fbLightbox img{max-width:92vw;max-height:88vh;border-radius:12px;box-shadow:0 20px 60px rgba(0,0,0,.5);background:#fff}
.fb-lb-x{position:fixed;top:18px;right:24px;color:#fff;font-size:30px;line-height:1;cursor:pointer;opacity:.85}
@keyframes fbIn{from{opacity:0}to{opacity:1}}
#fbHover{position:fixed;z-index:10001;pointer-events:none;display:none;padding:4px;background:#fff;
  border:1px solid var(--border);border-radius:10px;box-shadow:0 12px 32px rgba(0,0,0,.25)}
#fbHover.show{display:block}
#fbHover img{display:block;max-width:220px;max-height:220px;border-radius:7px}

.img-pick{display:flex;gap:16px;align-items:flex-start;margin:6px 0 4px;padding:14px;
  background:var(--surface-2);border:1px solid var(--border);border-radius:12px}
.img-pick-prev{width:96px;height:96px;flex-shrink:0;border-radius:11px;overflow:hidden;background:#fff;
  border:1px dashed var(--border);display:grid;place-items:center;position:relative}
.img-pick-prev img{width:100%;height:100%;object-fit:cover;display:none}
.img-pick-prev img[src]{display:block}
.img-pick-prev img[src] + .img-pick-ph{display:none}
.img-pick-ph{position:absolute;color:var(--muted);font-size:12px;pointer-events:none}
.img-pick-ctl{flex:1;min-width:0;display:flex;flex-direction:column;gap:10px}
.img-pick-ctl input[type=file]{font-size:12.5px}
