/* Timeless Tax — shared styles for generated pages (services, resources, tools, FAQ).
   Design tokens mirror the homepage (index.html). */
:root {
    --primary: #0071e3;
    --primary-dark: #0058b0;
    --primary-light: #e8f2ff;
    --accent: #5e5ce6;
    --green: #248a3d;
    --green-light: #e9f9ee;
    --orange: #b25000;
    --orange-light: #fff4e0;
    --red: #d70015;
    --red-light: #ffecea;
    --dark: #1d1d1f;
    --gray-900: #2c2c2e;
    --gray-700: #48484a;
    --gray-500: #6e6e73;
    --gray-300: #d2d2d7;
    --gray-100: #f2f2f7;
    --gray-50: #f9f9fb;
    --white: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.78);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --heading-font: 'Playfair Display', Georgia, serif;
    --body-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 96px; }

body {
    font-family: var(--body-font);
    background: var(--gray-50);
    color: var(--dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

a { color: var(--primary); text-decoration: none; transition: color .2s ease, background .2s ease; }
a:hover { color: var(--primary-dark); }

h1, h2, h3, h4 { font-family: var(--heading-font); letter-spacing: -0.02em; color: var(--dark); line-height: 1.2; }

.skip-link { position: absolute; inset-inline-start: 8px; top: 8px; transform: translateY(-300%); background: var(--dark); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 2000; }
.skip-link:focus { transform: none; color: #fff; }

:focus-visible { outline: 3px solid rgba(0, 113, 227, .45); outline-offset: 2px; border-radius: 6px; }

/* --- Buttons --- */
.btn {
    display: inline-block; background: var(--primary); color: var(--white);
    padding: 14px 28px; border-radius: 980px; font-weight: 600; font-size: .95rem;
    border: none; cursor: pointer; font-family: var(--body-font);
    transition: all .3s cubic-bezier(.25, .1, .25, 1);
}
.btn:hover { background: var(--primary-dark); color: var(--white); transform: scale(1.02); box-shadow: 0 4px 20px rgba(0, 113, 227, .3); }
.btn-ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost:hover { background: var(--primary); color: #fff; }
.btn-light { background: #fff; color: var(--primary); }
.btn-light:hover { background: var(--primary-light); color: var(--primary-dark); }
.btn-sm { padding: 9px 18px; font-size: .85rem; }

/* --- Header --- */
.header {
    position: sticky; top: 0; z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.header-top-bar { padding: 6px 0; font-size: .8rem; color: var(--gray-500); border-bottom: 1px solid rgba(0, 0, 0, .04); }
.top-bar-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tb-info { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.tb-sep { color: var(--gray-300); }
.header-top-bar a { color: var(--gray-700); font-weight: 500; }
.header-top-bar a:hover { color: var(--primary); }
.header-top-bar a.lang-link { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border: 1px solid rgba(0, 0, 0, .1); border-radius: 980px; color: var(--primary); font-weight: 600; background: #fff; white-space: nowrap; }
.header-top-bar a.lang-link:hover { border-color: var(--primary); background: var(--primary-light); }
.lang-link span:lang(ar), .lang-link[lang="ar"] span { font-family: 'Tajawal', 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif; font-size: .9rem; }
.nav-container { display: flex; justify-content: space-between; align-items: center; max-width: 1200px; margin: auto; padding: 10px 24px; position: relative; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--dark); }
.logo img { height: 42px; width: auto; }
.logo span { font-family: var(--heading-font); font-size: 1.35rem; font-weight: 700; color: var(--dark); }
.nav-links { list-style: none; display: flex; gap: 4px; align-items: center; }
.nav-links a { color: var(--gray-700); font-weight: 500; font-size: .87rem; padding: 8px 13px; border-radius: 980px; }
.nav-links a:hover, .nav-links a.active { color: var(--primary); background: var(--primary-light); }
.nav-links a.nav-cta { background: var(--primary); color: #fff; margin-left: 6px; }
.nav-links a.nav-cta:hover { background: var(--primary-dark); color: #fff; }
.hamburger { display: none; }

/* --- Page hero --- */
.page-hero {
    background: radial-gradient(circle at 15% 20%, rgba(0, 113, 227, .16), transparent 45%),
                radial-gradient(circle at 85% 30%, rgba(94, 92, 230, .14), transparent 45%),
                linear-gradient(180deg, #ffffff 0%, var(--gray-50) 100%);
    border-bottom: 1px solid rgba(0, 0, 0, .05);
}
.page-hero-inner { max-width: 1200px; margin: 0 auto; padding: 36px 24px 48px; }
.page-hero-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px; align-items: center; }
.page-hero h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); margin: 14px 0 16px; }
.page-hero .hero-lead { font-size: 1.15rem; color: var(--gray-700); max-width: 680px; }
.page-hero .hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.page-hero .hero-visual img { border-radius: var(--radius-lg); box-shadow: 0 24px 60px rgba(0, 0, 0, .14); width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.hero-badges span { font-size: .8rem; font-weight: 600; color: var(--gray-700); background: #fff; border: 1px solid rgba(0, 0, 0, .07); padding: 6px 12px; border-radius: 980px; }

.breadcrumb { font-size: .83rem; color: var(--gray-500); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumb li + li::before { content: '›'; margin-right: 6px; color: var(--gray-300); }
.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--primary); }

.article-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88rem; color: var(--gray-500); margin-top: 16px; align-items: center; }
.article-meta .tag { background: var(--primary-light); color: var(--primary); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .5px; padding: 5px 12px; border-radius: 980px; }

/* --- Article layout --- */
.layout { max-width: 1200px; margin: 0 auto; padding: 48px 24px 72px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 56px; align-items: start; }
.layout.no-aside { grid-template-columns: minmax(0, 1120px); justify-content: center; }
.layout.no-aside .prose > :not(.tool) { max-width: 800px; margin-left: auto; margin-right: auto; }
.aside { position: sticky; top: 110px; display: flex; flex-direction: column; gap: 20px; }
.toc, .aside-card { background: #fff; border: 1px solid rgba(0, 0, 0, .06); border-radius: var(--radius-md); padding: 22px; box-shadow: var(--shadow); }
.toc-title, .aside-card h2 { font-family: var(--body-font); font-size: .78rem; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-500); font-weight: 700; margin-bottom: 12px; }
.toc ol { list-style: none; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a { display: flex; gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; color: var(--gray-700); font-size: .88rem; line-height: 1.4; }
.toc a::before { content: counter(toc); color: var(--gray-300); font-weight: 700; min-width: 14px; }
.toc a:hover, .toc a.active { background: var(--primary-light); color: var(--primary); }
.aside-card p { font-size: .92rem; color: var(--gray-700); margin-bottom: 14px; }
.aside-card .btn { width: 100%; text-align: center; }
.aside-card .aside-phone { display: block; text-align: center; margin-top: 10px; font-weight: 600; font-size: .92rem; }

/* --- Prose --- */
.prose { font-size: 1.07rem; color: var(--gray-900); min-width: 0; }
.prose > * + * { margin-top: 1.15em; }
.prose p, .prose li { line-height: 1.75; color: var(--gray-700); }
.prose .lead { font-size: 1.2rem; color: var(--gray-900); line-height: 1.7; }
.prose h2 { font-size: clamp(1.55rem, 2.6vw, 2rem); margin-top: 2.2em; padding-top: .2em; }
.prose h3 { font-size: 1.3rem; margin-top: 1.7em; font-weight: 600; }
.prose h2 + *, .prose h3 + * { margin-top: .7em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .45em; }
.prose a { text-decoration: underline; text-decoration-color: rgba(0, 113, 227, .35); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--primary); }
.prose strong { color: var(--dark); }

.key-takeaways { background: linear-gradient(135deg, var(--primary-light), #efeffd); border-radius: var(--radius-md); padding: 24px 28px; border: 1px solid rgba(0, 113, 227, .12); }
.key-takeaways .kt-title { font-weight: 700; color: var(--primary-dark); text-transform: uppercase; letter-spacing: 1px; font-size: .8rem; margin-bottom: 10px; }
.key-takeaways ul { list-style: none; padding: 0; }
.key-takeaways li { position: relative; padding-left: 28px; color: var(--gray-900); }
.key-takeaways li::before { content: ''; position: absolute; left: 0; top: .55em; width: 16px; height: 16px; border-radius: 50%; background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2l2.3 2.3 4.7-5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; }

.callout { border-radius: var(--radius-md); padding: 20px 24px; border-left: 4px solid var(--primary); background: var(--primary-light); }
.callout .callout-title { font-weight: 700; color: var(--dark); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.callout .callout-title::before { font-size: 1.1rem; }
.callout > * + * { margin-top: .6em; }
.callout ul, .callout ol { padding-left: 1.3em; }
.callout-tip { border-color: var(--green); background: var(--green-light); }
.callout-tip .callout-title::before { content: '💡'; }
.callout-warning { border-color: #ff9f0a; background: var(--orange-light); }
.callout-warning .callout-title::before { content: '⚠️'; }
.callout-local { border-color: var(--accent); background: #efeffd; }
.callout-local .callout-title::before { content: '📍'; }
.callout-example { border-color: var(--primary); background: #fff; border: 1px solid rgba(0, 113, 227, .2); border-left: 4px solid var(--primary); }
.callout-example .callout-title::before { content: '🧮'; }

.checklist { list-style: none; padding-left: 0 !important; }
.checklist li { position: relative; padding-left: 34px; }
.checklist li::before { content: ''; position: absolute; left: 0; top: .3em; width: 20px; height: 20px; border: 2px solid var(--primary); border-radius: 6px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.3l3 3 6-6.5' fill='none' stroke='%230071e3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/80% no-repeat; }

.steps { list-style: none; padding-left: 0 !important; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 4px 0 4px 56px; min-height: 40px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.steps li + li { margin-top: 1em; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat { background: #fff; border: 1px solid rgba(0, 0, 0, .06); border-radius: var(--radius-md); padding: 18px; box-shadow: 0 2px 12px rgba(0, 0, 0, .04); }
.stat-num { display: block; font-family: var(--heading-font); font-size: 1.75rem; font-weight: 700; color: var(--primary); line-height: 1.15; }
.stat-label { display: block; font-size: .86rem; color: var(--gray-500); margin-top: 4px; line-height: 1.4; }

.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid rgba(0, 0, 0, .08); background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .04); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 520px; }
.table-wrap caption { caption-side: top; text-align: left; padding: 14px 18px; font-weight: 700; color: var(--dark); border-bottom: 1px solid rgba(0, 0, 0, .06); }
.table-wrap th, .table-wrap td { padding: 12px 18px; text-align: left; vertical-align: top; border-bottom: 1px solid rgba(0, 0, 0, .06); line-height: 1.5; }
.table-wrap thead th { background: var(--gray-100); font-size: .82rem; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-700); }
.table-wrap tbody tr:last-child td, .table-wrap tbody tr:last-child th { border-bottom: none; }
.table-wrap tbody tr:nth-child(even) { background: var(--gray-50); }
.table-wrap td { color: var(--gray-700); }

.infographic { background: #fff; border: 1px solid rgba(0, 0, 0, .06); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow); margin-top: 1.8em !important; margin-bottom: .6em; }
.infographic svg { width: 100%; height: auto; }
.infographic figcaption { font-size: .86rem; color: var(--gray-500); margin-top: 14px; text-align: center; line-height: 1.5; }

.cta-box { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border-radius: var(--radius-lg); padding: 30px 32px; display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 2em !important; }
.cta-box p { color: rgba(255, 255, 255, .88) !important; margin: 0; }
.cta-box .cta-title { font-family: var(--heading-font); font-size: 1.45rem; font-weight: 700; color: #fff !important; margin-bottom: 4px; }
.cta-box .cta-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cta-box a.btn { text-decoration: none; }
.cta-box .btn-outline-light { background: transparent; color: #fff; border: 1.5px solid rgba(255, 255, 255, .7); }
.cta-box .btn-outline-light:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* FAQ (details/summary) */
.faq-section { margin-top: 3em !important; }
.faq-list { margin-top: 1em; }
.faq-list details { background: #fff; border: 1px solid rgba(0, 0, 0, .07); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; }
.faq-list summary { cursor: pointer; list-style: none; padding: 18px 22px; font-weight: 600; color: var(--dark); display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after { content: '+'; flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--gray-100); color: var(--gray-500); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 300; }
.faq-list details[open] summary::after { content: '−'; background: var(--primary-light); color: var(--primary); }
.faq-list details[open] summary { color: var(--primary); }
.faq-list .faq-a { padding: 0 22px 18px; color: var(--gray-700); }

/* FAQ page: h3 + p pairs styled as cards */
.prose.faq-page h3 { font-family: var(--body-font); font-size: 1.07rem; font-weight: 700; background: #fff; border: 1px solid rgba(0, 0, 0, .07); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 16px 20px 6px; margin-top: 14px; }
.prose.faq-page h3 + p { background: #fff; border: 1px solid rgba(0, 0, 0, .07); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding: 0 20px 16px; margin-top: 0; }

.sources { font-size: .9rem; border-top: 1px solid rgba(0, 0, 0, .08); padding-top: 1.4em; margin-top: 2.6em !important; }
.sources h2 { font-family: var(--body-font); font-size: .82rem !important; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-500); margin-top: 0 !important; }
.sources ul { padding-left: 1.2em; }
.sources li { color: var(--gray-500); line-height: 1.5; }
.sources a { word-break: break-word; }
.disclaimer { font-size: .85rem; color: var(--gray-500) !important; background: var(--gray-100); padding: 14px 18px; border-radius: var(--radius-sm); }

.author-box { display: flex; gap: 16px; align-items: center; background: #fff; border: 1px solid rgba(0, 0, 0, .06); border-radius: var(--radius-md); padding: 18px 20px; }
.author-box img { width: 56px; height: 56px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .08); background: #fff; }
.author-box p { margin: 0; font-size: .92rem; line-height: 1.5; }
.author-box strong { display: block; }

/* --- Cards / grids --- */
.section { max-width: 1200px; margin: 0 auto; padding: 64px 24px; }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 36px; }
.section-head h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); }
.section-head p { color: var(--gray-500); margin-top: 8px; font-size: 1.07rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.card { background: #fff; border: 1px solid rgba(0, 0, 0, .06); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow); transition: transform .35s cubic-bezier(.25, .1, .25, 1), box-shadow .35s ease; display: flex; flex-direction: column; color: inherit; }
.card:hover { transform: translateY(-6px); box-shadow: 0 20px 60px rgba(0, 0, 0, .12); color: inherit; }
.card img { aspect-ratio: 1200 / 630; object-fit: cover; width: 100%; }
.card-body { padding: 22px 24px 26px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-body h3 { font-size: 1.22rem; }
.card-body p { color: var(--gray-500); font-size: .95rem; line-height: 1.6; }
.card-tag { align-self: flex-start; background: var(--primary-light); color: var(--primary); font-size: .72rem; font-weight: 700; padding: 4px 11px; border-radius: 980px; text-transform: uppercase; letter-spacing: .5px; }
.card-more { margin-top: auto; font-weight: 600; color: var(--primary); font-size: .92rem; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 30px; }
.filter-bar button { font-family: var(--body-font); border: 1px solid rgba(0, 0, 0, .1); background: #fff; color: var(--gray-700); padding: 8px 16px; border-radius: 980px; font-size: .87rem; font-weight: 500; cursor: pointer; }
.filter-bar button:hover { border-color: var(--primary); color: var(--primary); }
.filter-bar button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

.related { background: #fff; border-top: 1px solid rgba(0, 0, 0, .05); }

/* --- Tool (calculator) --- */
.tool { background: #fff; border: 1px solid rgba(0, 0, 0, .07); border-radius: var(--radius-lg); box-shadow: 0 24px 60px rgba(15, 35, 80, .08); overflow: hidden; }
.tool > form { padding: 30px 32px 32px; }
.tool-split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); align-items: stretch; }
.tool-form-head, .tool-panel-head { font-size: .78rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--gray-500); margin: 0; display: flex; align-items: center; gap: 8px; }
.tool-form-head { grid-column: 1 / -1; margin-bottom: 18px; }
.tool-grid > .tool-form-head { margin-bottom: -2px; }
.tool-form-head::before { content: '1'; }
.tool-panel-head::before { content: '2'; }
.tool-form-head::before, .tool-panel-head::before { width: 22px; height: 22px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; letter-spacing: 0; }
.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 18px; align-content: start; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 7px; color: var(--dark); line-height: 1.35; }
.field .hint { font-size: .78rem; color: var(--gray-500); margin-top: 6px; line-height: 1.45; }
.field input, .field select { width: 100%; height: 48px; padding: 0 14px; border-radius: 12px; border: 1.5px solid #dde1e8; font: inherit; font-size: 1rem; font-weight: 500; background: #fff; color: var(--dark); transition: border-color .15s ease, box-shadow .15s ease; font-variant-numeric: tabular-nums; }
.field input:hover, .field select:hover { border-color: #c3c9d4; }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0, 113, 227, .12); }
.field select { appearance: none; -webkit-appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%236e6e73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 14px center / 14px no-repeat; padding-right: 38px; }
.field .checkbox { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: .9rem; min-height: 48px; padding: 0 14px; border: 1.5px solid #dde1e8; border-radius: 12px; cursor: pointer; }
.field .checkbox input { width: 20px; height: 20px; accent-color: var(--primary); flex-shrink: 0; }
.field.wide { grid-column: 1 / -1; }

/* "$" / "%" adornments added by site.js */
.affix { position: relative; display: block; }
.affix::before { content: attr(data-prefix); position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-500); font-weight: 600; pointer-events: none; }
.affix::after { content: attr(data-suffix); position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-500); font-weight: 600; pointer-events: none; }
.affix[data-prefix] input { padding-left: 30px; }
.affix[data-suffix] input { padding-right: 34px; }

/* Segmented control (replaces short selects) and steppers (replace number inputs) */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--gray-100); border-radius: 12px; }
.segmented button { font: inherit; font-size: .84rem; font-weight: 600; color: var(--gray-700); background: transparent; border: 0; border-radius: 9px; padding: 9px 6px; cursor: pointer; line-height: 1.25; transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
.segmented button:hover { color: var(--dark); }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--primary); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 2px 8px rgba(0, 0, 0, .06); }
.field.has-segmented select { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.field.has-segmented { position: relative; }
.field.is-wide-seg { grid-column: 1 / -1; }
.stepper { display: flex; align-items: center; height: 48px; border: 1.5px solid #dde1e8; border-radius: 12px; overflow: hidden; background: #fff; }
.stepper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0, 113, 227, .12); }
.stepper button { width: 46px; height: 100%; border: 0; background: var(--gray-50); color: var(--primary); font-size: 1.25rem; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.stepper button:hover { background: var(--primary-light); }
.stepper button:disabled { color: var(--gray-300); cursor: default; background: var(--gray-50); }
.field .stepper input { border: 0; height: 100%; text-align: center; border-radius: 0; box-shadow: none; -moz-appearance: textfield; padding: 0; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Results panel */
.tool-panel { background: linear-gradient(180deg, #f5f8ff 0%, #f9fafc 100%); border-left: 1px solid rgba(0, 0, 0, .06); padding: 30px 28px 32px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.tool-panel-inner { position: sticky; top: 110px; display: flex; flex-direction: column; gap: 18px; }
.results { display: flex; flex-direction: column; gap: 0; margin: 0; }
.result { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 13px 2px; border-bottom: 1px solid rgba(0, 0, 0, .07); background: none; border-radius: 0; }
.result .label { font-size: .9rem; color: var(--gray-700); font-weight: 500; text-transform: none; letter-spacing: 0; }
.result .value { font-family: var(--body-font); font-size: 1.08rem; font-weight: 700; color: var(--dark); margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.result.highlight { order: -1; display: block; padding: 22px 22px 24px; margin-bottom: 8px; border: 0; border-radius: 18px; background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%); box-shadow: 0 14px 34px rgba(0, 113, 227, .28); }
.result.highlight .label { color: rgba(255, 255, 255, .85); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.result.highlight .value { color: #fff; font-size: clamp(2.2rem, 4vw, 2.8rem); letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.result.highlight.is-due { background: linear-gradient(135deg, #1d1d1f 0%, #3a3a5c 100%); box-shadow: 0 14px 34px rgba(29, 29, 31, .22); }
.tool-panel .hint { font-size: .84rem; color: var(--gray-500); line-height: 1.55; margin: 0 !important; }
.tool-panel .table-wrap { box-shadow: none; border-radius: 14px; }
.tool-panel .table-wrap table { min-width: 0; font-size: .86rem; }
.tool-panel .table-wrap th, .tool-panel .table-wrap td { padding: 9px 14px; }
.tool-panel .table-wrap caption { padding: 12px 14px; font-size: .9rem; }
.tool-panel .table-wrap td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--dark); }

.bracket-bar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; margin: 6px 0 0; background: var(--gray-100); gap: 2px; }
.bracket-bar div { min-width: 0; font-size: 0; transition: flex-grow .4s ease; }
.bracket-legend { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; font-size: .84rem; color: var(--gray-700); font-variant-numeric: tabular-nums; }
.bracket-legend span { display: flex; align-items: center; gap: 8px; }
.bracket-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }

/* --- Footer --- */
.site-footer { background: var(--dark); color: rgba(255, 255, 255, .62); }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 56px 24px 28px; display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 36px; }
.site-footer h2 { font-family: var(--body-font); color: #fff; font-size: .8rem; text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 14px; }
.site-footer ul { list-style: none; }
.site-footer li { margin-bottom: 8px; font-size: .92rem; }
.site-footer a { color: rgba(255, 255, 255, .78); }
.site-footer a:hover { color: #fff; }
.site-footer p { font-size: .92rem; line-height: 1.7; color: rgba(255, 255, 255, .62); }
.footer-brand img { height: 46px; width: auto; background: #fff; border-radius: 10px; padding: 6px 10px; margin-bottom: 14px; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .1); max-width: 1200px; margin: 0 auto; padding: 18px 24px 28px; font-size: .82rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* --- Animations --- */
@media (prefers-reduced-motion: no-preference) {
    .fade-in { opacity: 0; transform: translateY(24px); transition: opacity .7s cubic-bezier(.25, .1, .25, 1), transform .7s cubic-bezier(.25, .1, .25, 1); }
    .fade-in.visible { opacity: 1; transform: none; }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .layout { grid-template-columns: minmax(0, 1fr); gap: 32px; }
    .aside { position: static; order: -1; }
    .aside .aside-card { display: none; }
    .toc { box-shadow: none; }
    .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
    .tool-split { grid-template-columns: 1fr; }
    .tool-panel { border-left: 0; border-top: 1px solid rgba(0, 0, 0, .06); }
    .tool-panel-inner { position: static; }
}
@media (max-width: 900px) {
    .top-bar-inner { padding: 0 16px; }
    .tb-hide-sm { display: none; }
    .nav-links {
        display: none; flex-direction: column; align-items: stretch; width: 100%;
        position: absolute; top: 100%; left: 0; background: rgba(255, 255, 255, .97);
        box-shadow: 0 12px 32px rgba(0, 0, 0, .12); gap: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); padding: 8px;
    }
    .nav-links.active { display: flex; }
    .nav-links a { display: block; text-align: center; padding: 14px; border-radius: 10px; }
    .nav-links a.nav-cta { margin: 6px 0 0; }
    .hamburger { display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 22px; background: none; border: none; color: var(--dark); width: 44px; height: 44px; border-radius: 10px; }
    .hamburger:hover { background: var(--gray-100); }
    .page-hero-grid { grid-template-columns: 1fr; gap: 28px; }
}
@media (max-width: 640px) {
    .layout { padding: 32px 16px 56px; }
    .page-hero-inner { padding: 24px 16px 36px; }
    .section { padding: 48px 16px; }
    .prose { font-size: 1.02rem; }
    .infographic { padding: 12px; border-radius: var(--radius-md); }
    .cta-box { padding: 24px; }
    .footer-inner { grid-template-columns: 1fr; padding: 44px 16px 20px; }
    .footer-bottom { padding: 16px; }
    .card-grid { grid-template-columns: 1fr; }
    .logo span { font-size: 1.15rem; }
    .tool > form, .tool-panel { padding: 22px 18px; }
    .is-wide-seg .segmented { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
    .segmented button { padding: 11px 6px; }
    .tool-panel .table-wrap caption { position: sticky; left: 0; }
    .tool-panel .table-wrap th, .tool-panel .table-wrap td { padding: 8px 10px; }
    .tool-grid { grid-template-columns: 1fr; }
}
@media print {
    .header, .site-footer, .aside, .cta-box, .related, .newsletter { display: none !important; }
    .layout { display: block; padding: 0; }
    .infographic { box-shadow: none; break-inside: avoid; }
}

/* --- Language switch --- */
.lang-switch { margin-top: 16px; font-size: .92rem; }
.lang-switch a { font-weight: 600; border-bottom: 1px solid rgba(0, 113, 227, .3); }

/* --- Arabic / right-to-left pages --- */
[lang="ar"] { font-family: 'Tajawal', 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif; }
[lang="ar"] h1, [lang="ar"] h2, [lang="ar"] h3, [lang="ar"] h4 { font-family: 'Tajawal', 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif; font-weight: 800; letter-spacing: 0; line-height: 1.4; }
[lang="ar"] .prose p, [lang="ar"] .prose li { line-height: 1.95; }
[lang="ar"] .prose { font-size: 1.12rem; }
[lang="ar"] .stat-num, [lang="ar"] .cta-box .cta-title { font-family: 'Tajawal', sans-serif; }
[dir="rtl"] .prose ul, [dir="rtl"] .prose ol, [dir="rtl"] .callout ul, [dir="rtl"] .callout ol, [dir="rtl"] .sources ul { padding-left: 0; padding-right: 1.4em; }
[dir="rtl"] .checklist, [dir="rtl"] .steps { padding-right: 0 !important; }
[dir="rtl"] .key-takeaways li, [dir="rtl"] .checklist li { padding-left: 0; padding-right: 30px; }
[dir="rtl"] .key-takeaways li::before, [dir="rtl"] .checklist li::before { left: auto; right: 0; }
[dir="rtl"] .steps li { padding: 4px 56px 4px 0; }
[dir="rtl"] .steps li::before { left: auto; right: 0; }
[dir="rtl"] .callout { border-left: none; border-right: 4px solid var(--primary); }
[dir="rtl"] .callout-tip { border-right-color: var(--green); }
[dir="rtl"] .callout-warning { border-right-color: #ff9f0a; }
[dir="rtl"] .callout-local { border-right-color: var(--accent); }
[dir="rtl"] .callout-example { border-left: 1px solid rgba(0, 113, 227, .2); border-right: 4px solid var(--primary); }
[dir="rtl"] .table-wrap th, [dir="rtl"] .table-wrap td, [dir="rtl"] .table-wrap caption { text-align: right; }
[dir="rtl"] .breadcrumb li + li::before { content: '‹'; margin-right: 0; margin-left: 6px; }
[dir="rtl"] .toc a::before { content: counter(toc, arabic-indic); }
[dir="rtl"] .nav-links a.nav-cta { margin-left: 0; margin-right: 6px; }
[dir="rtl"] .site-footer h2 { text-align: right; }

[dir="rtl"] .tool-panel { border-left: 0; border-right: 1px solid rgba(0, 0, 0, .06); }
