@font-face {
    font-family: "Noto Naskh Arabic";
    src: url("/assets/NotoNaskhArabic-VariableFont_wght.ttf") format("truetype");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: "Noto Naskh Arabic";
    src: url("/assets/NotoNaskhArabic-Bold.ttf") format("truetype");
    font-style: normal;
    font-weight: 700 900;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --bg: #0f172a;
    --top: #111827;
    --surface: #1e293b;
    --surface-raised: #27364b;
    --surface-soft: #172033;
    --field: #111827;
    --border: #334155;
    --border-strong: #475569;
    --text: #f8fafc;
    --muted: #cbd5e1;
    --subtle: #94a3b8;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, .16);
    --success: #22c55e;
    --success-dark: #14532d;
    --warning: #f59e0b;
    --warning-dark: #78350f;
    --danger: #ef4444;
    --danger-dark: #7f1d1d;
    --return: #9f1239;
    --overlay: rgba(2, 6, 23, .72);
    --shadow: 0 22px 55px rgba(2, 6, 23, .24);
    --shadow-soft: 0 12px 28px rgba(2, 6, 23, .14);
    --sidebar-width: 292px;
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 15px;
    --radius-sm: 11px;
    --font: "Noto Naskh Arabic", Tahoma, Arial, sans-serif;
}

html[data-theme="light"] {
    color-scheme: light;
    --bg: #efebdd;
    --top: #f7f2e8;
    --surface: #faf7ef;
    --surface-raised: #f1ecdf;
    --surface-soft: #f7f2e8;
    --field: #fffdf8;
    --border: #d8cdbc;
    --border-strong: #c5b8a5;
    --text: #1f2937;
    --muted: #6b6458;
    --subtle: #81786b;
    --primary-soft: rgba(37, 99, 235, .11);
    --overlay: rgba(31, 41, 55, .42);
    --shadow: 0 22px 55px rgba(74, 59, 39, .13);
    --shadow-soft: 0 12px 28px rgba(74, 59, 39, .09);
}

*, *::before, *::after { box-sizing: border-box; }

html { min-width: 320px; overflow-x: hidden; background: var(--bg); scroll-behavior: smooth; }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    min-height: 100svh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
svg { width: 1.25rem; height: 1.25rem; fill: currentColor; }
bdi, [dir="ltr"] { unicode-bidi: isolate; }

:focus-visible {
    outline: 3px solid rgba(59, 130, 246, .42);
    outline-offset: 2px;
}

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Application shell */
.app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
    min-height: 100vh;
    min-height: 100svh;
}

.app-sidebar {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100svh;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--top), color-mix(in srgb, var(--top) 88%, var(--bg)));
    border-inline-start: 1px solid var(--border);
    box-shadow: -12px 0 38px rgba(2, 6, 23, .08);
    padding: 22px 17px 16px;
}

.sidebar-head { padding: 0 5px 17px; border-bottom: 1px solid var(--border); }
.sidebar-close { display: none; margin-inline-start: auto; margin-bottom: 8px; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark, .mobile-brand__logo, .login-logo {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}
.brand-mark { width: 68px; height: 68px; border-radius: 21px; }
.brand-mark img, .mobile-brand__logo img, .login-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-mark__fallback { display: none; place-items: center; width: 100%; height: 100%; color: #fff; background: var(--primary); font-family: Arial, sans-serif; font-size: 22px; font-weight: 800; }
[data-logo-wrap].is-fallback img { display: none; }
[data-logo-wrap].is-fallback .brand-mark__fallback { display: grid; }
.brand-copy { display: flex; min-width: 0; flex-direction: column; }
.brand-copy strong { overflow: hidden; color: var(--text); font-size: 21px; font-weight: 800; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small { color: var(--subtle); font-size: 12px; line-height: 1.45; }
.shop-meta { display: flex; flex-wrap: wrap; gap: 4px 7px; margin-top: 11px; padding-inline: 5px; color: var(--muted); font-size: 12px; }

.sidebar-nav { display: flex; flex: 1; flex-direction: column; gap: 5px; padding: 18px 0; }
.sidebar-label { margin: 0 12px 7px; color: var(--subtle); font-size: 12px; font-weight: 700; }
.nav-link {
    display: flex;
    align-items: center;
    min-height: 49px;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 15px;
    color: var(--muted);
    font-size: 15px;
    font-weight: 700;
    transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}
.nav-link:hover { color: var(--text); background: var(--surface-raised); border-color: var(--border); transform: translateX(-2px); }
.nav-link.is-active { color: #fff; background: linear-gradient(135deg, #2563eb, #1d4ed8); border-color: rgba(147, 197, 253, .28); box-shadow: 0 9px 22px rgba(37, 99, 235, .28); }
.nav-link__icon { display: grid; width: 33px; height: 33px; place-items: center; border-radius: 10px; background: var(--surface); color: var(--subtle); }
.nav-link.is-active .nav-link__icon { color: #fff; background: rgba(255, 255, 255, .14); }

.sidebar-foot { display: grid; gap: 8px; padding-top: 13px; border-top: 1px solid var(--border); }
.theme-switch, .logout-button {
    width: 100%; min-height: 43px; display: flex; align-items: center; gap: 10px; padding: 7px 11px;
    border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 700;
}
.theme-switch:hover, .logout-button:hover { background: var(--surface-raised); color: var(--text); }
.logout-button:hover { border-color: rgba(239, 68, 68, .55); color: #fca5a5; }
.theme-switch__icon { display: grid; place-items: center; }
.theme-icon--sun { display: none; }
html[data-theme="light"] .theme-icon--sun { display: block; }
html[data-theme="light"] .theme-icon--moon { display: none; }
.sidebar-copyright { margin: 5px 0 0; color: var(--subtle); font-size: 11px; text-align: center; }

.app-main { grid-column: 1; grid-row: 1; min-width: 0; }
.mobile-header { display: none; }
.drawer-scrim { display: none; }
.page-shell { width: 100%; max-width: 1720px; min-width: 0; margin: 0 auto; padding: 31px 38px 52px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-eyebrow { margin: 0 0 2px; color: var(--subtle); font-size: 13px; font-weight: 700; }
.page-title { margin: 0; color: var(--text); font-size: clamp(2rem, 3vw, 2.75rem); font-weight: 850; line-height: 1.2; letter-spacing: -.02em; }

/* Reusable page components */
.card, .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
}
.card { padding: 22px; }
.panel { padding: 25px; }
.card--raised, .subpanel { background: var(--surface-raised); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.card-title { margin: 0; color: var(--text); font-size: 21px; font-weight: 800; line-height: 1.35; }
.card-subtitle { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.section-title { margin: 0 0 12px; font-size: 24px; font-weight: 800; }
.section-lead { margin: -7px 0 18px; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stats-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card { position: relative; min-height: 124px; overflow: hidden; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-soft); }
.stat-card::after { position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; content: ""; background: var(--primary); }
.stat-card__label { margin: 0; color: var(--muted); font-size: 14px; font-weight: 700; }
.stat-card__value { margin: 8px 0 0; color: var(--text); font-family: var(--font); font-size: clamp(1.4rem, 2vw, 1.9rem); font-weight: 850; line-height: 1.25; }
.stat-card__icon { display: grid; width: 38px; height: 38px; margin-bottom: 9px; place-items: center; border-radius: 12px; color: var(--primary); background: var(--primary-soft); }
.stat-card--success::after { background: var(--success); }
.stat-card--success .stat-card__icon { color: var(--success); background: rgba(34, 197, 94, .13); }
.stat-card--warning::after { background: var(--warning); }
.stat-card--warning .stat-card__icon { color: var(--warning); background: rgba(245, 158, 11, .14); }
.stat-card--danger::after { background: var(--danger); }
.stat-card--danger .stat-card__icon { color: var(--danger); background: rgba(239, 68, 68, .13); }
.stat-card--expense-focus { border-color: color-mix(in srgb, var(--danger) 48%, var(--border)); box-shadow: 0 14px 32px rgba(239, 68, 68, .13); }
.stat-card--expense-focus .stat-card__label { color: var(--danger); }
.stat-card--expense-focus .field-hint { color: var(--danger); font-weight: 750; }
.dashboard-chart-card { min-height: 545px; }
.dashboard-chart { display: block; width: 100%; height: 420px; min-height: 420px; margin-top: 6px; overflow: visible; }
.dashboard-chart-layout { display: block; }
.chart-summary { display: flex; align-items: center; gap: 10px; }
.chart-summary__max { color: var(--muted); font-size: 12px; font-weight: 800; white-space: nowrap; }
.chart-grid line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 5 8; opacity: .72; vector-effect: non-scaling-stroke; }
.chart-grid .chart-grid__baseline { stroke-width: 2; stroke-dasharray: none; opacity: 1; }
.chart-area { fill: url(#sales-area-gradient); }
.chart-line { fill: none; stroke: #3b82f6; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 8px 10px rgba(37, 99, 235, .28)); vector-effect: non-scaling-stroke; }
.chart-guide { stroke: #60a5fa; stroke-width: 1; stroke-dasharray: 3 7; opacity: .28; vector-effect: non-scaling-stroke; }
.chart-point-halo { fill: rgba(59, 130, 246, .2); filter: url(#sales-point-glow); }
.chart-point { fill: #fff; stroke: #2563eb; stroke-width: 4; vector-effect: non-scaling-stroke; }
.chart-value { fill: var(--text); font-family: Arial, sans-serif; font-size: 12px; font-weight: 800; }
.chart-date { fill: var(--muted); font-family: var(--font); font-size: 14px; font-weight: 750; }
.chart-point-group { outline: none; }
.chart-point-group:hover .chart-point, .chart-point-group:focus .chart-point { fill: #60a5fa; stroke: #fff; }

.split-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); gap: 18px; align-items: start; }
.split-layout--wide-aside { grid-template-columns: minmax(0, 1fr) minmax(350px, 520px); }
.debts-layout { grid-template-columns: minmax(0, 1fr) minmax(260px, 310px); gap: 22px; }
.debt-main { min-width: 0; padding: 28px; }
.receipt-amount-card { margin-bottom: 26px; }
.receipt-selection-count { flex: 0 0 auto; }
.debt-products { min-width: 0; }
.debt-products > .card-header { margin-top: 2px; }
.data-table.debt-table { min-width: 1040px; }
.data-table.debt-table th, .data-table.debt-table td { padding: 14px; font-size: 14px; }
.receipt-select-column, .receipt-select-cell { width: 82px; text-align: center !important; }
.receipt-select-all { justify-content: center; color: var(--muted); white-space: nowrap; }
.receipt-debt-option { display: grid; min-height: 34px; place-items: center; cursor: pointer; }
.receipt-debt-option input, .receipt-select-all input { width: 22px; height: 22px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.debt-table tbody tr:has([data-receipt-debt]:checked) { background: var(--primary-soft); }
.debt-table .table-actions input { width: 112px; min-width: 112px; }
.customer-edit-panel { margin-top: 24px; }
.customer-edit-panel > summary { display: grid; gap: 2px; cursor: pointer; list-style: none; }
.customer-edit-panel > summary::-webkit-details-marker { display: none; }
.customer-edit-panel > summary span { color: var(--text); font-size: 17px; font-weight: 850; }
.customer-edit-panel > summary small { color: var(--muted); font-size: 13px; }
.customer-edit-panel[open] > summary { margin-bottom: 20px; }

.report-toolbar-card { margin-bottom: 20px; padding: 27px; }
.report-toolbar-actions { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.report-day-form { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.report-day-picker { flex: 0 1 260px; }
.report-recent-days { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--border); }
.report-day-chip { min-height: 35px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 800; }
.report-day-chip:hover { border-color: var(--border-strong); color: var(--text); }
.report-day-chip.is-active { border-color: transparent; background: var(--primary); color: #fff; box-shadow: 0 7px 18px rgba(37, 99, 235, .24); }
.report-primary-stats .stat-card { min-height: 150px; padding: 23px; }
.report-primary-stats .stat-card__value { margin-top: 13px; font-size: clamp(1.55rem, 2.15vw, 2.15rem); }
.report-primary-stats .field-hint { margin-top: 7px; }
.report-metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0 0 20px; }
.report-metric-strip > div { display: grid; min-width: 0; gap: 3px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-raised); }
.report-metric-strip span { color: var(--muted); font-size: 12px; font-weight: 750; }
.report-metric-strip strong { overflow: hidden; color: var(--text); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.reports-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.report-detail, .report-side { display: grid; min-width: 0; align-content: start; gap: 18px; }
.report-section-card { min-width: 0; padding: 0; overflow: hidden; }
.report-section-card > summary { display: flex; min-height: 82px; align-items: center; justify-content: space-between; gap: 16px; padding: 19px 23px; cursor: pointer; list-style: none; }
.report-section-card > summary::-webkit-details-marker { display: none; }
.report-section-card > summary > span:first-child { display: grid; min-width: 0; gap: 2px; }
.report-section-card > summary strong { font-size: 20px; }
.report-section-card > summary small { color: var(--muted); font-size: 13px; }
.report-section-card[open] > summary { border-bottom: 1px solid var(--border); }
.report-section-card > .table-wrap { width: auto; margin: 20px 22px 22px; }
.report-section-card > .empty-state { min-height: 135px; }
.data-table.report-table { min-width: 900px; }
.data-table.report-table th, .data-table.report-table td { padding: 14px; font-size: 14px; }
.report-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.report-all-time > summary { display: grid; gap: 2px; cursor: pointer; list-style: none; }
.report-all-time > summary::-webkit-details-marker { display: none; }
.report-all-time > summary span { font-size: 17px; font-weight: 850; }
.report-all-time > summary small { color: var(--muted); font-size: 12px; }
.report-all-time[open] > summary { margin-bottom: 17px; }
.report-all-time-grid { display: grid; gap: 9px; }
.report-all-time-grid > div { display: grid; gap: 2px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.report-all-time-grid span { color: var(--muted); font-size: 11px; font-weight: 750; }
.report-all-time-grid strong { font-size: 13px; }
.report-midnight-note h3 { margin: 0 0 5px; font-size: 17px; }
.report-midnight-note p { margin: 0; color: var(--muted); font-size: 13px; }
.sales-ledger-layout { grid-template-columns: minmax(0, 1fr) minmax(250px, 300px); }
.sales-history-card { min-width: 0; }
.sales-pending-card { min-width: 0; padding: 16px; }
.sales-pending-card .card-header { margin-bottom: 11px; }
.sales-pending-card .stack { max-height: 430px; gap: 8px; overflow-y: auto; padding-inline-end: 2px; scrollbar-width: thin; }
.sales-pending-card .list-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 9px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-raised); }
.sales-pending-card .list-row > div { display: grid; min-width: 0; gap: 1px; }
.sales-pending-card .list-row strong, .sales-pending-card .list-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sales-pending-card .list-row strong { font-size: 13px; }
.sales-pending-card .list-row small { color: var(--muted); font-size: 11px; }
.sales-pending-card .list-row .btn { min-height: 30px; flex: 0 0 auto; padding: 4px 8px; }
.stack { display: grid; gap: 16px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar > .grow { flex: 1 1 240px; }
.sales-product-toolbar > input { flex: 1 1 260px; }
.sales-product-toolbar > select { flex: 0 1 180px; }
.product-picker { display: grid; max-height: 310px; gap: 8px; overflow-y: auto; padding-inline-end: 3px; scrollbar-width: thin; }
.picker-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-raised); }
.picker-row > div { display: grid; min-width: 0; gap: 2px; }
.picker-row strong, .picker-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-row small { color: var(--muted); font-size: 12px; }
.picker-row .btn { flex: 0 0 auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-group { display: grid; gap: 6px; min-width: 0; }
.form-group--full { grid-column: 1 / -1; }
.form-group label, .field-label { color: var(--muted); font-size: 13px; font-weight: 750; }

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea, .form-control {
    width: 100%; min-height: 44px; padding: 8px 13px; border: 1px solid var(--border); border-radius: 13px;
    background: var(--field); color: var(--text); text-align: right; outline: none; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
textarea { min-height: 105px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--subtle); opacity: .9; }
input:focus, select:focus, textarea:focus, .form-control:focus { border-color: #3b82f6; box-shadow: 0 0 0 4px rgba(37, 99, 235, .13); }
.search-suggestions { position: fixed; z-index: 90; max-height: min(390px, 52vh); overflow-y: auto; padding: 7px; border: 1px solid var(--border-strong); border-radius: 16px; background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: 0 22px 55px rgba(2, 6, 23, .28); direction: rtl; backdrop-filter: blur(18px); }
.search-suggestions[hidden] { display: none !important; }
.search-suggestion { width: 100%; display: grid; grid-template-columns: 40px minmax(0, 1fr) 24px; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 11px; background: transparent; color: var(--text); cursor: pointer; text-align: right; transition: background .14s ease, transform .14s ease; }
.search-suggestion:hover, .search-suggestion.is-active { background: var(--primary-soft); transform: translateX(-2px); }
.search-suggestion.is-disabled { cursor: not-allowed; opacity: .56; }
.search-suggestion.is-disabled:hover { background: transparent; transform: none; }
.search-suggestion__mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: linear-gradient(145deg, #2563eb, #1d4ed8); color: #fff; font-family: Arial, sans-serif; font-size: 14px; font-weight: 900; box-shadow: 0 7px 18px rgba(37, 99, 235, .24); }
.search-suggestion__copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.search-suggestion__copy strong { overflow: hidden; color: var(--text); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.search-suggestion__copy small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.search-suggestion__arrow { color: var(--primary); font-size: 18px; font-weight: 900; }
.search-suggestions__empty { margin: 0; padding: 18px 12px; color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; }
input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .6; }
.field-hint { margin: 0; color: var(--subtle); font-size: 12px; }
.check-row { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }

.btn {
    display: inline-flex; min-height: 41px; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px;
    border: 1px solid transparent; border-radius: 13px; background: var(--surface-raised); color: var(--text); cursor: pointer; font-weight: 800; line-height: 1.2;
    transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled, .btn.is-disabled { cursor: not-allowed; opacity: .48; transform: none; }
.btn--large { min-height: 48px; padding-inline: 20px; font-size: 16px; }
.btn--small { min-height: 33px; padding: 5px 11px; border-radius: 10px; font-size: 12px; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); }
.btn--success { background: var(--success); color: #052e16; }
.btn--success:hover { background: #16a34a; color: #fff; }
.btn--warning { background: var(--warning); color: #111827; }
.btn--warning:hover { background: #d97706; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #dc2626; }
.btn--ghost { border-color: var(--border); background: var(--surface-raised); color: var(--text); }
.btn--ghost:hover { border-color: var(--border-strong); }
.icon-button { display: grid; width: 42px; height: 42px; padding: 0; place-items: center; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--text); cursor: pointer; }
.icon-button:hover { background: var(--surface-raised); }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; border-spacing: 0; }
.data-table th, .data-table td { padding: 12px 13px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: middle; }
.data-table th { position: sticky; top: 0; z-index: 1; background: var(--surface-raised); color: var(--muted); font-size: 12px; font-weight: 850; white-space: nowrap; }
.data-table td { color: var(--text); font-size: 13px; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .15s ease; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--surface-raised) 65%, transparent); }
.cell-number { direction: ltr; text-align: right; unicode-bidi: isolate; white-space: nowrap; }
.table-actions { display: flex; flex-wrap: nowrap; gap: 6px; }

.status-pill { display: inline-flex; min-height: 27px; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 850; white-space: nowrap; }
.status-pill::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.status-pill--success, .status-pill--paid { color: #4ade80; background: rgba(20, 83, 45, .46); }
.status-pill--warning, .status-pill--pending { color: #fbbf24; background: rgba(120, 53, 15, .42); }
.status-pill--danger, .status-pill--debt { color: #f87171; background: rgba(127, 29, 29, .43); }
.status-pill--neutral { color: var(--muted); background: var(--surface-raised); }
html[data-theme="light"] .status-pill--success, html[data-theme="light"] .status-pill--paid { color: #166534; background: #dcfce7; }
html[data-theme="light"] .status-pill--warning, html[data-theme="light"] .status-pill--pending { color: #92400e; background: #fef3c7; }
html[data-theme="light"] .status-pill--danger, html[data-theme="light"] .status-pill--debt { color: #991b1b; background: #fee2e2; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 5px; border-radius: 15px; background: var(--surface-raised); scrollbar-width: thin; }
.tab { flex: 0 0 auto; min-height: 38px; padding: 7px 14px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 750; }
.tab:hover { color: var(--text); }
.tab.is-active, .tab[aria-selected="true"] { background: var(--primary); color: #fff; box-shadow: 0 7px 16px rgba(37, 99, 235, .22); }
.empty-state { display: grid; min-height: 180px; place-items: center; padding: 30px; color: var(--muted); text-align: center; }
.empty-state__icon { display: grid; width: 52px; height: 52px; margin: 0 auto 9px; place-items: center; border-radius: 17px; background: var(--surface-raised); color: var(--subtle); }
.empty-state h3 { margin: 0 0 4px; color: var(--text); font-size: 18px; }
.empty-state p { max-width: 440px; margin: 0; }

/* Toasts and confirmation */
.toast-region { position: fixed; z-index: 100; top: 22px; left: 22px; display: grid; width: min(390px, calc(100vw - 32px)); gap: 10px; pointer-events: none; }
.toast { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 15px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(14px); pointer-events: auto; animation: toast-in .24s ease both; }
.toast.is-leaving { animation: toast-out .2s ease both; }
.toast p { margin: 0; color: var(--text); font-size: 13px; font-weight: 700; }
.toast__dot { width: 10px; height: 10px; border-radius: 50%; background: #60a5fa; box-shadow: 0 0 0 5px rgba(96, 165, 250, .12); }
.toast--success .toast__dot { background: var(--success); box-shadow: 0 0 0 5px rgba(34, 197, 94, .12); }
.toast--warning .toast__dot { background: var(--warning); box-shadow: 0 0 0 5px rgba(245, 158, 11, .12); }
.toast--danger .toast__dot, .toast--error .toast__dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(239, 68, 68, .12); }
.toast__close { width: 29px; height: 29px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font: 22px/1 Arial, sans-serif; }
.toast__close:hover { background: var(--surface-raised); color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-7px) scale(.98); } }

.confirm-dialog { width: min(460px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 24px; background: transparent; color: var(--text); }
.confirm-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(4px); }
.confirm-card { display: grid; grid-template-columns: auto 1fr; gap: 15px; padding: 24px; border: 1px solid var(--border); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.confirm-card__mark { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 14px; background: rgba(245, 158, 11, .14); color: var(--warning); font: 800 23px/1 Arial, sans-serif; }
.confirm-dialog.is-danger .confirm-card__mark { color: var(--danger); background: rgba(239, 68, 68, .13); }
.confirm-card__copy h2 { margin: 0 0 5px; font-size: 21px; }
.confirm-card__copy p { margin: 0; color: var(--muted); font-size: 14px; }
.confirm-card__actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; margin-top: 7px; }

/* Login */
.login-body { overflow-x: hidden; background: var(--bg); }
.login-page { position: relative; display: grid; min-height: 100vh; min-height: 100svh; place-items: center; padding: 40px 24px 24px; overflow: hidden; isolation: isolate; }
.login-page::before, .login-page::after { position: absolute; z-index: -1; width: 560px; height: 560px; border-radius: 50%; content: ""; filter: blur(3px); opacity: .65; }
.login-page::before { top: -300px; right: -180px; background: radial-gradient(circle, rgba(37, 99, 235, .34), transparent 67%); }
.login-page::after { bottom: -350px; left: -160px; background: radial-gradient(circle, rgba(34, 197, 94, .14), transparent 67%); }
.login-theme-control { position: fixed; z-index: 5; top: 20px; left: 20px; }
.login-theme-control__sun { display: none; }
html[data-theme="light"] .login-theme-control__sun { display: inline; }
html[data-theme="light"] .login-theme-control__moon { display: none; }
.login-layout { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(390px, .96fr); width: min(1010px, 100%); overflow: hidden; border: 1px solid var(--border); border-radius: 34px; background: var(--surface); box-shadow: var(--shadow); }
.login-brand-panel { position: relative; display: flex; min-height: 590px; flex-direction: column; align-items: flex-start; justify-content: center; overflow: hidden; padding: 50px; background: linear-gradient(145deg, #111827 0%, #172554 58%, #1e3a8a 130%); color: #fff; }
.login-brand-panel::after { position: absolute; inset: 18px; border: 1px solid rgba(255, 255, 255, .08); border-radius: 26px; content: ""; pointer-events: none; }
.login-brand-panel__glow { position: absolute; top: -120px; left: -90px; width: 330px; height: 330px; border-radius: 50%; background: rgba(59, 130, 246, .25); filter: blur(10px); }
.login-logo { z-index: 1; width: 118px; height: 118px; margin-bottom: 20px; border-color: rgba(255, 255, 255, .15); border-radius: 31px; background: rgba(255, 255, 255, .07); }
.login-logo--small { width: 62px; height: 62px; margin: 0; border-radius: 18px; }
.login-kicker { z-index: 1; margin: 0; color: #bfdbfe; font-size: 14px; font-weight: 800; }
.login-brand-panel h1 { z-index: 1; margin: 2px 0 10px; font-size: clamp(2.3rem, 4vw, 3.7rem); font-weight: 900; line-height: 1.2; }
.login-brand-panel__lead { z-index: 1; max-width: 450px; margin: 0; color: #dbeafe; font-size: 17px; }
.login-feature-list { z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 25px; }
.login-feature-list span { padding: 6px 13px; border: 1px solid rgba(191, 219, 254, .25); border-radius: 999px; background: rgba(255, 255, 255, .08); color: #eff6ff; font-size: 13px; font-weight: 750; }
.login-contact { z-index: 1; display: flex; flex-wrap: wrap; gap: 5px 9px; margin: 27px 0 0; color: #bfdbfe; font-size: 13px; }
.login-card { display: flex; min-height: 590px; flex-direction: column; justify-content: center; padding: 52px; background: var(--surface); }
.login-card__mobile-brand { display: none; }
.login-badge { align-self: flex-start; padding: 4px 11px; border-radius: 999px; background: var(--primary-soft); color: #60a5fa; font-size: 12px; font-weight: 850; }
html[data-theme="light"] .login-badge { color: #1d4ed8; }
.login-card h2 { margin: 13px 0 2px; font-size: 31px; font-weight: 900; }
.login-card__lead { margin: 0 0 24px; color: var(--muted); }
.login-alert { margin-bottom: 13px; padding: 10px 12px; border: 1px solid rgba(96, 165, 250, .35); border-radius: 12px; background: rgba(37, 99, 235, .1); color: var(--text); font-size: 13px; }
.login-alert--error, .login-alert--danger { border-color: rgba(239, 68, 68, .42); background: rgba(239, 68, 68, .1); }
.login-alert--success { border-color: rgba(34, 197, 94, .4); background: rgba(34, 197, 94, .1); }
.login-form { display: grid; gap: 9px; }
.login-form > label { color: var(--muted); font-size: 13px; font-weight: 800; }
.input-shell { position: relative; }
.input-shell input { min-height: 50px !important; padding-inline: 39px 73px !important; }
.input-shell__icon { position: absolute; z-index: 1; top: 50%; right: 15px; color: var(--primary); font: 10px/1 Arial, sans-serif; transform: translateY(-50%); }
.password-toggle { position: absolute; z-index: 1; top: 50%; left: 7px; min-height: 35px; padding: 4px 10px; border: 0; border-radius: 10px; background: var(--surface-raised); color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 800; transform: translateY(-50%); }
.password-toggle:hover { color: var(--text); }
.login-submit { width: 100%; justify-content: space-between; margin-top: 8px; }
.login-help { margin: 20px 0 0; color: var(--subtle); font-size: 12px; text-align: center; }
.login-footer { margin-top: 18px; color: var(--subtle); font-size: 12px; text-align: center; }

@media (max-width: 1499px) {
    .debts-layout { grid-template-columns: 1fr; }
}

@media (max-width: 1099px) {
    .app-shell { display: block; }
    .app-sidebar { position: fixed; inset-block: 0; right: 0; left: auto; width: min(320px, 88vw); transform: translateX(105%); transition: transform .24s ease; }
    .app-sidebar.is-open { transform: translateX(0); }
    .sidebar-close { display: grid; }
    .drawer-scrim { position: fixed; z-index: 25; inset: 0; width: 100%; height: 100%; border: 0; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
    .drawer-scrim.is-visible { display: block; opacity: 1; pointer-events: auto; }
    body.is-drawer-open { overflow: hidden; }
    .app-main { min-width: 0; }
    .mobile-header { position: sticky; z-index: 20; top: 0; display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 17px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--top) 92%, transparent); box-shadow: 0 8px 24px rgba(2, 6, 23, .08); backdrop-filter: blur(16px); }
    .mobile-brand { display: flex; min-width: 0; align-items: center; gap: 9px; }
    .mobile-brand__logo { width: 43px; height: 43px; border-radius: 13px; }
    .mobile-brand strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .page-shell { padding: 25px 24px 44px; }
    .toast-region { top: 82px; }
}

@media (max-width: 900px) {
    .stats-grid, .stats-grid--three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split-layout, .split-layout--wide-aside { grid-template-columns: 1fr; }
    .report-metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .report-side { grid-template-columns: 1fr; }
    .sales-ledger-layout { grid-template-columns: 1fr; }
    .dashboard-chart-card { min-height: 455px; }
    .dashboard-chart { min-height: 330px; }
    .form-grid--three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-layout { grid-template-columns: 1fr; width: min(520px, 100%); }
    .login-brand-panel { display: none; }
    .login-card { min-height: 0; padding: 43px; }
    .login-card__mobile-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 27px; }
    .login-card__mobile-brand strong { font-size: 21px; }
}

@media (max-width: 640px) {
    .page-shell { padding: 21px 15px 38px; }
    .page-heading { margin-bottom: 17px; }
    .page-eyebrow { font-size: 12px; }
    .page-title { font-size: 2rem; }
    .card, .panel { border-radius: 21px; padding: 17px; }
    .stats-grid, .stats-grid--three { grid-template-columns: 1fr; gap: 10px; }
    .stat-card { min-height: 106px; }
    .form-grid, .form-grid--three { grid-template-columns: 1fr; }
    .form-group--full { grid-column: auto; }
    .debt-main { padding: 17px; }
    .receipt-selection-count { width: 100%; justify-content: center; }
    .report-toolbar-card { padding: 19px; }
    .report-toolbar-actions, .report-day-form { align-items: stretch; flex-direction: column; }
    .report-toolbar-actions > form, .report-day-form > *, .report-day-picker { width: 100%; flex-basis: auto; }
    .report-recent-days { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
    .report-recent-days .field-label { flex: 0 0 auto; }
    .report-day-chip { flex: 0 0 auto; }
    .report-primary-stats .stat-card { min-height: 118px; }
    .report-metric-strip { grid-template-columns: 1fr; }
    .report-section-card > summary { min-height: 74px; padding: 16px 17px; }
    .report-section-card > .table-wrap { margin: 13px; }
    .button-row .btn { flex: 1 1 135px; }
    .mobile-full { width: 100%; }
    .toast-region { right: 12px; left: 12px; width: auto; }
    .confirm-card { padding: 19px; }
    .confirm-card__actions { flex-direction: column-reverse; }
    .confirm-card__actions .btn { width: 100%; }
    .search-suggestions { max-height: 48vh; padding: 5px; border-radius: 14px; }
    .search-suggestion { grid-template-columns: 36px minmax(0, 1fr) 20px; gap: 8px; padding: 8px; }
    .search-suggestion__mark { width: 34px; height: 34px; border-radius: 10px; }
    .sales-product-toolbar > input { flex-basis: 100%; }
    .sales-product-toolbar > select, .sales-product-toolbar > .btn { flex: 1 1 135px; }
    .product-picker { max-height: 42vh; }
    .picker-row { gap: 8px; padding: 8px; }
    .sales-pending-card .stack { max-height: 300px; }
    .data-table.debt-table, .data-table.report-table { min-width: 0; }
    .data-table--responsive { min-width: 0; }
    .data-table--responsive thead { display: none; }
    .data-table--responsive, .data-table--responsive tbody, .data-table--responsive tr, .data-table--responsive td { display: block; width: 100%; }
    .data-table--responsive tbody { padding: 8px; }
    .data-table--responsive tr { margin-bottom: 9px; padding: 9px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-raised); }
    .data-table--responsive tr:last-child { margin-bottom: 0; }
    .data-table--responsive td { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 7px 5px; border: 0; }
    .data-table--responsive td::before { flex: 0 0 auto; content: attr(data-label); color: var(--subtle); font-size: 11px; font-weight: 800; }
    .login-page { align-items: start; padding: 66px 13px 20px; }
    .login-layout { border-radius: 25px; }
    .login-card { padding: 29px 21px; }
    .login-card h2 { font-size: 27px; }
    .login-theme-control { top: 13px; left: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
