:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #ccfbf1;
  --accent: #f59e0b;
  --ink: #1f2937;
  --muted: #6b7280;
  --surface: #ffffff;
  --page: #f1f5f4;
  --line: #e5e7eb;
  --sidebar-w: 250px;
  --bs-primary: #0f766e;
  --bs-primary-rgb: 15, 118, 110;
  --bs-link-color: #0f766e;
  --bs-link-hover-color: #115e59;
}
html, body { font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; color: var(--ink); background: var(--page); }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }
.text-brand { color: var(--brand) !important; }
.bg-brand { background: var(--brand) !important; color: #fff; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 1030; height: 56px; display: flex; align-items: center; gap: .75rem; padding: 0 1rem; background: linear-gradient(90deg, var(--brand-dark), var(--brand)); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.topbar .brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.topbar .brand i { color: var(--accent); }
.branch-pill { background: rgba(255,255,255,.16); border-radius: 999px; padding: .15rem .7rem; font-size: .85rem; white-space: nowrap; }
.notif-badge { position: absolute; top: -6px; right: -6px; font-size: .65rem; }
.notif-menu { width: 340px; max-height: 70vh; overflow: auto; padding: 0; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); padding: .75rem 0; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.content { flex: 1; min-width: 0; padding: 1.25rem; }
.nav-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .9rem 1.1rem .3rem; font-weight: 600; }
.nav-item, .nav-group > summary { display: flex; align-items: center; gap: .6rem; padding: .5rem 1.1rem; color: var(--ink); text-decoration: none; font-size: .92rem; cursor: pointer; border-left: 3px solid transparent; }
.nav-item:hover, .nav-group > summary:hover { background: #f8fafc; color: var(--brand); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); border-left-color: var(--brand); font-weight: 600; }
.nav-group > summary { list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after { content: '\F282'; font-family: 'bootstrap-icons'; margin-left: auto; font-size: .7rem; transition: transform .15s; }
.nav-group[open] > summary::after { transform: rotate(180deg); }
.nav-sub { display: block; padding: .38rem 1.1rem .38rem 2.9rem; font-size: .87rem; color: var(--muted); text-decoration: none; }
.nav-sub:hover { color: var(--brand); background: #f8fafc; }
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 56px; z-index: 1020; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 16px rgba(0,0,0,.1); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: .9rem; }
}

/* ---------- cards / stats ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; }
.panel-title { font-weight: 600; font-size: 1.02rem; margin-bottom: .9rem; display: flex; align-items: center; gap: .5rem; }
.panel-title i { color: var(--brand); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem; height: 100%; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.55rem; font-weight: 700; line-height: 1.2; }
.stat .sub { font-size: .8rem; color: var(--muted); }
.stat.accent { border-left: 4px solid var(--brand); }

.program-card { display: block; border-radius: 16px; padding: 1.2rem; color: #fff; text-decoration: none; min-height: 130px; position: relative; overflow: hidden; transition: transform .12s, box-shadow .12s; }
.program-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.15); color: #fff; }
.program-card h5 { font-weight: 700; margin-bottom: .35rem; }
.program-card p { font-size: .85rem; opacity: .92; margin: 0; }
.program-card .big-icon { position: absolute; right: -8px; bottom: -14px; font-size: 5.5rem; opacity: .18; }
.program-card .tag { position: absolute; top: .7rem; right: .7rem; background: rgba(255,255,255,.25); border-radius: 999px; font-size: .72rem; padding: .1rem .55rem; }
.program-card.disabled { filter: grayscale(.6); opacity: .75; pointer-events: none; }
.pc-stock { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.pc-pledge { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.pc-repair { background: linear-gradient(135deg, #b45309, #f59e0b); }
.pc-barcode { background: linear-gradient(135deg, #1d4ed8, #60a5fa); }
.pc-expense { background: linear-gradient(135deg, #be123c, #fb7185); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; font-size: .9rem; }
table.tbl th { font-weight: 600; color: var(--muted); font-size: .82rem; white-space: nowrap; border-bottom: 2px solid var(--line); padding: .55rem .6rem; }
table.tbl td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:hover { background: #f8fafc; }
.st { display: inline-block; font-size: .75rem; border-radius: 999px; padding: .12rem .6rem; font-weight: 600; white-space: nowrap; }
.st-in_stock { background: #dbeafe; color: #1e40af; }
.st-sold { background: #dcfce7; color: #166534; }
.st-transferring { background: #fef3c7; color: #92400e; }
.st-transferred { background: #e5e7eb; color: #374151; }
.st-claim { background: #fee2e2; color: #991b1b; }
.st-deleted { background: #f3f4f6; color: #6b7280; }
.cat-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- scanner input (POS, transfer, checking) ---------- */
.scan-input { font-size: 1.9rem; font-weight: 600; height: 70px; border: 2px solid var(--line); }
.scan-input:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(15,118,110,.18); }
.big-action { height: 70px; font-size: 1.35rem; font-weight: 700; }

/* ---------- POS ---------- */
body.pos .content { padding: 1rem; }
.pos-grid { display: grid; grid-template-columns: 1fr 330px; gap: 1rem; }
@media (max-width: 991.98px) { .pos-grid { grid-template-columns: 1fr; } }
.pos-total { font-size: 3rem; font-weight: 700; color: var(--brand); text-align: right; line-height: 1; }
.pos-side .info-row { border-left: 3px solid var(--brand); padding: .3rem .7rem; margin-bottom: .6rem; }
.pos-side .info-row .k { font-size: .78rem; color: var(--muted); }
.pos-side .info-row .v { font-weight: 600; }
.pay-btn { height: 74px; font-size: 1.6rem; font-weight: 700; }
.cart-empty { color: var(--muted); text-align: center; padding: 3rem 0; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 20%, #14b8a6, var(--brand-dark) 60%); padding: 1rem; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 2rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); }

/* ---------- print receipt ---------- */
@media print {
  .no-print, .topbar, .sidebar { display: none !important; }
  body, .content { background: #fff; padding: 0; }
}
.receipt { width: 80mm; margin: 0 auto; font-size: 13px; color: #000; background: #fff; padding: 4mm; }
.receipt hr { border-top: 1px dashed #000; opacity: 1; margin: 6px 0; }
