:root {
    /* Brand Colors - Restored Deep Blue with Material Structure */
    --primary-color: #285079;
    /* Original Deep Blue */
    --primary-dark: #1c3a59;
    --secondary-color: #f0f4f8;
    /* Soft Blue-Gray Mix */

    --accent-gold: #d4af37;
    /* Classic Gold */
    --accent-silver: #718096;
    /* Classic Silver */

    /* Neutral & Backgrounds */
    --bg-color: #f4f7fa;
    /* Restored Soft Background */
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;

    /* Functional Colors */
    --error-color: #dc2626;
    --success-color: #059669;
    --success-bg: #d1fae5;

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;

    /* Spacing & UI */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 32px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        /* Slate 900 */
        --card-bg: #1e293b;
        /* Slate 800 */
        --text-main: #f1f5f9;
        /* Slate 100 */
        --text-secondary: #cbd5e1;
        /* Slate 300 */
        --text-muted: #64748b;
        /* Slate 500 */
        --border-color: #334155;
        /* Slate 700 */
        --secondary-color: #1e1b4b;
        /* Indigo 950 */
        --primary-color: #6366f1;
        /* Indigo 500 */
        --primary-dark: #818cf8;
        /* Indigo 400 */
    }
}

/* Hard Toggle Class */
.dark-mode {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --secondary-color: #1e1b4b;
    --primary-color: #6366f1;
    --primary-dark: #818cf8;
}

/* Dark Mode Logo Handling - White Filter */
.dark-mode .app-logo {
    filter: brightness(0) invert(1);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    padding: 12px;
    /* Reduced from 20px */
    transition: background-color 0.3s, color 0.3s;
}

.main-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* Refined spacing */
}

/* 2-Column Layout */
.calculator-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    /* Refined spacing */
}

@media (min-width: 992px) {
    .calculator-grid {
        grid-template-columns: 1.8fr 1fr;
        align-items: start;
    }

    .calc-sidebar {
        position: sticky;
        top: 16px;
        /* Reduced from 24px */
    }
}

/* Header Removed */

/* Theme Toggle Button - Integrated in Card */
/* Header removed, controls moved */

/* Embedded Mode Overrides */
body.is-embedded {
    padding: 0 !important;
    background-color: transparent !important;
    min-height: auto !important;
    overflow: hidden auto;
    /* Allow vertical scroll if needed, but prefer auto-height */
}

/* Theme Toggle Button - Improved Visibility */
.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-main);
    padding: 0;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Size handled inline or here */
    width: 36px;
    height: 36px;
}

.theme-toggle:hover {
    background-color: var(--secondary-color);
    border-color: var(--primary-color);
    transform: rotate(15deg);
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
    /* Reduced from 32px for compactness */
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    margin-bottom: 20px;
    /* Reduced from 24px */
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.card-title {
    color: var(--text-main);
    font-size: 1.25rem;
    /* Slightly smaller */
    font-weight: 700;
}

/* Form Elements */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    /* Reduced from 300px for narrow constraint */
    gap: 20px;
    /* Reduced from 24px */
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-weight: 600;
    pointer-events: none;
    z-index: 2;
}

.form-input,
.form-select {
    width: 100%;
    padding: 14px 14px 14px 50px;
    /* Increased from 40px to 50px for wider symbols */
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    background-color: var(--card-bg);
    color: var(--text-main);
    transition: var(--transition);
    height: 52px;
}

.form-select {
    padding-left: 50px;
    /* Match input padding */
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
    /* Indigo glow */
}

.form-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.field-help {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Radio Cards */
.toggle-group {
    display: flex;
    gap: 16px;
}

.radio-card {
    flex: 1;
    cursor: pointer;
    position: relative;
    user-select: none;
}

.radio-card input {
    position: absolute;
    opacity: 0;
}

.radio-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    transition: var(--transition);
}

.radio-title {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.radio-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Check State */
.radio-card:hover .radio-content {
    border-color: var(--primary-color);
}

/* Gold Standard Selected */
.radio-card input[value="gold"]:checked+.radio-content {
    border-color: var(--accent-gold);
    background-color: rgba(245, 158, 11, 0.08);
    /* Amber Tint */
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.15);
}

.radio-card input[value="gold"]:checked+.radio-content .radio-title {
    color: var(--accent-gold);
}

/* Silver Standard Selected */
.radio-card input[value="silver"]:checked+.radio-content {
    border-color: var(--accent-silver);
    background-color: rgba(100, 116, 139, 0.08);
    /* Silver Tint */
    box-shadow: 0 4px 6px -1px rgba(100, 116, 139, 0.15);
}

.radio-card input[value="silver"]:checked+.radio-content .radio-title {
    color: var(--accent-silver);
}


/* Nisab Status Box */
.nisab-status {
    background-color: var(--secondary-color);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-top: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--primary-color);
    transition: all 0.3s ease;
}

.nisab-status.gold-mode {
    background-color: #fffbeb;
    /* Amber 50 */
    border-left-color: var(--accent-gold);
}

.nisab-status.silver-mode {
    background-color: #f8fafc;
    /* Slate 50 */
    border-left-color: var(--accent-silver);
}

.nisab-status strong {
    color: var(--text-secondary);
}

.highlight {
    color: var(--primary-color);
    font-weight: 800;
    font-size: 1.1rem;
}

/* Results Section */
.result-card.hidden {
    display: none;
}

.result-card {
    border: 2px solid var(--primary-color);
    animation: fadeIn 0.5s ease;
}

.summary-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 30px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 16px 20px;
    background-color: var(--bg-color);
    border-radius: var(--radius-md);
    align-items: center;
}

.summary-item .label {
    color: var(--text-secondary);
    font-weight: 600;
}

.summary-item .value {
    font-weight: 700;
    font-size: 1.1rem;
}

.summary-item .value.negative {
    color: var(--error-color);
}

.final-result-box {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 32px;
    border-radius: var(--radius-lg);
    text-align: center;
    margin-top: 30px;
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.4);
    position: relative;
    overflow: hidden;
}

.final-result-box::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.1' fill-rule='evenodd'%3E%3Ccircle cx='3' cy='3' r='3'/%3E%3Ccircle cx='13' cy='13' r='3'/%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.3;
}

.final-result-box.not-due {
    background: linear-gradient(135deg, #64748b, #475569);
    box-shadow: none;
}

.amount {
    display: block;
    font-size: 3.5rem;
    font-weight: 800;
    margin: 10px 0;
    line-height: 1.1;
    letter-spacing: -0.03em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nisab-msg {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
    font-size: 0.95rem;
    backdrop-filter: blur(4px);
    margin-top: 10px;
}


/* Pulsing Live Indicator */
.live-indicator {
    font-size: 0.8rem;
    color: var(--success-color);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.pulse {
    animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

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

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

/* Logic Breakdown Details */
.calc-breakdown {
    background-color: var(--bg-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 24px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.calc-breakdown summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--primary-color);
    outline: none;
}

.breakdown-content {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.breakdown-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 10px;
    font-style: italic;
}

/* Actions */
.result-actions {
    margin-top: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-color);
    border-color: var(--text-secondary);
}

/* Refresh Button - "More Good" */
.refresh-icon {
    background: var(--secondary-color);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
    padding: 0;
    margin-left: 8px;
}

.refresh-icon:hover {
    background: var(--primary-color);
    color: white;
    transform: rotate(180deg);
}

/* Info Outline Button */
.btn-info-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 10px 20px;
    border-radius: var(--radius-md);
}

.btn-info-outline:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

/* Danger Button - Fixed Visibility in Light Mode */
.btn-danger-outline {
    background: transparent;
    border: 2px solid var(--error-color);
    /* Thicker border */
    color: var(--error-color);
    padding: 10px 24px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    /* Bold */
    transition: var(--transition);
}

.btn-danger-outline:hover {
    background: #fef2f2;
    /* Light Red */
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.dark-mode .btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Donate Button */
.btn-accent {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 300px;
}

.btn-accent:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.donation-card {
    background-color: var(--secondary-color);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    margin-top: 30px;
}

.donation-card h3 {
    color: var(--primary-color);
    margin-bottom: 8px;
}

/* Methodology Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    padding: 32px;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    color: var(--text-main);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-content.small-modal {
    max-width: 400px;
    text-align: center;
}

.modal.visible .modal-content {
    transform: scale(1);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 24px;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.close-modal:hover {
    color: var(--error-color);
}

.modal-footer {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Toast */
/* --- Toast Notification (Modern Fintech Style) --- */
#toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    /* Allow clicks through container area */
}

.toast {
    background: var(--card-bg);
    color: var(--text-main);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    border-left: 4px solid var(--primary-color);
    opacity: 0;
    transform: translateX(100%);
    /* Slide in from right */
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    /* Smooth eased slide */
    pointer-events: auto;
    /* Re-enable clicks on toast itself */
    min-width: 300px;
    max-width: 400px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--error-color);
}

.toast.info {
    border-left-color: var(--primary-color);
}

/* Footer */
footer {
    text-align: center;
    color: var(--text-muted);
    margin-top: 40px;
    padding-bottom: 20px;
    font-size: 0.9rem;
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-color);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-top: 8px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* PRINT STYLES */
@media print {
    @page {
        margin: 0.5in;
        size: auto;
    }

    body {
        background-color: white !important;
        color: black !important;
        font-family: serif;
        padding: 0 !important;
        font-size: 11pt;
    }

    .main-wrapper,
    #toast-container {
        display: none !important;
    }

    #printContainer {
        display: block !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        margin: 0;
        padding: 20px;
    }

    .print-header {
        text-align: center;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
        margin-bottom: 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .print-title h1 {
        font-size: 20pt;
        margin: 0;
        text-transform: uppercase;
    }

    .print-logo {
        height: 40px;
    }

    .print-content-wrapper {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .print-section h3 {
        font-size: 14pt;
        border-bottom: 1px solid #ccc;
        margin-bottom: 5px;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 10pt;
    }

    .print-table td {
        padding: 4px 0;
        border-bottom: 1px dotted #eee;
    }

    .amount-col {
        text-align: right;
        font-weight: bold;
    }

    .print-summary-box {
        border: 1px solid #000;
        padding: 15px;
        margin-top: 10px;
    }

    .summary-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 5px;
    }

    .summary-row.final {
        font-size: 14pt;
        font-weight: bold;
        border-top: 2px solid #000;
        padding-top: 10px;
        margin-top: 10px;
    }

    .print-disclaimer {
        font-size: 8pt;
        color: #555;
        margin-top: 20px;
        text-align: justify;
    }

    .print-footer {
        text-align: center;
        font-size: 8pt;
        margin-top: 20px;
    }
}

/* --- CSS OVERRIDES FOR BRAND COLORS & REFINEMENTS --- */
:root {
    /* Brand Colors - Restored Deep Blue with Material Structure */
    --primary-color: #285079 !important;
    /* Original Deep Blue */
    --primary-dark: #1c3a59 !important;
    --secondary-color: #f0f4f8 !important;
    /* Soft Blue-Gray Mix */

    --accent-gold: #d4af37 !important;
    --accent-silver: #718096 !important;

    /* Neutral & Backgrounds */
    --bg-color: #f4f7fa !important;
    --card-bg: #ffffff !important;
    --text-main: #1f2937 !important;
    --text-secondary: #4b5563 !important;
    --text-muted: #9ca3af !important;
    --border-color: #e5e7eb !important;

    /* Functional Colors */
    --error-color: #dc2626 !important;
    --success-color: #059669 !important;
    --success-bg: #d1fae5 !important;
}

/* Header Override */
.app-header h1 {
    color: var(--primary-color) !important;
    background: none !important;
    -webkit-text-fill-color: initial !important;
}

/* Alignment Fix */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start !important;
    /* Force top alignment */
}

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

/* Silver Standard Styling Override */
.radio-card input[value="silver"]:checked+.radio-content {
    border-color: var(--accent-silver) !important;
    background-color: #e2e8f0 !important;
    /* Solid light gray */
    box-shadow: 0 4px 6px -1px rgba(113, 128, 150, 0.15) !important;
}

.radio-card input[value="silver"]:checked+.radio-content .radio-title {
    color: #334155 !important;
}

/* Update inputs to verify alignment */
.form-input,
.form-select {
    height: 54px !important;
}

/* Info Icon Visibility Ensure */
.info-icon-btn {
    display: inline-flex !important;
    background: transparent;
    border: none;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 8px;
    color: var(--text-muted);
}

.info-icon-btn:hover {
    color: var(--primary-color) !important;
}

/* --- Donation Section Refinements --- */
.donation-card {
    padding: 40px !important;
    /* More internal breathing room */
    margin-top: 48px !important;
    /* More separation from results */
    box-shadow: var(--shadow-md) !important;
    border: 1px solid var(--border-color) !important;
    /* Softer border */
    background: var(--card-bg) !important;
    /* Solid material background */
}

/* Ensure Dark Mode uses solid dark card background */
.dark-mode .donation-card {
    background-color: #1e293b !important;
    /* Slate 800 - Material Dark */
    border-color: #334155 !important;
    /* Slate 700 border */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3) !important;
}

.donation-card h3 {
    font-size: 1.5rem !important;
    margin-bottom: 12px !important;
}

.donation-card p {
    margin-bottom: 24px !important;
    color: var(--text-secondary) !important;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.btn-accent {
    padding: 16px 32px !important;
    /* Larger button */
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 14px 0 rgba(40, 80, 121, 0.39) !important;
    /* Deep Blue Glow */
    transition: transform 0.2s, box-shadow 0.2s !important;
}

/* --- Accordion Modal Styles --- */
.large-modal {
    max-width: 720px !important;
    width: 95%;
}

.modal-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: -5px;
    margin-bottom: 20px;
}

.accordion {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

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

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

.accordion-header {
    width: 100%;
    background: var(--card-bg);
    border: none;
    outline: none;
    text-align: left;
    padding: 16px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-header:hover {
    background-color: var(--bg-color);
}

.accordion-header.active {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.accordion-content {
    background: var(--card-bg);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding: 0 20px;
}

.accordion-content p,
.accordion-content ul {
    margin: 16px 0;
    line-height: 1.6;
    color: var(--text-secondary);
}

.accordion-content ul {
    padding-left: 20px;
}

.accordion-header .icon {
    font-size: 1.2rem;
    font-weight: 300;
    transition: transform 0.3s;
}

.accordion-header.active .icon {
    transform: rotate(45deg);
}

.formula-box {
    background: var(--bg-color);
    padding: 12px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary-color);
    margin: 10px 0;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-main);
}

.caution-box {
    margin-top: 24px;
    padding: 16px;
    background-color: #fefce8;
    /* Light Yellow */
    border: 1px solid #fde047;
    border-radius: var(--radius-md);
    color: #854d0e;
    font-size: 0.9rem;
}

.dark-mode .caution-box {
    background-color: rgba(234, 179, 8, 0.1);
    border-color: rgba(234, 179, 8, 0.3);
    color: #fef08a;
}

.btn-accent:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px 0 rgba(40, 80, 121, 0.23) !important;
}

/* --- Results Actions Refinement --- */
.result-actions {
    flex-direction: column !important;
    /* Stack them for better hierarchy */
    align-items: center !important;
    gap: 12px !important;
}

.btn-primary-large {
    background-color: var(--primary-color);
    color: white;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: var(--radius-lg);
    /* More rounded */
    box-shadow: 0 4px 6px rgba(40, 80, 121, 0.2);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    max-width: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary-large:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(40, 80, 121, 0.3);
}

.btn-ghost-small {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 8px 16px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius-md);
}

.btn-ghost-small:hover {
    color: var(--primary-color);
    background-color: var(--secondary-color);
    border-color: var(--border-color);
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {

    .btn-group,
    .modal-actions {
        flex-direction: column;
        width: 100%;
        gap: 12px;
    }

    /* Nisab Toggle: Keep Side-by-Side on Mobile */
    .toggle-group {
        flex-direction: row;
        /* Force row */
        width: 100%;
        gap: 12px;
    }

    .radio-card {
        flex: 1;
        /* Equal width */
        margin-bottom: 0;
        /* Reset */
        text-align: center;
        padding: 12px 8px;
        /* Tighter padding for small screens */
    }

    .radio-card span {
        font-size: 0.9rem;
        /* Slightly smaller text if needed */
    }

    /* Buttons */
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-ghost-small,
    .btn-accent,
    button:not(.info-icon-btn):not(.refresh-icon):not(.close-modal) {
        width: 100%;
        min-height: 48px;
        /* Touch target */
        display: flex;
        justify-content: center;
        align-items: center;
        margin-bottom: 8px;
    }

    /* Exceptions for inline icons */
    .info-icon-btn,
    .refresh-icon,
    .close-modal {
        min-height: auto;
        width: auto;
        margin-bottom: 0;
    }

    /* Inputs */
    .input-grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 16px;
        width: 100%;
    }

    .card {
        padding: 20px 16px;
    }

    /* PDF Generation Container Visibility */
    /* Ensure it's not display:none during generation */
    #printContainer {
        width: 100%;
        left: 0;
        top: 0;
    }
}

/* --- Financial Table Subtotals (New UI) --- */
.financial-row.subtotal {
    margin-top: 16px;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    background-color: var(--bg-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    transition: var(--transition);
}

/* Assets Subtotal - Green Theme */
.financial-row.subtotal-assets {
    background-color: #f0fdf4;
    /* Green 50 */
    border-color: #d1fae5;
}

.financial-row.subtotal-assets .col-desc strong {
    color: #15803d;
    /* Green 700 */
    font-size: 1.1rem;
    font-weight: 700;
}

.financial-row.subtotal-assets .highlight-text {
    color: #15803d !important;
    /* Force override */
    font-size: 1.25rem;
    font-weight: 800;
}

/* Liabilities Subtotal - Red Theme */
.financial-row.subtotal-liabilities {
    background-color: #fef2f2;
    /* Red 50 */
    border-color: #fee2e2;
}

.financial-row.subtotal-liabilities .col-desc strong {
    color: #b91c1c;
    /* Red 700 */
    font-size: 1.1rem;
    font-weight: 700;
}

.financial-row.subtotal-liabilities .highlight-text {
    color: #b91c1c !important;
    /* Force override */
    font-size: 1.25rem;
    font-weight: 800;
}

/* Dark Mode Adjustments for Subtotals */
.dark-mode .financial-row.subtotal-assets {
    background-color: rgba(6, 95, 70, 0.2);
    border-color: rgba(6, 95, 70, 0.4);
}

.dark-mode .financial-row.subtotal-assets .col-desc strong,
.dark-mode .financial-row.subtotal-assets .highlight-text {
    color: #34d399 !important;
}

.dark-mode .financial-row.subtotal-liabilities {
    background-color: rgba(153, 27, 27, 0.2);
    border-color: rgba(153, 27, 27, 0.4);
}

.dark-mode .financial-row.subtotal-liabilities .col-desc strong,
.dark-mode .financial-row.subtotal-liabilities .highlight-text {
    color: #f87171 !important;
}