:root {
    --q-primary: #0f766e;
    --q-primary-dark: #115e59;
    --q-primary-soft: #ccfbf1;
    --q-bg: #f4f6f8;
    --q-surface: #ffffff;
    --q-text: #1f2937;
    --q-muted: #6b7280;
    --q-border: #e5e7eb;
    --q-danger: #b91c1c;
    --q-sidebar: #0b3b38;
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: #115e59;
    --bs-link-hover-color-rgb: 17, 94, 89;
    --bs-body-font-family: "Cairo", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

body {
    background: var(--q-bg);
    color: var(--q-text);
    font-family: var(--bs-body-font-family);
}

a { text-decoration: none; }

.btn-primary {
    --bs-btn-bg: var(--q-primary);
    --bs-btn-border-color: var(--q-primary);
    --bs-btn-hover-bg: var(--q-primary-dark);
    --bs-btn-hover-border-color: var(--q-primary-dark);
    --bs-btn-active-bg: var(--q-primary-dark);
    --bs-btn-active-border-color: var(--q-primary-dark);
    --bs-btn-disabled-bg: var(--q-primary);
    --bs-btn-disabled-border-color: var(--q-primary);
}

.btn-outline-primary {
    --bs-btn-color: var(--q-primary);
    --bs-btn-border-color: var(--q-primary);
    --bs-btn-hover-bg: var(--q-primary);
    --bs-btn-hover-border-color: var(--q-primary);
    --bs-btn-active-bg: var(--q-primary);
    --bs-btn-active-border-color: var(--q-primary);
}

.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: #5eead4;
    box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .2);
}

.form-check-input:checked { background-color: var(--q-primary); border-color: var(--q-primary); }

.nav-pills .nav-link.active { background: var(--q-primary); }
.nav-pills .nav-link { color: var(--q-text); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--q-sidebar);
    color: #d1fae5;
    padding: 1rem .75rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem 1rem; }
.brand-name { font-weight: 800; font-size: 1.25rem; line-height: 1.1; }
.brand-sub { font-size: .75rem; opacity: .7; }
.sidebar .brand-name { color: #fff; }

.sidebar .nav-link {
    color: #ccfbf1;
    border-radius: .5rem;
    padding: .5rem .75rem;
    display: flex;
    gap: .6rem;
    align-items: center;
    font-size: .95rem;
}
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar .nav-link.active { background: rgba(94, 234, 212, .18); color: #fff; font-weight: 700; }
.sidebar .nav-cta { background: #14b8a6; color: #04201e !important; font-weight: 700; margin: .4rem 0; }
.sidebar .nav-cta:hover { background: #2dd4bf; }
.nav-section { font-size: .75rem; color: #5eead4; opacity: .8; padding: 1rem .75rem .35rem; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--q-surface);
    border-bottom: 1px solid var(--q-border);
    padding: .6rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

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

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        z-index: 1050;
        transform: translateX(100%);
        transition: transform .2s ease;
    }
    .sidebar.open { transform: none; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 1040; }
    .content { padding: 1rem; }
}

/* ---------- Building blocks ---------- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 800; margin: 0; }

.card { border: 1px solid var(--q-border); border-radius: .75rem; box-shadow: 0 1px 2px rgba(0, 0, 0, .03); }
.card-header { background: transparent; font-weight: 700; border-bottom-color: var(--q-border); }
.table > :not(caption) > * > * { padding-top: .6rem; padding-bottom: .6rem; }
.table thead th { color: var(--q-muted); font-weight: 600; font-size: .85rem; white-space: nowrap; }
tr[role=button] { cursor: pointer; }

.stat {
    display: block;
    background: var(--q-surface);
    border: 1px solid var(--q-border);
    border-radius: .75rem;
    padding: 1rem 1.1rem;
    height: 100%;
    color: inherit;
}
.stat-label { color: var(--q-muted); font-size: .85rem; }
.stat-value { font-size: 1.5rem; font-weight: 800; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--q-muted); font-size: .8rem; }
.stat-link:hover { border-color: var(--q-primary); }
.stat-danger { border-color: #fecaca; background: #fef2f2; }
.stat-danger .stat-value { color: var(--q-danger); }
.stat-good { border-color: #99f6e4; background: #f0fdfa; }
.stat-good .stat-value { color: var(--q-primary-dark); }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.bar { width: 100%; background: linear-gradient(180deg, #2dd4bf, var(--q-primary)); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-label { font-size: .7rem; color: var(--q-muted); margin-top: 4px; }

.search-results { position: absolute; left: 1rem; right: 1rem; z-index: 20; max-height: 340px; overflow-y: auto; }

.totals { display: grid; grid-template-columns: 1fr auto; gap: .4rem 1rem; align-items: center; margin-bottom: 1rem; }
.totals dt { font-weight: 500; color: var(--q-muted); margin: 0; }
.totals dd { margin: 0; text-align: left; font-variant-numeric: tabular-nums; }
.totals dd input { max-width: 140px; }
.totals .grand { font-size: 1.35rem; font-weight: 800; color: var(--q-text); border-top: 1px solid var(--q-border); padding-top: .4rem; }

.schedule-list { max-height: 160px; overflow-y: auto; background: #f9fafb; border-radius: .5rem; padding: .5rem .75rem; }

.wa-preview {
    white-space: pre-line;
    background: #dcf8c6;
    border-radius: .75rem .75rem .75rem 0;
    padding: .75rem 1rem;
    max-width: 420px;
    font-size: .95rem;
}

.pay-box { background: var(--q-primary-soft); border-radius: .75rem; padding: .9rem 1rem; }

.modal { background: transparent; }

/* ---------- Auth ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: radial-gradient(circle at top right, #ccfbf1, transparent 50%), var(--q-bg);
}
.auth-card {
    width: 100%;
    max-width: 520px;
    background: var(--q-surface);
    border: 1px solid var(--q-border);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(15, 118, 110, .08);
}
.auth-brand { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.5rem; color: var(--q-text); }

/* ---------- Landing ---------- */
.landing { background: var(--q-surface); }
.landing-nav { border-bottom: 1px solid var(--q-border); }
.hero { padding: 4rem 0; background: linear-gradient(180deg, #f0fdfa, #fff); }
.hero-badge { background: var(--q-primary-soft); color: var(--q-primary-dark); font-weight: 700; }
.hero-card { background: #fff; border: 1px solid var(--q-border); border-radius: 1rem; padding: 1.5rem; box-shadow: 0 20px 40px rgba(15, 118, 110, .12); }
.hero-row { display: flex; justify-content: space-between; padding: .6rem 0; border-bottom: 1px dashed var(--q-border); }
.hero-total { display: flex; justify-content: space-between; padding-top: .9rem; font-size: 1.1rem; }
.feature { padding: 1.5rem; border: 1px solid var(--q-border); border-radius: 1rem; height: 100%; }
.feature i { font-size: 1.8rem; color: var(--q-primary); display: inline-block; margin-bottom: .5rem; }
.pricing { background: var(--q-bg); }
.price-card { background: #fff; border: 2px solid var(--q-border); border-radius: 1rem; padding: 1.5rem; height: 100%; }
.price-card.featured { border-color: var(--q-primary); box-shadow: 0 10px 30px rgba(15, 118, 110, .12); }
.price-card .price { margin: .5rem 0; color: var(--q-muted); }
.price-card .price span { font-size: 2rem; font-weight: 800; color: var(--q-text); }

/* ---------- Print ---------- */
.print-only { display: none; }

@media print {
    .sidebar, .topbar, .no-print, .btn, .alert { display: none !important; }
    .print-only { display: block; }
    .content { padding: 0; }
    body { background: #fff; }
    .card { border: none; box-shadow: none; }
    .table-danger > td { background: none !important; }
}

/* ---------- Print pages: thermal receipt & barcode labels ---------- */
.print-shell { background: #fff; min-height: 100vh; padding: 16px; color: #000; }
.receipt-toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 16px; }
.receipt { margin: 0 auto; font-family: "Cairo", Tahoma, sans-serif; line-height: 1.45; color: #000; background: #fff; }
.receipt .r-center { text-align: center; }
.receipt .r-shop { font-size: 1.35em; font-weight: 800; }
.receipt .r-title { font-weight: 700; margin-top: 4px; font-size: 1.1em; }
.receipt .r-line { border-top: 1px dashed #000; margin: 6px 0; }
.receipt .r-row { display: flex; justify-content: space-between; gap: 8px; }
.receipt .r-total { font-size: 1.25em; font-weight: 800; border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 2px 0; margin: 3px 0; }
.receipt .r-items { width: 100%; border-collapse: collapse; }
.receipt .r-items th { font-weight: 700; border-bottom: 1px solid #000; text-align: start; }
.receipt .r-items th:not(:first-child), .receipt .r-nums td { text-align: end; white-space: nowrap; }
.receipt .r-name { font-weight: 600; padding-top: 3px; }
.receipt .r-barcode { height: 12mm; margin: 4px 8mm; }
.receipt .r-footer { font-size: .9em; margin-top: 4px; }
.barcode-svg { width: 100%; height: 100%; display: block; }

.labels-screen { max-width: 1100px; margin: 0 auto; }
.labels-preview .label { border: 1px dashed #adb5bd; background: #fff; }
.labels-print { display: none; }
.label { box-sizing: border-box; overflow: hidden; padding: 1mm 2mm; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-family: "Cairo", Tahoma, sans-serif; color: #000; line-height: 1.15; }
.label .l-shop { font-size: .8em; font-weight: 600; }
.label .l-name { font-weight: 700; max-height: 2.35em; overflow: hidden; width: 100%; }
.label .barcode-box { width: 100%; margin: .5mm 0; }
.label .l-code { font-size: .85em; letter-spacing: .5px; }
.label .l-price { font-weight: 800; font-size: 1.15em; }
.label .l-sep { margin: 0 3px; font-weight: 400; }

@media print {
    .print-shell { padding: 0; min-height: 0; }
    .labels-print { display: block; }
    .receipt { margin: 0 4mm; }
}

/* ---------- Company logo ---------- */
.logo-box { width: 180px; height: 110px; border: 1px dashed #ced4da; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #fff; padding: 8px; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.doc-logo { max-height: 70px; max-width: 200px; object-fit: contain; display: block; }
.topbar-logo { height: 30px; max-width: 90px; object-fit: contain; }
.receipt .r-logo { max-height: 18mm; max-width: 60%; object-fit: contain; filter: grayscale(1); margin-bottom: 2px; }
.wa-qr { width: 240px; height: 240px; border: 1px solid #dee2e6; border-radius: 12px; background: #fff; padding: 6px; }

/* ---------- A4 documents: installment contract, promissory notes, trust receipt ---------- */
.doc-a4 { max-width: 190mm; margin: 0 auto; font-family: "Cairo", Tahoma, sans-serif; color: #000; background: #fff; line-height: 1.7; font-size: 13px; }
.doc-a4 h1 { font-size: 20px; font-weight: 800; text-align: center; margin: 6px 0 2px; }
.doc-a4 h2 { font-size: 14px; font-weight: 800; margin: 14px 0 4px; border-bottom: 1px solid #000; padding-bottom: 2px; }
.doc-a4 .doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 2px solid #000; padding-bottom: 8px; }
.doc-a4 .doc-sub { text-align: center; font-size: 12px; }
.doc-a4 table { width: 100%; border-collapse: collapse; margin: 4px 0; }
.doc-a4 th, .doc-a4 td { border: 1px solid #000; padding: 2px 6px; text-align: start; }
.doc-a4 th { background: #f1f1f1; }
.doc-a4 .party { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
.doc-a4 ol.terms { padding-inline-start: 20px; margin: 0; }
.doc-a4 .signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 30px; text-align: center; }
.doc-a4 .signs div { border-top: 1px dotted #000; padding-top: 4px; }
.note-card { border: 2px solid #000; padding: 10px 14px; margin: 0 0 8mm; page-break-inside: avoid; break-inside: avoid; }
.note-card .note-top { display: flex; justify-content: space-between; font-weight: 700; border-bottom: 1px solid #000; padding-bottom: 4px; margin-bottom: 6px; }
.note-card .note-title { font-size: 18px; font-weight: 800; text-align: center; }
.note-card .note-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; font-size: 12px; }
.fill { border-bottom: 1px dotted #000; display: inline-block; min-width: 120px; }
@media print {
    @page { size: A4; margin: 12mm; }
    .doc-a4 { max-width: none; }
    .page-break { page-break-after: always; break-after: page; }
}

/* ---------- Online store (public) ---------- */
.store-shell { max-width: 1140px; margin: 0 auto; padding: 16px; min-height: 100vh; background: #fff; }
.store-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0 16px; border-bottom: 1px solid #e9ecef; margin-bottom: 16px; }
.store-brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.store-brand img { height: 52px; max-width: 140px; object-fit: contain; }
.store-name { font-size: 1.35rem; font-weight: 800; }
.store-tagline { color: #6c757d; font-size: .9rem; }
.store-cart-btn { white-space: nowrap; }
.store-tools { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.store-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.store-card { border: 1px solid #e9ecef; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; background: #fff; }
.store-img { display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1; background: #f8f9fa; color: #ced4da; font-size: 3rem; overflow: hidden; }
.store-img img { width: 100%; height: 100%; object-fit: contain; }
.store-img-lg { border-radius: 14px; border: 1px solid #e9ecef; }
.store-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; flex: 1; }
.store-pname { font-weight: 700; color: inherit; text-decoration: none; line-height: 1.4; min-height: 2.8em; }
.store-price { font-weight: 800; color: #1f7a4d; font-size: 1.15rem; }
.store-price small { font-weight: 600; font-size: .75em; }
.store-inst { font-size: .8rem; color: #6c757d; }
.store-empty { text-align: center; color: #6c757d; padding: 48px 16px; }
.store-footer { text-align: center; color: #adb5bd; font-size: .8rem; padding: 32px 0 8px; }
@media (max-width: 575px) { .store-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } .store-name { font-size: 1.1rem; } }

/* ---------- Landing page extras ---------- */
html { scroll-behavior: smooth; }
.lp-link { color: var(--q-text); text-decoration: none; }
.lp-link:hover { color: var(--q-primary); }
.lp-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.lp-chips span { background: #fff; border: 1px solid var(--q-border); border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; color: var(--q-text); }
.lp-chips i { color: var(--q-primary); }
.lp-strip { background: var(--q-sidebar); color: #fff; padding: 1.6rem 0; }
.lp-strip strong { display: block; font-size: 1.35rem; font-weight: 800; }
.lp-strip span { font-size: .85rem; opacity: .8; }
.lp-pain { border: 1px solid var(--q-border); border-radius: 1rem; overflow: hidden; height: 100%; background: #fff; }
.lp-before { padding: .8rem 1.1rem; background: #fef2f2; color: #991b1b; text-decoration: line-through; text-decoration-color: rgba(153, 27, 27, .35); }
.lp-after { padding: .9rem 1.1rem; color: var(--q-text); font-weight: 600; }
.lp-before i, .lp-after i { margin-inline-end: .35rem; }
.lp-after i { color: var(--q-primary); }
.lp-features { background: var(--q-bg); }
.lp-features .feature { background: #fff; transition: transform .15s ease, box-shadow .15s ease; }
.lp-features .feature:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(15, 118, 110, .10); }
.lp-list li { padding: .3rem 0; }
.lp-list i { color: var(--q-primary); margin-inline-end: .4rem; }
.lp-mock { background: #fff; border: 1px solid var(--q-border); border-radius: 1rem; overflow: hidden; box-shadow: 0 20px 40px rgba(15, 23, 42, .10); }
.lp-mock-bar { background: #134e4a; color: #fff; padding: .55rem 1rem; font-size: .85rem; display: flex; align-items: center; gap: .35rem; }
.lp-mock-bar span { width: .6rem; height: .6rem; border-radius: 50%; background: rgba(255, 255, 255, .5); display: inline-block; }
.lp-mock-body { padding: 1.3rem; display: grid; gap: .7rem; font-size: 1.05rem; }
.lp-mock-status { display: flex; justify-content: space-between; padding: .6rem 1rem; border-top: 1px solid var(--q-border); background: #f8fafc; font-size: .85rem; color: var(--q-muted); }
.lp-store { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem; }
.lp-store-item { background: #fff; border: 1px solid var(--q-border); border-radius: .9rem; padding: .8rem; }
.lp-store-img { aspect-ratio: 4 / 3; background: #f1f5f9; border-radius: .6rem; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: #cbd5e1; margin-bottom: .5rem; }
.lp-step-num { width: 3.2rem; height: 3.2rem; border-radius: 50%; background: var(--q-primary); color: #fff; font-size: 1.4rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.lp-faq { border: 1px solid var(--q-border); border-radius: .8rem; padding: .9rem 1.1rem; margin-bottom: .7rem; background: #fff; }
.lp-faq summary { font-weight: 700; cursor: pointer; list-style: none; }
.lp-faq summary::-webkit-details-marker { display: none; }
.lp-faq summary::before { content: "+"; display: inline-block; width: 1.4rem; color: var(--q-primary); font-weight: 800; }
.lp-faq[open] summary::before { content: "−"; }
.lp-faq[open] summary { margin-bottom: .5rem; }
.lp-cta { background: linear-gradient(135deg, var(--q-primary), var(--q-sidebar)); color: #fff; padding: 3.5rem 0; }
.lp-wa-float { position: fixed; bottom: 1.2rem; left: 1.2rem; width: 3.4rem; height: 3.4rem; border-radius: 50%; background: #25d366; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; box-shadow: 0 8px 20px rgba(0, 0, 0, .2); z-index: 50; text-decoration: none; }
.lp-wa-float:hover { color: #fff; transform: scale(1.05); }
.landing { overflow-x: hidden; }
@media (max-width: 575px) { .landing .row.g-5 { --bs-gutter-x: 1.5rem; } .lp-wa-float { width: 3rem; height: 3rem; font-size: 1.5rem; } }

/* ---------- «ابدأ» checklist on the dashboard ---------- */
.onboarding { border: 1px solid var(--q-primary-soft); background: #f7fdfc; }
.onboarding-step { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .75rem; border-radius: .6rem; background: #fff; border: 1px solid #e3eee7; color: inherit; text-decoration: none; height: 100%; }
.onboarding-step:hover { border-color: var(--q-primary); }
.onboarding-step i { font-size: 1.2rem; margin-top: .1rem; }
.onboarding-step.done .fw-semibold { text-decoration: line-through; color: #6c757d; }

/* ---------- landing: footer links + sticky sign-up button on phones ---------- */
.lp-footer nav a { color: inherit; }
.lp-sticky-cta { position: fixed; inset-inline: 12px; bottom: 12px; z-index: 60; background: var(--q-primary); color: #fff; text-align: center; font-weight: 700; padding: .85rem; border-radius: .8rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); text-decoration: none; }
.lp-sticky-cta:hover { color: #fff; }
@media (max-width: 767.98px) { .lp-wa-float { bottom: 5.2rem; } .landing footer { padding-bottom: 5.5rem !important; } }

/* ---------- legal / about pages ---------- */
.legal-page { max-width: 820px; }
.legal-page h1 { font-size: 1.6rem; font-weight: 800; }
.legal-page h2 { font-size: 1.15rem; font-weight: 700; margin-top: 1.6rem; }
.legal-page p, .legal-page li { line-height: 1.9; }
