* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    letter-spacing: 0px !important;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.page {
    display: none;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.page.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 90vh;
    width: 100%;
}

.login-box {
    background: white;
    border-radius: 30px;
    padding: 40px 30px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.login-icon { font-size: 60px; margin-bottom: 15px; }
.login-box h1 { font-size: 28px; color: #333; margin-bottom: 5px; }
.login-box .subtitle { color: #888; font-size: 14px; margin-bottom: 30px; }

.input-group { text-align: right; }
.input-group label { display: block; font-size: 14px; font-weight: bold; color: #555; margin-bottom: 8px; }
.input-group input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 18px;
    text-align: center;
    letter-spacing: 5px;
    transition: border-color 0.3s ease;
    direction: ltr;
}
.input-group input:focus { outline: none; border-color: #667eea; }

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
}
.btn-login:active { transform: scale(0.95); }

.error-message {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 12px;
    padding: 10px;
    background: #fde8e8;
    border-radius: 8px;
}

.login-footer {
    margin-top: 25px;
    font-size: 13px;
    color: #999;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.dashboard-container {
    background: white;
    border-radius: 25px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.dashboard-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.header-content h1 { font-size: 22px; color: #333; }

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.btn-logout {
    padding: 6px 16px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-logout:active { transform: scale(0.95); }

.total-balance-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 25px;
}

.balance-card {
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
}
.balance-card.riyal-balance { background: linear-gradient(135deg, #f8f9fa 0%, #e8f5e9 100%); }
.balance-card.dollar-balance { background: linear-gradient(135deg, #f8f9fa 0%, #e3f2fd 100%); }

.balance-label { display: block; font-size: 12px; color: #888; margin-bottom: 5px; }
.balance-number { display: block; font-size: 28px; font-weight: bold; color: #333; margin: 5px 0; }
.balance-unit { font-size: 12px; color: #999; }

.main-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.option-card {
    background: white;
    border: 2px solid #e8e8e8;
    border-radius: 18px;
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}
.option-card:active { transform: scale(0.95); }
.option-card.disabled { opacity: 0.6; cursor: not-allowed; }
.option-card .option-icon { font-size: 40px; margin-bottom: 8px; }
.option-card h3 { font-size: 16px; color: #333; margin-bottom: 4px; }
.option-card p { font-size: 12px; color: #999; }

.page-container {
    background: white;
    border-radius: 25px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
    flex-wrap: wrap;
    gap: 10px;
}
.page-header h1 { font-size: 20px; color: #333; }

.btn-back {
    padding: 8px 16px;
    background: #f0f0f0;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-back:active { transform: scale(0.95); }

.btn-edit {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-edit:active { transform: scale(0.95); }

.user-badge { font-size: 14px; color: #666; }

.balance-display { margin-bottom: 20px; }
.balance-box {
    background: linear-gradient(135deg, #f8f9fa 0%, #e8f5e9 100%);
    border-radius: 18px;
    padding: 20px;
    text-align: center;
    border: 2px solid #e0e0e0;
}
.balance-box .balance-label { font-size: 14px; color: #666; }
.balance-box .balance-number { font-size: 36px; font-weight: bold; margin: 8px 0; }
.balance-box .balance-unit { font-size: 14px; color: #888; }

.sub-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}
.sub-option-btn {
    padding: 14px;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    background: white;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}
.sub-option-btn:active { transform: scale(0.95); }
.sub-option-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.sort-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 15px;
}
.sort-btn {
    padding: 10px 8px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}
.sort-btn:active { transform: scale(0.95); }
.sort-btn.active {
    border-color: #667eea;
    background: #667eea;
    color: white;
}
.sort-btn:hover:not(.active) {
    border-color: #667eea;
    background: #f0f2ff;
}

.invoices-section { margin-top: 15px; }
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}
.section-header h2 { font-size: 18px; color: #333; }

.btn-pdf {
    padding: 8px 16px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-pdf:active { transform: scale(0.95); }

.invoices-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.invoice-item {
    background: white;
    border-radius: 15px;
    padding: 15px;
    border-right: 5px solid #667eea;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.invoice-item:active { transform: scale(0.98); }
.invoice-item.credit { border-right-color: #27ae60; }
.invoice-item.debit { border-right-color: #e74c3c; }

.invoice-info { flex: 1; }
.invoice-amount { display: block; font-size: 18px; font-weight: bold; color: #333; }
.invoice-desc { display: block; font-size: 14px; color: #666; margin: 4px 0; }
.invoice-date { display: block; font-size: 12px; color: #999; }
.invoice-balance {
    display: block;
    font-size: 12px;
    margin-top: 4px;
    padding: 2px 8px;
    background: #f5f5f5;
    border-radius: 4px;
    font-weight: bold;
}

.invoice-type {
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: bold;
}
.credit-badge { background: #e8f5e9; color: #27ae60; }
.debit-badge { background: #fde8e8; color: #e74c3c; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 16px;
}

.add-invoice-section { margin-top: 15px; }
.add-invoice-section h2 { font-size: 20px; color: #333; margin-bottom: 20px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 14px; font-weight: bold; color: #555; margin-bottom: 6px; }
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 15px;
    transition: border-color 0.3s ease;
}
.form-group input:focus,
.form-group textarea:focus { outline: none; border-color: #667eea; }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group small { display: block; font-size: 12px; color: #999; margin-top: 5px; }

.amount-input {
    direction: ltr !important;
    text-align: right !important;
    font-size: 16px !important;
    letter-spacing: 0px !important;
}

.date-group {
    display: flex;
    align-items: center;
    gap: 5px;
    direction: ltr;
}
.date-input {
    flex: 1;
    padding: 12px 8px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    text-align: center;
    transition: border-color 0.3s ease;
    min-width: 0;
    width: 100%;
}
.date-input:focus { outline: none; border-color: #667eea; }
.date-input.year-input { flex: 1.5; }
.date-input.month-input { flex: 0.8; }
.date-input.day-input { flex: 0.8; }
.date-separator { font-size: 20px; font-weight: bold; color: #888; padding: 0 2px; }
.date-input::-webkit-inner-spin-button,
.date-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.date-input[type="number"] { -moz-appearance: textfield; }

.toggle-group {
    display: flex;
    gap: 10px;
}
.toggle-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}
.toggle-btn.active {
    border-color: #667eea;
    background: #667eea;
    color: white;
}
.toggle-btn:active { transform: scale(0.95); }

.btn-submit {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 8px;
}
.btn-submit:active { transform: scale(0.95); }

.btn-cancel {
    width: 100%;
    padding: 14px;
    background: #f0f0f0;
    color: #666;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-cancel:active { transform: scale(0.95); }

.detail-content {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 15px;
    margin-bottom: 15px;
}
.detail-content .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}
.detail-content .detail-row:last-child { border-bottom: none; }
.detail-content .detail-label { font-weight: bold; color: #555; }
.detail-content .detail-value { color: #333; font-weight: 500; }

.detail-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.detail-images img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s ease;
}
.detail-images img:active { transform: scale(0.95); }
.detail-images .image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100px;
    background: #f0f0f0;
    border-radius: 12px;
    color: #999;
    font-size: 14px;
}

.download-btn {
    display: inline-block;
    padding: 6px 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 5px;
    transition: all 0.3s ease;
}
.download-btn:active { transform: scale(0.95); }

.btn-delete {
    width: 100%;
    padding: 14px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s ease;
}
.btn-delete:active { transform: scale(0.95); }

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
}
#loadingOverlay .loading-box {
    background: white;
    padding: 30px 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 300px;
}

/* ===== استایل زبان ===== */
.lang-fa {
    font-family: 'Vazirmatn', 'Vazir', 'Tahoma', 'Segoe UI', sans-serif !important;
    letter-spacing: 0px !important;
}
.lang-ar {
    font-family: 'Amiri', 'Tahoma', 'Segoe UI', sans-serif !important;
    letter-spacing: 0px !important;
}

/* ===== استایل دکمه میکروفون ===== */
.voice-btn {
    padding: 10px 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 20px;
    cursor: pointer;
    min-width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}
.voice-btn:hover {
    background: #2980b9;
}
.voice-btn:active {
    transform: scale(0.95);
}
.voice-btn.listening {
    background: #f39c12;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ===== ریسپانسیو ===== */
@media (max-width: 400px) {
    .login-box { padding: 30px 20px; }
    .dashboard-container, .page-container { padding: 15px; }
    .main-options, .sub-options { grid-template-columns: 1fr; }
    .sort-options { grid-template-columns: 1fr 1fr; gap: 5px; }
    .sort-btn { font-size: 11px; padding: 8px 4px; }
    .total-balance-container { grid-template-columns: 1fr; }
    .balance-number { font-size: 24px; }
    .header-content h1 { font-size: 18px; }
    .detail-images { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
    .date-group { gap: 3px; }
    .date-input { padding: 10px 4px; font-size: 13px; }
    .date-separator { font-size: 16px; padding: 0 1px; }
    .date-input.year-input { flex: 1.2; }
    .date-input.month-input { flex: 0.7; }
    .date-input.day-input { flex: 0.7; }
    .voice-btn {
        padding: 8px 10px;
        min-width: 38px;
        height: 38px;
        font-size: 16px;
    }
}

.invoice-item { animation: slideUp 0.4s ease; }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   کارت حساب‌های پارسیان - بدون تغییر ساختار ظاهری اصلی
============================================================ */
.card-account-item {
    min-height: 88px;
}
.card-account-item.zero-account,
.invoice-item.zero-invoice {
    background: #fff8d9 !important;
    border-right-color: #f1c40f !important;
}
.card-account-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-delete-card {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    font-weight: bold;
}
.card-detail-name {
    font-size: 16px !important;
    line-height: 1.5;
}
.card-detail-delete {
    margin-right: auto;
}
.card-detail-sort {
    margin-top: 15px;
}
.card-excel-preview {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 12px;
    margin: 10px 0;
    overflow-x: auto;
}
.card-invoice-modal {
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: rgba(0,0,0,.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}
.card-invoice-modal-box {
    width: min(680px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 15px 50px rgba(0,0,0,.3);
    position: relative;
}
.card-invoice-modal-box h2 {
    margin: 0 0 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid #eee;
}
.card-modal-close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: #e74c3c;
    color: white;
    font-size: 18px;
    cursor: pointer;
}
@media (max-width: 600px) {
    .card-detail-delete {
        font-size: 11px;
        padding: 8px;
    }
}

/* ============================================================
   هماهنگی نهایی index و style
   - فارسی/مدیر بدون تغییر ظاهری
   - عربی فقط هنگام فعال شدن زبان عربی
============================================================ */
html[lang="ar"] {
    direction: rtl;
}

html[lang="ar"] body,
html[lang="ar"] input,
html[lang="ar"] textarea,
html[lang="ar"] button,
html[lang="ar"] select {
    font-family: 'Amiri', 'Tahoma', 'Segoe UI', sans-serif;
}

/* جلوگیری از به‌هم‌ریختگی ورودی‌های عددی و تاریخ */
.amount-input,
.date-group,
.date-input,
.balance-number,
.invoice-amount {
    font-family: inherit;
}

/* کلاس‌های موجود در index برای تغییر زبان */
.lang-fa {
    font-family: 'Vazirmatn', 'Vazir', 'Tahoma', 'Segoe UI', sans-serif !important;
}

.lang-ar {
    font-family: 'Amiri', 'Tahoma', 'Segoe UI', sans-serif !important;
    direction: rtl;
}



/* کارت حساب: نمایش دقیق مانده و رنگ‌بندی */
.card-detail-name { font-size: 22px !important; word-break: break-word; }
#cardDetailCount { display:block; margin-top:8px; font-weight:bold; }
#page-card-detail .invoice-date { line-height:1.8; }
#page-card-detail .invoice-balance { display:block; margin-top:6px; font-weight:bold; }
#page-card-detail .sort-options { grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) {
  #page-card-detail .sort-options { grid-template-columns: 1fr; }
}
