
        /* --- 1. FONT EMBEDDING --- */
        @font-face {
            font-family: 'Jameel Noori Nastaleeq';
            src: local('Jameel Noori Nastaleeq'), url('https://fonts.cdnfonts.com/s/15467/JameelNooriNastaleeq.woff') format('woff');
            font-weight: normal;
            font-style: normal;
            font-display: swap;
        }

        /* --- 2. DESIGN TOKENS --- */
        :root {
            --primary: #064E3B; /* Emerald Green */
            --primary-dark: #043629;
            --accent: #C5A059; /* Gold */
            --label-gold: #B45309; /* Contrast Golden/Bronze for Labels */
            --slate: #1F2937;
            --text-muted: #6B7280;
            --bg: #F9FAFB;
            --white: #FFFFFF;
            --border: #E5E7EB;
            --danger: #991B1B;
            
            /* Fonts */
            --font-english: 'Playfair Display', serif; 
            --font-urdu: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif;
            --font-urdu-title: 'Scheherazade New', serif; 
        }

        * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
        
        body {
            font-family: var(--font-english);
            background-color: var(--bg);
            color: var(--slate);
            line-height: 1.4;
            overflow-x: hidden;
            width: 100%;
        }

        /* --- TYPOGRAPHY --- */
        .urdu-label-main {
            font-family: var(--font-urdu) !important;
            font-size: 1.25rem; 
            color: var(--primary); 
            font-weight: normal; 
            direction: rtl;
            display: block;
            text-align: center;
            line-height: 1.5;
            margin-top: 1px;
            margin-bottom: 4px;
        }
        
        .urdu-subtitle {
            font-family: var(--font-urdu) !important;
            color: #4B5563;
            font-size: 1.1rem; 
            text-align: center;
            display: block;
            direction: rtl;
            margin-bottom: 4px;
            line-height: 1.4;
        }

        .urdu-body {
            font-family: var(--font-urdu) !important;
            direction: rtl;
            unicode-bidi: embed;
            line-height: 2.1;
            text-align: right;
            font-size: 1.1rem;
            color: #374151;
        }

        /* --- LAYOUT --- */
        header {
            background: linear-gradient(135deg, var(--primary-dark), var(--primary));
            color: white;
            padding: 10px;
            border-bottom: 3px solid var(--accent);
            box-shadow: 0 2px 6px rgba(0,0,0,0.1);
            position: sticky;
            top: 0;
            z-index: 50;
            display: flex;
            justify-content: space-between;
            align-items: center; 
        }

        .header-content {
            flex: 0 1 auto; 
            display: flex;
            flex-direction: column;
            align-items: center; 
            justify-content: center;
        }

        header h1 { 
            font-family: var(--font-english);
            font-size: 1.25rem; 
            font-weight: 800; 
            margin: 0; 
            line-height: 1.1; 
            color: #FEF3C7;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            white-space: nowrap;
        }
        .header-urdu-title {
            font-family: var(--font-urdu-title);
            font-size: 1.5rem;
            color: #FFFFFF;
            margin-top: 0px;
            line-height: 1.2;
            font-weight: 700;
        }
        .header-urdu-subtitle {
            font-family: var(--font-urdu-title);
            font-size: 1.1rem;
            color: var(--accent);
            margin-top: 0px;
            font-weight: 700;
        }
        
        .hist-btn-top {
            background: rgba(255,255,255,0.15);
            border: 1px solid rgba(255,255,255,0.3);
            color: white;
            padding: 4px 8px;
            border-radius: 8px;
            cursor: pointer;
            display: flex;
            flex-direction: column;
            align-items: center;
            line-height: 1.1;
            min-width: 65px;
            text-align: center;
            margin-left: 10px;
        }
        .hist-btn-top .icon { font-size: 1rem; margin-bottom: 0px; }
        .hist-btn-top .txt-en { font-family: var(--font-english); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; }
        .hist-btn-top .txt-ur { font-family: var(--font-urdu); font-size: 0.8rem; margin-top: 0px; }

        .container {
            width: 100%;
            max-width: 600px;
            margin: 0 auto;
            padding: 8px;
            padding-bottom: 60px;
        }

        /* --- FIELD CARDS --- */
        .field-card {
            background: var(--white);
            border-radius: 8px;
            padding: 12px;
            margin-bottom: 10px;
            border: 1px solid #E5E7EB;
            box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        }
        
        .step-title { 
            color: var(--primary); 
            font-family: var(--font-english);
            font-weight: 700; 
            font-size: 1.35rem; 
            border-bottom: 2px solid #E5E7EB; 
            padding-bottom: 6px; 
            margin-bottom: 10px;
            text-align: center; 
            background: white;
            padding-top: 4px;
            border-radius: 8px 8px 0 0;
        }

        label { 
            display: block; 
            font-weight: 700; 
            font-size: 0.95rem; 
            margin-bottom: 1px; 
            color: var(--label-gold); 
            text-align: center; 
            font-family: var(--font-english); 
            letter-spacing: 0.3px; 
            text-transform: uppercase;
        }
        
        input, select {
            width: 100%;
            padding: 10px;
            border: 1px solid #D1D5DB;
            border-radius: 6px;
            font-size: 1.15rem;
            text-align: center;
            background: #FAFAFA;
            color: #111;
            font-weight: 500;
            font-family: var(--font-english);
            margin-top: 2px;
        }
        input:focus, select:focus { outline: none; border-color: var(--primary); background: white; }
        
        .accordion-header, .sub-acc-header {
            font-size: 0.9rem;
            padding: 8px 10px;
            background: #F3F4F6; 
            border: 1px solid #E5E7EB;
            border-radius: 6px;
            cursor: pointer;
            text-align: right;
            color: var(--primary);
            font-family: var(--font-urdu);
            margin-top: 6px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            direction: rtl;
        }
        .accordion-header:hover { background: #E5E7EB; }
        .accordion-header.active, .sub-acc-header.active {
            background: #ECFDF5; 
            border-color: var(--primary);
            color: var(--primary-dark);
        }
        .accordion-header::after, .sub-acc-header::after { content: '▼'; font-size: 0.8rem; color: #6B7280; margin-right: 10px; }
        .accordion-header.active::after, .sub-acc-header.active::after { content: '✕'; font-size: 1rem; color: var(--danger); font-weight: bold; }
        
        .accordion-content, .sub-acc-body {
            display: none;
            padding: 10px;
            background: #FFFFFF;
            border: 1px solid #E5E7EB;
            border-top: none;
            text-align: right;
            font-family: var(--font-urdu);
            line-height: 2.1;
            font-size: 1.0rem; 
            color: #374151;
            border-radius: 0 0 6px 6px;
            margin-bottom: 5px;
        }

        .read-first-btn {
            background: #FFFBEB; color: #92400E; padding: 10px; text-align: center; cursor: pointer;
            display: flex; align-items: center; justify-content: center; gap: 8px;
            border: 1px solid #FCD34D; border-radius: 8px; margin-bottom: 10px;
        }
        .read-first-btn span.en { font-family: var(--font-english); font-weight: 700; font-size: 0.9rem; }
        .read-first-btn span.ur { font-family: var(--font-urdu); font-weight: 400; font-size: 1.1rem; margin-top:4px; }
        .read-first-content { display: none; border: 1px solid #FCD34D; border-top: none; padding: 10px; background: #FFF; border-radius: 0 0 8px 8px; margin-bottom: 15px; }

        .advice-box-single-line {
            background: #F0F9FF; border-left: 4px solid #3B82F6; padding: 8px; border-radius: 6px;
            font-size: 1.05rem; margin: 6px 0; color: #1E40AF; text-align: right; font-family: var(--font-urdu);
            line-height: 1.8; 
        }
        .warning-box { background: #FFFBEB; border-left: 4px solid #F59E0B; padding: 10px; border-radius: 6px; font-size: 0.9rem; margin-bottom: 8px; font-family: var(--font-english); color: #78350F; }
        .warning-box .urdu { font-family: var(--font-urdu) !important; font-size: 1.1rem; display: block; margin-top: 4px; text-align: right; line-height: 2.0; color: #92400E; }

        .nisab-sketch-container {
            border: 2px solid var(--primary);
            border-radius: 10px;
            padding: 15px;
            margin-top: 15px;
            background: white;
            position: relative;
        }
        .sketch-title-box {
            border: 1px solid var(--primary);
            border-radius: 6px;
            padding: 5px 12px;
            text-align: center;
            margin: -28px auto 8px auto;
            width: 85%;
            background: white;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .sketch-title-en { font-family: var(--font-english); font-size: 1rem; font-weight: 700; color: var(--primary); display: block; }
        .sketch-title-ur { font-family: var(--font-urdu); font-size: 1.25rem; color: var(--primary); display: block; line-height: 1.2; }
        .sketch-instruction { font-family: var(--font-urdu); font-size: 1.1rem; text-align: center; line-height: 1.5; color: var(--slate); margin-bottom: 10px; }
        .sketch-input-row { display: flex; gap: 6px; margin-bottom: 10px; align-items: center; }
        .sketch-result-box { border: 2px solid var(--primary); border-radius: 6px; padding: 8px; text-align: center; background: #F0FDF4; }

        /* --- SUMMARY TABLE --- */
        .statement-table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid #E5E7EB; border-radius: 8px; overflow: hidden; margin-bottom: 12px; background: white; }
        .statement-table th { background: #F9FAFB; padding: 8px 10px; text-align: left; font-weight: 700; color: var(--slate); font-size: 0.9rem; text-transform: uppercase; font-family: var(--font-english); }
        .statement-table td { padding: 8px 10px; border-bottom: 1px solid #E5E7EB; vertical-align: top; }
        .row-header { font-weight: 600; color: var(--slate); font-size: 0.95rem; display: block; font-family: var(--font-english); }
        
        .row-urdu { 
            font-family: var(--font-urdu); 
            color: var(--text-muted); 
            font-size: 1rem; 
            font-weight: normal; 
            display: block; 
            text-align: left; /* Captions aligned left under English */
            direction: rtl; 
            line-height: 1.3; 
            margin-top: 2px; 
        }
        
        .row-val { font-weight: 700; color: var(--primary); text-align: right; font-size: 1.1rem; vertical-align: middle; font-family: var(--font-english); }
        .row-final { background: var(--primary); color: white; }
        
        .row-final .row-header { color: white !important; font-size: 1.2rem; }
        .row-final .row-urdu { color: white !important; font-size: 1.1rem; }
        .row-final .row-val { color: white !important; font-size: 1.6rem; font-weight: 900; }

        .faq-item { margin-bottom: 10px; border-bottom: 1px dashed #E5E7EB; padding-bottom: 10px; }
        .faq-q { color: #991B1B; font-weight: bold; font-family: var(--font-urdu); font-size: 1.1rem; text-align: right; margin-bottom: 4px; line-height: 1.6; }
        .faq-a { color: #064E3B; font-family: var(--font-urdu); font-size: 1.05rem; text-align: right; line-height: 2.0; }

        .btn-row { display: flex; gap: 8px; margin-top: 15px; }
        .btn { flex: 1; padding: 12px; border-radius: 8px; border: none; font-weight: 700; cursor: pointer; transition: 0.2s; font-size: 1rem; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 1px 2px rgba(0,0,0,0.1); font-family: var(--font-english); }
        .btn span.en { font-size: 0.95rem; }
        .btn span.ur { font-family: var(--font-urdu); font-size: 0.9rem; font-weight: normal; margin-top: 0px; }
        .btn-primary { background: var(--primary); color: white; }
        .btn-prev { background: #E5E7EB; color: var(--slate); }
        .btn-gold { background: var(--accent); color: var(--primary-dark); width: 100%; margin-top: 10px; font-weight: 700; }
        
        .btn-clear { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 700; font-family: var(--font-english); font-size: 0.9rem; }
        
        /* --- TOP NAV STYLES --- */
        .top-nav-row { display: flex; align-items: center; margin-bottom: 5px; }
        .top-back-btn { 
            background: none; border: none; color: #6B7280; font-size: 0.95rem; 
            font-weight: 600; cursor: pointer; display: flex; align-items: center; 
            gap: 5px; font-family: var(--font-english); padding: 5px 0;
        }
        .top-back-btn:hover { color: var(--primary); }

        #installBtn { 
            display: none; 
            width: 100%; 
            background: #B45309; 
            color: white; 
            padding: 10px; 
            border: none; 
            border-radius: 8px; 
            font-weight: 700; 
            margin-bottom: 15px; 
            cursor: pointer;
            text-align: center;
        }

        .hidden { display: none !important; }
        #toast { visibility: hidden; min-width: 250px; background: #333; color: #fff; text-align: center; border-radius: 8px; padding: 16px; position: fixed; z-index: 1000; left: 50%; bottom: 30px; transform: translateX(-50%); font-size: 1rem; }
        #toast.show { visibility: visible; }
        
        #historyModal { display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); backdrop-filter: blur(5px); align-items: center; justify-content: center; }
        .modal-content { background-color: white; margin: 5% auto; padding: 20px; border-radius: 12px; width: 95%; max-width: 500px; max-height: 85vh; overflow-y: auto; border: 1px solid var(--border); position: relative; }
        .close-modal { position: absolute; top: 15px; right: 15px; font-size: 1.5rem; width: 36px; height: 36px; background: #f1f1f1; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; }
        
        .history-card { 
            background: #FFFFFF; 
            border: 1px solid #E5E7EB; 
            border-radius: 10px; 
            padding: 15px; 
            margin-bottom: 15px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.05);
            border-left: 5px solid var(--primary);
        }
        .hist-header {
            display: flex; justify-content: space-between; align-items: flex-start;
            margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #F3F4F6;
        }
        .hist-name { font-family: var(--font-english); font-size: 1.2rem; font-weight: 800; color: var(--primary-dark); }
        .hist-date { font-family: var(--font-english); font-size: 0.85rem; color: #6B7280; }
        
        .hist-grid {
            display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 15px;
        }
        .hist-item { background: #F9FAFB; padding: 8px; border-radius: 6px; text-align: center; }
        .hist-lbl { display: block; font-size: 0.75rem; color: #6B7280; font-weight: 600; text-transform: uppercase; }
        .hist-val { display: block; font-size: 1rem; font-weight: 700; color: var(--slate); }
        .hist-total-box { 
            background: #ECFDF5; padding: 10px; border-radius: 6px; text-align: center; margin-top: 5px; border: 1px solid #D1FAE5;
        }
        
        .hist-actions-row { display: flex; gap: 10px; margin-top: 10px; }
        .h-btn { 
            flex: 1; padding: 8px; border-radius: 6px; border: none; font-weight: 600; cursor: pointer; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; gap: 5px;
        }
        .h-btn-edit { background: #EFF6FF; color: #1E40AF; }
        .h-btn-share { background: #FFF7ED; color: #9A3412; }
        .h-btn-del { background: #FEF2F2; color: #991B1B; }

        footer { text-align: center; padding: 20px 10px; color: #6B7280; font-size: 0.8rem; background: var(--white); border-top: 1px solid var(--border); margin-top: 15px; font-family: var(--font-english); }
        footer strong { color: var(--label-gold); font-weight: 900; }

        .hijri-panel { background: var(--primary-dark); color: white; padding: 8px; border-radius: 6px; display: flex; align-items: center; justify-content: space-between; margin-top: 5px; }
        .adj-btn { background: var(--accent); border: none; color: var(--primary-dark); width: 30px; height: 30px; border-radius: 50%; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
        
        .rtl-list {
            padding-right: 25px;
            padding-left: 0;
            margin: 0;
            list-style-type: decimal;
            direction: rtl;
            text-align: right;
        }
        .rtl-list li {
            margin-bottom: 6px;
            padding-right: 5px;
        }
    