
        @import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700&display=swap');
        
        :root {
            --primary-color: #4CAF50;
            --primary-hover: #45a049;
            --secondary-color: #f8f9fa;
            --border-color: #e0e0e0;
            --text-color: #333;
            --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            --error-color: #ff5252;
            --warning-color: #ff9800;
            --info-color: #2196F3;
        }
        
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        
        body {
            font-family: 'Vazirmatn', Arial, sans-serif;
            max-width: 900px;
            margin: 0 auto;
            padding: 20px;
            direction: rtl;
            background-color: #f5f8ff;
            color: var(--text-color);
            line-height: 1.6;
        }
        
        .rtl-parentheses {
            direction: rtl;
            unicode-bidi: embed;
        }

        .app-container {
            background-color: white;
            border-radius: 15px;
            padding: 25px;
            box-shadow: var(--shadow);
        }
        
        .app-header {
            margin-bottom: 20px;
            text-align: center;
            color: var(--primary-color);
            border-bottom: 2px solid var(--border-color);
            padding-bottom: 15px;
        }
        
        .summary-info {
            display: flex;
            justify-content: space-between;
            margin-bottom: 20px;
            padding: 15px;
            background-color: rgba(76, 175, 80, 0.1);
            border-radius: 10px;
            font-weight: 500;
        }
        
        .summary-info div {
            text-align: center;
            flex: 1;
        }
        
        .summary-info .total-days { color: var(--info-color); }
        .summary-info .total-amount { color: var(--primary-color); }
        .summary-info .ras-number { color: #673ab7; }
        
        .total-advance-container { margin-bottom: 15px; }
        
        .total-amount-container, .advance-field {
            background-color: transparent;
            padding: 0;
            margin-bottom: 15px;
        }
        
        #totalAmountCheck {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #ddd;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s;
        }
        
        #totalAmountCheck.valid { color: #4CAF50; }
        
        .percentage-info {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #4CAF50;
            font-size: 14px;
            font-weight: 500;
            display: none;
        }
        
        .remaining-amount {
            color: #673ab7;
            font-weight: 500;
            margin-top: 10px;
            padding: 10px;
            background-color: rgba(103, 58, 183, 0.1);
            border-radius: 8px;
            display: none;
        }
        
        .days-toggle {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #607d8b;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .days-toggle:hover { color: var(--primary-color); }
        
        .days-display {
            position: absolute;
            left: 40px;
            top: 50%;
            transform: translateY(-50%);
            color: #4CAF50;
            font-size: 14px;
            font-weight: 500;
            display: none;
        }
        
        .start-date-container {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
            gap: 10px;
        }
        
        .form-group { margin-bottom: 15px; }
        
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
        }
        
        input {
            width: 100%;
            padding: 12px 40px 12px 70px;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            font-family: 'Vazirmatn', Arial, sans-serif;
            font-size: 16px;
            transition: border-color 0.3s, background-color 0.5s;
        }
        
        input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
        }
        
        button {
            background-color: var(--primary-color);
            color: white;
            border: none;
            padding: 12px 20px;
            border-radius: 8px;
            cursor: pointer;
            font-family: 'Vazirmatn', Arial, sans-serif;
            font-size: 16px;
            font-weight: 500;
            transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s, opacity 0.3s;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        
        button:hover {
            background-color: var(--primary-hover);
            transform: translateY(-2px);
        }
        
        button:active { transform: translateY(0); }

        button:disabled {
            background-color: #a5d6a7;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
            color: #e8f5e9;
        }
        
        .add-button {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            padding: 0;
            font-size: 24px;
        }
        
        .field {
            background-color: var(--secondary-color);
            margin: 15px 0;
            padding: 15px;
            border-radius: 10px;
            border: 1px solid var(--border-color);
            position: relative;
            transition: all 0.3s ease;
        }
        
        .field:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); }
        
        .remove-field {
            position: absolute;
            top: 10px;
            left: 10px;
            background-color: var(--error-color);
            color: white;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s;
        }
        
        .remove-field:hover { background-color: #ff1744; }
        
        .result {
            color: #1e88e5;
            font-weight: 500;
            margin-top: 10px;
            padding: 10px;
            background-color: rgba(30, 136, 229, 0.1);
            border-radius: 8px;
        }
        
        .result-written {
            color: var(--primary-color);
            font-weight: bold;
        }
        
        .error {
            color: var(--error-color);
            background-color: rgba(255, 82, 82, 0.1);
            padding: 10px;
            border-radius: 8px;
            margin: 10px 0;
            display: none;
        }
        
        .warning {
            color: var(--warning-color);
            background-color: rgba(255, 152, 0, 0.1);
            padding: 10px;
            border-radius: 8px;
            margin: 10px 0;
            display: none;
        }
        
        .alert {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background-color: rgba(255, 82, 82, 0.7);
            color: white;
            padding: 10px 20px;
            border-radius: 8px;
            display: none;
            align-items: center;
            gap: 10px;
            font-size: 14px;
            z-index: 1000;
        }
        
        .alert-close {
            background: none;
            border: none;
            color: white;
            font-size: 16px;
            cursor: pointer;
        }
        
        .no-fields-message {
            text-align: center;
            padding: 20px;
            color: #757575;
            font-style: italic;
        }
        .suggested-check-placeholder {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            font-size: 18px;
            font-weight: 500;
            color: #aaa;
            display: none;
        }

        .suggested-check-loading::after {
            content: '';
            display: inline-block;
            animation: dots 1.2s steps(3, end) infinite;
            width: 3em;
            font-size: 20px;
            text-align: left;
        }

        @keyframes dots {
            0%   { content: ''; }
            25%  { content: '.'; }
            50%  { content: '..'; }
            75%  { content: '...'; }
            100% { content: '....'; }
        }

        .suggested-check-active {
            color: #4CAF50;
            font-weight: bold;
            font-size: 18px;
            animation: glow 1.2s ease-in-out infinite alternate;
        }

        @keyframes glow {
            0% {
                text-shadow: 0 0 4px rgba(76, 175, 80, 0.3), 0 0 8px rgba(76, 175, 80, 0.2);
            }
            100% {
                text-shadow: 0 0 20px rgba(76, 175, 80, 0.9), 0 0 30px rgba(76, 175, 80, 0.6);
            }
        }
        
        .field-container {
            display: flex;
            gap: 15px;
        }
        
        .field-part {
            flex: 1;
            min-width: 0;
        }
        
        .add-between {
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 10px 0;
            gap: 10px;
        }
        
        .ras-display, .remaining-check-amount {
            font-size: 12px;
            font-weight: 500;
            padding: 5px 10px;
            border-radius: 5px;
            background-color: #e0f7fa;
            color: #0277bd;
            width: 150px;
            text-align: center;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            opacity: 0.7;
        }
        
        .ras-display { order: 1; }
        .remaining-check-amount { order: -1; }
        
        .date-info {
            font-size: 14px;
            color: #666;
            margin-top: 5px;
        }
        .centered-h5 {
            display: block;
            text-align: center;
            margin: 8px auto;
        }
        .centered-h6 {
            display: block;
            text-align: center;
            margin: 8px auto;
        }
        .final-summary {
            margin-top: 30px;
            padding: 20px;
            background-color: #f5f5f5;
            border-radius: 10px;
            border: 1px solid var(--border-color);
        }
        
        .final-summary h3 {
            margin-bottom: 15px;
            color: #004494;
            text-align: center;
        }
        
        .final-summary-content { line-height: 2; }
        
        .final-summary-content .check-item:last-child { border-bottom: none; }
        
        .final-summary-content .divider {
            margin: 15px 0;
            border-top: 1px solid #ddd;
        }
                
        .period-buttons {
            display: flex;
            gap: 10px;
            margin-top: 10px;
            justify-content: center;
            flex-wrap: wrap;
        }
        
        .check-count-field {
            margin-top: 15px;
        }
        
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }
        
        .modal-content {
            background-color: white;
            padding: 20px;
            border-radius: 10px;
            width: 90%;
            max-width: 500px;
            box-shadow: var(--shadow);
            max-height: 85vh;
            overflow-y: auto;
        }
        
        .modal-content h2 {
            margin-bottom: 20px;
            color: var(--primary-color);
            text-align: center;
        }
        
        .modal-content .form-group { margin-bottom: 15px;
        margin-top: 13px; }
        
        .modal-content input { padding: 10px; }
        
        .modal-buttons {
            display: flex;
            gap: 10px;
            justify-content: center;
            margin-top: 20px;
        }
        
        .modal-buttons button { padding: 10px 20px; }
        
        .reset-button {
            position: fixed;
            bottom: 20px;
            left: 20px;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background-color: #607d8b;
            font-size: 24px;
            z-index: 1000;
        }
        
        .reset-button:hover {
            background-color: #455a64;
        }
        #error, #checkCountError {
            font-size: 14px;
            border-right: 4px solid var(--error-color);
            padding-right: 10px;
            animation: shake 0.3s ease;
        }

        @keyframes shake {
            0% { transform: translateX(0); }
            25% { transform: translateX(-3px); }
            50% { transform: translateX(3px); }
            75% { transform: translateX(-3px); }
            100% { transform: translateX(0); }
        }

        .side-by-side-inputs {
            display: flex;
            gap: 15px; 
            align-items: flex-start;
        }

        .side-by-side-inputs .form-group {
            flex: 1;
            min-width: 0;
        }
        
        #suggestionModal .modal-content {
            border-top: 5px solid var(--warning-color);
        }
        #suggestionMessage strong {
            color: var(--primary-color);
        }
        .revert-container {
            background-color: #e3f2fd;
            color: #0d47a1;
            padding: 8px 12px;
            border-radius: 6px;
            margin-top: 8px;
            font-size: 13px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border: 1px solid #bbdefb;
        }
        .revert-button {
            background-color: #2196F3;
            color: white;
            border: none;
            padding: 5px 10px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 12px;
            font-family: 'Vazirmatn', sans-serif;
            transition: background-color 0.3s;
        }
        .revert-button:hover {
            background-color: #1976D2;
            transform: translateY(-1px);
        }

        .summary-actions-container {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            margin-top: 20px;
        }
        .dual-action-btn {
            display: flex;
            align-items: stretch;
            border-radius: 12px; 
            overflow: hidden;    
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            height: 50px;
        }
        .dual-action-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
        }
        .dual-action-btn .share-part {
            flex: 0 0 50px;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            border-right: 1px solid rgba(255, 255, 255, 0.3);
            transition: background-color 0.3s;
        }
        .dual-action-btn .share-part i {
            color: white;
            font-size: 18px;
        }
        .dual-action-btn .main-action-part {
            flex-grow: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 0 15px;
            font-weight: 500;
            font-size: 15px;
            color: white;
            cursor: pointer;
        }
        .download-style .share-part { background-color: #0069d9; }
        .download-style .main-action-part { background-color: #007bff; }
        .download-style:hover .share-part { background-color: #0056b3; }
        .copy-style .share-part { background-color: #5a6268; }
        .copy-style .main-action-part { background-color: #6c757d; }
        .copy-style:hover .share-part { background-color: #494f54; }

        .compact-labels label {
            font-size: 13px;
        }

        @media (max-width: 768px) {
            body { padding: 10px; }
            .app-container { padding: 15px; }
            .field-container { flex-direction: column; gap: 10px; }
            .summary-info { flex-direction: column; gap: 10px; }
            input, button { padding: 10px 12px; }
            .result, .final-summary { font-size: 14px; }
            .period-button { max-width: 70px; padding: 6px 10px; font-size: 13px; }
            .settings-button { max-width: 40px; }
            .alert { width: 90%; font-size: 12px; }
            .reset-button { width: 40px; height: 40px; font-size: 20px; }
            .modal-content { 
                max-height: 80vh; 
                overflow-y: auto; 
                padding: 15px; 
            }
            .side-by-side-inputs.compact-labels label {
                font-size: 12px;
            }

            .side-by-side-inputs .form-group label {
                font-size: 13px;
            }
            .summary-actions-container {
                grid-template-columns: 1fr;
                gap: 12px;
            }
            .dual-action-btn {
                height: 45px;
            }
            .dual-action-btn .main-action-part {
                font-size: 13px;
            }
        }

        .percentage-buttons-wrapper {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 12px;
            align-items: center;
        }
        .percentage-btn {
            background-color: #e9ecef;
            color: #495057;
            border: 1px solid #ced4da;
            padding: 4px 10px;
            font-size: 13px;
            font-weight: 500;
            border-radius: 20px;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        .percentage-btn:hover {
            background-color: #d1d9e0;
            border-color: #adb5bd;
            transform: translateY(-1px);
        }
        .percentage-settings-btn {
            background: none;
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #6c757d;
            padding: 0 5px;
        }
        .percentage-settings-btn:hover {
            color: var(--primary-color);
        }
        .percentage-list-container {
            max-height: 250px;
            overflow-y: auto;
            border: 1px solid #eee;
            padding: 10px;
            border-radius: 8px;
            margin-bottom: 15px;
        }
        .percentage-list-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px;
            border-bottom: 1px solid #f0f0f0;
        }
        .percentage-list-item:last-child {
            border-bottom: none;
        }
        .percentage-list-item span {
            font-weight: 500;
        }
        .delete-percentage-btn {
            background-color: transparent;
            color: var(--error-color);
            border: none;
            font-size: 20px;
            font-weight: bold;
            cursor: pointer;
            padding: 0 8px;
        }
        .add-percentage-form {
            display: flex;
            gap: 10px;
        }
        .add-percentage-form input {
            flex-grow: 1;
            padding: 10px;
        }
        .add-percentage-form button {
            padding: 10px 20px;
            border-radius: 8px;
        }
        #percentageSettingsModal .reset-btn {
            background-color: var(--warning-color);
        }

        #period-selection-section {
            margin: 25px 0;
        }
        .decorative-line {
            height: 1px;
            background: linear-gradient(to left, transparent, #ccc, transparent);
            margin-bottom: 20px;
        }
        .period-buttons {
            justify-content: center;
            gap: 12px;
        }
        .period-select-btn {
            background-color: #e3f2fd;
            color: #0d47a1;
            border: 1px solid #bbdefb;
            padding: 6px 14px;
            font-size: 14px;
            font-weight: 500;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.2s ease-in-out;
        }
        .period-select-btn:hover,
        .period-select-btn.selected-period {
            background-color: #0d47a1;
            color: white;
            border-color: #0d47a1;
            transform: translateY(-2px);
            box-shadow: 0 4px 10px rgba(13, 71, 161, 0.25);
        }
        .period-select-btn.selected-period {
            transform: translateY(-2px);
        }
        .period-settings-btn {
            background: none;
            border: none;
            font-size: 22px;
            cursor: pointer;
            color: #6c757d;
            padding: 0 5px;
            vertical-align: middle;
        }
        .period-settings-btn:hover {
            color: #0d47a1;
        }
        .period-list-container {
            max-height: 250px;
            overflow-y: auto;
            border: 1px solid #eee;
            padding: 10px;
            border-radius: 8px;
            margin-bottom: 15px;
            margin-top: 13px;
        }
        .period-list-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px;
            border-bottom: 1px solid #f0f0f0;
        }
        .period-list-item:last-child {
            border-bottom: none;
        }
        .period-list-item .period-text {
            font-weight: 500;
        }
        .period-list-item .controls {
            display: flex;
            gap: 15px;
        }
        .period-list-item .controls span {
            cursor: pointer;
            font-size: 20px;
        }
        .period-list-item .controls .delete-btn {
            color: var(--error-color);
        }
        .add-period-form {
            border-top: 1px solid #eee;
            padding-top: 15px;
        }
        .add-period-form button {
            width: 100%;
            margin-top: 10px;
            border-radius: 8px;
        }
        #periodSettingsModal .reset-btn {
            background-color: var(--warning-color);
        }
        
        #action-buttons-container {
            text-align: center;
            margin: 25px 0 10px;
        }

        #confirm-calculate-btn {
            width: 80%;
            max-width: 350px;
            padding: 14px;
            font-size: 18px;
            font-weight: bold;
            letter-spacing: 0.5px;
            border-radius: 10px;
            background-color: var(--primary-color);
            box-shadow: 0 4px 10px rgba(76, 175, 80, 0.3);
        }

        #confirm-calculate-btn:not(:disabled) {
            animation: glow-active 1.5s infinite alternate;
        }

        #confirm-calculate-btn:disabled {
            background-color: #bdc3c7;
            box-shadow: none;
            cursor: help;
        }

        #edit-period-btn {
            background-color: #95a5a6;
            font-size: 14px;
            padding: 8px 20px;
        }
        #edit-period-btn:hover {
            background-color: #7f8c8d;
        }
        
        @keyframes glow-active {
            from {
                box-shadow: 0 0 5px rgba(76, 175, 80, 0.5), 0 0 10px rgba(76, 175, 80, 0.4);
            }
            to {
                box-shadow: 0 0 20px rgba(76, 175, 80, 0.8), 0 0 30px rgba(76, 175, 80, 0.6);
            }
        }
        
        #calculation-results-section {
            max-height: 0;
            overflow: hidden;
            opacity: 0;
            transition: max-height 2.5s ease-in-out, opacity 2s ease-in-out;
        }
        
        #calculation-results-section.visible {
            opacity: 1;
            max-height: 10000px;
        }
        
        /* ======================================================== */
        /* ==   FINAL CSS for On-Screen Display & Image Generation   == */
        /* ======================================================== */

        /* --- 1. Fix Font and General Styles --- */
        body, button, input {
            font-family: 'Vazirmatn', Arial, sans-serif !important;
        }

        /* استایل برای نمایشگر اصلی (متن ساده) */
        #finalSummary {
            white-space: pre-wrap; /* برای حفظ فاصله‌ها و خطوط جدید در متن ساده */
            text-align: right;
            direction: rtl;
            background-color: #f8f9fa;
            padding: 20px;
            border-radius: 8px;
            line-height: 2.2;
            font-size: 15px;
        }
        #finalSummary strong {
            color: #004494;
        }


        /* --- 2. Styles for OFF-SCREEN A4 Image Generation --- */
        /* این استایل‌ها فقط زمانی استفاده می‌شوند که تصویر در پشت صحنه ساخته می‌شود */
        .a4-image-render-container {
            font-family: 'Vazirmatn', Arial, sans-serif;
            padding: 2cm;
            background-color: white;
        }
        .a4-image-render-container .summary-header-text {
            line-height: 1.8;
            text-align: justify;
            font-size: 14px;
        }
        .a4-image-render-container .summary-header-text h3 {
            text-align: center;
            color: #004494;
            margin-bottom: 15px;
            font-size: 20px;
        }
        .a4-image-render-container .summary-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 13px;
            text-align: center;
            margin-top: 20px;
        }
        .a4-image-render-container .summary-table th {
            background-color: #004494;
            color: white;
            padding: 14px 10px;
        }
        .a4-image-render-container .summary-table td {
            padding: 12px 10px;
            border-bottom: 1px solid #dee2e6;
            vertical-align: middle;
        }
        .a4-image-render-container .summary-table tbody tr:nth-child(even) {
            background-color: #f3f7fb;
        }
        .a4-image-render-container .summary-table .row-number {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 30px;
            height: 30px;
            background-color: #004494;
            color: white;
            border-radius: 50%;
            font-weight: bold;
        }
        .a4-image-render-container .summary-table .amount-in-words-cell {
            min-width: 300px;
            text-align: right;
        }
        .a4-image-render-container .summary-table tfoot {
            font-weight: bold;
            background-color: #e7f0f9;
            color: #004494;
        }

/* --- Styles for a new column --- */
.a4-image-render-container .summary-table th:nth-child(3) {
    font-size: 11px; /* برای بزرگتر نمایش دادن آیکون ساعت */
}

.a4-image-render-container .summary-table .interval-cell {
    text-align: center;
    vertical-align: middle;
    font-size: 8px; /* فونت متن اصلی سلول */
    line-height: 1.6;
    min-width: 90px; /* اختصاص فضای کافی به ستون */
}

.a4-image-render-container .summary-table .interval-cell strong {
    font-size: 9px;
    color: #23272bce; /* استفاده از رنگ اصلی تم برای هماهنگی */
}
/*---------------------------------*/

        /* ======================================================== */
        /* ==           STYLES FOR PRINTING (A4 Landscape)         == */
        /* ======================================================== */
        @media print {
            @page {
                size: A4 landscape;
                margin: 1.5cm;
            }

            body {
                -webkit-print-color-adjust: exact !important; /* برای چاپ رنگ‌ها در Chrome/Safari */
                print-color-adjust: exact !important; /* استاندارد */
                margin: 0;
                padding: 0;
            }
            
            body > *:not(.app-container),
            .app-container > *:not(.final-summary),
            .final-summary > *:not(.printable-section) {
                display: none !important;
            }

            .printable-section {
                display: block !important;
                width: 100%;
                box-shadow: none;
                border: none;
                margin: 0;
                padding: 0;
            }
            
            .final-summary {
              padding: 0 !important;
              border: none !important;
            }

            .summary-table {
                font-size: 12px; /* کمی کوچک‌تر کردن فونت برای جا شدن بهتر */
                box-shadow: none;
                border: 1px solid #ccc;
            }
            
            .summary-header-text {
                font-size: 13px;
                line-height: 1.8;
            }
        }
