@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    --bg: #ecf0f9;
    --surface: #ffffff;
    --surface-soft: #f7f9ff;
    --line: #e6eaf5;
    --line-strong: #d9dfef;
    --text: #1f2942;
    --muted: #8a93ad;
    --primary: #5b67f6;
    --primary-strong: #4250dc;
    --success: #0fb98b;
    --danger: #ef6079;
    --warning: #f3ab3f;
    --shadow-lg: 0 30px 60px rgba(31, 42, 68, 0.15);
    --shadow-md: 0 14px 30px rgba(31, 42, 68, 0.09);
    --shadow-sm: 0 8px 18px rgba(31, 42, 68, 0.06);
    --radius-xl: 28px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Tajawal", "Manrope", "Segoe UI", sans-serif;
    font-size: 15px;
    color: var(--text);
    background:
        radial-gradient(1000px 420px at 2% 0%, rgba(133, 95, 255, 0.12) 0%, rgba(133, 95, 255, 0) 55%),
        radial-gradient(940px 460px at 95% 0%, rgba(91, 103, 246, 0.12) 0%, rgba(91, 103, 246, 0) 57%),
        var(--bg);
}

.app-body {
    position: relative;
    padding: 22px;
}

.bg-orb {
    position: fixed;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(8px);
    z-index: 0;
}

.bg-orb-1 {
    width: 300px;
    height: 300px;
    top: -110px;
    left: 45%;
    background: rgba(91, 103, 246, 0.14);
}

.bg-orb-2 {
    width: 260px;
    height: 260px;
    bottom: 16px;
    right: 50px;
    background: rgba(15, 185, 139, 0.12);
}

.app-shell {
    position: relative;
    z-index: 1;
    max-width: 1460px;
    margin: 0 auto;
    padding: 14px;
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.52);
    border: 1px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(5px);
    box-shadow: var(--shadow-lg);
}

.app-shell-auth {
    max-width: 980px;
}

.app {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    gap: 14px;
    min-height: calc(100vh - 82px);
}

.app-single {
    grid-template-columns: 1fr;
    min-height: 0;
}

.sidebar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #7280ff, #5b67f6);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.5px;
    font-family: "Manrope", "Tajawal", sans-serif;
    box-shadow: 0 12px 20px rgba(91, 103, 246, 0.32);
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-text strong {
    font-size: 13px;
    font-weight: 800;
    color: #1f2942;
    font-family: "Manrope", "Tajawal", sans-serif;
}

.brand-text span {
    font-size: 10px;
    color: var(--muted);
    font-family: "Manrope", "Tajawal", sans-serif;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 10px;
    background: linear-gradient(180deg, #f8f9ff, #f3f6ff);
}

.meta {
    margin-bottom: 11px;
}

.meta-name {
    font-size: 14px;
    font-weight: 800;
}

.meta-role,
.meta-tenant {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.nav {
    overflow: auto;
    scrollbar-width: thin;
    min-height: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    color: #5a6481;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    margin-bottom: 4px;
    transition: all .2s ease;
}

.nav-link::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #c5ccdc;
    transition: all .2s ease;
}

.nav-link:hover {
    background: #f5f7ff;
    border-color: #e7eaf6;
    color: #2f3b61;
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(91, 103, 246, 0.2), rgba(91, 103, 246, 0.05));
    border-color: rgba(91, 103, 246, 0.26);
    color: #3343c9;
}

.nav-link.active::before {
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(91, 103, 246, 0.16);
}

.main {
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    padding: 14px;
    min-width: 0;
}

.topbar {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff, #fbfcff);
    padding: 11px 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.page-title {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.topbar-subtitle {
    font-size: 12px;
    color: var(--muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.topbar-clock {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 7px 12px;
    color: #5f6a87;
    font-size: 12px;
    font-family: "Manrope", "Tajawal", sans-serif;
}

.mobile-menu-btn {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

.mobile-tabbar {
    display: none;
}

.page-content {
    display: grid;
    gap: 12px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 10px;
    line-height: 1.3;
}

h2 {
    font-size: 21px;
    font-weight: 800;
}

h3 {
    font-size: 16px;
    font-weight: 800;
}

.card {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #fff, #fcfdff);
    padding: 14px;
    box-shadow: var(--shadow-sm);
}

.grid {
    display: grid;
    gap: 12px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(180deg, #fff, #fafbff);
    padding: 12px;
    box-shadow: var(--shadow-sm);
}

.stat .label {
    color: var(--muted);
    font-size: 12px;
}

.stat .value {
    margin-top: 8px;
    font-size: 24px;
    font-weight: 800;
    font-family: "Manrope", "Tajawal", sans-serif;
}

.sales-month-chart-card {
    background: radial-gradient(circle at top left, #f8fbff 0%, #ffffff 58%, #f7f9ff 100%);
}

.sales-month-chart {
    margin-top: 12px;
    padding: 10px 4px 6px;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    min-height: 226px;
    overflow-x: auto;
    border-top: 1px dashed #e3e9fb;
}

.sales-month-chart-col {
    flex: 1;
    min-width: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.sales-month-chart-bar-wrap {
    height: 176px;
    width: 100%;
    display: flex;
    align-items: flex-end;
}

.sales-month-chart-bar {
    width: 100%;
    display: block;
    border-radius: 10px 10px 4px 4px;
    background: linear-gradient(180deg, #6cb6ff 0%, #2a74e8 62%, #1f5fcd 100%);
    box-shadow: 0 8px 14px rgba(42, 95, 197, 0.2);
    transition: transform 0.15s ease, filter 0.15s ease;
}

.sales-month-chart-col:hover .sales-month-chart-bar {
    transform: translateY(-2px);
    filter: brightness(1.04);
}

.sales-month-chart-day {
    font-size: 11px;
    color: #727996;
    font-weight: 700;
    line-height: 1;
}

.sales-month-chart-meta {
    margin-top: 8px;
}

.flex {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.sales-head {
    justify-content: space-between;
    align-items: center;
}

.sales-head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sales-head-actions .btn,
.sales-head-actions .btn-secondary {
    width: auto;
    padding: 8px 14px;
}

.sales-filter-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.sales-filter-actions {
    justify-content: flex-start;
}

.sales-filter-actions button,
.sales-filter-actions .btn-secondary {
    width: auto;
    padding: 8px 14px;
}

.sales-summary-head {
    justify-content: space-between;
    margin-bottom: 8px;
}

.sales-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.sales-card {
    border: 1px solid #e6ecfa;
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sales-card-cancelled {
    border-color: #f4c3c3;
    background: #fff8f8;
}

.sales-card-returned {
    border-color: #ffd5d5;
    background: #fff9f9;
}

.sales-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.sales-card-title {
    font-size: 16px;
    font-weight: 800;
}

.sales-card-source {
    font-size: 12px;
}

.sales-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px 10px;
    font-size: 13px;
}

.sales-card-grid > div {
    min-width: 0;
    overflow-wrap: anywhere;
}

.sales-card-date {
    grid-column: 1 / -1;
}

.sales-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.sales-card-actions .btn-secondary,
.sales-card-actions .btn-danger {
    width: auto;
    min-height: 34px;
    padding: 6px 10px;
}

.sales-card-actions form {
    margin: 0;
}

.sales-table-wrap {
    overflow-x: auto;
}

.sales-table {
    width: 100%;
    min-width: 1080px;
    table-layout: fixed;
}

.sales-table th,
.sales-table td {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: top;
}

.sales-table th:nth-child(1),
.sales-table td:nth-child(1) {
    width: 64px;
}

.sales-table th:nth-child(2),
.sales-table td:nth-child(2) {
    width: 112px;
}

.sales-table th:nth-child(3),
.sales-table td:nth-child(3) {
    width: 148px;
}

.sales-table th:nth-child(13),
.sales-table td:nth-child(13) {
    width: 260px;
}

.sales-source-status {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.35;
}

.sales-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.sales-actions .btn-secondary,
.sales-actions .btn-danger {
    width: auto;
    padding: 5px 9px;
    min-height: 34px;
}

.sales-actions form {
    margin: 0;
}

.sales-status-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sales-status-form select {
    width: auto;
    min-width: 102px;
    padding: 5px 8px;
    min-height: 34px;
}

.sales-card-actions .sales-status-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sales-muted-chip {
    padding: 6px 10px;
}

.sales-pagination {
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.sales-pagination .btn-secondary {
    width: auto;
    padding: 6px 10px;
}

.muted {
    color: var(--muted);
}

.scan-result {
    margin-top: 8px;
    font-size: 12px;
}

.scan-muted {
    color: var(--muted);
}

.scan-ok {
    color: var(--success);
}

.scan-error {
    color: var(--danger);
}

a {
    color: #3343c9;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

input,
select,
textarea,
button,
.btn {
    font: inherit;
}

label {
    font-size: 12px;
    font-weight: 700;
    color: #5f6a87;
    margin-bottom: 6px;
    display: block;
}

form .row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    color: #24314f;
    padding: 9px 10px;
    outline: none;
    transition: all .2s ease;
}

textarea {
    min-height: 84px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(91, 103, 246, 0.55);
    box-shadow: 0 0 0 4px rgba(91, 103, 246, 0.14);
}

button,
.btn {
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 12px;
    font-weight: 700;
    transition: all .2s ease;
}

button,
.btn,
.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    box-shadow: 0 10px 18px rgba(91, 103, 246, 0.28);
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.btn-secondary,
.btn.light {
    background: #f6f8ff;
    border-color: #dce2f2;
    color: #3343c9;
    box-shadow: none;
}

.btn-secondary:hover,
.btn.light:hover {
    background: #eef2ff;
}

.btn-danger,
.btn.danger {
    background: #fff3f5;
    border-color: #ffd1dc;
    color: #cd2f54;
    box-shadow: none;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th,
td {
    font-size: 13px;
    text-align: right;
    padding: 10px;
    border-bottom: 1px solid #edf1fa;
    white-space: nowrap;
}

thead th {
    font-size: 12px;
    color: #6e7894;
    background: #f7f9ff;
    font-weight: 800;
}

tbody tr:hover {
    background: #fbfcff;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid transparent;
}

.badge-success,
.badge.success {
    background: rgba(15, 185, 139, 0.12);
    border-color: rgba(15, 185, 139, 0.25);
    color: #0b8e6c;
}

.badge-danger,
.badge.danger {
    background: rgba(239, 96, 121, 0.12);
    border-color: rgba(239, 96, 121, 0.25);
    color: #cc3f61;
}

.badge-warn,
.badge.warning {
    background: rgba(243, 171, 63, 0.14);
    border-color: rgba(243, 171, 63, 0.27);
    color: #bf8123;
}

tr.invoice-row-cancelled td {
    background: rgba(239, 96, 121, 0.08);
}

tr.invoice-row-returned td {
    background: rgba(239, 96, 121, 0.06);
}

.invoice-table tr.invoice-row-returned td {
    background: rgba(239, 96, 121, 0.07);
}

.flash,
.alert {
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 10px;
    border: 1px solid transparent;
}

.flash.success,
.alert-success {
    background: rgba(15, 185, 139, 0.14);
    border-color: rgba(15, 185, 139, 0.25);
    color: #0b8e6c;
}

.flash.error,
.alert-error {
    background: rgba(239, 96, 121, 0.13);
    border-color: rgba(239, 96, 121, 0.25);
    color: #c53758;
}

.flash.info {
    background: rgba(91, 103, 246, 0.13);
    border-color: rgba(91, 103, 246, 0.25);
    color: #3f4dca;
}

.variant-row,
.item-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr 0.8fr 0.8fr auto;
    gap: 8px;
    margin-bottom: 8px;
}

.variant-grid-head {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr 0.8fr 0.8fr auto;
    gap: 8px;
    margin-bottom: 8px;
    color: #5f6a87;
    font-size: 12px;
    font-weight: 700;
}

.variant-grid-head > div {
    padding: 0 2px;
}

.product-variant-row,
.product-variant-grid-head {
    grid-template-columns: 1.2fr 1fr 1fr 0.8fr auto;
}

.item-grid-head {
    grid-template-columns: 1.2fr 1fr 1fr 0.8fr 0.8fr auto;
}

.purchase-item-row,
.purchase-item-grid-head {
    grid-template-columns: 1.2fr 0.8fr 0.9fr 0.9fr 0.9fr 0.8fr 0.8fr auto;
}

.product-thumb {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    background: #fff;
}

.product-thumb-lg {
    width: 120px;
    height: 120px;
}

.stock-model-card {
    display: grid;
    gap: 10px;
}

.stock-model-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ebeff9;
}

.stock-model-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.stock-model-thumb {
    width: 62px;
    height: 62px;
    border-radius: 12px;
}

.stock-model-placeholder {
    width: 62px;
    height: 62px;
    border-radius: 12px;
    border: 1px dashed #d4dcf0;
    background: #f7faff;
    color: #8c97b2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.4px;
}

.stock-model-title {
    margin: 0 0 3px;
    font-size: 16px;
}

.stock-model-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.stock-adjust-form {
    gap: 6px;
    align-items: center;
}

.stock-adjust-form select {
    width: 95px;
}

.stock-adjust-form input[name="quantity"] {
    width: 84px;
}

.stock-adjust-form input[name="notes"] {
    min-width: 170px;
}

.invoice {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.inline-check-wrap {
    display: flex;
    align-items: flex-end;
}

.inline-check {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin: 0;
    font-size: 13px;
    color: #465274;
}

.inline-check input {
    width: auto;
    min-height: auto;
}

.invoice-paper {
    width: 100%;
    max-width: 210mm;
    margin: 0 auto;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    border: 1px solid #d7dfef;
    border-radius: 16px;
    box-shadow: 0 24px 42px rgba(31, 42, 68, 0.11);
    padding: 15mm 12mm 13mm;
    page-break-inside: avoid;
}

.invoice-paper-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 2px solid #e5ebf8;
    background: linear-gradient(180deg, #f9fbff 0%, #ffffff 100%);
    border-radius: 12px;
    padding: 10px 10px 12px;
    margin-bottom: 12px;
}

.invoice-brand-block {
    display: flex;
    align-items: center;
    gap: 10px;
}

.invoice-brand-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7280ff, #5b67f6);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 10px 18px rgba(91, 103, 246, 0.28);
}

.invoice-company-logo {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid #d6ddef;
    background: #fff;
    box-shadow: 0 10px 18px rgba(31, 42, 68, 0.12);
}

.invoice-brand-block h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
}

.invoice-brand-block p {
    margin: 3px 0 0;
    color: #6f7a95;
    font-size: 12px;
}

.invoice-company-contact {
    margin-top: 6px;
    display: grid;
    gap: 3px;
    font-size: 11px;
    color: #5b6684;
}

.invoice-company-contact a {
    color: #3343c9;
    text-decoration: none;
}

.invoice-company-contact a:hover {
    text-decoration: underline;
}

.invoice-meta-block {
    min-width: 220px;
    border: 1px solid #dfe6f6;
    border-radius: 10px;
    background: #f4f8ff;
    padding: 10px;
    display: grid;
    gap: 6px;
    font-size: 12px;
}

.invoice-party-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.invoice-party-card {
    border: 1px solid #dde6f7;
    border-radius: 10px;
    background: #fcfdff;
    padding: 10px;
    display: grid;
    gap: 6px;
    font-size: 12px;
}

.invoice-party-card h4 {
    margin: 0 0 4px;
    font-size: 13px;
}

.invoice-party-customer {
    order: 1;
}

.invoice-party-summary {
    order: 2;
}

.invoice-net {
    margin-top: 2px;
    padding-top: 6px;
    border-top: 1px dashed #dfe5f3;
    color: #3243ca;
    font-size: 14px;
}

.invoice-table-wrap {
    margin-top: 8px;
    border: 1px solid #d8e2f5;
    border-radius: 10px;
    overflow: hidden;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
}

.invoice-table th,
.invoice-table td {
    padding: 9px 8px;
    font-size: 12px;
    text-align: right;
    border-bottom: 1px solid #edf1fa;
    white-space: normal;
}

.invoice-table thead th {
    background: #edf3ff;
    color: #4f5a77;
    font-weight: 800;
}

.invoice-table tbody tr:last-child td {
    border-bottom: 0;
}

.invoice-table tr {
    page-break-inside: avoid;
}

.invoice-footer-note {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #dce2f2;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    color: #667393;
    flex-wrap: wrap;
}

.company-logo-preview {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    background: #fff;
}

.company-logo-placeholder {
    width: 96px;
    height: 96px;
    display: grid;
    place-items: center;
    text-align: center;
    border-radius: 12px;
    border: 1px dashed #d7deef;
    background: #fafcff;
    color: #7b86a5;
    font-size: 12px;
    padding: 8px;
}

.company-header-preview {
    width: 100%;
    max-width: 520px;
    height: 140px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    background: #fff;
}

.company-header-placeholder {
    width: 100%;
    max-width: 520px;
    min-height: 140px;
    display: grid;
    place-items: center;
    text-align: center;
    border-radius: 12px;
    border: 1px dashed #d7deef;
    background: #fafcff;
    color: #7b86a5;
    font-size: 12px;
    padding: 12px;
}

.login-wrap {
    min-height: 68vh;
    display: grid;
    place-items: center;
}

.login-card,
.auth-card {
    width: min(860px, 95vw);
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff, #f8faff);
    box-shadow: var(--shadow-md);
    padding: 22px;
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 999px;
    background: rgba(91, 103, 246, 0.08);
    top: -120px;
    left: -90px;
}

.login-card::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 999px;
    background: rgba(15, 185, 139, 0.08);
    bottom: -120px;
    right: -80px;
}

.login-card > * {
    position: relative;
    z-index: 1;
}

.no-print {
    display: block;
}

@media print {
    .sidebar,
    .mobile-tabbar,
    .sidebar-backdrop,
    .no-print,
    .topbar,
    .flash,
    .alert {
        display: none !important;
    }

    .app {
        grid-template-columns: 1fr;
    }

    .main {
        border: 0;
        box-shadow: none;
        padding: 0;
    }

    .app-shell {
        box-shadow: none;
        border: 0;
        background: #fff;
        padding: 0;
    }

    @page {
        size: A4;
        margin: 10mm;
    }

    body,
    .app-body {
        background: #fff !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .main {
        padding: 0 !important;
    }

    .page-content {
        display: block !important;
    }

    .invoice-paper {
        width: 190mm;
        max-width: 190mm;
        border: 0;
        box-shadow: none;
        border-radius: 0;
        margin: 0 auto;
        padding: 3mm 2mm 2mm;
        background: #fff;
    }

    .invoice-paper-head {
        flex-direction: row !important;
        align-items: flex-start !important;
    }

    .invoice-meta-block {
        min-width: 220px !important;
    }

    .invoice-party-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .invoice-party-customer {
        order: 1 !important;
    }

    .invoice-party-summary {
        order: 2 !important;
    }

    table,
    .invoice-table {
        width: 100% !important;
        border-collapse: collapse !important;
        border-spacing: 0 !important;
    }

    thead {
        display: table-header-group !important;
    }

    tbody {
        display: table-row-group !important;
    }

    tbody tr {
        display: table-row !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    td,
    th {
        display: table-cell !important;
        border-bottom: 1px solid #eceff6 !important;
    }

    td::before {
        content: none !important;
    }
}

@media (max-width: 1180px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
    }

    .nav {
        max-height: 250px;
    }

    .grid-4 {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

@media (max-width: 980px) {
    .app-body {
        padding: 8px 8px 86px;
    }

    .bg-orb {
        display: none;
    }

    .app-shell {
        padding: 6px;
        border-radius: 14px;
        box-shadow: var(--shadow-md);
    }

    .app {
        grid-template-columns: 1fr;
        min-height: 0;
        gap: 10px;
    }

    .main {
        border-radius: 12px;
        padding: 10px 10px 12px;
    }

    .topbar {
        position: sticky;
        top: 6px;
        z-index: 30;
        margin-bottom: 10px;
        padding: 10px;
    }

    .topbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .page-title {
        font-size: 17px;
    }

    .topbar-subtitle {
        font-size: 11px;
    }

    .topbar-clock {
        padding: 6px 10px;
        font-size: 11px;
    }

    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 38px;
        padding: 0 14px;
        border-radius: 999px;
        border: 1px solid #d9dfef;
        background: #fff;
        color: #2f3b61;
        font-size: 12px;
        font-weight: 800;
        box-shadow: none;
    }

    .mobile-menu-btn:hover {
        transform: none;
        background: #f5f7ff;
    }

    .sidebar {
        position: fixed;
        top: 10px;
        right: 10px;
        bottom: 76px;
        width: min(86vw, 330px);
        z-index: 60;
        overflow: auto;
        border-radius: 16px;
        transform: translateX(115%);
        opacity: 0;
        pointer-events: none;
        transition: transform .24s ease, opacity .2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(20, 29, 47, 0.35);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        z-index: 55;
        transition: opacity .2s ease;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .nav {
        max-height: none;
        padding-bottom: 10px;
    }

    .mobile-tabbar {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: 8px;
        z-index: 70;
        display: flex;
        gap: 6px;
        padding: 7px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(8px);
        box-shadow: var(--shadow-md);
        overflow: auto;
    }

    .mobile-tab-link {
        flex: 1;
        min-width: 72px;
        text-align: center;
        padding: 8px 6px;
        font-size: 11px;
        font-weight: 800;
        color: #5a6481;
        border-radius: 10px;
        border: 1px solid transparent;
        white-space: nowrap;
    }

    .mobile-tab-link.active {
        background: rgba(91, 103, 246, 0.12);
        color: #3343c9;
        border-color: rgba(91, 103, 246, 0.25);
    }

    .mobile-tab-link:hover {
        text-decoration: none;
        background: #f4f6ff;
    }

    .grid-2,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 11px;
        border-radius: 12px;
    }

    .sales-head {
        flex-direction: column;
        align-items: stretch;
    }

    .sales-head-actions {
        width: 100%;
    }

    .sales-head-actions .btn,
    .sales-head-actions .btn-secondary {
        flex: 1;
        text-align: center;
    }

    form .row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .sales-filter-actions {
        width: 100%;
    }

    .sales-filter-actions button,
    .sales-filter-actions .btn-secondary {
        flex: 1;
        text-align: center;
    }

    .sales-summary-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
        min-height: 42px;
    }

    button,
    .btn {
        min-height: 40px;
    }

    .variant-grid-head,
    .item-grid-head {
        display: none;
    }

    .variant-row,
    .item-row {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 8px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: #fff;
    }

    .login-card,
    .auth-card {
        width: min(100%, 96vw);
        padding: 14px;
        border-radius: 14px;
    }

    .login-wrap {
        min-height: 56vh;
    }

    .product-thumb {
        width: 46px;
        height: 46px;
    }

    .product-thumb-lg {
        width: 90px;
        height: 90px;
    }

    .stock-model-head {
        flex-direction: column;
        align-items: stretch;
    }

    .stock-model-identity {
        align-items: flex-start;
    }

    .stock-model-thumb,
    .stock-model-placeholder {
        width: 52px;
        height: 52px;
    }

    .stock-adjust-form {
        width: 100%;
    }

    .stock-adjust-form input[name="quantity"],
    .stock-adjust-form select {
        width: 100%;
    }

    .stock-adjust-form input[name="notes"] {
        min-width: 0;
    }

    .invoice-paper {
        padding: 12px;
        border-radius: 12px;
    }

    .invoice-paper-head {
        flex-direction: column;
        align-items: stretch;
    }

    .invoice-meta-block {
        min-width: 0;
    }

    .invoice-party-grid {
        grid-template-columns: 1fr;
    }

    .table-wrap {
        border: 0;
        background: transparent;
        overflow: visible;
    }

    .sales-table-wrap {
        overflow: visible;
    }

    .sales-table {
        min-width: 0;
        table-layout: auto;
    }

    table {
        border-collapse: separate;
        border-spacing: 0 8px;
    }

    thead {
        display: none;
    }

    tbody {
        display: block;
    }

    tbody tr {
        display: block;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #fff;
        box-shadow: var(--shadow-sm);
        overflow: hidden;
    }

    tbody tr:hover {
        background: #fff;
    }

    td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        width: 100%;
        white-space: normal;
        border-bottom: 1px dashed #edf1fa;
        padding: 9px 10px;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: #6e7894;
        font-size: 11px;
        font-weight: 800;
        min-width: 40%;
        max-width: 48%;
        line-height: 1.4;
    }

    td > * {
        max-width: 58%;
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    td > form,
    td > .flex {
        max-width: 100%;
    }

    td form {
        width: 100%;
    }

    td .flex {
        justify-content: flex-end;
    }

    td[data-label="الإجراءات"] {
        align-items: flex-start;
    }

    td[data-label="الإجراءات"]::before {
        max-width: 100%;
        min-width: 100%;
    }

    td[data-label="الإجراءات"] > * {
        max-width: 100%;
        width: 100%;
    }

    .sales-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .sales-cards-grid {
        grid-template-columns: 1fr;
    }

    .sales-card {
        padding: 10px;
    }

    .sales-card-grid {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .sales-card-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .sales-card-actions .btn-secondary,
    .sales-card-actions .btn-danger {
        width: 100%;
        text-align: center;
    }

    .sales-card-actions .sales-status-form {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .sales-card-actions .sales-status-form select,
    .sales-card-actions .sales-status-form button {
        width: 100%;
    }

    .sales-actions .btn-secondary,
    .sales-actions .btn-danger {
        width: 100%;
        text-align: center;
    }

    .sales-actions form,
    .sales-status-form {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .sales-status-form select,
    .sales-status-form button {
        width: 100%;
    }

    .sales-source-status {
        font-size: 10px;
        line-height: 1.4;
    }

    .sales-pagination {
        justify-content: stretch;
    }

    .sales-pagination .btn-secondary {
        flex: 1;
        text-align: center;
    }
}

@media (max-width: 680px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-right {
        justify-content: space-between;
    }

    .flex {
        gap: 8px;
    }

    .mobile-tab-link {
        font-size: 10px;
        padding: 8px 4px;
    }

    .stat .value {
        font-size: 20px;
    }
}
