/* =====================================================================
   Billing Panel + Auth pages
   ===================================================================== */
:root {
    --bp-bg: #f3f5f9;
    --bp-surface: #ffffff;
    --bp-surface-2: #f8fafc;
    --bp-border: #e3e8ef;
    --bp-text: #0f172a;
    --bp-muted: #64748b;
    --bp-primary: #2563eb;
    --bp-primary-600: #1d4ed8;
    --bp-primary-50: #eff6ff;
    --bp-success: #059669;
    --bp-success-50: #ecfdf5;
    --bp-warning: #d97706;
    --bp-warning-50: #fffbeb;
    --bp-danger: #dc2626;
    --bp-danger-50: #fef2f2;
    --bp-nav: #0f172a;
    --bp-radius: 12px;
    --bp-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --bp-topbar-h: 60px;
}

body.bp-body {
    margin: 0;
    background: var(--bp-bg);
    color: var(--bp-text);
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
}

/* ---------- Top bar ---------- */
.bp-topbar {
    position: sticky; top: 0; z-index: 1030;
    height: var(--bp-topbar-h);
    display: flex; align-items: center; gap: 24px;
    padding: 0 20px;
    background: var(--bp-nav);
    color: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
}
.bp-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; white-space: nowrap; }
.bp-brand:hover { color: #fff; }
.bp-brand-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #3b82f6, #10b981); }
.bp-brand small { display: block; font-weight: 500; font-size: .7rem; color: rgba(255, 255, 255, .55); letter-spacing: .4px; }

.bp-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.bp-nav::-webkit-scrollbar { display: none; }
.bp-nav a {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 8px;
    color: rgba(255, 255, 255, .7); text-decoration: none; font-weight: 500; white-space: nowrap;
    transition: background .15s, color .15s;
}
.bp-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.bp-nav a.active { color: #fff; background: rgba(59, 130, 246, .28); }
.bp-nav kbd { font-size: .65rem; background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .8); padding: 1px 5px; border-radius: 4px; }

.bp-user { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.bp-clock { font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .7); font-size: .85rem; }
.bp-user .dropdown-toggle { color: #fff; text-decoration: none; }
.bp-avatar { width: 32px; height: 32px; border-radius: 50%; background: #334155; display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; margin-right: 6px; }

.bp-main { padding: 20px; max-width: 1600px; margin: 0 auto; }
.bp-main.bp-full { max-width: none; padding: 16px; }

/* ---------- Generic cards ---------- */
.bp-card { background: var(--bp-surface); border: 1px solid var(--bp-border); border-radius: var(--bp-radius); box-shadow: var(--bp-shadow); }
.bp-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--bp-border); }
.bp-card-header h2, .bp-card-header h3 { font-size: 1rem; font-weight: 700; margin: 0; }
.bp-card-body { padding: 18px; }
.bp-page-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.bp-page-title h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.bp-page-title p { margin: 2px 0 0; color: var(--bp-muted); }

/* ---------- KPI tiles ---------- */
.bp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.bp-kpi { padding: 16px 18px; }
.bp-kpi-label { color: var(--bp-muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.bp-kpi-value { font-size: 1.6rem; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.bp-kpi-sub { color: var(--bp-muted); font-size: .8rem; margin-top: 2px; }
.bp-kpi-icon { width: 28px; height: 28px; border-radius: 8px; display: inline-grid; place-items: center; font-size: .8rem; }
.bp-tone-blue { background: var(--bp-primary-50); color: var(--bp-primary); }
.bp-tone-green { background: var(--bp-success-50); color: var(--bp-success); }
.bp-tone-amber { background: var(--bp-warning-50); color: var(--bp-warning); }
.bp-tone-red { background: var(--bp-danger-50); color: var(--bp-danger); }

/* ---------- Quick actions ---------- */
.bp-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.bp-action {
    display: flex; align-items: center; gap: 14px; padding: 18px;
    color: var(--bp-text); text-decoration: none; transition: transform .12s, box-shadow .12s, border-color .12s;
}
.bp-action:hover { transform: translateY(-2px); border-color: #bfdbfe; color: var(--bp-text); box-shadow: 0 8px 24px rgba(37, 99, 235, .12); }
.bp-action-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }
.bp-action strong { display: block; font-size: 1rem; }
.bp-action span { color: var(--bp-muted); font-size: .82rem; }
.bp-action.primary { background: linear-gradient(135deg, var(--bp-primary), #4f46e5); color: #fff; border-color: transparent; }
.bp-action.primary span { color: rgba(255, 255, 255, .8); }
.bp-action.primary .bp-action-icon { background: rgba(255, 255, 255, .18); color: #fff; }
.bp-action.primary:hover { color: #fff; }

/* ---------- Tables ---------- */
.bp-table { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; }
.bp-table th { background: var(--bp-surface-2); color: var(--bp-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--bp-border); white-space: nowrap; }
.bp-table td { padding: 10px 14px; border-bottom: 1px solid var(--bp-border); vertical-align: middle; }
.bp-table tr:last-child td { border-bottom: 0; }
.bp-table tbody tr:hover td { background: #fafcff; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.bp-status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.bp-status.paid { background: var(--bp-success-50); color: var(--bp-success); }
.bp-status.partially-paid { background: var(--bp-warning-50); color: var(--bp-warning); }
.bp-status.unpaid, .bp-status.overdue { background: var(--bp-danger-50); color: var(--bp-danger); }
.bp-status.cancel, .bp-status.return { background: #f1f5f9; color: #475569; text-decoration: line-through; }

/* ---------- 7-day bars ---------- */
.bp-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 150px; padding-top: 10px; }
.bp-bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bp-bar-fill { width: 100%; max-width: 38px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #60a5fa, var(--bp-primary)); min-height: 3px; }
.bp-bar.today .bp-bar-fill { background: linear-gradient(180deg, #34d399, var(--bp-success)); }
.bp-bar-label { font-size: .7rem; color: var(--bp-muted); }

/* =====================================================================
   New Bill screen
   ===================================================================== */
.nb { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; height: calc(100vh - var(--bp-topbar-h) - 32px); }
.nb-left { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.nb-right { display: flex; flex-direction: column; min-height: 0; }

.nb-customer { display: flex; gap: 12px; align-items: center; padding: 12px 14px; flex-wrap: wrap; }
.nb-customer .select2-container { flex: 1; min-width: 240px; }
.nb-customer-info { display: flex; gap: 8px; flex-wrap: wrap; }
.nb-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--bp-surface-2); border: 1px solid var(--bp-border); color: var(--bp-muted); }
.nb-chip.due { background: var(--bp-danger-50); color: var(--bp-danger); border-color: #fecaca; }
.nb-chip.credit { background: var(--bp-success-50); color: var(--bp-success); border-color: #a7f3d0; }
.nb-notes { padding: 8px 14px; background: var(--bp-warning-50); border: 1px solid #fde68a; border-radius: 10px; font-size: .82rem; color: #92400e; }

.nb-search { position: relative; }
.nb-search-input {
    width: 100%; height: 54px; padding: 0 120px 0 50px;
    border: 2px solid var(--bp-border); border-radius: 12px; background: var(--bp-surface);
    font-size: 1.05rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
.nb-search-input:focus { border-color: var(--bp-primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
.nb-search-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--bp-muted); font-size: 1.1rem; }
.nb-search-hint { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--bp-muted); font-size: .75rem; }
.nb-results {
    position: absolute; left: 0; right: 0; top: 60px; z-index: 50; max-height: 360px; overflow-y: auto;
    background: var(--bp-surface); border: 1px solid var(--bp-border); border-radius: 12px; box-shadow: 0 16px 40px rgba(15, 23, 42, .16);
    display: none;
}
.nb-results.open { display: block; }
.nb-result { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--bp-border); }
.nb-result:last-child { border-bottom: 0; }
.nb-result.active, .nb-result:hover { background: var(--bp-primary-50); }
.nb-result-name { font-weight: 600; }
.nb-result-meta { font-size: .75rem; color: var(--bp-muted); }
.nb-result-stock { font-size: .78rem; color: var(--bp-muted); white-space: nowrap; }
.nb-result-stock.low { color: var(--bp-danger); font-weight: 600; }
.nb-result-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.nb-results-empty { padding: 18px; text-align: center; color: var(--bp-muted); }

.nb-cart { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.nb-cart-scroll { flex: 1; overflow-y: auto; }
.nb-cart table { width: 100%; }
.nb-cart th { position: sticky; top: 0; z-index: 1; }
.nb-cart td { padding: 8px 10px; }
.nb-cart input.form-control { height: 34px; padding: 4px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.nb-qty { display: inline-flex; align-items: center; border: 1px solid var(--bp-border); border-radius: 8px; overflow: hidden; }
.nb-qty button { width: 30px; height: 34px; border: 0; background: var(--bp-surface-2); font-weight: 700; color: var(--bp-text); }
.nb-qty button:hover { background: #e2e8f0; }
.nb-qty input { width: 56px; border: 0 !important; border-radius: 0 !important; text-align: center !important; box-shadow: none !important; }
.nb-line-name { font-weight: 600; line-height: 1.25; }
.nb-line-meta { font-size: .72rem; color: var(--bp-muted); }
.nb-line-warn { font-size: .72rem; color: var(--bp-danger); font-weight: 600; }
.nb-row-error td { background: var(--bp-danger-50) !important; }
.nb-remove { border: 0; background: transparent; color: #94a3b8; width: 30px; height: 30px; border-radius: 8px; }
.nb-remove:hover { background: var(--bp-danger-50); color: var(--bp-danger); }
.nb-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--bp-muted); gap: 8px; padding: 40px; text-align: center; }
.nb-empty i { font-size: 2.6rem; color: #cbd5e1; }

.nb-summary { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.nb-summary-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.nb-sum-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; color: var(--bp-muted); }
.nb-sum-row strong { color: var(--bp-text); font-variant-numeric: tabular-nums; }
.nb-sum-row input { width: 120px; text-align: right; }
.nb-total { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0 6px; margin-top: 6px; border-top: 2px dashed var(--bp-border); }
.nb-total span { font-weight: 700; font-size: 1rem; }
.nb-total strong { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.nb-section-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; color: var(--bp-muted); margin: 14px 0 8px; }

.nb-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.nb-method { border: 1px solid var(--bp-border); background: var(--bp-surface); border-radius: 10px; padding: 8px 4px; font-size: .8rem; font-weight: 600; color: var(--bp-text); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nb-method i { font-size: 1rem; color: var(--bp-muted); }
.nb-method.active { border-color: var(--bp-primary); background: var(--bp-primary-50); color: var(--bp-primary); box-shadow: inset 0 0 0 1px var(--bp-primary); }
.nb-method.active i { color: var(--bp-primary); }

.nb-received { height: 52px; font-size: 1.4rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.nb-quick { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.nb-quick button { flex: 1; min-width: 64px; }
.nb-balance { margin-top: 12px; padding: 12px 14px; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.nb-balance.change { background: var(--bp-success-50); color: var(--bp-success); }
.nb-balance.due { background: var(--bp-warning-50); color: var(--bp-warning); }
.nb-balance.error { background: var(--bp-danger-50); color: var(--bp-danger); }
.nb-balance strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.nb-summary-footer { padding: 14px 18px; border-top: 1px solid var(--bp-border); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: var(--bp-surface-2); border-radius: 0 0 var(--bp-radius) var(--bp-radius); }
.nb-summary-footer .btn { height: 50px; font-weight: 700; border-radius: 10px; }
.nb-summary-footer .btn-save-print { grid-column: 1 / -1; height: 56px; font-size: 1.05rem; }
.nb-summary-footer kbd { font-size: .65rem; margin-left: 6px; opacity: .85; }

.nb-shortcuts { display: flex; gap: 16px; flex-wrap: wrap; color: var(--bp-muted); font-size: .75rem; padding: 0 4px; }
.nb-shortcuts kbd { background: #e2e8f0; color: var(--bp-text); padding: 1px 6px; border-radius: 4px; font-size: .7rem; }

.bp-toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.bp-toast { padding: 12px 16px; border-radius: 10px; color: #fff; background: #0f172a; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); max-width: 380px; animation: bpIn .18s ease-out; }
.bp-toast.error { background: var(--bp-danger); }
.bp-toast.success { background: var(--bp-success); }
@keyframes bpIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.nb-success-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--bp-success-50); color: var(--bp-success); display: grid; place-items: center; margin: 0 auto 12px; font-size: 2rem; }

/* Select2 sizing inside the panel */
.bp-body .select2-container--default .select2-selection--single { height: 42px; border: 1px solid var(--bp-border); border-radius: 10px; }
.bp-body .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 40px; padding-left: 12px; }
.bp-body .select2-container--default .select2-selection--single .select2-selection__arrow { height: 40px; }
.bp-body .select2-results__option .s2-sub { font-size: .75rem; color: var(--bp-muted); }

/* ---------- Receipt ---------- */
.rc { max-width: 420px; margin: 0 auto; padding: 24px; font-family: 'Courier New', monospace; }
.rc h2 { font-family: 'Inter', sans-serif; font-size: 1.1rem; font-weight: 800; text-align: center; margin: 0; }
.rc .rc-center { text-align: center; }
.rc .rc-line { border-top: 1px dashed #94a3b8; margin: 10px 0; }
.rc .rc-row { display: flex; justify-content: space-between; gap: 10px; }
.rc .rc-big { font-size: 1.3rem; font-weight: 700; }

@media (max-width: 1100px) {
    .nb { grid-template-columns: 1fr; height: auto; }
    .nb-cart { min-height: 320px; }
}

@media print {
    .bp-topbar, .bp-no-print, .bp-toast-wrap { display: none !important; }
    body.bp-body { background: #fff; }
    .bp-main { padding: 0; }
    .bp-card { box-shadow: none; border-color: #cbd5e1; }
}

/* =====================================================================
   Auth pages (login, access denied)
   ===================================================================== */
.auth-body { min-height: 100vh; margin: 0; font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; background: radial-gradient(1200px 600px at 10% -10%, #1e3a8a 0%, transparent 60%), radial-gradient(900px 600px at 110% 110%, #065f46 0%, transparent 55%), #0f172a; }
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-logo { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 1.3rem; background: linear-gradient(135deg, #3b82f6, #10b981); }
.auth-company { font-weight: 800; font-size: 1.05rem; color: #0f172a; }
.auth-tagline { font-size: .8rem; color: #64748b; }
.auth-title { font-size: 1.5rem; font-weight: 800; margin: 0 0 4px; color: #0f172a; }
.auth-subtitle { color: #64748b; margin-bottom: 22px; font-size: .9rem; }
.auth-footer { color: rgba(255, 255, 255, .5); font-size: .8rem; margin-top: 18px; }
.auth-denied-icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; background: #fef2f2; color: #dc2626; font-size: 1.8rem; }

/* ---------- Panel switcher (shared partial; full styles live in app.css) ---------- */
.shell-panel-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: .82rem; border: 1px solid var(--bp-border); background: #fff; color: var(--bp-text); }
.shell-panel-btn.dark { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); color: #fff; }
.shell-panel-btn.dark:hover { background: rgba(255, 255, 255, .14); }
.shell-panel-menu { min-width: 300px; padding: 8px; border: 1px solid var(--bp-border); border-radius: 12px; box-shadow: 0 20px 50px rgba(15, 23, 42, .18); }
.shell-panel-item { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 9px; color: var(--bp-text); text-decoration: none; }
.shell-panel-item:hover { background: var(--bp-surface-2); color: var(--bp-text); }
.shell-panel-item.current { background: var(--bp-primary-50); }
.shell-panel-item .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.shell-panel-item strong { display: block; font-size: .9rem; }
.shell-panel-item small { color: var(--bp-muted); font-size: .76rem; }
.tone-blue { background: var(--bp-primary-50); color: var(--bp-primary); }
.tone-green { background: var(--bp-success-50); color: var(--bp-success); }
.tone-violet { background: #f5f3ff; color: #7c3aed; }
@media (max-width: 767.98px) { .shell-panel-btn span { display: none; } }

/* ---------- Small screens: icon-only tabs ---------- */
@media (max-width: 991.98px) {
    .bp-topbar { gap: 12px; padding: 0 12px; }
    .bp-brand-text, .bp-nav kbd { display: none; }
    .bp-user .dropdown-toggle .d-lg-inline { display: none; }
}
@media (max-width: 767.98px) {
    .bp-nav { justify-content: space-around; }
    .bp-nav a { flex-direction: column; gap: 2px; padding: 6px 10px; font-size: .65rem; }
    .bp-nav a i { font-size: 1.05rem; }
    .bp-nav-label { white-space: nowrap; }
    .bp-main { padding: 12px; }
}

/* Toasts sit under the top bar so they never cover the Save / Pay buttons */
.bp-toast-wrap { top: calc(var(--bp-topbar-h) + 12px); bottom: auto; }
@media (max-width: 575.98px) {
    .bp-brand { display: none; }
    .bp-topbar { gap: 6px; padding: 0 8px; }
    .bp-nav { gap: 0; }
    .bp-nav a { padding: 6px 4px; min-width: 64px; font-size: .62rem; }
    .bp-user { gap: 6px; }
    .bp-user .shell-panel-btn { padding: 0 9px; }
    .bp-user .shell-panel-btn .fa-chevron-down, .bp-user .dropdown-toggle::after { display: none; }
    .bp-avatar { margin-right: 0; }
}
