/* =============================================
   POS SYSTEM - Indigo Theme
   โทนสี Indigo ตรงกับ Customer Display
   ============================================= */

/* ---- DARK MODE (Default) ---- */
:root {
    /* Accent: สี Indigo — ทันสมัย อ่านง่าย ตรงกับ Customer Display */
    --primary:        #6366f1;
    --primary-dark:   #4f46e5;
    --primary-light:  rgba(99,102,241,0.12);

    --success:        #10b981;
    --warning:        #f59e0b;
    --danger:         #ef4444;
    --info:           #38bdf8;

    --bg:       #0f172a;
    --bg2:      #1a2234;
    --bg3:      #263348;
    --surface:  #1e293b;
    --surface2: #263348;
    --border:   rgba(148,163,184,0.12);
    --text:     #f1f5f9;
    --text2:    #94a3b8;
    --text3:    #475569;

    --sidebar-w:  240px;
    --topbar-h:   60px;
    --radius:     12px;
    --shadow:     0 4px 24px rgba(0,0,0,0.5);
    --font:       'Kanit', sans-serif;
    --mono:       'JetBrains Mono', monospace;

    --input-bg:       rgba(255,255,255,0.05);
    --input-focus-bg: rgba(99,102,241,0.07);
    --table-hover:    rgba(99,102,241,0.04);
    --overlay-bg:     rgba(0,0,0,0.72);
    --scrollbar:      rgba(99,102,241,0.2);
    --cart-bg:        rgba(99,102,241,0.04);

    /* aliases สำหรับ light/dark compat */
    --bg-secondary:   #1e293b;
    --text-muted:     #64748b;
    --text-secondary: #94a3b8;
    --chart-grid:     rgba(255,255,255,0.05);
    --chart-tick:     #94a3b8;
    --chart-legend:   #94a3b8;
    --hover-overlay:  rgba(255,255,255,0.05);
    --text1:          #f1f5f9;
}

/* ---- LIGHT MODE ---- */
html.light {
    --primary:        #4f46e5;
    --primary-dark:   #3730a3;
    --primary-light:  rgba(79,70,229,0.10);
    --success:        #059669;
    --warning:        #d97706;
    --danger:         #dc2626;
    --info:           #0284c7;

    --bg:       #f8fafc;
    --bg2:      #f1f5f9;
    --bg3:      #e2e8f0;
    --surface:  #ffffff;
    --surface2: #f8fafc;
    --border:   rgba(99,102,241,0.15);
    --text:     #0f172a;
    --text2:    #475569;
    --text3:    #94a3b8;

    --shadow:         0 4px 24px rgba(30,40,80,0.10);
    --input-bg:       #f8fafc;
    --input-focus-bg: rgba(99,102,241,0.05);
    --table-hover:    rgba(99,102,241,0.04);
    --overlay-bg:     rgba(15,23,42,0.5);
    --scrollbar:      rgba(99,102,241,0.2);
    --cart-bg:        #f8fafc;

    /* aliases สำหรับ light mode */
    --bg-secondary:   #f1f5f9;
    --text-muted:     #64748b;
    --text-secondary: #475569;
    --chart-grid:     rgba(0,0,0,0.06);
    --chart-tick:     #475569;
    --chart-legend:   #475569;
    --hover-overlay:  rgba(0,0,0,0.04);
    --text1:          #0f172a;
}

/* ---- Reset + Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg); color: var(--text);
    font-size: 14px; overflow-x: hidden;
    transition: background .25s, color .15s;
}
a { text-decoration: none; color: inherit; }
input, select, textarea, button { font-family: var(--font); }

/* ---- Theme Toggle ---- */
.btn-theme-toggle {
    width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--input-bg); color: var(--text2);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 15px; transition: all .2s; flex-shrink: 0;
}
.btn-theme-toggle:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); transform: rotate(18deg); }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100; overflow-y: auto;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}
html.light .sidebar { box-shadow: 2px 0 16px rgba(30,40,80,.08); }

.sidebar-logo { display: flex; align-items: center; gap: 12px; padding: 20px 16px; border-bottom: 1px solid var(--border); }
.logo-icon {
    width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex; align-items: center; justify-content: center; color: white; font-size: 18px;
}
.logo-text strong { display: block; font-size: 15px; font-weight: 700; }
.logo-text span { font-size: 11px; color: var(--text3); }

.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-section { margin-bottom: 8px; }
.nav-label { font-size: 10px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .8px; padding: 8px 10px 4px; display: block; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px; color: var(--text2);
    font-size: 13.5px; transition: all .2s; margin-bottom: 2px;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: linear-gradient(90deg, var(--primary-light), transparent); color: var(--primary); font-weight: 600; border-left: 3px solid var(--primary); padding-left: 9px; }
.nav-item i { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; color: white; font-weight: 700; font-size: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex; align-items: center; justify-content: center;
}
.user-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--text3); }
.btn-logout { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text3); transition: all .2s; flex-shrink: 0; }
.btn-logout:hover { background: rgba(239,68,68,.1); color: var(--danger); }

/* ---- Main ---- */
.main-content { flex: 1; margin-left: calc(var(--sidebar-w) + 12px); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px; padding: 0 20px;
    position: sticky; top: 0; z-index: 50;
}
html.light .topbar { box-shadow: 0 2px 8px rgba(30,40,80,.06); }
.btn-toggle-sidebar { background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer; padding: 4px; border-radius: 6px; transition: all .2s; }
.btn-toggle-sidebar:hover { background: var(--primary-light); color: var(--primary); }
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.clock { font-family: var(--mono); font-size: 13px; color: var(--text2); }
.page-content { padding: 24px; flex: 1; }

/* ---- Cards ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
html.light .card { box-shadow: 0 2px 12px rgba(30,40,80,.06); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 15px; font-weight: 600; }

/* ---- Stats ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; transition: transform .2s; }
html.light .stat-card { box-shadow: 0 2px 10px rgba(30,40,80,.05); }
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-icon.purple { background: rgba(99,102,241,.15); color: var(--primary); }
.stat-icon.green  { background: rgba(34,197,94,.15);  color: var(--success); }
.stat-icon.yellow { background: rgba(251,146,60,.15); color: var(--warning); }
.stat-icon.red    { background: rgba(248,113,113,.15); color: var(--danger); }
.stat-icon.blue   { background: rgba(56,189,248,.15);  color: var(--info); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 2px; }
.stat-change { font-size: 11px; margin-top: 4px; }
.stat-change.up { color: var(--success); } .stat-change.down { color: var(--danger); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 14px; background: var(--input-bg); color: var(--text2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--table-hover); }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-family: var(--font); font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all .2s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: white; font-weight: 700; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: .88; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: .88; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { opacity: .88; }
.btn-secondary { background: var(--input-bg); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 7px 10px; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: rgba(34,197,94,.15);   color: var(--success); }
.badge-danger  { background: rgba(248,113,113,.15); color: var(--danger); }
.badge-warning { background: rgba(251,146,60,.15);  color: var(--warning); }
.badge-primary { background: var(--primary-light);  color: var(--primary); }
.badge-info    { background: rgba(56,189,248,.15);   color: var(--info); }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.form-control {
    width: 100%; padding: 9px 12px;
    background: var(--input-bg); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-family: var(--font); font-size: 14px; outline: none; transition: all .2s;
}
.form-control:focus { border-color: var(--primary); background: var(--input-focus-bg); box-shadow: 0 0 0 3px var(--primary-light); }
.form-control::placeholder { color: var(--text3); }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
select.form-control { cursor: pointer; }
select.form-control option { background: var(--surface); color: var(--text); }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay-bg); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all .2s; padding: 16px; }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; transform: scale(.95) translateY(-10px); transition: transform .2s; }
html.light .modal { box-shadow: 0 20px 60px rgba(30,40,80,.14); }
.modal-overlay.show .modal { transform: scale(1) translateY(0); }
.modal-lg { max-width: 780px; } .modal-xl { max-width: 1000px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--surface); }
.btn-close { background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer; padding: 4px; border-radius: 6px; transition: all .2s; }
.btn-close:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* ---- Search ---- */
.search-bar { position: relative; display: flex; align-items: center; }
.search-bar i { position: absolute; left: 12px; color: var(--text3); font-size: 14px; }
.search-bar input { padding-left: 36px !important; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar-right { margin-left: auto; display: flex; gap: 10px; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.alert-success { background: rgba(34,197,94,.1);   border: 1px solid rgba(34,197,94,.3);   color: var(--success); }
.alert-danger  { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3); color: var(--danger); }
.alert-warning { background: rgba(251,146,60,.1);  border: 1px solid rgba(251,146,60,.3);  color: var(--warning); }
.alert-info    { background: rgba(56,189,248,.1);   border: 1px solid rgba(56,189,248,.3);   color: var(--info); }

/* ---- Toast ---- */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 360px; animation: slideIn .3s ease; box-shadow: var(--shadow); font-size: 13px; }
html.light .toast { background: var(--surface); box-shadow: 0 8px 30px rgba(30,40,80,.12); }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }

/* ---- Spinner ---- */
.loading-spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   POS LAYOUT
   ============================================ */
.page-content.pos-page { padding: 12px 20px 12px 20px; overflow: hidden; }

.pos-layout {
    display: grid;
    grid-template-columns: 1fr 390px;
    gap: 16px;
    height: calc(100vh - var(--topbar-h) - 24px);
    overflow: hidden;
}

.pos-left { display: flex; flex-direction: column; gap: 10px; overflow: hidden; min-height: 0; padding-top: 10px; }
.pos-search-row { display: flex; gap: 10px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
.cat-filter { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; flex-shrink: 0; scrollbar-width: none; }
.cat-filter::-webkit-scrollbar { display: none; }
.product-grid { display: flex; flex-direction: column; gap: 5px; overflow-y: auto; padding: 2px; flex: 1; min-height: 0; }

.pos-right { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; min-height: 0; margin-top: 10px; margin-right: 6px; }
html.light .pos-right { box-shadow: 0 2px 14px rgba(30,40,80,.08); }
.cart-header { padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.cart-items  { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.cart-summary { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--cart-bg); flex-shrink: 0; }

/* ---- POS Search ---- */
.pos-search {
    padding: 10px 14px; width: 100%;
    background: var(--input-bg); border: 1.5px solid var(--border);
    border-radius: 10px; color: var(--text); font-family: var(--font); font-size: 14px; outline: none; transition: all .2s;
}
.pos-search:focus { border-color: var(--primary); background: var(--input-focus-bg); box-shadow: 0 0 0 3px var(--primary-light); }
.pos-search.scanning { border-color: var(--warning); animation: scanPulse .5s ease; }
.pos-search.scan-success { border-color: var(--success); background: rgba(34,197,94,.06); }
@keyframes scanPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.01)} }

.scan-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; background: var(--primary-light); color: var(--primary); border: 1px solid rgba(99,102,241,.25); transition: all .3s; white-space: nowrap; }
.scan-badge.active { background: rgba(251,146,60,.15); color: var(--warning); border-color: rgba(251,146,60,.3); }
.scan-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.scan-dot.pulse { animation: dotPulse 1s infinite; }
@keyframes dotPulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.last-scan-info { font-size: 11px; color: var(--text3); height: 16px; overflow: hidden; transition: all .3s; flex-shrink: 0; }

/* ---- Product Cards ---- */
.product-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px; cursor: pointer; transition: all .15s; user-select: none; display: flex; align-items: center; gap: 12px; text-align: left; }
html.light .product-card { box-shadow: 0 1px 4px rgba(30,40,80,.06); }
.product-card:hover { border-color: var(--primary); background: var(--primary-light); transform: translateX(2px); }
.product-card:active { transform: scale(.99); }
.product-card.out-of-stock { opacity: .4; pointer-events: none; }
.product-emoji { font-size: 24px; flex-shrink: 0; width: 34px; text-align: center; }
.product-info { flex: 1; min-width: 0; }
.product-name { font-size: 13px; font-weight: 500; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-stock { font-size: 11px; color: var(--text3); margin-top: 1px; }
.product-price { font-size: 14px; font-weight: 700; color: var(--primary); flex-shrink: 0; white-space: nowrap; }
.product-add-icon { width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 15px; transition: all .15s; }
.product-card:hover .product-add-icon { background: var(--primary); color: white; }

/* ---- Cart ---- */
.cart-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--input-bg); margin-bottom: 6px; border: 1px solid var(--border); }
.cart-item-name { flex: 1; font-size: 12px; font-weight: 500; line-height: 1.3; }
.cart-item-price { font-size: 12px; color: var(--text2); }
.qty-control { display: flex; align-items: center; gap: 4px; }
.qty-btn { width: 24px; height: 24px; border: 1px solid var(--border); background: var(--input-bg); border-radius: 6px; color: var(--text); cursor: pointer; font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.qty-btn:hover { background: var(--primary); border-color: var(--primary); color: white; }
.qty-num { width: 28px; text-align: center; font-size: 13px; font-weight: 600; font-family: var(--mono); }
.cart-item-total { font-size: 12px; font-weight: 700; color: var(--primary); min-width: 60px; text-align: right; }
.cart-remove { color: var(--text3); cursor: pointer; font-size: 12px; transition: color .15s; }
.cart-remove:hover { color: var(--danger); }
.cart-empty { text-align: center; padding: 30px; color: var(--text3); }
.cart-empty i { font-size: 32px; margin-bottom: 8px; opacity: .3; }

/* ---- Cart Summary ---- */
.summary-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; color: var(--text2); }
.summary-total { font-size: 20px; font-weight: 700; color: var(--text); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 6px; }
.btn-checkout {
    width: 100%; margin-top: 10px; padding: 13px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none; border-radius: 10px; color: white;
    font-family: var(--font); font-size: 15px; font-weight: 700;
    cursor: pointer; transition: all .2s; box-shadow: 0 4px 15px rgba(99,102,241,.3);
}
.btn-checkout:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99,102,241,.45); }
.btn-checkout:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---- Category Filter ---- */
.cat-btn { display: flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border); background: var(--input-bg); border-radius: 20px; color: var(--text2); cursor: pointer; transition: all .15s; white-space: nowrap; font-family: var(--font); font-size: 13px; }
.cat-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.cat-btn.active { background: var(--primary); border-color: var(--primary); color: white; font-weight: 600; }

/* ---- Payment Buttons ---- */
.payment-methods { display: flex; gap: 6px; flex-wrap: wrap; }
.payment-btn { flex: 1; min-width: 70px; padding: 10px 6px; border: 2px solid var(--border); border-radius: 10px; background: var(--input-bg); cursor: pointer; font-family: var(--font); font-size: 12px; color: var(--text2); transition: all .2s; text-align: center; line-height: 1.4; }
.payment-btn i { display: block; font-size: 18px; margin-bottom: 4px; }
.payment-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }
.payment-btn:hover:not(.active) { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* ---- Omise ---- */
.omise-card-form input { font-family: var(--mono); letter-spacing: 1px; }
.omise-logo { height: 22px; vertical-align: middle; margin-left: 6px; }

/* ---- Receipt ---- */
.receipt { font-family: var(--mono); font-size: 13px; background: white; color: black; padding: 20px; border-radius: 8px; max-width: 300px; margin: 0 auto; line-height: 1.6; }
.receipt-divider { border: none; border-top: 1px dashed #999; margin: 8px 0; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.page-btn { width: 32px; height: 32px; border: 1px solid var(--border); background: var(--input-bg); border-radius: 7px; color: var(--text2); cursor: pointer; font-family: var(--font); font-size: 13px; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.page-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text3); }
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ============================================
   SIDEBAR MOBILE OVERLAY
   ============================================ */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 99; backdrop-filter: blur(2px); }
.sidebar-overlay.show { display: block; }

/* ============================================
   RESPONSIVE MOBILE FIRST
   ============================================ */

/* Tablet ≤900px */
@media (max-width: 900px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-240px); width: 240px; z-index: 200; }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.4); }
    .main-content { margin-left: 0; }
    .pos-layout { grid-template-columns: 1fr; height: auto; overflow: visible; }
    .page-content.pos-page { padding: 12px 16px; overflow: visible; }
    .pos-left { overflow: visible; height: auto; }
    .pos-right { max-height: 520px; }
    .form-row   { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr 1fr; }
    .grid-3     { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile ≤640px */
@media (max-width: 640px) {
    .topbar { padding: 0 12px; gap: 10px; }
    .topbar-title { font-size: 14px; }
    .clock { display: none; }
    .page-content { padding: 12px; }
    .pos-layout { grid-template-columns: 1fr; gap: 12px; height: auto; }
    .page-content.pos-page { padding: 10px 12px; }
    .pos-search-row { flex-direction: column; gap: 8px; }
    .pos-search-row > div { width: 100%; }
    .pos-search-row select { width: 100% !important; }
    .product-grid { max-height: 45vh; overflow-y: auto; }
    .pos-right { max-height: none; height: auto; }
    .cart-items { max-height: 35vh; overflow-y: auto; }
    .cat-btn { padding: 8px 14px; font-size: 13px; }
    .qty-btn { width: 30px; height: 30px; font-size: 16px; }
    .btn { padding: 10px 16px; font-size: 14px; }
    .btn-checkout { padding: 15px; font-size: 16px; }
    th, td { padding: 10px 10px; font-size: 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-value { font-size: 18px; }
    .form-row   { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .toolbar { gap: 8px; }
    .toolbar-right { margin-left: 0; width: 100%; }
    .modal-body { padding: 16px; }
    .modal-header { padding: 16px; }
    .modal-footer { padding: 12px 16px; flex-wrap: wrap; }
    .modal-footer .btn { flex: 1; justify-content: center; }
    #toast-container { top: auto; bottom: 16px; right: 12px; left: 12px; }
    .toast { min-width: 0; width: 100%; max-width: 100%; }
}

/* Small ≤380px */
@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stats-grid-6 { grid-template-columns: 1fr; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ---- Utils ---- */
.text-right { text-align: right; } .text-center { text-align: center; }
.fw-bold { font-weight: 700; } .text-muted { color: var(--text2); }
.text-small { font-size: 12px; } .text-success { color: var(--success); }
.text-danger { color: var(--danger); } .text-warning { color: var(--warning); }
.text-primary { color: var(--primary); } .text-info { color: var(--info); }
.mt-8{margin-top:8px;} .mt-16{margin-top:16px;} .mt-24{margin-top:24px;} .mb-16{margin-bottom:16px;}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.flex{display:flex;} .flex-center{display:flex;align-items:center;}
.gap-8{gap:8px;} .gap-12{gap:12px;} .number{font-family:var(--mono);}

/* Settings tabs */
.settings-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab { padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .2s; background: none; border-top: none; border-left: none; border-right: none; font-family: var(--font); white-space: nowrap; flex-shrink: 0; }
.settings-tab:hover { color: var(--primary); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.settings-panel { display: none; } .settings-panel.active { display: block; }

/* =============================================
   DASHBOARD: 6-Card Grid
   ============================================= */
.stats-grid-6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px; margin-bottom: 24px;
}
@media (max-width: 1400px) { .stats-grid-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .stats-grid-6 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .stats-grid-6 { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
@media (max-width: 380px)  { .stats-grid-6 { grid-template-columns: 1fr; } }

/* Stat card variants — โทน Indigo สอดคล้องกับ customer display */
.stat-card-teal    { border-top: 3px solid #2dd4bf; }
.stat-card-indigo  { border-top: 3px solid var(--primary); }
.stat-card-sky     { border-top: 3px solid #38bdf8; }
.stat-card-rose    { border-top: 3px solid #fb7185; }
.stat-card-violet  { border-top: 3px solid #8b5cf6; }
.stat-card-emerald { border-top: 3px solid var(--success); }

.stat-icon.teal    { background: rgba(45,212,191,.13);  color: #2dd4bf; }
.stat-icon.indigo  { background: rgba(99,102,241,.13);  color: var(--primary); }
.stat-icon.sky     { background: rgba(56,189,248,.13);  color: #38bdf8; }
.stat-icon.rose    { background: rgba(251,113,133,.13); color: #fb7185; }
.stat-icon.violet  { background: rgba(139,92,246,.13);  color: #8b5cf6; }
.stat-icon.emerald { background: rgba(34,197,94,.13);   color: var(--success); }

.stat-card-teal:hover, .stat-card-indigo:hover, .stat-card-sky:hover,
.stat-card-rose:hover, .stat-card-violet:hover, .stat-card-emerald:hover {
    transform: translateY(-3px); box-shadow: 0 8px 28px rgba(0,0,0,.2);
}

html.light .stat-card-teal    { background: #f0fdfa; }
html.light .stat-card-indigo  { background: #eef2ff; }
html.light .stat-card-sky     { background: #f0f9ff; }
html.light .stat-card-rose    { background: #fff1f2; }
html.light .stat-card-violet  { background: #f5f3ff; }
html.light .stat-card-emerald { background: #f0fdf4; }

html.light .card      { background: #ffffff; box-shadow: 0 2px 12px rgba(30,40,80,.06); }
html.light .stat-card { background: #ffffff; box-shadow: 0 2px 12px rgba(30,40,80,.06); }

/* =============================================
   TOGGLE SWITCH
   ============================================= */
.toggle-switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--bg3); border-radius: 26px; transition: background .25s; }
.toggle-slider::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: transform .25s; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* =============================================
   POS MOBILE: Floating Cart Button
   ============================================= */
.mobile-cart-toggle { display: none; }
@media (max-width: 640px) {
    .mobile-cart-toggle {
        display: flex !important;
        position: fixed; bottom: 20px; right: 16px; z-index: 150;
        background: linear-gradient(135deg, var(--primary), var(--primary-dark));
        color: white; border: none; border-radius: 50px;
        padding: 12px 20px; font-family: var(--font); font-size: 14px; font-weight: 700;
        cursor: pointer; box-shadow: 0 4px 20px rgba(99,102,241,.5);
        align-items: center; gap: 8px; transition: all .2s;
    }
    .mobile-cart-toggle:active { transform: scale(.96); }
    .mobile-cart-toggle .cart-count-badge {
        background: white; color: var(--primary);
        border-radius: 50%; width: 22px; height: 22px;
        display: flex; align-items: center; justify-content: center;
        font-size: 12px; font-weight: 700;
    }
}
