:root {
    --color-green: #0b5d34;
    --color-green-dark: #073d22;
    --color-gold: #c9a227;
    --color-gold-light: #e6c65c;
    --color-charcoal: #14110d;
    --color-bg: #faf7f0;
    --color-surface: #ffffff;
    --color-text: #1c1a16;
    --color-muted: #6b6558;
    --color-border: #e7e0cf;
    --color-up: #1e8e3e;
    --color-down: #c5221f;
    --radius: 12px;
    --font-sans: "Tajawal", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 960px;
    margin-inline: auto;
    padding-inline: 1rem;
}

a { color: var(--color-green); text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -3rem;
    left: 1rem;
    background: var(--color-gold);
    color: var(--color-charcoal);
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-weight: 700;
    z-index: 100;
    transition: top 0.15s ease;
}
.skip-link:focus { top: 1rem; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
    outline: 2px solid var(--color-gold);
    outline-offset: 2px;
}

/* Header */
.site-header {
    background: var(--color-charcoal);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding-block: 0.75rem;
    max-width: 1320px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-gold-light), var(--color-gold));
    color: var(--color-charcoal);
    font-weight: 800;
    font-size: 0.9rem;
}
.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.85rem;
    flex: 1 1 auto;
    justify-content: center;
    font-size: 0.92rem;
}
.main-nav a { color: #e9e4d8; font-weight: 500; padding-block: 0.25rem; white-space: nowrap; }
.main-nav a.nav-secondary { display: none; }
.main-nav a[aria-current="page"] {
    color: var(--color-gold-light);
    border-bottom: 2px solid var(--color-gold);
}
.mobile-only-actions { display: none; }

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 2.2rem;
    height: 2.2rem;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
}
.nav-toggle-bar {
    display: block;
    width: 1.2rem;
    height: 2px;
    background: #fff;
    margin-inline: auto;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.lang-switch {
    border: 1px solid var(--color-gold);
    color: var(--color-gold-light);
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-size: 0.9rem;
    white-space: nowrap;
}
.lang-switch:hover { background: var(--color-gold); color: var(--color-charcoal); text-decoration: none; }

.header-actions { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.account-link {
    color: #e9e4d8;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}
.account-link:hover { color: var(--color-gold-light); text-decoration: none; }

.site-flash {
    margin-block: 1rem 0;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.92rem;
}
.site-flash-success { background: #e6f4ea; color: #1e6b34; border: 1px solid #b7e0c3; }
.site-flash-error { background: #fdecea; color: #9c1c17; border: 1px solid #f3b7b3; }

/* Buttons & cards (shared by auth/account pages) */
.btn {
    display: inline-block;
    background: var(--color-green);
    color: #fff;
    border: none;
    padding: 0.6rem 1.3rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--color-green-dark); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #f4f2ea; }
.btn-danger { background: var(--color-down); }
.btn-danger:hover { background: #a11a17; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.82rem; }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-block: 1rem 2rem;
}
.form-hint { color: var(--color-muted); font-size: 0.85rem; }

/* Auth forms */
.auth-card {
    max-width: 420px;
    margin: 2rem auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.75rem;
}
.auth-card h1 { text-align: center; font-size: 1.3rem; margin-top: 0; }
.auth-card .form-row { margin-bottom: 1rem; }
.auth-card label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
.auth-card input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
}
.auth-card .btn { width: 100%; margin-top: 0.5rem; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: 0.9rem; color: var(--color-muted); }
.link-btn { background: none; border: none; padding: 0; font: inherit; color: var(--color-green); text-decoration: none; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* Account page */
.account-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.tier-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}
.tier-badge.free { background: #eef0f2; color: #4b5563; }
.tier-badge.premium { background: #fdf3d8; color: #8a6d1a; }

.premium-note {
    max-width: 640px;
    margin: 1rem auto 0;
    background: #fbf6e8;
    border: 1px solid var(--color-gold);
    border-radius: 10px;
    padding: 0.75rem 1.1rem;
    font-size: 0.88rem;
    color: #6b5c1f;
    text-align: start;
}
.premium-note .tier-badge { margin-inline-end: 0.4rem; vertical-align: middle; }
.premium-note a { font-weight: 700; white-space: nowrap; }

.field-locked { position: relative; opacity: 0.6; }
.field-locked input { background: #f4f4f2; cursor: not-allowed; }
.field-lock-hint { display: block; font-size: 0.78rem; color: var(--color-muted); font-weight: 500; margin-top: 0.2rem; }
.alerts-list { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: 0.6rem; }
.alert-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.7rem 1rem;
}
.alert-status { font-size: 0.78rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: #eef0f2; }
.alert-status.active { background: #e6f4ea; color: #1e6b34; }

/* Hero */
.hero {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 0%, rgba(201,162,39,0.16), transparent 60%),
        linear-gradient(180deg, var(--color-charcoal) 0%, #201a10 100%);
    color: #fff;
    padding-block: 2.5rem 2rem;
    text-align: center;
}
.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='84' height='84' viewBox='0 0 84 84'%3E%3Cg fill='none' stroke='%23c9a227' stroke-width='1'%3E%3Crect x='12' y='12' width='60' height='60'/%3E%3Crect x='12' y='12' width='60' height='60' transform='rotate(45 42 42)'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 84px 84px;
    opacity: 0.07;
    pointer-events: none;
}
.hero > .container { position: relative; z-index: 1; }
.hero h1 {
    margin: 0 0 0.4rem;
    font-size: clamp(1.5rem, 4vw, 2.25rem);
}
.hero-subtitle {
    color: #d8d2c2;
    margin: 0 0 1.25rem;
}
.hero-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    font-size: 0.95rem;
}
.hero-meta span {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(201,162,39,0.4);
    border-radius: 999px;
    padding: 0.4rem 1rem;
}
.hero-meta strong { color: var(--color-gold-light); }
.hero .page-intro { color: #d8d2c2; max-width: 720px; margin: 0 auto 1.25rem; font-size: 0.92rem; }

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--color-up);
    background: rgba(30,142,62,0.12) !important;
    border-color: rgba(30,142,62,0.5) !important;
}
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-up);
    animation: live-pulse 1.8s ease-in-out infinite;
}
@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(30,142,62,0.55); }
    70% { box-shadow: 0 0 0 9px rgba(30,142,62,0); }
    100% { box-shadow: 0 0 0 0 rgba(30,142,62,0); }
}

/* Price table */
.price-section { padding-block: 1.5rem 2rem; }
.price-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.price-table th, .price-table td {
    padding: 0.75rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}
.price-table th {
    background: var(--color-green);
    color: #fff;
    font-weight: 600;
}
.price-table tbody tr:last-child td { border-bottom: none; }
.price-table tbody tr:hover { background: #fbf6e8; }
.price-cell {
    font-weight: 700;
    color: var(--color-green-dark);
    font-size: 1.05rem;
}
.silver-row td { background: #f4f4f2; font-weight: 600; }

.price-table tr.flash-up td { animation: flash-up-row 1.8s ease-out; }
.price-table tr.flash-down td { animation: flash-down-row 1.8s ease-out; }
@keyframes flash-up-row {
    0% { background-color: rgba(30,142,62,0.28); }
    100% { background-color: transparent; }
}
@keyframes flash-down-row {
    0% { background-color: rgba(197,34,31,0.28); }
    100% { background-color: transparent; }
}
.price-change-indicator { display: inline-block; margin-inline-start: 0.3rem; font-size: 0.8rem; }
.price-change-indicator.up { color: var(--color-up); }
.price-change-indicator.down { color: var(--color-down); }
.price-usd { color: var(--color-muted); font-size: 0.9rem; }
.vat-note {
    color: var(--color-muted);
    font-size: 0.85rem;
    margin-top: 0.75rem;
    text-align: center;
}

/* FAQ */
.faq-section { padding-block: 1rem 3rem; }
.faq-section h2 { text-align: center; margin-bottom: 1.25rem; }
.faq-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.85rem 1.1rem;
    margin-bottom: 0.6rem;
}
.faq-item summary {
    cursor: pointer;
    font-weight: 600;
}
.faq-item p { margin: 0.6rem 0 0.2rem; color: var(--color-muted); }

/* Footer */
.site-footer {
    background: var(--color-charcoal);
    color: #cfc9ba;
    margin-top: 2rem;
}
.footer-inner {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1.5rem;
    padding-block: 2rem;
}
.footer-col h3 { color: #fff; font-size: 1rem; margin-bottom: 0.6rem; }
.footer-col .brand-name { color: #fff; font-weight: 700; margin-bottom: 0.4rem; }
.footer-links { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.footer-links a { color: #cfc9ba; }
.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-block: 1rem;
    font-size: 0.85rem;
    text-align: center;
    color: #a29c8d;
}

/* Breadcrumb */
.breadcrumb {
    padding-block: 0.75rem;
    font-size: 0.85rem;
    color: var(--color-muted);
}
.breadcrumb a { color: var(--color-green-dark); }

/* Generic page hero (non-home pages) */
.page-hero {
    padding-block: 1.5rem 1rem;
    text-align: center;
}
.page-hero h1 { font-size: clamp(1.4rem, 4vw, 2rem); margin-bottom: 0.5rem; }
.page-intro { color: var(--color-muted); max-width: 640px; margin-inline: auto; }

/* Related links */
.related-links { padding-block: 1.5rem; }
.related-links h2 { font-size: 1.1rem; text-align: center; margin-bottom: 0.75rem; }
.related-links-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
}
.related-links-list a {
    display: inline-block;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.4rem 1rem;
    font-size: 0.88rem;
    color: var(--color-green-dark);
}
.related-links-list a:hover { background: var(--color-green); color: #fff; text-decoration: none; }

/* Calculators */
.calculator-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-block: 1rem 2rem;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.form-grid label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.9rem; }
.form-grid input, .form-grid select {
    font-family: inherit;
    font-size: 1rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}
.calc-result {
    background: #fbf6e8;
    border: 1px solid var(--color-gold);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
    margin-bottom: 0.5rem;
}
.calc-result-label { color: var(--color-muted); font-size: 0.9rem; }
.calc-result-value { font-size: 1.4rem; font-weight: 700; color: var(--color-green-dark); }
.zakat-status { width: 100%; }
.check-offer-title { margin-top: 1.5rem; font-size: 1.05rem; }

/* Articles */
.article-list { list-style: none; padding: 0; margin: 0 0 2rem; display: grid; gap: 1rem; }
.article-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}
.article-card a { color: inherit; display: block; }
.article-card a:hover { text-decoration: none; }
.article-card h2 { margin: 0 0 0.4rem; font-size: 1.1rem; color: var(--color-green-dark); }
.article-card p { margin: 0 0 0.5rem; color: var(--color-muted); }
.article-date { color: var(--color-muted); font-size: 0.82rem; }
.article-body { padding-block: 1rem 2rem; max-width: 760px; }
.article-content { line-height: 1.9; }
.article-content h2 { margin-top: 1.75rem; font-size: 1.2rem; }
.article-content p { margin-bottom: 1rem; }
.article-content ul, .article-content ol { margin-bottom: 1rem; padding-inline-start: 1.5rem; }

/* History / charts */
.card-chart {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.card-chart h2 { margin: 0 0 0.75rem; font-size: 1rem; }
.sparkline-wrap { position: relative; direction: ltr; }
.sparkline { width: 100%; height: 180px; display: block; }
.sparkline-axis-label { font-size: 11px; fill: var(--color-muted); font-family: inherit; }
.sparkline-current-label { font-size: 12px; font-weight: 700; fill: var(--color-text); font-family: inherit; }
.sparkline-capture { cursor: crosshair; }
.sparkline-hover-guide, .sparkline-hover-dot { pointer-events: none; transition: opacity 0.1s ease; }

.sparkline-tooltip {
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(-50%, -100%);
    margin-top: -10px;
    background: var(--color-charcoal);
    color: #fff;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.sparkline-tooltip[hidden] { display: none; }
.sparkline-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--color-charcoal);
}
.sparkline-tooltip .tt-date { color: #cfc9ba; margin-inline-end: 0.4rem; }
.sparkline-tooltip .tt-value { font-weight: 700; }
.history-table { margin-top: 0; }

.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.9rem;
}
.insight-stat {
    background: #f9f8f3;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.insight-label { font-size: 0.78rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.insight-value { font-size: 1.05rem; font-weight: 700; color: var(--color-text); }
.insight-value.trend-up { color: var(--color-up); }
.insight-value.trend-down { color: var(--color-down); }
.insight-value.trend-flat { color: var(--color-muted); }
.insight-disclaimer {
    margin-top: 1rem;
    padding: 0.65rem 0.9rem;
    background: #fdf6e3;
    border: 1px solid var(--color-gold);
    border-radius: 8px;
    font-size: 0.82rem;
    color: #6b5c1f;
}

@media (max-width: 640px) {
    .footer-inner { grid-template-columns: 1fr; }
    .price-table th, .price-table td { padding: 0.5rem 0.35rem; font-size: 0.8rem; }
    .price-cell { font-size: 0.95rem; }
    .price-usd { font-size: 0.75rem; }

    .nav-toggle { display: flex; }
    .header-actions .account-link { display: none; }

    .main-nav {
        display: none;
        position: absolute;
        inset-inline: 0;
        top: 100%;
        flex-direction: column;
        gap: 0;
        background: var(--color-charcoal);
        border-top: 1px solid rgba(255,255,255,0.1);
        box-shadow: 0 8px 16px rgba(0,0,0,0.25);
    }
    .main-nav.is-open { display: flex; }
    .main-nav a {
        padding: 0.85rem 1.25rem;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }
    .main-nav a.nav-secondary { display: block; }
    .main-nav a[aria-current="page"] { border-inline-start: 3px solid var(--color-gold); border-bottom: 1px solid rgba(255,255,255,0.08); }
    .mobile-only-actions { display: block; }
    .mobile-only-actions a { padding: 0.85rem 1.25rem; display: block; color: var(--color-gold-light); font-weight: 600; }
}
