/* Tech Plus - AM Digital */

@font-face { font-family: "Vazirmatn"; src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("../fonts/Vazirmatn-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("../fonts/Vazirmatn-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
    --tp-primary: #2563eb;
    --tp-primary-dark: #1d4ed8;
    --tp-side: #0f172a;
    --tp-side-2: #1e293b;
    --tp-side-text: #94a3b8;
    --tp-bg: #f1f5f9;
    --tp-border: #e2e8f0;
    --tp-text: #0f172a;
    --tp-muted: #64748b;
    --tp-radius: 14px;
    --sidebar-w: 240px;

    --bs-primary: var(--tp-primary);
    --bs-primary-rgb: 37, 99, 235;
    --bs-body-font-family: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
    --bs-body-color: var(--tp-text);
    --bs-body-bg: var(--tp-bg);
    --bs-border-color: var(--tp-border);
}

html { font-size: 14px; }
@media (min-width: 1680px) { html { font-size: 15px; } }
body { font-size: 1rem; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
kbd { font-family: inherit; font-size: .7rem; padding: .1rem .35rem; background: rgba(255,255,255,.2); }

.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { --bs-btn-bg: var(--tp-primary); --bs-btn-border-color: var(--tp-primary); --bs-btn-hover-bg: var(--tp-primary-dark); --bs-btn-hover-border-color: var(--tp-primary-dark); }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; padding: 0; }
.form-control, .form-select, .input-group-text { border-radius: 10px; }
.form-control:focus, .form-select:focus { border-color: #93c5fd; box-shadow: 0 0 0 .2rem rgba(37,99,235,.15); }
.form-label { font-weight: 500; font-size: .9rem; margin-bottom: .3rem; }
.form-control, .form-select { padding-top: .45rem; padding-bottom: .45rem; }
.form-control-lg, .input-group-lg > .form-control, .input-group-lg > .btn, .input-group-lg > .input-group-text { font-size: 1.1rem; padding-top: .55rem; padding-bottom: .55rem; }

/* ---------- layout ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--tp-side); color: var(--tp-side-text);
    display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0; z-index: 1040;
    transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; display: grid; place-items: center; font-size: 1.35rem; }
.brand-name { color: #fff; font-weight: 700; font-size: 1.1rem; line-height: 1.2; }
.brand-shop { font-size: .78rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .75rem 1rem; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.nav-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; padding: 1rem .75rem .35rem; font-weight: 600; }
.sidebar .nav-link { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: 10px; color: var(--tp-side-text); font-weight: 500; margin-bottom: 2px; }
.sidebar .nav-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.sidebar .nav-link:hover { background: var(--tp-side-2); color: #e2e8f0; }
.sidebar .nav-link.active { background: var(--tp-primary); color: #fff; box-shadow: 0 6px 16px -6px rgba(37,99,235,.6); }
.sidebar-foot { font-size: .72rem; padding: .85rem 1.25rem; border-top: 1px solid rgba(255,255,255,.06); color: #64748b; }

.main { flex: 1; min-width: 0; margin-inline-start: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem;
    height: 58px; padding: 0 1.5rem;
    background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--tp-border);
}
.page-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .5rem; }
.lang-btn { min-width: 52px; font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: .5rem; background: none; border: 0; padding: .25rem .5rem; border-radius: 10px; color: var(--tp-text); font-weight: 500; }
.user-chip:hover { background: var(--tp-bg); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #dbeafe; color: var(--tp-primary); display: inline-grid; place-items: center; font-weight: 700; }
.avatar-xl { width: 84px; height: 84px; font-size: 2rem; display: grid; }

.content { padding: 1.5rem; flex: 1; }

.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: none; }
    .main { margin-inline-start: 0; }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1035; }
    .content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
}

/* ---------- cards & panels ---------- */

.panel { background: #fff; border: 1px solid var(--tp-border); border-radius: var(--tp-radius); padding: 1.25rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.panel-head h3 { font-size: 1rem; font-weight: 700; margin: 0; }

.stat-card { background: #fff; border: 1px solid var(--tp-border); border-radius: var(--tp-radius); padding: 1.1rem 1.25rem; height: 100%; position: relative; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; margin-bottom: .75rem; }
.stat-label { color: var(--tp-muted); font-size: .82rem; font-weight: 500; }
.stat-value { font-size: 1.3rem; font-weight: 700; margin: .15rem 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-note { font-size: .78rem; color: var(--tp-muted); }

.table { --bs-table-bg: transparent; }
.table > thead th { font-size: .78rem; font-weight: 600; color: var(--tp-muted); background: #f8fafc; border-bottom: 1px solid var(--tp-border); white-space: nowrap; }
.table td { border-color: #f1f5f9; }

.badge-soft-success { color: #15803d !important; }
.badge-soft-warning { color: #b45309 !important; }
.badge-soft-info { color: #0369a1 !important; }

.empty-state { text-align: center; color: var(--tp-muted); padding: 2rem 1rem; }
.empty-state > i, .empty-icon { font-size: 2.5rem; opacity: .5; }
.empty-state p { margin: .5rem 0 0; }

/* bar chart */
.bar-chart { display: flex; align-items: flex-end; gap: .75rem; height: 230px; padding-top: .5rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar-value { font-size: .7rem; color: var(--tp-muted); height: 1.1rem; white-space: nowrap; }
.bar-track { flex: 1; width: 100%; max-width: 46px; display: flex; align-items: flex-end; background: #f8fafc; border-radius: 8px; }
.bar { width: 100%; background: #bfdbfe; border-radius: 8px; transition: height .4s ease; }
.bar-col.is-today .bar { background: var(--tp-primary); }
.bar-col:hover .bar { background: #60a5fa; }
.bar-label { font-size: .75rem; color: var(--tp-muted); text-align: center; margin-top: .4rem; line-height: 1.2; }
.bar-col.is-today .bar-label { color: var(--tp-primary); font-weight: 600; }

/* quick actions */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.quick-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; padding: 1rem .5rem; border: 1px solid var(--tp-border); border-radius: 12px; color: var(--tp-text); font-weight: 500; font-size: .85rem; transition: all .15s; }
.quick-item i { font-size: 1.5rem; color: var(--tp-primary); }
.quick-item:hover { border-color: var(--tp-primary); background: #eff6ff; color: var(--tp-primary); }

.mini-stats { margin-top: 1rem; border-top: 1px dashed var(--tp-border); }
.mini-stats > div { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px dashed var(--tp-border); font-size: .875rem; }
.mini-stats > div:last-child { border-bottom: 0; }
.mini-stats span { color: var(--tp-muted); }

/* ---------- login ---------- */

.login-page { background: #fff; }
.login-wrap { display: flex; min-height: 100vh; }
.login-side {
    width: 44%; flex-direction: column; justify-content: space-between;
    padding: 3rem; color: #fff;
    background: radial-gradient(circle at 20% 20%, rgba(99,102,241,.55), transparent 50%),
                radial-gradient(circle at 80% 90%, rgba(37,99,235,.6), transparent 45%),
                var(--tp-side);
}
.login-side h1 { font-size: 2.4rem; font-weight: 700; margin: 1rem 0 .25rem; }
.login-side p { color: #cbd5e1; font-size: 1.05rem; }
.login-logo { width: 60px; height: 60px; border-radius: 16px; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: 1.9rem; color: #fff; }
.login-logo.sm { width: 46px; height: 46px; font-size: 1.4rem; background: linear-gradient(135deg, #3b82f6, #6366f1); }
.login-points { list-style: none; padding: 0; margin: 0; }
.login-points li { display: flex; align-items: center; gap: .75rem; padding: .55rem 0; color: #e2e8f0; font-size: 1rem; }
.login-points i { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.1); display: grid; place-items: center; }
.login-form-area { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: var(--tp-bg); }
.login-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--tp-border); border-radius: 18px; padding: 2rem; box-shadow: 0 20px 45px -25px rgba(15,23,42,.25); }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; }
}

@media (max-width: 575.98px) {
    .stat-card { padding: .9rem 1rem; }
    .stat-value { font-size: 1.05rem; white-space: normal; }
    .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; }
    .bar-chart { gap: .35rem; height: 190px; }
    .bar-value { visibility: hidden; }
    .bar-label { font-size: .65rem; }
}

/* ---------- list pages ---------- */

.min-w-0 { min-width: 0; }
.page-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.code-chip { background: #e0e7ff; color: #3730a3; font-weight: 600; padding: .3rem .75rem; border-radius: 8px; font-size: .85rem; direction: ltr; }

.stat-link { display: block; color: inherit; transition: border-color .15s, transform .15s; }
.stat-link:hover { border-color: #93c5fd; transform: translateY(-1px); color: inherit; }

.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--tp-border); }
.list-toolbar .form-select { width: auto; min-width: 120px; max-width: 175px; }
.search-box { position: relative; flex: 1 1 220px; max-width: 380px; }
.search-box > i { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: .85rem; color: var(--tp-muted); }
.search-box .form-control { padding-inline-start: 2.4rem; padding-inline-end: 2.2rem; background: #f8fafc; }
.search-box .form-control:focus { background: #fff; }
.search-box kbd { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: .6rem; background: #e2e8f0; color: var(--tp-muted); }

.cat-tabs { display: flex; gap: .35rem; overflow-x: auto; padding: .65rem 1.25rem; border-bottom: 1px solid var(--tp-border); scrollbar-width: none; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tabs a { white-space: nowrap; padding: .3rem .85rem; border-radius: 999px; color: var(--tp-muted); font-size: .85rem; font-weight: 500; border: 1px solid transparent; }
.cat-tabs a:hover { background: #f1f5f9; color: var(--tp-text); }
.cat-tabs a.active { background: #eff6ff; color: var(--tp-primary); border-color: #bfdbfe; }

.list-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--tp-border); }
.pagination { --bs-pagination-border-radius: 8px; }

.product-table tbody tr { cursor: pointer; }
.product-table td { padding-top: .65rem; padding-bottom: .65rem; }
.thumb { width: 44px; height: 44px; border-radius: 10px; background: #f1f5f9; display: grid; place-items: center; overflow: hidden; color: #94a3b8; font-size: 1.2rem; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-inactive { opacity: .55; }

.stock-pill { display: inline-block; min-width: 2.6rem; padding: .2rem .6rem; border-radius: 999px; font-weight: 700; font-size: .82rem; text-align: center; }
.stock-pill.ok  { background: #dcfce7; color: #15803d; }
.stock-pill.low { background: #fef3c7; color: #b45309; }
.stock-pill.out { background: #fee2e2; color: #b91c1c; }

/* ---------- product form ---------- */

.condition-toggle .btn { min-width: 130px; }
.spec-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.spec-chip { border: 1px dashed #cbd5e1; background: #fff; color: var(--tp-muted); border-radius: 999px; padding: .2rem .7rem; font-size: .8rem; }
.spec-chip:hover { border-color: var(--tp-primary); color: var(--tp-primary); background: #eff6ff; }
.spec-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: .5rem; margin-bottom: .5rem; }
.spec-row .btn-icon { width: 38px; height: 38px; font-size: 1rem; }

.image-drop { display: grid; place-items: center; width: 100%; max-width: 320px; margin: 0 auto; aspect-ratio: 1; border: 2px dashed #cbd5e1; border-radius: 12px; background: #f8fafc; cursor: pointer; overflow: hidden; transition: border-color .15s; }
.image-drop:hover { border-color: var(--tp-primary); }
.image-drop img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.image-drop-text { text-align: center; color: var(--tp-muted); font-size: .82rem; padding: 1rem; }
.image-drop-text i { display: block; font-size: 2.2rem; color: #94a3b8; margin-bottom: .25rem; }

.margin-note { font-size: .78rem; margin-top: .3rem; font-weight: 500; min-height: 1.1rem; }
.stock-box { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.stock-box > div { background: #f8fafc; border-radius: 10px; padding: .65rem .8rem; }
.stock-box span { display: block; font-size: .75rem; color: var(--tp-muted); }
.stock-box strong { font-size: 1.25rem; }

/* ---------- product view ---------- */

.product-photo { aspect-ratio: 1; border-radius: 14px; background: #f8fafc; display: grid; place-items: center; overflow: hidden; }
.product-photo img { width: 100%; height: 100%; object-fit: contain; }
.product-photo i { font-size: 4rem; color: #cbd5e1; }
.price-big { font-size: 1.6rem; font-weight: 700; color: var(--tp-primary); }
.info-grid, .spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .65rem; }
.info-grid > div, .spec-grid > div { background: #f8fafc; border-radius: 10px; padding: .6rem .8rem; }
.info-grid span, .spec-grid span { display: block; font-size: .75rem; color: var(--tp-muted); }
.info-grid strong, .spec-grid strong { font-weight: 600; }
.spec-grid > div { border-inline-start: 3px solid #93c5fd; }

/* ---------- categories & brands ---------- */

.ps-sub { padding-inline-start: 2rem !important; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; padding: 1.25rem; }
.brand-card { display: flex; align-items: center; gap: .75rem; border: 1px solid var(--tp-border); border-radius: 12px; padding: .75rem; transition: border-color .15s, box-shadow .15s; }
.brand-card:hover { border-color: #bfdbfe; box-shadow: 0 6px 18px -12px rgba(37,99,235,.5); }
.brand-letter { width: 42px; height: 42px; border-radius: 10px; background: linear-gradient(135deg, #eff6ff, #e0e7ff); color: var(--tp-primary); display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; flex-shrink: 0; }

.modal-content { border: 0; border-radius: 16px; }
.modal-header, .modal-footer { border-color: var(--tp-border); }

@media (max-width: 767.98px) {
    .list-toolbar .form-select { flex: 1 1 45%; max-width: none; }
    .spec-row { grid-template-columns: 1fr 1fr auto; }
}

/* ---------- parties (suppliers / customers) ---------- */

.party-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .85rem; padding: 1.25rem; }
.party-card { display: block; border: 1px solid var(--tp-border); border-radius: 14px; padding: 1rem; color: var(--tp-text); transition: all .15s; background: #fff; }
.party-card:hover { border-color: #93c5fd; box-shadow: 0 10px 24px -16px rgba(37,99,235,.55); transform: translateY(-2px); color: var(--tp-text); }
.party-avatar { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, #dbeafe, #e0e7ff); color: var(--tp-primary); display: grid; place-items: center; font-size: 1.5rem; font-weight: 700; flex-shrink: 0; }
.party-avatar.sm { width: 44px; height: 44px; border-radius: 12px; font-size: 1.1rem; }
.party-meta { display: flex; justify-content: space-between; gap: .5rem; margin-top: .85rem; padding-top: .75rem; border-top: 1px dashed var(--tp-border); font-size: .78rem; color: var(--tp-muted); }
.bal { font-size: .8rem; font-weight: 700; padding: .25rem .6rem; border-radius: 8px; white-space: nowrap; }
.bal-owe { background: #fee2e2; color: #b91c1c; }
.bal-adv { background: #dbeafe; color: #1d4ed8; }
.bal-zero { background: #dcfce7; color: #15803d; }

.contact-list > * { display: flex; align-items: center; gap: .65rem; padding: .5rem 0; color: var(--tp-text); border-bottom: 1px dashed var(--tp-border); }
.contact-list > *:last-child { border-bottom: 0; }
.contact-list i { width: 30px; height: 30px; border-radius: 8px; background: #f1f5f9; display: grid; place-items: center; color: var(--tp-muted); flex-shrink: 0; }
.balance-card { background: #f0fdf4; border-color: #bbf7d0; }
.balance-card .stat-icon { background: #dcfce7; color: #15803d; }
.balance-card.is-owe { background: #fef2f2; border-color: #fecaca; }
.balance-card.is-owe .stat-icon { background: #fee2e2; color: #b91c1c; }
.balance-card.is-owe .stat-value { color: #b91c1c; }

.khata-table td { font-size: .88rem; }
.khata-table tfoot th { background: #f8fafc; font-weight: 700; }
.ktype { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; margin-inline-end: .35rem; font-size: .8rem; }
.ktype-purchase { background: #dbeafe; color: #1d4ed8; }
.ktype-payment { background: #dcfce7; color: #15803d; }
.ktype-return { background: #fee2e2; color: #b91c1c; }
.ktype-opening, .ktype-adjustment { background: #f1f5f9; color: #475569; }
.pay-balance { display: flex; justify-content: space-between; align-items: center; background: #fef2f2; border-radius: 12px; padding: .85rem 1rem; }
.pay-balance span { color: #991b1b; }
.pay-balance strong { font-size: 1.3rem; color: #b91c1c; }

/* ---------- purchase entry ---------- */

.item-search { position: relative; padding: 1rem 1.25rem; border-bottom: 1px solid var(--tp-border); background: linear-gradient(180deg, #f8fafc, #fff); border-radius: var(--tp-radius) var(--tp-radius) 0 0; }
.item-search > i { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 2.1rem; font-size: 1.3rem; color: var(--tp-primary); }
.item-search .form-control { padding-inline-start: 3rem; border: 2px solid #bfdbfe; font-size: 1rem; }
.item-search .form-control:focus { border-color: var(--tp-primary); }
.item-search .hint { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: 2.1rem; font-size: .75rem; color: var(--tp-muted); }
.search-results { display: none; position: absolute; z-index: 30; inset-inline: 1.25rem; top: calc(100% - .5rem); background: #fff; border: 1px solid var(--tp-border); border-radius: 12px; box-shadow: 0 18px 40px -18px rgba(15,23,42,.35); max-height: 360px; overflow-y: auto; }
.search-results.show { display: block; }
.sr-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; border: 0; background: none; padding: .65rem 1rem; text-align: start; border-bottom: 1px solid #f1f5f9; }
.sr-item:hover, .sr-item.active { background: #eff6ff; }
.sr-name { font-weight: 600; min-width: 0; }
.sr-name small { display: block; font-weight: 400; color: var(--tp-muted); }
.sr-stock { background: #dcfce7; color: #15803d; border-radius: 999px; padding: .1rem .6rem; font-weight: 700; font-size: .8rem; }
.sr-stock.low { background: #fef3c7; color: #b45309; }
.sr-stock.out { background: #fee2e2; color: #b91c1c; }
.sr-empty { padding: 1rem; text-align: center; color: var(--tp-muted); }

.items-head, .item-row { display: grid; grid-template-columns: minmax(180px, 2.2fr) .8fr 1.1fr 1.1fr 1.1fr 1fr 44px; gap: .6rem; align-items: center; padding: .6rem 1.25rem; }
.items-head { font-size: .75rem; font-weight: 600; color: var(--tp-muted); background: #f8fafc; border-bottom: 1px solid var(--tp-border); }
.item-row { border-bottom: 1px solid #f1f5f9; animation: rowIn .25s ease; }
.item-row:hover { background: #fafcff; }
.item-row .form-control { padding: .35rem .5rem; font-size: .95rem; }
.item-row > div { position: relative; }
.item-row .btn-icon { width: 36px; height: 36px; font-size: 1rem; }
.afn-note { position: absolute; inset-inline-start: .2rem; top: 100%; font-size: .68rem; color: var(--tp-primary); white-space: nowrap; }
.item-row { padding-bottom: .95rem !important; }
.items-note { font-size: .78rem; color: var(--tp-muted); padding: .75rem 1.25rem; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.totals-panel { position: sticky; top: 80px; }
.tot-row { display: flex; justify-content: space-between; padding: .45rem 0; font-size: .9rem; }
.tot-row span { color: var(--tp-muted); }
.grand-box { background: linear-gradient(135deg, #1d4ed8, #4f46e5); color: #fff; border-radius: 14px; padding: 1rem 1.1rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem; }
.grand-box span { width: 100%; font-size: .8rem; opacity: .85; }
.grand-box strong { font-size: 1.55rem; line-height: 1; }
.grand-box small { opacity: .8; }
.grand-box.danger { background: linear-gradient(135deg, #dc2626, #e11d48); }
.due-row { border-top: 1px dashed var(--tp-border); padding-top: .7rem; font-size: 1.05rem; }
.due-row strong { font-size: 1.15rem; }

.stat-cta { background: linear-gradient(135deg, #2563eb, #4f46e5); color: #fff !important; border: 0; }
.stat-cta .stat-icon { background: rgba(255,255,255,.18); color: #fff; }
.stat-cta:hover { color: #fff; box-shadow: 0 12px 26px -14px rgba(37,99,235,.8); }

.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.choice-cards input { display: none; }
.choice-cards span { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; border: 2px solid var(--tp-border); border-radius: 12px; padding: .75rem .5rem; cursor: pointer; font-size: .85rem; font-weight: 500; }
.choice-cards span i { font-size: 1.3rem; color: var(--tp-muted); }
.choice-cards input:checked + span { border-color: var(--tp-primary); background: #eff6ff; color: var(--tp-primary); }
.choice-cards input:checked + span i { color: var(--tp-primary); }

.print-head { display: none; }

@media (max-width: 767.98px) {
    .item-row { grid-template-columns: 1fr 1fr; padding: .85rem 1rem; gap: .5rem .6rem; }
    .item-row .item-name { grid-column: 1 / -1; }
    .item-row label { font-size: .72rem; color: var(--tp-muted); margin-bottom: .1rem; }
    .item-row .r-line { grid-column: 1 / 2; font-size: 1.05rem; text-align: start !important; align-self: center; }
    .item-search > i { inset-inline-start: 1.85rem; }
    .party-grid { padding: 1rem; grid-template-columns: 1fr; }
    .totals-panel { position: static; }
}

@media print {
    body { background: #fff; }
    .doc-card, .panel { border: 0; padding: 0; }
    .print-head { display: block; text-align: center; margin-bottom: 1rem; }
    .print-head h2 { font-size: 1.3rem; margin: 0; }
    .stat-card { border: 1px solid #ddd; }
    a { color: inherit !important; }
}

.btn-qa { border-color: var(--tp-border); color: var(--tp-primary); background: #fff; min-width: 42px; }
.btn-qa:hover { background: #eff6ff; border-color: #93c5fd; color: var(--tp-primary-dark); }
.input-group > .form-select { min-width: 0; }

/* image cropper */
.crop-stage { height: min(60vh, 460px); background: #0f172a; }
.crop-stage img { display: block; max-width: 100%; }
.crop-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; padding: .75rem; border-top: 1px solid var(--tp-border); background: #f8fafc; }
.crop-tools .btn { min-width: 42px; }
.ratio-group .btn.active { background: var(--tp-primary); color: #fff; }
.cropper-view-box { outline-color: #60a5fa; }
.cropper-line, .cropper-point { background-color: #60a5fa; }

/* totals panel next to the items on wide screens, as a compact grid below them on smaller screens */
@media (max-width: 1199.98px) {
    .totals-panel { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .5rem 1rem; align-items: end; }
    .totals-panel > * { margin: 0 !important; }
    .totals-panel .grand-box { align-self: stretch; }
    .totals-panel .btn-lg { grid-column: 1 / -1; }
    .totals-panel .due-row { border-top: 0; padding-top: .45rem; }
}
.sidebar .nav-link { padding: .5rem .75rem; }
.nav-group { padding: .85rem .75rem .3rem; }


/* ---------- printed documents ---------- */

.doc-card { background: #fff; border: 1px solid var(--tp-border); border-radius: var(--tp-radius); padding: 2.25rem 2.5rem; max-width: 900px; margin: 0 auto; color: #111827; }
.doc-head { display: flex; justify-content: space-between; align-items: stretch; gap: 1.5rem; padding-bottom: 1.25rem; border-bottom: 3px solid #1e293b; }
.doc-brand { display: flex; gap: .9rem; align-items: center; }
.doc-logo { width: 58px; height: 58px; border-radius: 14px; background: #1e293b; color: #fff; display: grid; place-items: center; font-size: 1.6rem; font-weight: 700; flex-shrink: 0; }
.doc-logo-img { width: 64px; height: 64px; object-fit: contain; }
.doc-shop { font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.doc-sub { font-size: .82rem; color: #4b5563; }
.doc-titlebox { min-width: 210px; border-radius: 12px; padding: .75rem 1rem; background: #eff6ff; border: 1px solid #bfdbfe; }
.doc-titlebox.doc-danger { background: #fef2f2; border-color: #fecaca; }
.doc-title { font-size: 1.05rem; font-weight: 700; color: #1d4ed8; margin-bottom: .35rem; }
.doc-danger .doc-title { color: #b91c1c; }
.doc-kv { display: flex; justify-content: space-between; gap: 1rem; font-size: .85rem; }
.doc-kv span { color: #4b5563; }

.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.25rem 0; }
.doc-box { border: 1px solid #e5e7eb; border-radius: 10px; padding: .8rem 1rem; font-size: .88rem; }
.doc-box-title { font-size: .72rem; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem; }
.doc-party { font-size: 1.05rem; font-weight: 700; color: #111827; display: block; }
.doc-tag { display: inline-block; font-size: .68rem; font-weight: 600; vertical-align: middle;
           background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; border-radius: 5px; padding: .05rem .3rem; }
.doc-line { display: flex; justify-content: space-between; gap: 1rem; padding: .15rem 0; }
.doc-line span { color: #6b7280; }
.doc-ltr { text-align: start; unicode-bidi: plaintext; }

.doc-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: 1.25rem; }
.doc-table th { background: #1e293b; color: #fff; font-weight: 600; font-size: .8rem; padding: .6rem .75rem; text-align: start; }
.doc-table th:first-child { border-start-start-radius: 8px; border-end-start-radius: 8px; }
.doc-table th:last-child { border-start-end-radius: 8px; border-end-end-radius: 8px; }
.doc-table td { padding: .65rem .75rem; border-bottom: 1px solid #e5e7eb; vertical-align: top; }
.doc-table tbody tr:nth-child(even) td { background: #f9fafb; }
.doc-table .c-no { width: 42px; text-align: center; color: #6b7280; }
.doc-table .c-num { text-align: end; white-space: nowrap; }
.doc-code { font-size: .75rem; color: #6b7280; unicode-bidi: plaintext; text-align: start; }
.doc-ret { font-size: .72rem; color: #b91c1c; }

.doc-bottom { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; align-items: start; }
.doc-mini { width: 100%; border-collapse: collapse; font-size: .8rem; }
.doc-mini th { text-align: start; color: #6b7280; font-weight: 600; border-bottom: 1px solid #d1d5db; padding: .35rem .4rem; }
.doc-mini td { padding: .35rem .4rem; border-bottom: 1px dashed #e5e7eb; }
.doc-mini .c-num { text-align: end; }
.doc-note { margin-top: .75rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: .55rem .75rem; font-size: .82rem; }
.doc-totals { border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; font-size: .9rem; }
.doc-totals > div { display: flex; justify-content: space-between; padding: .5rem .9rem; border-bottom: 1px solid #f3f4f6; }
.doc-totals > div:last-child { border-bottom: 0; }
.doc-totals span { color: #4b5563; }
.doc-totals .grand { background: #1e293b; color: #fff; font-size: 1.05rem; padding: .7rem .9rem; }
.doc-totals .grand span { color: #fff; font-weight: 600; }
.doc-totals .grand.danger { background: #b91c1c; }
.doc-totals .due strong { color: #b91c1c; }

.doc-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; margin-top: 3.5rem; }
.doc-sign > div { border-top: 1px solid #9ca3af; padding-top: .4rem; text-align: center; font-size: .8rem; color: #4b5563; }
.doc-foot { display: flex; justify-content: space-between; margin-top: 1.75rem; padding-top: .6rem; border-top: 1px dashed #d1d5db; font-size: .72rem; color: #9ca3af; }

@media screen and (max-width: 767.98px) {
    .doc-card { padding: 1.1rem; }
    .doc-head { flex-direction: column; }
    .doc-parties, .doc-bottom { grid-template-columns: 1fr; }
    .doc-table { font-size: .82rem; }
    .doc-table th, .doc-table td { padding: .5rem .4rem; }
}

@page { size: A4; margin: 12mm; }
@media print {
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    html { font-size: 12px; }
    .doc-card { border: 0; border-radius: 0; padding: 0; max-width: none; }
    .doc-table tr { page-break-inside: avoid; }
    .doc-bottom, .doc-sign { page-break-inside: avoid; }
    .alert { display: none !important; }
}
