/* ===== Modules added for the web version: toasts, bell, orders, suppliers, barcode, admin ===== */

/* ---------- Shell additions ---------- */
body:not(.ready):not(.auth-page) .content { visibility: hidden; }
.user-name { display: flex; flex-direction: column; line-height: 1.2; }
.user-name small { font-size: 11px; color: var(--muted); font-weight: 500; }
.user-chip.no-link { pointer-events: none; }
.topbar-link { font-size: 13px; font-weight: 600; color: var(--brand-primary); padding: 7px 12px; border-radius: 8px; background: var(--brand-primary-light); }
.topbar-link:hover { background: var(--brand-primary); color: var(--white); }
.btn-danger-solid { background: var(--danger); color: var(--white); }
.btn-danger-solid:hover { background: #b91c1c; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.input-error { border-color: var(--danger) !important; }
.confirm-text { color: var(--muted); line-height: 1.5; }
.text-right, .num { text-align: right; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.link { color: var(--brand-primary); font-weight: 600; }
.link:hover { text-decoration: underline; }
.mt { margin-top: 16px; }
.inline-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-fields .form-group { flex: 1; min-width: 140px; margin: 0; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox-row input { width: auto; }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--muted); }

/* ---------- Toasts ---------- */
.toast-box { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 8px; color: var(--white); font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.18); transition: opacity .3s; max-width: 340px; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast.hide { opacity: 0; }

/* ---------- Notification bell (admin) ---------- */
.bell-wrap { position: relative; }
.bell-btn { background: none; border: none; font-size: 20px; cursor: pointer; position: relative; padding: 4px 8px; }
.bell-count { position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 6px; }
.bell-panel { display: none; position: absolute; right: 0; top: 40px; width: 340px; max-height: 420px; overflow-y: auto; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 30px rgba(0,0,0,.15); z-index: 70; }
.bell-panel.open { display: block; }
.bell-head { padding: 12px 16px; font-weight: 700; border-bottom: 1px solid var(--border); }
.bell-item { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.bell-item.unread { background: var(--brand-primary-light); }
.bell-item span { color: var(--muted); font-size: 13px; }
.bell-item small { color: var(--muted); font-size: 11px; }
.bell-empty { padding: 20px; text-align: center; color: var(--muted); }

/* ---------- Auth pages ---------- */
.auth-card.wide { max-width: 520px; }
.auth-card .form-grid { gap: 0 14px; }
.auth-links { margin-top: 16px; text-align: center; font-size: 13px; color: var(--muted); }
.auth-links a { color: var(--brand-primary); font-weight: 600; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.install-card { max-width: 560px; }
.install-section { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.install-section h3 { font-size: 14px; margin-bottom: 4px; }

/* ---------- Status badges ---------- */
.badge-pending { background: var(--warning-light); color: var(--warning); }
.badge-approved, .badge-active { background: var(--success-light); color: var(--success); }
.badge-rejected, .badge-suspended, .badge-disabled { background: var(--danger-light); color: var(--danger); }

/* ---------- Date range ---------- */
.range-bar { display: none; gap: 10px; align-items: flex-end; flex-wrap: wrap; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; }
.range-bar.show { display: flex; }
.range-bar .form-group { margin: 0; }
.range-bar input { width: 170px; }
.page-header .segmented { flex-wrap: wrap; }

/* ---------- Customer autocomplete (POS) ---------- */
.customer-box { position: relative; }
.customer-picked { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--brand-primary-light); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.customer-picked .btn-small { padding: 3px 8px; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 40; background: var(--white); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 24px rgba(0,0,0,.12); margin-top: 4px; max-height: 260px; overflow-y: auto; }
.suggest-item { display: flex; justify-content: space-between; gap: 8px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; }
.suggest-item:hover, .suggest-item.active { background: var(--brand-primary-light); }
.suggest-item small { color: var(--muted); display: block; }
.suggest-empty { padding: 12px; color: var(--muted); font-size: 13px; }
.scan-input { font-size: 15px; font-weight: 600; letter-spacing: .5px; }
.scan-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.scan-flash { animation: flash 0.6s; }
@keyframes flash { 0% { background: var(--success-light); } 100% { background: var(--white); } }

/* ---------- Price check ---------- */
.price-check { max-width: 640px; margin: 0 auto; }
.price-result { text-align: center; padding: 28px 16px; }
.price-result .price-big { font-size: 56px; font-weight: 800; color: var(--brand-primary); line-height: 1.1; }
.price-result .price-name { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.price-result .price-meta { color: var(--muted); margin-top: 8px; }

/* ---------- Barcode labels ---------- */
.label-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.label-sheet { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; background: var(--white); border: 1px dashed var(--border); border-radius: var(--radius); min-height: 80px; }
.label { width: 200px; border: 1px solid #d1d5db; padding: 6px 8px; text-align: center; background: #fff; color: #000; page-break-inside: avoid; break-inside: avoid; }
.label-name { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-price { font-size: 12px; font-weight: 700; }
.label .barcode-svg { width: 100%; height: 44px; display: block; margin: 3px 0 0; }
.label-code { font-size: 10px; letter-spacing: 1px; }
.pick-col { width: 36px; }
.pick-col input { width: auto; }
.copies { width: 70px; }

/* ---------- Orders ---------- */
.order-lines { display: flex; flex-direction: column; gap: 10px; }
.order-line { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; padding: 12px; background: var(--bg); border-radius: 10px; }
.order-line .form-group { margin: 0; }
.order-line .new-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.order-total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; padding: 14px 0; }
.line-total { font-weight: 700; padding: 10px 0; }

/* ---------- Suppliers ---------- */
.supplier-head { display: flex; gap: 14px; justify-content: space-between; flex-wrap: wrap; align-items: flex-start; }
.order-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.order-card-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { background: none; border: none; padding: 10px 16px; font-weight: 600; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; font-family: inherit; font-size: 14px; }
.tabs button.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }

/* ---------- Admin ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; margin: 14px 0; }
.detail-grid dt { font-size: 12px; color: var(--muted); }
.detail-grid dd { font-weight: 600; margin-bottom: 6px; word-break: break-word; }
.note-box { background: var(--warning-light); border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 13px; }

@media (max-width: 900px) {
    .order-line { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .bell-panel { position: fixed; left: 12px; right: 12px; top: 60px; width: auto; }
    .range-bar input { width: 100%; }
    .range-bar .form-group { flex: 1; min-width: 140px; }
}

/* ---------- Print: barcode labels ---------- */
@media print {
    .label-sheet, .label-sheet * { visibility: visible; }
    .label-sheet { position: absolute; left: 0; top: 0; width: 100%; border: none; padding: 0; gap: 4px; }
    .modal-box { box-shadow: none; max-height: none; overflow: visible; }
}

/* ---------- Invoice paper sizes (Account > Invoice size) ---------- */
.invoice.size-a5 { font-size: 11px; max-width: 148mm; margin: 0 auto; }
.invoice.size-a5 .invoice-logo { width: 48px; height: 48px; }
.invoice.size-letter { max-width: 8.5in; margin: 0 auto; }
.invoice.size-thermal80, .invoice.size-thermal58 { margin: 0 auto; font-size: 11px; }
.invoice.size-thermal80 { max-width: 80mm; }
.invoice.size-thermal58 { max-width: 58mm; font-size: 10px; }
.invoice.size-thermal80 .invoice-head, .invoice.size-thermal58 .invoice-head { flex-direction: column; align-items: flex-start; gap: 8px; padding-bottom: 8px; border-bottom-width: 2px; }
.invoice.size-thermal80 .invoice-title, .invoice.size-thermal58 .invoice-title { text-align: left; }
.invoice.size-thermal80 .invoice-title h2, .invoice.size-thermal58 .invoice-title h2 { font-size: 15px; }
.invoice.size-thermal80 .invoice-logo, .invoice.size-thermal58 .invoice-logo { width: 40px; height: 40px; }
.invoice.size-thermal80 .invoice-meta, .invoice.size-thermal58 .invoice-meta { flex-direction: column; gap: 8px; }
.invoice.size-thermal80 .invoice-block.right, .invoice.size-thermal58 .invoice-block.right { text-align: left; }
.invoice.size-thermal80 .invoice-bottom, .invoice.size-thermal58 .invoice-bottom { flex-direction: column; gap: 8px; }
.invoice.size-thermal80 .invoice-totals, .invoice.size-thermal58 .invoice-totals { width: 100%; min-width: 0; }
.invoice.size-thermal80 .invoice-table th, .invoice.size-thermal80 .invoice-table td,
.invoice.size-thermal58 .invoice-table th, .invoice.size-thermal58 .invoice-table td { padding: 4px 3px; }
.invoice.size-thermal58 .invoice-table th:first-child, .invoice.size-thermal58 .invoice-table td:first-child { display: none; }
.invoice.size-thermal80 .stamp, .invoice.size-thermal58 .stamp { font-size: 12px; padding: 3px 8px; }
@media print {
    .invoice.size-a5, .invoice.size-letter, .invoice.size-thermal80, .invoice.size-thermal58 { max-width: none; margin: 0; }
    .invoice.size-thermal80 { width: 80mm; }
    .invoice.size-thermal58 { width: 58mm; }
}

/* ----- Top-bar calculator ----- */
.calc-wrap { position: relative; }
.calc-btn { width: 38px; height: 38px; border: 1px solid var(--border, #dde3ee); background: #fff; border-radius: 10px; font-size: 18px; cursor: pointer; }
.calc-btn:hover { background: #f1f6ff; }
.calc-panel { display: none; position: absolute; right: 0; top: 46px; width: 260px; background: #fff; border: 1px solid #dde3ee; border-radius: 14px; box-shadow: 0 12px 32px rgba(8, 32, 63, .18); padding: 12px; z-index: 60; }
.calc-panel.open { display: block; }
.calc-hist { min-height: 18px; text-align: right; font-size: 12px; color: #6b7686; }
.calc-display { text-align: right; font-size: 28px; font-weight: 700; padding: 4px 4px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-key { height: 44px; border: 0; border-radius: 10px; background: #f1f4f9; font-size: 17px; font-weight: 600; cursor: pointer; }
.calc-key:hover { background: #e3e9f3; }
.calc-key.fn { background: #e8eef8; color: #08203f; }
.calc-key.op { background: #dcebff; color: #0770EF; }
.calc-key.zero { grid-column: span 2; }
.calc-key.eq { background: #0770EF; color: #fff; }
.calc-key.eq:hover { background: #0560c9; }
@media (max-width: 640px) { .calc-panel { position: fixed; right: 12px; left: 12px; top: 60px; width: auto; } }
