* {
    box-sizing: border-box;
}

html {
    font-size: 15px;
}

body {
    margin: 0;
    font-family: "Vazirmatn", "IRANSans", "Segoe UI", Tahoma, Arial, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

.app {
    min-height: 100vh;
    display: flex;
}

/* Sidebar */

.sidebar {
    width: 250px;
    background: #172033;
    color: #fff;
    padding: 24px 16px;
    flex-shrink: 0;
}

.brand {
    padding: 8px 12px 28px;
}

.brand-title {
    font-size: 20px;
    font-weight: bold;
}

.brand-subtitle {
    margin-top: 6px;
    font-size: 12px;
    color: #9ca8bb;
}

.menu-title {
    padding: 14px 12px 8px;
    font-size: 11px;
    color: #7f8ba0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    margin: 4px 0;
    border-radius: 9px;
    color: #cbd5e1;
    transition: 0.2s;
}

.menu-item:hover,
.menu-item.active {
    background: #26334d;
    color: #fff;
}

/* Main */

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    height: 70px;
    background: #fff;
    border-bottom: 1px solid #e7eaf0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.page-title {
    font-size: 19px;
    font-weight: bold;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-name {
    font-size: 13px;
    color: #4b5563;
}

.logout {
    color: #dc2626;
    font-size: 13px;
}

.user-area form { margin: 0; }
.user-area button.logout { border: 0; padding: 0; background: transparent; cursor: pointer; font-family: inherit; }

/* Content */

.content {
    padding: 28px;
}

/* Cards */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.stats-grid.dashboard-stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat-card {
    background: #fff;
    border: 1px solid #e7eaf0;
    border-radius: 12px;
    padding: 20px;
}

.stat-label {
    color: #6b7280;
    font-size: 13px;
}

.stat-value {
    margin-top: 10px;
    font-size: 25px;
    font-weight: bold;
}

/* Panels */

.panel {
    background: #fff;
    border: 1px solid #e7eaf0;
    border-radius: 12px;
    margin-bottom: 22px;
}

.panel-header {
    padding: 18px 20px;
    border-bottom: 1px solid #edf0f4;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title {
    font-size: 15px;
    font-weight: bold;
}

.panel-body {
    padding: 20px;
}

/* Buttons */

.btn {
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    display: inline-block;
}

.btn-primary {
    background: #27364f;
    color: #fff;
}

.btn-primary:hover {
    background: #1d2a3f;
}

.btn-light {
    background: #f1f3f7;
    color: #374151;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

/* Customer list */

.customer-list {
    display: grid;
    gap: 10px;
}

.customer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid #e7eaf0;
    border-radius: 9px;
}

.customer-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.customer-name {
    font-weight: bold;
}

.customer-phone {
    color: #6b7280;
    font-size: 12px;
}

.order-badge {
    background: #e8f5ed;
    color: #187443;
    padding: 5px 9px;
    border-radius: 20px;
    font-size: 11px;
}

.no-order-badge {
    background: #f1f3f6;
    color: #6b7280;
    padding: 5px 9px;
    border-radius: 20px;
    font-size: 11px;
}

/* Responsive */

@media (max-width: 1000px) {

    .sidebar {
        width: 210px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid.dashboard-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {

    .app {
        display: block;
    }

    .sidebar {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid.dashboard-stats-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }
}
.page-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.page-intro-title {
    font-size: 20px;
    font-weight: bold;
    color: #1f2937;
}

.page-intro-text {
    margin-top: 7px;
    color: #6b7280;
    font-size: 13px;
}

.alert {
    padding: 13px 16px;
    border-radius: 9px;
    margin-bottom: 20px;
    font-size: 13px;
}

.alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group-wide {
    max-width: 650px;
}

.form-group label {
    font-size: 13px;
    font-weight: bold;
    color: #374151;
}

.form-control {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid #d9dee7;
    border-radius: 8px;
    background: #fff;
    color: #1f2937;
    outline: none;
    font-size: 13px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: #64748b;
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.10);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.data-table th {
    background: #f8fafc;
    color: #64748b;
    font-size: 12px;
    font-weight: bold;
    text-align: right;
    padding: 13px 12px;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.data-table td {
    padding: 11px 8px;
    border-bottom: 1px solid #edf0f4;
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.current-stock {
    display: inline-block;
    min-width: 90px;
    color: #64748b;
    font-size: 12px;
    white-space: nowrap;
}

.remove-row {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: #fef2f2;
    color: #dc2626;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.remove-row:hover {
    background: #fee2e2;
}

.receipt-summary {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-top: 22px;
    padding: 16px 18px;
    background: #f8fafc;
    border: 1px solid #e8ecf2;
    border-radius: 9px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.summary-item span {
    color: #6b7280;
    font-size: 12px;
}

.summary-item strong {
    color: #1f2937;
    font-size: 15px;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid #edf0f4;
}

.success-page {
    min-height: calc(100vh - 150px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-card {
    width: 100%;
    max-width: 620px;
    background: #fff;
    border: 1px solid #e7eaf0;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}

.success-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e8f5ed;
    color: #187443;
    font-size: 30px;
    font-weight: bold;
}

.success-title {
    font-size: 21px;
    font-weight: bold;
    color: #1f2937;
}

.success-text {
    margin-top: 9px;
    color: #6b7280;
    font-size: 13px;
}

.success-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 28px;
}

.success-detail {
    padding: 15px;
    background: #f8fafc;
    border: 1px solid #e8ecf2;
    border-radius: 9px;
}

.success-detail span {
    display: block;
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 7px;
}

.success-detail strong {
    display: block;
    color: #1f2937;
    font-size: 14px;
}

.success-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 28px;
}

@media (max-width: 700px) {

    .form-grid {
        grid-template-columns: 1fr;
    }

    .receipt-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .success-card {
        padding: 28px 20px;
    }

    .success-details {
        grid-template-columns: 1fr;
    }

    .success-actions {
        flex-direction: column;
    }

    .success-actions .btn {
        width: 100%;
    }
}
.stat-unit {
    font-size: 12px;
    font-weight: normal;
    color: #6b7280;
}

.empty-state {
    padding: 35px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 13px;
}

.product-name {
    font-weight: bold;
    color: #1f2937;
}

.stock-value {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 7px;
    background: #eef6f1;
    color: #187443;
    font-weight: bold;
    font-size: 12px;
    white-space: nowrap;
}

.stock-value.stock-zero {
    background: #f3f4f6;
    color: #6b7280;
}

.stock-table td {
    color: #4b5563;
    font-size: 13px;
}

.stock-summary {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.stock-summary-item {
    padding: 16px;
    border: 1px solid #e7eaf0;
    border-radius: 9px;
    background: #fafbfc;
}

.stock-summary-item span {
    display: block;
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 7px;
}

.stock-summary-item strong {
    color: #1f2937;
    font-size: 14px;
}

.stock-summary-total {
    background: #f1f5f9;
}

.stock-summary-total strong {
    font-size: 16px;
}

@media (max-width: 900px) {

    .stock-summary {
        grid-template-columns: repeat(2, 1fr);
    }

}

@media (max-width: 600px) {

    .stock-summary {
        grid-template-columns: 1fr;
    }

}
.payment-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
        "customer type"
        "balance amount"
        "method reference"
        "notes notes";
    gap: 20px 24px;
    align-items: stretch;
}

.payment-customer-field { grid-area: customer; }
.payment-customer-balance { grid-area: balance; }
.payment-amount-group { grid-area: amount; }
.payment-type-field { grid-area: type; }
.payment-method-field { grid-area: method; }
.payment-reference-field { grid-area: reference; }
.payment-notes-field { grid-area: notes; }

.payment-form-page {
    max-width: 1120px;
    margin: 0 auto;
}

.payment-form-page .page-intro {
    padding: 22px 25px;
    margin-bottom: 24px;
    border: 1px solid #dce5f0;
    border-right: 4px solid #536f95;
    border-radius: 13px;
    background: linear-gradient(120deg, #fff 0%, #f1f6fc 100%);
    box-shadow: 0 6px 20px rgba(15, 23, 42, .045);
}

.payment-form-page .page-intro-title {
    color: #172b46;
    font-size: 23px;
}

.payment-form-page .page-intro-text {
    margin-top: 7px;
    color: #64748b;
}

.payment-form-page .panel {
    overflow: hidden;
    border-color: #e1e7ef;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

.payment-form-page .panel-header {
    min-height: 60px;
    background: linear-gradient(120deg, #f8fafc, #eef4fb);
}

.payment-form-page .panel-body {
    padding: 24px;
}

.payment-form-page .form-group label {
    display: block;
    min-height: 20px;
    margin: 0;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
}

.payment-form-page .form-group {
    min-width: 0;
    gap: 8px;
}

.payment-form-page .form-control {
    min-height: 44px;
    border-color: #d7dee8;
    border-radius: 9px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.payment-form-page .form-control:focus {
    border-color: #647b9b;
    box-shadow: 0 0 0 3px rgba(71, 97, 133, .12);
}

.payment-amount-hint {
    display: block;
    margin-top: 7px;
    color: #64748b;
    font-size: 11px;
}

#payment-amount-words {
    color: #166534;
    font-size: 12px;
    font-weight: 700;
}

.payment-form-page .customer-balance-box {
    min-height: 68px;
    padding: 8px 12px;
    border-color: #dce5f0;
    border-radius: 10px;
    background: #f6f9fd;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 4px;
}

.payment-form-page .customer-balance-box > span {
    min-height: 20px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 20px;
}

.payment-form-page .customer-balance-box strong {
    display: flex;
    min-height: 44px;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid #d7dee8;
    border-radius: 9px;
    background: #fff;
    font-size: 15px;
}

.payment-form-page .payment-amount-controls {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.payment-form-page .payment-amount-controls #amount_display {
    min-width: 0;
    flex: 1 1 0;
}

.payment-form-page .settle-balance-button {
    flex: none;
    min-height: 44px;
    padding: 7px 12px;
    border: 1px solid #0f766e;
    border-radius: 8px;
    background: #e6f5f2;
    color: #115e59;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
}

.payment-form-page .settle-balance-button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.payment-form-wide {
    grid-column: 1 / -1;
}

.customer-balance-box {
    min-height: 42px;
    padding: 9px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.customer-balance-box span {
    color: #6b7280;
    font-size: 12px;
}

.customer-balance-box strong {
    font-size: 13px;
}

.balance-debtor {
    color: #b45309;
}

.balance-creditor {
    color: #2563eb;
}

.balance-zero {
    color: #187443;
}

.reference-box {
    margin-top: 20px;
    padding: 14px 18px;
    border-radius: 9px;
    background: #f8fafc;
    border: 1px solid #e7eaf0;
}

.reference-box span {
    display: block;
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 6px;
}

.reference-box strong {
    color: #1f2937;
    font-size: 14px;
}

@media (max-width: 700px) {

    .payment-form-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "customer"
            "balance"
            "amount"
            "type"
            "method"
            "reference"
            "notes";
    }

    .payment-form-wide {
        grid-column: auto;
    }

}

.customer-account-table td {
    vertical-align: middle;
}

.customer-table-name {
    font-weight: bold;
    color: #1f2937;
}

.customer-table-phone {
    margin-top: 5px;
    color: #6b7280;
    font-size: 11px;
}

.btn-small {
    padding: 7px 11px;
    font-size: 12px;
}

.account-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
}

.account-badge.debtor {
    background: #fff7ed;
    color: #c2410c;
}

.account-badge.creditor {
    background: #eff6ff;
    color: #2563eb;
}

.account-badge.settled {
    background: #ecfdf5;
    color: #187443;
}

.account-actions {
    display: flex;
    align-items: center;
    gap: 9px;
}

.account-main-value {
    font-size: 17px;
}

.account-main-value span {
    font-size: 15px;
}

.account-movement-table td {
    vertical-align: middle;
}

.movement-description {
    font-weight: bold;
    color: #374151;
}

.movement-reference {
    margin-top: 4px;
    color: #9ca3af;
    font-size: 11px;
}

.amount-debit {
    color: #c2410c;
    font-weight: bold;
    white-space: nowrap;
}

.amount-credit {
    color: #187443;
    font-weight: bold;
    white-space: nowrap;
}

.muted-dash {
    color: #cbd5e1;
}

.running-debit {
    color: #c2410c;
    font-weight: bold;
    white-space: nowrap;
}

.running-credit {
    color: #2563eb;
    font-weight: bold;
    white-space: nowrap;
}

.running-zero {
    color: #187443;
    font-weight: bold;
}

.account-bottom-actions {
    margin-top: 18px;
}

@media (max-width: 700px) {

    .account-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .account-actions .btn {
        text-align: center;
    }

}
/* ---------------------------------------------------------------
   Confirmed order - Green full card
---------------------------------------------------------------- */

.customer-row.confirmed-order {
    background-color: #ecfdf3 !important;
    border: 2px solid #22c55e !important;
    box-shadow: 0 3px 10px rgba(34, 197, 94, 0.12) !important;
}

.customer-row.confirmed-order:hover {
    background-color: #dcfce7 !important;
    border-color: #16a34a !important;
}

.customer-row.confirmed-order .customer-name {
    color: #166534 !important;
    font-weight: 800;
}

.customer-row.confirmed-order .customer-phone {
    color: #3f6f4d !important;
}

.customer-row.confirmed-order .customer-number {
    background-color: #bbf7d0 !important;
    color: #166534 !important;
}

.customer-row.confirmed-order .confirmed-badge {
    background-color: #16a34a !important;
    color: #ffffff !important;
}

/* Collapsible application navigation */
.sidebar {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(270px, 86vw);
    height: 100dvh;
    overflow-y: auto;
    z-index: 1001;
    transform: translateX(105%);
    transition: transform .22s ease, box-shadow .22s ease;
    box-shadow: none;
}

.sidebar.is-open {
    transform: translateX(0);
    box-shadow: -14px 0 40px rgba(15, 23, 42, .22);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(15, 23, 42, .48);
    cursor: pointer;
}

body.sidebar-open .sidebar-backdrop { display: block; }
body.sidebar-open { overflow: hidden; }
.main { width: 100%; margin: 0; }
.topbar-title-area { display: flex; align-items: center; gap: 14px; min-width: 0; }
.sidebar-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}
.sidebar-toggle span { display: block; width: 20px; height: 2px; border-radius: 2px; background: #334155; }

/* Modern data entry controls */
.form-control,
input.form-control,
select.form-control,
textarea.form-control {
    min-height: 46px;
    border: 1px solid #d7e2dc;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfefc 100%);
    box-shadow: 0 2px 8px rgba(22, 101, 52, .035);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.form-control:hover,
input.form-control:hover,
select.form-control:hover { border-color: #a9cdb5; }

.form-control:focus,
input.form-control:focus,
select.form-control:focus,
textarea.form-control:focus {
    border-color: #20a464;
    box-shadow: 0 0 0 4px rgba(32, 164, 100, .13), 0 5px 14px rgba(22, 101, 52, .07);
    transform: translateY(-1px);
}

select.form-control,
.form-control[type="number"] { font-variant-numeric: tabular-nums; }

/* Amount fields across payment and account forms */
#amount_display,
#discount,
#payment,
.purchase-price-input,
.purchase-unit-price-input,
.ledger-return-price-form input {
    direction: ltr;
    text-align: left;
    font-weight: 700;
    letter-spacing: .02em;
    font-variant-numeric: tabular-nums;
}

#amount_display,
#discount,
#payment {
    background: linear-gradient(135deg, #f0fdf4, #ffffff 72%);
    border-color: #b8dec4;
}

#amount_display::placeholder,
#discount::placeholder,
#payment::placeholder { color: #9ab2a1; }

@media (max-width: 700px) {
    .form-control,
    input.form-control,
    select.form-control { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
}
