:root {
    --bg-color: #0f172a;
    /* Deep Slate */
    --card-bg: rgba(30, 41, 59, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --gold: #d4af37;
    --gold-glow: rgba(212, 175, 55, 0.3);
    --gold-hover: #c4a029;
    --emerald: #10b981;
    --emerald-glow: rgba(16, 185, 129, 0.2);
    --input-bg: rgba(15, 23, 42, 0.8);
    --input-border: #334155;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-mode {
    --bg-color: #f1f5f9;
    /* Slate 100 */
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(0, 0, 0, 0.1);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --gold: #b48512;
    --gold-glow: rgba(180, 133, 18, 0.2);
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(212, 175, 55, 0.04), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.04), transparent 25%);
}

.app-container {
    max-width: 1420px;
    margin: 0 auto;
    padding: 20px 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #0b1121;
    /* Dark background as requested */
    padding: 12px 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.app-logo-small {
    max-height: 50px;
    width: auto;
    object-fit: contain;
}

.app-logo {
    max-width: 300px;
    height: auto;
    margin-bottom: 15px;
}

.header-titles {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.main-title {
    font-family: 'Cairo', sans-serif;
    font-size: 1.5rem;
    color: #ffffff;
    margin: 0;
    font-weight: 800;
    letter-spacing: 1px;
}

.sub-title {
    font-size: 0.9rem;
    color: #ffffff;
    opacity: 0.9;
    margin-top: 2px;
    font-weight: 600;
}

.creator-title {
    font-family: 'Cairo', sans-serif;
    font-size: 0.65rem;
    color: var(--gold);
    opacity: 0.9;
    margin-top: 2px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-weight: bold;
    font-family: inherit;
    font-size: 0.95rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.icon-button:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--gold);
}

/* Tabs Navigation */
.tabs-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    background: var(--card-bg);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 15px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
    max-width: 300px;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.tab-btn.active {
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.5), rgba(15, 23, 42, 0.8));
    color: var(--text-primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    border-bottom: 3px solid var(--gold);
}

/* Mobile Tab Select */
.mobile-tab-select-container {
    display: none;
}

.mobile-tab-select {
    width: 100%;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--gold);
    padding: 15px 20px;
    font-size: 1.25rem;
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23d4af37%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: left 20px top 50%;
    background-size: 16px auto;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.mobile-tab-select:focus {
    box-shadow: 0 0 0 3px var(--gold-glow);
}

[data-theme="light"] .mobile-tab-select,
body.light-mode .mobile-tab-select {
    border-color: #3b82f6;
    /* Blue tint for light mode */
}

/* Tab Content Visibility */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.tab-content.active {
    display: grid;
}

@media (min-width: 900px) {
    .tab-content.active {
        grid-template-columns: minmax(0, 4fr) minmax(0, 6fr);
        /* 40% inputs, 60% results to give the table more room on web */
        align-items: start;
    }
}

/* layout */
.dashboard {
    gap: 30px;
    margin-bottom: 40px;
    align-items: start;
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    min-width: 0; /* Prevents grid blowout from large content */
}

/* Results card before any calculation: compact, no wasted vertical space */
.results-card:not(:has(.results-grid:not(.hidden))) {
    padding-top: 20px;
    padding-bottom: 20px;
}

/* Keep results-card h2 tightly spaced before results appear */
.results-card:not(:has(.results-grid:not(.hidden))) h2 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--input-border);
    padding-bottom: 15px;
}

.icon {
    font-size: 1.5rem;
}

/* Forms */
.input-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

input {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
    min-width: 0; /* Prevents inputs from expanding past their container */
}

input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

input::placeholder {
    color: #475569;
}

input.error-border {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

.error-msg {
    color: #ef4444;
    font-size: 0.8rem;
    margin-top: 5px;
    display: none;
    animation: fadeIn 0.3s ease;
}

.error-msg.visible {
    display: block;
}

.divider {
    height: 1px;
    background: var(--input-border);
    margin: 25px 0;
}

/* ── Smart Cert Name Bar ── */
.smart-cert-row {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--input-border);
}

.smart-cert-row:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.smart-cert-name-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(212, 175, 55, 0.07);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 14px;
}

.cert-badge {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.smart_cert_name {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px dashed rgba(212, 175, 55, 0.4);
    color: var(--gold);
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 2px 4px;
    outline: none;
    transition: var(--transition);
    min-width: 0;
}

.smart_cert_name:focus {
    border-bottom-color: var(--gold);
    box-shadow: none;
}

.smart_cert_name::placeholder {
    color: rgba(212, 175, 55, 0.4);
    font-weight: 400;
}

.remove-cert-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    padding: 0 4px;
    flex-shrink: 0;
    transition: var(--transition);
    opacity: 0.7;
}

.remove-cert-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

.btn-calculate {
    background: linear-gradient(135deg, var(--gold), #bd9724);
    color: #000;
    border: none;
    padding: 16px;
    width: 100%;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    margin-top: 10px;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px var(--gold-glow);
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.5);
}

#smart-analysis-btn:hover {
    background: rgba(212, 175, 55, 0.2) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.2);
}

.arrow {
    transition: transform 0.3s ease;
}

.btn-calculate:hover .arrow {
    transform: translateX(-5px);
}

/* Results section */
.gauge-wrapper {
    position: relative;
    width: 280px;
    margin: 0 auto 30px auto;
    text-align: center;
}

.gauge-svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

.gauge-bg {
    fill: none;
    stroke: var(--card-border);
    stroke-width: 8;
    stroke-linecap: round;
}

.gauge-fill {
    fill: none;
    stroke: url(#gaugeGradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 126;
    /* pi * r => ~125.6 */
    stroke-dashoffset: 126;
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-value-display {
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
}

#gauge_percentage {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--emerald);
    text-shadow: 0 0 15px var(--emerald-glow);
}

.gauge-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 5px;
    font-weight: 500;
}

/* empty-state removed — no placeholder box shown before calculation */
.empty-state {
    display: none !important;
}

.results-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 15px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.results-grid.visible {
    opacity: 1;
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

.result-box {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: var(--transition);
}

.result-box:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.result-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-value small {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.8;
}

.result-hint {
    font-size: 0.7rem;
    /* Make it significantly smaller (approx 11px) */
    color: rgba(148, 163, 184, 0.6);
    /* Very muted gray */
    margin-top: 10px;
    line-height: 1.4;
    font-weight: 400;
}

/* Hero Boxes (Loan & 2nd CD) */
.result-box.hero-box {
    background: #1e293b;
    /* Solid muted dark slate */
    border: 1px solid #3b82f6;
    /* Soft distinct blue border */
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.1);
    /* Subtle light glow */
}

.result-box.hero-box:hover {
    border-color: #60a5fa;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.15);
}

.result-box.hero-box .result-label {
    font-size: 1.15rem;
    font-weight: 700;
    color: #93c5fd;
    margin-bottom: 12px;
}

.result-box.hero-box .result-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: none;
    /* Flat minimalist appearance */
}

.result-box.hero-box .result-hint {
    color: rgba(255, 255, 255, 0.8);
}

/* Income Box Variant */
.result-box.hero-box.income-box {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.1);
}

.result-box.hero-box.income-box .result-label {
    color: #34d399;
    /* soft green */
}

/* Extra Hero Variant (Prominent Net Cost) */
.result-box.hero-box.extra-hero {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 2px solid var(--gold);
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.15);
    padding: 30px 20px;
    transform: scale(1.02);
}

.result-box.hero-box.extra-hero .result-label {
    font-size: 1.3rem;
    color: var(--gold);
}

.result-box.hero-box.extra-hero .result-value {
    font-size: 2.8rem;
    color: #ffffff;
}

/* Sales Guidance Bar */
.sales-guidance {
    margin-top: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: bold;
    text-align: center;
    font-size: 1.05rem;
    transition: var(--transition);
}

.sales-guidance.guidance-success {
    background-color: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--emerald);
    color: var(--emerald);
}

.sales-guidance.guidance-error {
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.result-box.primary {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.3);
}

.result-box.primary .result-value {
    color: var(--gold);
}

.result-box.success {
    background: var(--emerald-glow);
    border-color: rgba(16, 185, 129, 0.3);
}

.result-box.success .result-value {
    color: var(--emerald);
}

.result-box.accent {
    border-color: rgba(16, 185, 129, 0.2);
}

/* Tooltip on hover for Labels */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--card-border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: bold;
    margin-right: 5px;
    margin-left: 5px;
    cursor: help;
    position: relative;
}

.info-icon .tooltip-text {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 20;
    pointer-events: none;
    font-weight: normal;
}

.info-icon:hover .tooltip-text {
    opacity: 1;
    visibility: visible;
    bottom: 22px;
}

/* Tooltip on hover for Result Boxes */
.tooltip {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 10;
}

.result-box:hover .tooltip {
    opacity: 1;
    visibility: visible;
    bottom: -30px;
}

/* Footer */
.app-footer {
    text-align: center;
    margin-top: auto;
    padding-top: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-logo {
    max-width: 130px;
    margin-bottom: 15px;
    opacity: 0.8;
    transition: var(--transition);
}

.footer-logo:hover {
    opacity: 1;
}

.app-footer strong {
    color: var(--gold);
    font-weight: 700;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard section {
    animation: fadeIn 0.6s ease forwards;
}

@media (max-width: 600px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Print / PDF overrides using @media print */
@media print {

    /* فرض الخلفية البيضاء والخط الأسود بوضوح */
    body,
    .app-container,
    html {
        background: white !important;
        background-color: white !important;
        color: black !important;
        background-image: none !important;
    }

    /* إخفاء العناصر غير المرغوبة تماماً (المدخلات وأزرار الموظف) */
    .inputs-card,
    .tabs-container,
    .header-left,
    .theme-toggle,
    #lang-btn,
    .objection-handler,
    .btn-calculate,
    #export-section,
    #cash-export-section,
    #cd-loan-export-section,
    .actions-section {
        display: none !important;
    }

    /* Hide inactive tabs in print */
    .tab-content {
        display: none !important;
    }

    .tab-content.active {
        display: block !important;
    }

    /* إزالة جميع الظلال لضمان الطباعة النظيفة */
    * {
        color: black !important;
        text-shadow: none !important;
        box-shadow: none !important;
    }

    .app-container {
        padding: 0px !important;
        margin: 0px !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .dashboard,
    .results-grid {
        display: block !important;
    }

    /* تحديد إطارات المربعات لعدم تداخلها ولونها أبيض */
    .card,
    .result-box,
    .gauge-wrapper,
    .accordion {
        border: 1px solid #ddd !important;
        background: white !important;
        background-color: white !important;
        box-shadow: none !important;
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 20px !important;
    }

    /* استهداف نصوص وعداد الدائرة */
    .gauge-wrapper text,
    #gauge_percentage {
        fill: black !important;
        color: black !important;
        text-shadow: none !important;
    }

    .gauge-bg {
        stroke: #eee !important;
    }

    .result-value {
        color: black !important;
        font-weight: 800 !important;
        font-size: 1.6rem !important;
    }

    .result-value small {
        font-weight: 800 !important;
    }

    /* التوثيق وتذييل الصفحة */
    .app-footer {
        display: flex !important;
        opacity: 1 !important;
        text-align: center !important;
        margin-top: 50px !important;
        border-top: 1px solid #ccc;
        padding-top: 20px;
    }

    .app-footer p,
    .app-footer strong,
    .app-footer a,
    .footer-details {
        color: black !important;
    }

    /* إزالة هوامش الطباعة الافتراضية إذا أمكن */
    @page {
        margin: 10mm;
    }
}

/* Accordion */
.main-accordion-btn {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 16px 20px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.main-accordion-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--gold);
}

.main-accordion-btn .toggle-icon {
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: transform 0.4s ease;
}

.main-accordion-btn.expanded .toggle-icon {
    transform: rotate(180deg);
}

.main-accordion-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s ease-in-out;
}

.main-accordion-wrapper.expanded {
    grid-template-rows: 1fr;
}

.main-accordion-inner {
    overflow: hidden;
}

.accordion {
    border: 1px solid var(--input-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--input-bg);
}

.accordion-item {
    border-bottom: 1px solid var(--input-border);
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-header {
    width: 100%;
    text-align: right;
    padding: 15px 20px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.3s;
}

.accordion-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .accordion-header:hover {
    background: rgba(0, 0, 0, 0.05);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .accordion-content {
    background: rgba(0, 0, 0, 0.02);
}

.accordion-content p {
    padding: 15px 20px;
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    border-bottom: 1px dashed var(--input-border);
    line-height: 1.6;
}

.accordion-content p strong {
    color: var(--gold);
    margin-left: 5px;
}

.accordion-content p:last-child {
    border-bottom: none;
}

/* ========================================= */
/* SEO Content Section                       */
/* ========================================= */
.seo-content {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 30px;
    background: var(--card-bg);
}

.seo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.seo-block h3 {
    font-size: 1.3rem;
    color: var(--gold);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--input-border);
    padding-bottom: 10px;
}

.seo-block p, .seo-block li {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.seo-block ul {
    list-style: none;
    padding-right: 5px;
}

.seo-block ul li {
    position: relative;
    padding-right: 20px;
    margin-bottom: 8px;
}

.seo-block ul li::before {
    content: "•";
    color: var(--emerald);
    position: absolute;
    right: 0;
    font-weight: bold;
    font-size: 1.2rem;
}

.seo-block article {
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px 15px;
    border-radius: 8px;
    border-right: 3px solid var(--emerald);
    transition: var(--transition);
}

.seo-block article:hover {
    background: rgba(0, 0, 0, 0.3);
    border-right-color: var(--gold);
}

[data-theme="light"] .seo-block article {
    background: rgba(0, 0, 0, 0.05);
}

.seo-block article strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 5px;
    font-size: 1rem;
}

.seo-block article p {
    margin: 0;
}

.faq-item {
    margin-bottom: 15px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 15px;
    border-radius: 8px;
    transition: var(--transition);
}

.faq-item:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.faq-item strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 8px;
    font-size: 1rem;
}

.faq-item p {
    margin: 0;
}

/* ========================================= */
/* Modal Styles                              */
/* ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--gold);
    border-radius: 16px;
    width: 92%;
    max-width: 450px;
    padding: 25px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    max-height: 90vh;
    overflow-y: auto;
    direction: rtl;
    text-align: right;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

[data-theme="light"] .modal-content,
body.light-mode .modal-content {
    background: #ffffff;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
    border-color: #cbd5e1;
}

.modal-header h3 {
    color: var(--gold);
    font-size: 1.35rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px dashed var(--input-border);
    padding-bottom: 15px;
    font-family: 'Cairo', sans-serif;
    line-height: 1.4;
}

.modal-body p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: #e2e8f0; /* High Contrast Light Gray for Dark Mode */
    margin-bottom: 15px;
}

.modal-body p:last-child {
    margin-bottom: 25px;
}

/* New Banker Modal Specific Styles */
.modal-subtitle {
    color: var(--emerald);
    font-size: 1.15rem;
    margin: 20px 0 10px 0;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
}

.modal-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.modal-list li {
    position: relative;
    padding-right: 22px;
    margin-bottom: 12px;
    font-size: 1rem;
    line-height: 1.6;
    color: #e2e8f0; /* High Contrast Light Gray */
}

.modal-list li::before {
    content: '🎯';
    position: absolute;
    right: 0;
    top: 2px;
    font-size: 0.9rem;
}

.modal-list li strong, .modal-body p strong {
    color: var(--gold);
    font-weight: 700;
}

.modal-footer {
    text-align: center;
    border-top: 1px dashed var(--input-border);
    padding-top: 20px;
}

#how-it-works-btn:hover {
    background: var(--gold) !important;
    color: #000 !important;
}

/* Shared style for all "كيف يعمل؟" buttons across tabs */
.how-it-works-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: auto;
    padding: 6px 16px;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: 'Tajawal', sans-serif;
    border-radius: 20px;
    border: 1px solid var(--gold);
    color: var(--gold);
    background: rgba(212, 175, 55, 0.08);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
}

.how-it-works-tab-btn:hover {
    background: var(--gold);
    color: #000;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.35);
    transform: translateY(-1px);
}

/* On very small screens, hide text and show only icon */
@media (max-width: 380px) {
    .how-it-works-tab-btn {
        padding: 6px 10px;
        font-size: 0;          /* hide text */
        gap: 0;
    }
    .how-it-works-tab-btn .icon {
        font-size: 1.15rem !important;
    }
}

/* Print UI Hiding Utility */
.print-only {
    display: none !important;
}

/* ========================================= */
/* Print Styles                              */
/* ========================================= */
@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    body {
        margin: 0;
        padding: 0;
        background: #fff;
        color: #000;
        font-family: 'Cairo', sans-serif !important;
        font-size: 10pt;
        line-height: 1.3;
    }
    
    .print-only { display: block !important; }

    /* Hide everything we don't want printed */
    .app-header,
    .tabs-container,
    .mobile-tab-select-container,
    .actions-section,
    .seo-content,
    .app-footer,
    .modal-overlay,
    .sales-guidance,
    #auto-fill-btn,
    .result-hint,
    .tooltip,
    .objection-handler,
    .btn-calculate,
    #how-it-works-btn,
    .how-it-works-tab-btn,
    .divider,
    .info-icon,
    .gauge-wrapper,
    .result-box.primary {
        display: none !important;
    }

    /* Format visible content container */
    .app-container {
        padding: 0;
        max-width: 100%;
        margin: 0;
        position: relative;
    }

    .card { background: none !important; box-shadow: none !important; border: none !important; padding: 0 !important; margin: 0 !important; }
    .tab-content, .dashboard { display: none !important; }
    .tab-content.active { display: block !important; }
    .tab-content.active .card.results-card h2 { display: none !important; }

    /* ------------------------------------------- */
    /* Header & Layout                             */
    /* ------------------------------------------- */
    #print-header { width: 100%; margin-bottom: 25px !important; }

    /* ------------------------------------------- */
    /* Inputs Table Design                         */
    /* ------------------------------------------- */
    .inputs-card {
        display: block !important;
        width: 100% !important; /* Full width now that gauge is gone */
        margin-bottom: 15px !important; /* Reduced margin */
        background: transparent !important;
        border: 2px solid #555 !important;
        border-radius: 6px !important;
        padding: 8px 12px !important; /* Drastically reduced padding */
        page-break-inside: avoid !important;
    }
    
    .inputs-card h2 {
        display: block !important;
        font-size: 11pt !important; /* Compressed title */
        margin-bottom: 6px !important; /* Tight margin */
        border-bottom: 1px solid #555 !important;
        padding-bottom: 4px !important;
        text-align: right !important;
        color: #000 !important;
    }

    .input-group {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        border-bottom: 1px dashed #ccc !important; /* Thinner subdivision */
        padding: 3px 0 !important; /* Minimal gap between rows */
        margin: 0 !important;
    }
    
    /* Remove border from the last item so it looks extremely tight */
    .input-group:last-child {
        border-bottom: none !important;
    }

    .input-group label { width: 75% !important; font-weight: 700 !important; font-size: 9.5pt !important; color: #000 !important; margin: 0 !important; }
    
    .input-group input { width: 25% !important; background: transparent !important; border: none !important; font-weight: 700 !important; font-size: 10pt !important; color: #000 !important; text-align: left !important; direction: ltr !important; padding: 0 !important; }

    .grid-2 { display: block !important; }

    /* ------------------------------------------- */
    /* Master Result Table Design                  */
    /* ------------------------------------------- */
    .results-grid {
        display: table !important;
        width: 100% !important;
        border-collapse: collapse !important;
        margin-top: 15px !important;
    }

    .result-box {
        display: table-row !important;
        background: transparent !important;
        border: none !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
    }

    .result-label, .result-value {
        display: table-cell !important;
        padding: 8px 10px !important;
        vertical-align: middle !important;
        border: 1px solid #444 !important;
    }

    .result-label { width: 65% !important; font-weight: 700 !important; font-size: 11pt !important; color: #000 !important; background: #f1f5f9 !important; text-align: right !important; }
    .result-value { width: 35% !important; font-size: 12pt !important; font-weight: 700 !important; color: #000 !important; text-align: left !important; }
    .result-value small, .result-value .highlight, #res_profit, #res_advantage { color: #000 !important; background: transparent !important; padding: 0 !important; border-radius: 0 !important; }
    .hero-box { background: transparent !important; border-color: #444 !important; }
    .income-box { background: transparent !important; border-color: #444 !important; }
    .extra-hero .result-value { font-size: 13pt !important; }

    * { page-break-inside: avoid !important; }
}

/* ========================================= */
/* Media Queries for Mobile Responsiveness   */
/* ========================================= */
@media (max-width: 768px) {

    /* 1. Stacking: Ensure 1 column layout and Inputs first, then Results */
    .tab-content.active {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px;
    }

    /* 2. Margins/Padding: Reduce spacing and fit 95% screen */
    .app-container {
        padding: 10px;
    }

    .app-header {
        padding: 12px 15px;
        margin-bottom: 20px;
    }

    .card {
        padding: 20px 15px;
        width: 100%;
        border-radius: 16px;
    }

    /* 3. Hide Tabs, Show Dropdown */
    .tabs-container {
        display: none !important;
    }

    .mobile-tab-select-container {
        display: block;
        margin-bottom: 25px;
    }

    .btn-calculate,
    .main-accordion-btn {
        padding: 18px;
        font-size: 1.15rem;
    }

    /* 4. Font Sizes: Enlarged for UX */
    .card h2 {
        font-size: 1.8rem !important;
        /* Larger box titles */
    }

    input,
    label {
        font-size: 1.15rem !important;
        /* Larger inputs */
    }

    .result-value small {
        font-size: 1.1rem !important;
        /* Larger currency icons EGP */
    }

    .result-box.hero-box .result-value {
        font-size: 2.1rem;
        word-break: break-word;
    }

    .result-box.hero-box.extra-hero .result-value {
        font-size: 2.5rem;
        word-break: break-word;
    }

    .result-box .result-value {
        font-size: 1.6rem;
    }

    #gauge_percentage {
        font-size: 2.1rem;
    }

    /* Make header titles fit better */
    .main-title {
        font-size: 1.1rem;
    }

    .app-logo-small {
        height: 38px;
    }

    /* Adjust Input grid to single column on small screens */
    .grid-2 {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* ===================================================
   Tab 4 — Smart Collateral Reduction — Base Styles
   =================================================== */

/* Grid for certificate input rows (3 columns on desktop) */
.smart-cert-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 15px;
    margin-top: 10px;
    box-sizing: border-box;
}

.smart-cert-grid * {
    box-sizing: border-box;
}

/* Prevent horizontal overflow on the Tab 4 container */
#smart-calc-tab {
    overflow-x: hidden;
}

/* Enlarge table fonts for clarity */
#smart-results-table-container table {
    font-size: 1.15rem;
    letter-spacing: 0.3px;
    white-space: normal; /* Forces the table to stay within limits on desktop */
}

/* ===================================================
   Tab 4 — Smart Collateral Reduction — Mobile Styles
   =================================================== */
@media (max-width: 600px) {

    /* 1. Certificate rows: stack fields vertically */
    .smart-cert-grid {
        grid-template-columns: 1fr !important;
    }

    /* 2. Results table: horizontal scroll + smaller font */
    #smart-results-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #smart-results-table-container table {
        font-size: 0.95rem;
        white-space: nowrap;
    }

    #smart-results-table-container th,
    #smart-results-table-container td {
        padding: 8px 10px;
    }

    /* 3. Goal selector: comfortable touch targets, prevent text overlap */
    #smart-goal-selector {
        padding: 12px 14px;
    }

    #smart-goal-selector label {
        align-items: flex-start !important;
        padding: 12px !important;
        gap: 10px !important;
    }

    #smart-goal-selector input[type="radio"] {
        margin-top: 3px;
        flex-shrink: 0;
    }

    #smart-goal-selector strong {
        font-size: 0.95rem;
        display: block;
    }

    #smart-goal-selector small {
        font-size: 0.78rem;
        line-height: 1.4;
    }

    /* 4. Add-cert button: clear and tap-friendly */
    #add-smart-cert-btn {
        font-size: 1rem;
        padding: 13px 10px;
        min-height: 48px;
    }

    /* Remove-cert button (×): larger tap area */
    .remove-cert-btn {
        font-size: 1.8rem !important;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
}

/* ===================================================
   Tab 4 — Table Footer (Totals Row)
   =================================================== */

.smart-table-footer {
    background: rgba(255, 255, 255, 0.06);
    border-top: 2px solid var(--input-border);
}

.smart-table-footer td {
    white-space: nowrap;
}

/* Table clickable hint */
.smart-table-hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 6px 0 0;
    padding: 0 8px;
}

/* ===================================================
   Smart Loan Popup — Dark Glass Modal
   =================================================== */
#smart-loan-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

#smart-loan-popup-overlay.popup-visible {
    opacity: 1;
}

#smart-loan-popup-overlay.popup-visible #smart-loan-popup {
    transform: scale(1);
}

#smart-loan-popup {
    position: relative;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--gold);
    border-radius: 20px;
    padding: 36px 28px 28px;
    max-width: 420px;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    transform: scale(0.88);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(212, 175, 55, 0.15);
}

#smart-popup-close {
    position: absolute;
    top: 14px;
    left: 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
#smart-popup-close:hover { color: #ef4444; }

.popup-icon {
    font-size: 2.4rem;
    margin-bottom: 10px;
}

.popup-title {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff; /* Pure white for high contrast */
    margin: 0 0 8px;
    line-height: 1.4;
}

.popup-sub {
    font-size: 0.8rem;
    color: #cbd5e1; /* Much lighter gray for better contrast */
    margin: 0 0 20px;
    line-height: 1.5;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

.popup-highlight {
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    padding: 12px 14px;
    margin: 8px 0 20px;
}

.popup-row-label {
    font-size: 0.88rem;
    color: #e2e8f0; /* Crisp light gray to contrast against dark backgrounds */
    text-align: start;
}

.popup-row-value {
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
}

.popup-divider {
    height: 1px;
    background: var(--input-border);
    margin: 4px 0;
}

.popup-close-btn {
    width: 100%;
    margin-top: 0 !important;
    font-size: 0.95rem !important;
    padding: 12px !important;
}

@media (max-width: 480px) {
    #smart-loan-popup {
        padding: 30px 18px 22px;
    }
    .popup-title { font-size: 0.92rem; }
    .popup-row-value { font-size: 0.95rem; }
}

/* ========================================= */
/* Light Mode Overrides for Modals & Popups  */
/* ========================================= */

/* إصلاح ألوان النافذة المنبثقة في الوضع الفاتح */
[data-theme="light"] .modal-content {
    background: #ffffff !important;
    border: 1px solid #dee2e6;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .modal-header {
    background: #f8f9fa !important;
    border-bottom: 1px solid #e9ecef;
}

[data-theme="light"] .modal-header h3 {
    color: var(--primary-dark) !important;
}

[data-theme="light"] .modal-close {
    color: #495057 !important;
}

[data-theme="light"] .info-value {
    background: #f8f9fa !important;
    color: #212529 !important;
    border-color: #dee2e6 !important;
}

[data-theme="light"] .modal-highlight {
    background: rgba(0, 102, 204, 0.05) !important;
    color: var(--primary-dark) !important;
    border: 2px solid rgba(0, 102, 204, 0.2) !important;
}

[data-theme="light"] .info-note {
    background: #fff3cd !important;
    color: #856404 !important;
    border-left-color: #ffe8a1 !important;
}

/* إصلاح ألوان نافذة تفاصيل القرض (الشهادات) المخصصة في الوضع الفاتح */
[data-theme="light"] #smart-loan-popup {
    background: #ffffff !important;
    border: 1px solid #dee2e6;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15) !important;
}

[data-theme="light"] .popup-title {
    color: #212529 !important;
}

[data-theme="light"] .popup-sub,
[data-theme="light"] .popup-row-label {
    color: #495057 !important;
}

[data-theme="light"] .popup-highlight {
    background: rgba(16, 185, 129, 0.05) !important;
    border: 1px solid rgba(16, 185, 129, 0.2) !important;
}

[data-theme="light"] .popup-divider {
    background: #e9ecef !important;
}

[data-theme="light"] #smart-popup-close {
    color: #6c757d !important;
}

[data-theme="light"] #smart-popup-close:hover {
    color: #dc3545 !important;
}