:root {
    --primary: #2e6f4e;
    --primary-dark: #1f5138;
    --bg: #f4f6f8;
    --sidebar-bg: #1e2a26;
    --sidebar-active: #2e6f4e;
}

* { font-family: 'Vazirmatn', sans-serif; }

body {
    background: var(--bg);
    margin: 0;
}

/* ---------- Login page ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2a26, #2e6f4e);
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h1 {
    font-size: 22px;
    text-align: center;
    margin-bottom: 4px;
    color: var(--primary-dark);
}
.login-card p.subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 24px;
    font-size: 14px;
}

/* ---------- App layout ---------- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: #cfd8d4;
    flex-shrink: 0;
    padding: 16px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-align: center;
    padding: 0 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 10px;
}
.sidebar-user {
    text-align: center;
    font-size: 13px;
    color: #a9b8b1;
    padding-bottom: 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-nav { padding: 0 10px; }
.sidebar-nav li { list-style: none; }
.sidebar-nav a {
    display: block;
    padding: 10px 14px;
    color: #cfd8d4;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14.5px;
    margin-bottom: 2px;
    transition: background .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }

.main-content {
    flex: 1;
    padding: 24px;
    max-width: 100%;
    overflow-x: auto;
}

.mobile-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
}

@media (max-width: 767px) {
    .sidebar {
        position: fixed;
        right: -260px;
        z-index: 1000;
        transition: right .2s;
        box-shadow: 5px 0 20px rgba(0,0,0,.3);
    }
    .sidebar.show { right: 0; }
    .main-content { padding: 12px; }
}

/* ---------- Cards / widgets ---------- */
.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
    border-right: 4px solid var(--primary);
    height: 100%;
}
.stat-card .stat-title { color: #888; font-size: 13px; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 22px; font-weight: 700; color: #222; }

.card-panel {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
    margin-bottom: 20px;
}

.table-custom thead { background: #f0f2f4; }
.table-custom td, .table-custom th { vertical-align: middle; }

.badge-debtor { background: #dc3545; }
.badge-creditor { background: #198754; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}
.page-header h2 { margin: 0; font-size: 20px; font-weight: 700; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ---------- Printable Invoice ---------- */
.invoice-print-box {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    max-width: 800px;
    margin: 0 auto;
    padding: 30px;
}
.invoice-print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px solid var(--primary);
    padding-bottom: 16px;
    margin-bottom: 20px;
}
.invoice-print-header .store-name {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 4px;
}
.invoice-print-header .store-meta {
    font-size: 13px;
    color: #666;
    line-height: 1.9;
}
.invoice-print-header .invoice-meta {
    text-align: left;
    font-size: 13px;
    color: #444;
    line-height: 2;
}
.invoice-print-header .invoice-meta .inv-no {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-dark);
}
.invoice-party-box {
    background: #f7f9f8;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
}
.invoice-print-box table.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.invoice-print-box table.items-table th {
    background: var(--primary);
    color: #fff;
    padding: 10px 8px;
    font-weight: 600;
}
.invoice-print-box table.items-table td {
    padding: 9px 8px;
    border-bottom: 1px solid #eee;
}
.invoice-totals-box {
    max-width: 340px;
    margin-inline-start: auto;
    margin-top: 16px;
    font-size: 14px;
}
.invoice-totals-box .row-line {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed #ddd;
}
.invoice-totals-box .row-line.final {
    font-size: 17px;
    font-weight: 800;
    color: var(--primary-dark);
    border-bottom: none;
    border-top: 2px solid var(--primary);
    margin-top: 4px;
    padding-top: 10px;
}
.invoice-print-footer {
    text-align: center;
    color: #999;
    font-size: 12px;
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 14px;
}
.invoice-notes-box {
    margin-top: 24px;
    border: 1px dashed #ccc;
    border-radius: 8px;
    padding: 12px 16px;
}
.invoice-notes-box .notes-label {
    font-size: 13px;
    color: #888;
    margin-bottom: 40px;
}
.invoice-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    gap: 40px;
}
.invoice-signatures .sig-box {
    flex: 1;
    text-align: center;
}
.invoice-signatures .sig-line {
    border-top: 1px solid #999;
    margin-top: 50px;
    padding-top: 8px;
    font-size: 13px;
    color: #555;
}

@media print {
    body * { visibility: hidden; }
    .sidebar, .mobile-topbar, .page-header, .no-print { display: none !important; }
    #printArea, #printArea * { visibility: visible; }
    #printArea {
        position: absolute;
        top: 0; right: 0; left: 0;
        margin: 0;
        padding: 0;
    }
    .invoice-print-box { border: none; box-shadow: none; max-width: 100%; }
    .main-content { padding: 0 !important; }
}
