/* Shop POS - base theme. Navy sidebar, blue actions, light-gray canvas, white cards. */
:root {
    --navy: #0b1f3f;
    --navy-2: #14305c;
    --blue: #2563eb;
    --blue-soft: #e8f0fe;
    --bg: #f1f4f9;
    --card: #ffffff;
    --text: #1b2437;
    --muted: #64708a;
    --border: #e1e6ef;
    --green: #16a34a;
    --orange: #ea7a0c;
    --red: #dc2626;
    --sidebar-w: 268px;
    --radius: 12px;
    --bs-primary: var(--blue);
    --bs-primary-rgb: 37, 99, 235;
    --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); overflow-x: hidden; font-size: .95rem; }
.btn-primary { --bs-btn-bg: var(--blue); --bs-btn-border-color: var(--blue); --bs-btn-hover-bg: #1d4ed8; --bs-btn-hover-border-color: #1d4ed8; --bs-btn-active-bg: #1e40af; }
.btn, .form-control, .form-select { border-radius: 10px; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .45); outline-offset: 2px; }

/* Layout */
.app { min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); height: 100vh; height: 100dvh;
    background: var(--navy); color: #c5cee0; display: flex; flex-direction: column; z-index: 1040;
    transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.25rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, .08); flex: none; }
.brand-name { font-weight: 650; font-size: 1.05rem; line-height: 1.2; overflow-wrap: anywhere; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 1.15rem; flex: none; }
.brand-mark.lg { width: 56px; height: 56px; font-size: 1.6rem; margin: 0 auto .75rem; }
.brand-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.sidebar-nav { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: .5rem .75rem 1.5rem; -webkit-overflow-scrolling: touch; }
.nav-heading { font-size: .75rem; font-weight: 600; color: #7e8cab; padding: 1.1rem .75rem .35rem; letter-spacing: .02em; }
.nav-link-item { display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; margin: 1px 0; border-radius: 10px; color: #c5cee0; text-decoration: none; min-height: 44px; }
.nav-link-item i { font-size: 1.1rem; width: 1.25rem; text-align: center; flex: none; }
.nav-link-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link-item.active { background: var(--blue); color: #fff; }
.nav-link-item.disabled { opacity: .5; cursor: default; }
.nav-link-item.disabled:hover { background: transparent; color: #c5cee0; }
.soon { margin-left: auto; font-style: normal; font-size: .68rem; background: rgba(255, 255, 255, .12); border-radius: 999px; padding: .1rem .5rem; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(8, 15, 33, .55); z-index: 1035; opacity: 0; visibility: hidden; transition: opacity .2s; }
.main { margin-left: var(--sidebar-w); min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--border); min-height: 64px; }
.topbar-title { font-size: 1.2rem; font-weight: 650; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 1.5rem 1.25rem 3rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.icon-btn { border: 0; background: transparent; font-size: 1.6rem; line-height: 1; width: 44px; height: 44px; border-radius: 10px; color: var(--navy); }
.icon-btn:hover { background: var(--bg); }
.user-chip { display: flex; align-items: center; gap: .6rem; background: transparent; border: 1px solid var(--border); border-radius: 999px; padding: .25rem .75rem .25rem .3rem; color: var(--text); }
.user-chip::after { margin-left: .25rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 600; }
.user-meta { text-align: left; line-height: 1.15; }
.user-meta small { display: block; color: var(--muted); font-size: .75rem; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
    body.nav-open .sidebar-backdrop { opacity: 1; visibility: visible; }
    body.nav-open { overflow: hidden; }
    .main { margin-left: 0; }
    .topbar { padding: .6rem .75rem; }
    .content { padding: 1rem .85rem 2.5rem; }
}
@media (max-width: 575.98px) {
    .sidebar { width: min(86vw, var(--sidebar-w)); }
}

/* Cards and panels */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.panel-title { font-size: 1.05rem; font-weight: 650; margin-bottom: 1rem; }
.section-title { font-size: 1rem; font-weight: 650; margin: 1.25rem 0 .5rem; }
.panel.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.panel.empty i { font-size: 2.5rem; color: var(--blue); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 1rem; }
.stat-card { display: flex; align-items: center; gap: 1rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.15rem; min-width: 0; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex: none; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.tone-blue .stat-icon { background: var(--blue-soft); color: var(--blue); }
.tone-navy .stat-icon { background: #e4e9f3; color: var(--navy-2); }
.tone-green .stat-icon { background: #e1f6e8; color: var(--green); }
.tone-orange .stat-icon { background: #fdeedb; color: var(--orange); }
.tone-red .stat-icon { background: #fde6e6; color: var(--red); }

.checklist { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .6rem; }
.checklist li { display: flex; align-items: center; gap: .65rem; }
.checklist i { color: #a5aec2; font-size: 1.15rem; }
.checklist li.done i { color: var(--green); }
.checklist li.done span { color: var(--muted); text-decoration: line-through; }

/* Forms */
.form-label { font-weight: 550; font-size: .88rem; margin-bottom: .3rem; }
.form-actions { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 1rem 0 .25rem; margin-top: 1rem; }
.settings-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: thin; }
.settings-tabs .nav-link { white-space: nowrap; color: var(--text); background: var(--card); border: 1px solid var(--border); margin-right: .4rem; }
.settings-tabs .nav-link.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.logo-row { display: flex; gap: 1rem; align-items: flex-start; }
.logo-preview { width: 72px; height: 72px; object-fit: contain; border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 4px; flex: none; }
.table > :not(caption) > * > * { padding: .7rem .75rem; }
.table thead th { font-size: .8rem; color: var(--muted); font-weight: 600; background: #f7f9fc; border-bottom: 1px solid var(--border); white-space: nowrap; }

/* Auth / install */
.auth-body { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, #1d4ed8 140%); min-height: 100vh; }
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 16px; padding: 2rem 1.75rem; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.auth-card.wide { max-width: 680px; }
.auth-head { text-align: center; margin-bottom: 1.25rem; }
.auth-head h1 { font-size: 1.45rem; font-weight: 700; margin-bottom: .25rem; }
.auth-head p { color: var(--muted); margin: 0; }
.error-code { font-size: 4.5rem; font-weight: 800; color: var(--navy); line-height: 1; margin-bottom: .75rem; }
.req-list { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .35rem; }
.req-list li { display: flex; align-items: center; gap: .6rem; }
.req-list small { margin-left: auto; color: var(--muted); }
.req-list .ok i { color: var(--green); }
.req-list .fail i { color: var(--red); }

/* Feedback */
.loading-overlay { position: fixed; inset: 0; background: rgba(255, 255, 255, .6); display: grid; place-items: center; z-index: 2000; }
.loading-overlay[hidden] { display: none; }

/* Touch devices */
@media (pointer: coarse) {
    .btn, .form-control, .form-select, .dropdown-item { min-height: 46px; }
    .form-check-input { width: 1.25rem; height: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .sidebar, .topbar, .sidebar-backdrop, .form-actions { display: none !important; } .main { margin: 0; } }

/* ---- Lists, filters and detail pages ---- */
.page-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; flex: 1 1 520px; min-width: 0; }
.filter-bar .form-select { width: auto; flex: 0 1 180px; }
.filter-bar .search-wide, .search-form { flex: 1 1 260px; min-width: 0; max-width: 460px; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.empty-cell { text-align: center; color: var(--muted); padding: 2.25rem 1rem !important; }
.min-w-0 { min-width: 0; }
.prod-cell { display: flex; align-items: center; gap: .75rem; min-width: 190px; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #eef1f7; flex: none; }
.thumb.ph { display: grid; place-items: center; color: #9aa6bd; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-top: 1rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv-wide { grid-template-columns: max-content 1fr; }
.image-drop { aspect-ratio: 4 / 3; border: 1px dashed var(--border); border-radius: 12px; background: #f7f9fc; display: grid; place-items: center; overflow: hidden; text-align: center; }
.image-drop img { width: 100%; height: 100%; object-fit: contain; }
.inline-edit { min-width: 160px; }
.table-hover > tbody > tr:hover > * { background: #f7f9fc; }
code { color: var(--navy-2); background: #eef2fa; padding: .1rem .35rem; border-radius: 6px; }
@media (max-width: 575.98px) {
    .filter-bar .form-select { flex: 1 1 140px; }
    .page-actions > .btn-row { width: 100%; }
    .page-actions > .btn-row .btn { flex: 1 1 auto; }
}

/* ---- POS ---- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 1rem; align-items: start; }
.pos-products { min-width: 0; }
.pos-search { margin-bottom: .75rem; }
.chip-row { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .5rem; scrollbar-width: thin; }
.chip { border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: .45rem 1rem; white-space: nowrap; min-height: 40px; color: var(--text); }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; transition: opacity .15s; }
.pos-grid.loading { opacity: .5; }
.pcard { display: flex; flex-direction: column; gap: .35rem; text-align: left; padding: .6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); min-height: 150px; }
.pcard:hover:not(:disabled) { border-color: var(--blue); box-shadow: 0 2px 10px rgba(37, 99, 235, .15); }
.pcard:active:not(:disabled) { transform: scale(.98); }
.pcard img, .pcard .pimg { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: #eef1f7; display: grid; place-items: center; color: #9aa6bd; font-size: 1.6rem; }
.pname { font-weight: 600; font-size: .88rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pmeta { display: flex; justify-content: space-between; align-items: center; gap: .25rem; margin-top: auto; font-size: .85rem; }
.pstock { font-size: .72rem; padding: .1rem .45rem; border-radius: 999px; background: #e1f6e8; color: #166534; white-space: nowrap; }
.pstock.low { background: #fdeedb; color: #9a5200; } .pstock.out { background: #fde6e6; color: #b91c1c; }
.pcard.is-out { opacity: .55; }
.pos-cart { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; position: sticky; top: 80px; max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px); }
.cart-head { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.cart-head h2 { font-size: 1.05rem; font-weight: 650; margin: 0; }
.cart-body { padding: .75rem 1rem; overflow-y: auto; flex: 1 1 auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: .75rem; }
.cart-foot { padding: .75rem 1rem; border-top: 1px solid var(--border); }
.cust-chip { display: flex; align-items: center; justify-content: space-between; gap: .5rem; background: var(--blue-soft); border-radius: 10px; padding: .5rem .75rem; }
.pick-list { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(11, 31, 63, .15); max-height: 280px; overflow-y: auto; margin-top: 4px; }
.cust-box { position: relative; }
.pick-item { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; border: 0; background: transparent; padding: .6rem .8rem; min-height: 46px; }
.pick-item:hover { background: var(--blue-soft); }
.pick-item small { color: var(--muted); }
.cart-empty { text-align: center; color: var(--muted); padding: 1.5rem 0; }
.cart-empty i { font-size: 2.2rem; }
.cline { border-bottom: 1px solid var(--border); padding-bottom: .6rem; }
.cline-top { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.cname { font-weight: 600; font-size: .9rem; }
.cline-grid { display: grid; grid-template-columns: auto 1fr; gap: .4rem .75rem; align-items: center; }
.qty-ctl { display: flex; }
.qty-ctl .btn { width: 40px; padding: 0; }
.qty-ctl .btn:first-child { border-radius: 10px 0 0 10px; } .qty-ctl .btn:last-child { border-radius: 0 10px 10px 0; }
.qty-in { width: 64px; text-align: center; border-radius: 0; padding-left: .25rem; padding-right: .25rem; }
.cprice { text-align: right; font-size: .85rem; }
.disc-in { max-width: 100px; }
.cline-total { text-align: right; font-weight: 700; }
.row-line { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.row-line.grand { font-size: 1.25rem; padding-top: .5rem; border-top: 2px solid var(--navy); }
.money-in { max-width: 120px; text-align: right; }
.pay-box { background: #f7f9fc; border: 1px solid var(--border); border-radius: 10px; padding: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.pay-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; }
.pay-row { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(90px, 1fr) auto; gap: .4rem; margin-bottom: .4rem; }
.pos-cart-toggle { display: none; }
.done-icon { font-size: 3.5rem; color: var(--green); line-height: 1; }
.totals-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; }
.totals-list .grand { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--navy); margin-top: .35rem; padding-top: .55rem; }
.row-muted > * { color: var(--muted) !important; text-decoration: line-through; text-decoration-color: rgba(100, 112, 138, .4); }
.row-muted .badge { text-decoration: none; }
.range-inputs { display: inline-flex; gap: .5rem; flex-wrap: wrap; }
.range-inputs[hidden] { display: none; }
.range-inputs .form-control { width: 150px; }
.pf-side { position: sticky; top: 80px; }
.pf-side .money-in { max-width: 130px; }

@media (max-width: 991.98px) {
    .pos { display: block; padding-bottom: 76px; }
    .pos-cart { position: fixed; inset: 0; z-index: 1050; max-height: none; border-radius: 0; transform: translateY(100%); transition: transform .25s ease; visibility: hidden; }
    .pos-cart.open { transform: none; visibility: visible; }
    .pos-cart-toggle { display: flex; justify-content: space-between; align-items: center; position: fixed; left: .75rem; right: .75rem; bottom: calc(.75rem + env(safe-area-inset-bottom, 0px)); z-index: 1030;
        background: var(--navy); color: #fff; border: 0; border-radius: 14px; padding: .9rem 1.1rem; font-size: 1.05rem; box-shadow: 0 8px 24px rgba(11, 31, 63, .35); min-height: 56px; }
    body.cart-open { overflow: hidden; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .pf-side { position: static; }
}
@media (max-width: 575.98px) {
    .pay-row { grid-template-columns: 1fr 1fr auto; }
    .range-inputs .form-control { width: 100%; }
}

/* ---- Reports, bars, print ---- */
.print-title { display: none; margin-bottom: .75rem; font-size: 1rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: .75rem; align-items: center; margin-bottom: .5rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #eaeef6; border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
@media print {
    .no-print { display: none !important; }
    .print-title { display: block; }
    .content { padding: 0 !important; max-width: none; }
    .panel, .stat-card { border-color: #bbb; box-shadow: none; }
    body { background: #fff; }
    .table-responsive { overflow: visible !important; }
}

/* ---- Reports ---- */
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 380px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.report-card { display: flex; gap: 1rem; align-items: flex-start; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; color: var(--text); text-decoration: none; }
.report-card:hover { border-color: var(--blue); box-shadow: 0 2px 10px rgba(37, 99, 235, .12); }
.report-card p { margin: .2rem 0 0; color: var(--muted); font-size: .85rem; }
.report-card .stat-icon { background: var(--blue-soft); color: var(--blue); }
.mini-chart { position: relative; height: 240px; }
.dl-table th { width: 55%; font-weight: 500; color: var(--text); }
.section-head td { background: #f1f4f9; font-weight: 700; color: var(--navy-2); }
@media print { .chart-box { height: 260px; } .chart-box canvas { max-width: 100% !important; } }
a.stat-card.linked { color: inherit; text-decoration: none; }
a.stat-card.linked:hover { border-color: var(--blue); }

/* ---- Administration ---- */
.danger-zone { border-color: #f1b4b4; background: #fffafa; }
.reset-opt { padding: .9rem 1.1rem; }
.reset-opt-strong { background: #fff6f6; }
.perm-matrix th, .perm-matrix td { white-space: nowrap; }
.perm-matrix thead th { position: sticky; top: 0; }
.perm-matrix .form-check-input { width: 1.2rem; height: 1.2rem; cursor: pointer; }

/* ---- Language switch, offline bar, install ---- */
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--card); }
.lang-switch button { border: 0; background: transparent; padding: .35rem .7rem; font-size: .8rem; font-weight: 600; color: var(--muted); min-height: 36px; }
.lang-switch button.active { background: var(--navy); color: #fff; }
.auth-lang { position: fixed; top: .75rem; right: .75rem; z-index: 5; }
.auth-install-wrap { text-align: center; margin: 1rem 0 0; }
.auth-install { color: #cbd5e1; text-decoration: none; }
.offline-bar { position: sticky; top: 0; z-index: 3000; background: #b45309; color: #fff; text-align: center; padding: .5rem 1rem; font-size: .9rem; }
.offline-bar[hidden] { display: none; }
@media print { .lang-switch, .offline-bar { display: none !important; } }
