:root {
  --sidebar-w: 258px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --page-bg: #f1f2f9;
  --brand: #16a34a;
  --ink: #0f172a;
  --muted: #94a3b8;
}
* { font-family: 'Inter', system-ui, sans-serif; }
body { background: var(--page-bg); color: var(--ink); font-size: .875rem; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--sidebar-bg); display: flex; flex-direction: column;
  z-index: 1040; transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem; padding: 0 1rem; height: 64px;
  border-bottom: 1px solid rgba(255,255,255,.07); text-decoration: none;
}
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px; background: #1e3a8a;
  display: grid; place-items: center; color: #38bdf8; font-weight: 800; font-size: 1rem;
}
.brand-name { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.1; }
.brand-sub  { color: var(--sidebar-muted); font-size: .72rem; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding-bottom: .5rem; }
.sidebar-scroll::-webkit-scrollbar { width: 0; }
.nav-label {
  color: var(--sidebar-muted); font-size: .65rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; padding: 1rem 1rem .4rem;
}
.sidebar .nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .62rem 1rem;
  color: var(--sidebar-text); font-weight: 500; font-size: .84rem; border-radius: 0;
}
.sidebar .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.07); }

/* ---------- Main / topbar ---------- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; transition: margin .25s ease; }
.topbar {
  height: 64px; background: #fff; display: flex; align-items: center; gap: .9rem;
  padding: 0 1.5rem; border-bottom: 1px solid #e8eaf3; position: sticky; top: 0; z-index: 1030;
}
.icon-btn {
  width: 38px; height: 38px; border: 1px solid #e2e5ef; background: #fff; border-radius: 8px;
  display: grid; place-items: center; color: #475569;
}
.icon-btn:hover { background: #f8fafc; }
.search-box { position: relative; width: 240px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.search-box input { padding-left: 36px; background: #f1f5f9; border: 1px solid #e2e5ef; border-radius: 8px; height: 38px; font-size: .85rem; }
.page-title { font-weight: 700; font-size: 1rem; margin: 0; }
.user-chip { display: flex; align-items: center; gap: .6rem; padding: .35rem .75rem .35rem .4rem; background: #ecfdf5; border-radius: 999px; cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.user-name { font-weight: 600; font-size: .78rem; line-height: 1.1; }
.user-role { color: var(--muted); font-size: .68rem; }
.content { padding: 1.5rem; }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1035; }
.backdrop.show { display: block; }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h2 { font-size: 1.15rem; font-weight: 700; margin: 0; }
.page-head p { margin: 0; color: #64748b; font-size: .8rem; }

/* ---------- Gradient stat cards ---------- */
.stat-card { position: relative; overflow: hidden; border: 0; border-radius: 12px; color: #fff; padding: 1.35rem 1.35rem 1.2rem; height: 100%; box-shadow: 0 6px 16px rgba(15,23,42,.12); }
.stat-card .label { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .95; }
.stat-card .value { font-size: 1.85rem; font-weight: 800; line-height: 1.2; margin: .25rem 0 .1rem; }
.stat-card .sub { font-size: .75rem; opacity: .85; }
.stat-card .bg-icon { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 3.6rem; opacity: .22; }
.g-green  { background: linear-gradient(135deg,#16a34a,#22c55e); }
.g-blue   { background: linear-gradient(135deg,#1d4ed8,#3b82f6); }
.g-orange { background: linear-gradient(135deg,#c2410c,#f97316); }
.g-teal   { background: linear-gradient(135deg,#0f766e,#14b8a6); }
.g-red    { background: linear-gradient(135deg,#b91c1c,#ef4444); }
.g-purple { background: linear-gradient(135deg,#6d28d9,#8b5cf6); }

/* ---------- Panels ---------- */
.panel { background: #fff; border: 0; border-radius: 12px; box-shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.04); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .9rem 1.2rem; border-bottom: 1px solid #eef0f6; font-weight: 600; font-size: .85rem; }
.panel-head i { margin-right: .45rem; }
.panel-body { padding: 1.2rem; }
.metric { padding: 1.25rem 1.5rem; }
.metric .label { font-size: .75rem; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: #475569; }
.metric .value { font-size: 1.65rem; font-weight: 800; margin: .3rem 0 .15rem; }
.metric .sub { color: var(--muted); font-size: .74rem; }
.chart-wrap { padding: 1rem 1.2rem 1.2rem; height: 270px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; color: #64748b; padding: 2.5rem 1rem; gap: .6rem; text-align: center; }
.empty-state i { font-size: 2.2rem; color: #475569; }
.healthy { display: flex; flex-direction: column; align-items: center; padding: 2rem 1rem; gap: .8rem; color: var(--brand); font-weight: 600; }
.healthy .tick { width: 42px; height: 42px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.4rem; }

/* ---------- Buttons ---------- */
.btn-quick { font-weight: 600; font-size: .82rem; padding: .6rem; border-radius: 6px; }
.btn-outline-teal { color: #0f766e; border: 1px solid #14b8a6; background: #fff; }
.btn-outline-teal:hover { background: #14b8a6; color: #fff; }
.btn-outline-blue { color: #2563eb; border: 1px solid #3b82f6; background: #fff; }
.btn-outline-blue:hover { background: #3b82f6; color: #fff; }
.btn-outline-gray { color: #475569; border: 1px solid #cbd5e1; background: #fff; }
.btn-outline-gray:hover { background: #f1f5f9; }
.btn-success { --bs-btn-bg: #16a34a; --bs-btn-border-color: #16a34a; --bs-btn-hover-bg: #15803d; --bs-btn-hover-border-color: #15803d; }

/* ---------- Tables ---------- */
.table-pos { margin: 0; font-size: .83rem; }
.table-pos thead th { background: #f8fafc; color: #475569; font-weight: 600; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; border-bottom: 1px solid #e8eaf3; padding: .75rem 1rem; white-space: nowrap; }
.table-pos td { padding: .75rem 1rem; vertical-align: middle; border-color: #eef0f6; }
.table-pos tbody tr:hover { background: #fafbff; }
.badge-soft { font-weight: 600; padding: .35em .65em; border-radius: 6px; font-size: .72rem; }
.bs-green  { background: #dcfce7; color: #15803d; }
.bs-red    { background: #fee2e2; color: #b91c1c; }
.bs-orange { background: #ffedd5; color: #c2410c; }
.bs-blue   { background: #dbeafe; color: #1d4ed8; }
.bs-purple { background: #ede9fe; color: #6d28d9; }
.bs-gray   { background: #f1f5f9; color: #475569; }
.act-btn { width: 30px; height: 30px; border: 1px solid #e2e5ef; background: #fff; border-radius: 6px; color: #475569; display: inline-grid; place-items: center; font-size: .85rem; }
.act-btn:hover { background: #f1f5f9; }
.act-btn.danger:hover { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.form-label { font-weight: 600; font-size: .78rem; color: #334155; margin-bottom: .3rem; }
.form-control, .form-select { font-size: .85rem; border-color: #dbe0ec; }
.form-control:focus, .form-select:focus { border-color: #22c55e; box-shadow: 0 0 0 .2rem rgba(34,197,94,.15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.modal-content { border: 0; border-radius: 12px; }
.modal-title { font-size: 1rem; font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .9rem 1.2rem; border-bottom: 1px solid #eef0f6; }
.toolbar .search-box { width: 260px; }

/* ---------- POS (New Bill) ---------- */
.pos-wrap { display: grid; grid-template-columns: 1fr 400px; gap: 1rem; align-items: start; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; padding: 1.2rem; }
.prod-tile { border: 1px solid #e8eaf3; border-radius: 10px; padding: .9rem; background: #fff; cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s; }
.prod-tile:hover { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.12); }
.prod-tile .ico { width: 40px; height: 40px; border-radius: 10px; background: #ecfdf5; color: var(--brand); display: grid; place-items: center; font-size: 1.2rem; margin-bottom: .6rem; }
.prod-tile .nm { font-weight: 600; font-size: .82rem; }
.prod-tile .pr { color: var(--brand); font-weight: 700; margin-top: .15rem; }
.prod-tile .st { color: var(--muted); font-size: .7rem; }
.cart-items { max-height: 290px; overflow-y: auto; }
.cart-row { display: flex; align-items: center; gap: .6rem; padding: .7rem 1.2rem; border-bottom: 1px solid #eef0f6; }
.cart-row .nm { flex: 1; font-weight: 600; font-size: .82rem; }
.cart-row .nm small { display: block; color: var(--muted); font-weight: 400; }
.qty { display: inline-flex; align-items: center; border: 1px solid #e2e5ef; border-radius: 6px; overflow: hidden; }
.qty button { border: 0; background: #f8fafc; width: 26px; height: 26px; }
.qty span { min-width: 28px; text-align: center; font-weight: 600; }
.totals div { display: flex; justify-content: space-between; padding: .25rem 0; color: #475569; }
.totals .grand { font-size: 1.2rem; font-weight: 800; color: var(--ink); border-top: 1px dashed #cbd5e1; margin-top: .4rem; padding-top: .6rem; }
.pay-opt { flex: 1; border: 1px solid #dbe0ec; border-radius: 8px; padding: .55rem .3rem; text-align: center; background: #fff; font-weight: 600; font-size: .78rem; color: #475569; }
.pay-opt.active { border-color: var(--brand); background: #ecfdf5; color: #15803d; }
.pay-opt i { display: block; font-size: 1.1rem; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.login-art { background: linear-gradient(145deg, #0f172a 0%, #1e3a8a 60%, #16a34a 130%); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { font-size: 2.1rem; font-weight: 800; line-height: 1.2; max-width: 420px; }
.login-art p { color: #cbd5e1; max-width: 420px; }
.login-feature { display: flex; gap: .75rem; align-items: center; margin-top: .9rem; color: #e2e8f0; }
.login-feature i { width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.login-form-side { display: grid; place-items: center; padding: 2rem; }
.login-box { width: 100%; max-width: 380px; }
.login-box h2 { font-weight: 800; font-size: 1.5rem; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.input-icon .form-control { padding-left: 38px; height: 44px; }
.input-icon .toggle-pw { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: #94a3b8; }

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) { .pos-wrap { grid-template-columns: 1fr; } }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: none; }
  .main { margin-left: 0; }
  .search-box.top { display: none; }
  .login-page { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { margin: 0; }
}
