:root {
  --ink: #152a27;
  --muted: #667773;
  --brand: #0c5149;
  --brand-2: #16766a;
  --mint: #dff3ee;
  --mint-soft: #f2faf7;
  --cream: #f7f4ec;
  --amber: #dfa644;
  --danger: #b94c48;
  --surface: #ffffff;
  --line: #dfe8e5;
  --shadow: 0 22px 60px rgba(15, 60, 53, .10);
  --radius-lg: 28px;
  --radius-md: 18px;
  --font-body: "Alexandria", "Segoe UI", Tahoma, sans-serif;
  --font-display: "Noto Kufi Arabic", "Alexandria", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: #fbfcfa; font-family: var(--font-body); font-size: 15px; line-height: 1.75; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.container { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.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: fixed; z-index: 999; top: 10px; right: 10px; transform: translateY(-160%); padding: 10px 16px; background: #fff; border-radius: 10px; box-shadow: var(--shadow); }
.skip-link:focus { transform: none; }

.topbar { position: sticky; z-index: 30; top: 0; border-bottom: 1px solid rgba(223,232,229,.8); background: rgba(251,252,250,.9); backdrop-filter: blur(14px); }
.nav-wrap { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; color: #fff; background: var(--brand); border-radius: 14px 14px 5px 14px; font-family: var(--font-display); font-size: 20px; box-shadow: 0 9px 20px rgba(12,81,73,.18); }
.brand > span:last-child { display: grid; line-height: 1.3; }
.brand strong { font-family: var(--font-display); font-size: 18px; }
.brand small { color: var(--muted); font-size: 10px; }
.nav-actions, .hero-actions, .export-actions { display: flex; align-items: center; gap: 10px; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border: 1px solid transparent; border-radius: 13px; font-weight: 700; transition: transform .2s, box-shadow .2s, background .2s; }
.button:hover { transform: translateY(-2px); }
.button:focus-visible, input:focus-visible, select:focus-visible, .text-button:focus-visible { outline: 3px solid rgba(22,118,106,.22); outline-offset: 2px; }
.button-primary { color: #fff; background: var(--brand-2); box-shadow: 0 12px 26px rgba(22,118,106,.22); }
.button-dark { color: #fff; background: var(--ink); }
.button-ghost { color: var(--brand); background: transparent; border-color: var(--line); }
.button-outline { color: var(--ink); background: #fff; border-color: var(--line); }
.button-large { min-height: 52px; padding-inline: 24px; }

.hero { position: relative; overflow: hidden; padding: 82px 0 92px; background: radial-gradient(circle at 17% 24%, rgba(223,243,238,.9), transparent 28%), linear-gradient(135deg, #fbfcfa 30%, #f4f0e5 100%); }
.hero::after { content: ""; position: absolute; left: -120px; bottom: -200px; width: 420px; height: 420px; border: 1px solid rgba(12,81,73,.10); border-radius: 50%; box-shadow: 0 0 0 55px rgba(12,81,73,.025), 0 0 0 110px rgba(12,81,73,.02); }
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: 1.08fr .92fr; gap: 76px; align-items: center; }
.eyebrow, .section-kicker { display: inline-block; color: var(--brand-2); font-size: 12px; font-weight: 800; letter-spacing: .02em; }
.hero h1 { max-width: 680px; margin: 14px 0 20px; font-family: var(--font-display); font-size: clamp(38px, 5vw, 66px); line-height: 1.35; letter-spacing: -.04em; }
.hero h1 em { display: block; color: var(--brand-2); font-style: normal; }
.hero-copy > p { max-width: 650px; margin: 0 0 28px; color: var(--muted); font-size: 17px; }
.privacy-note { color: var(--muted); font-size: 12px; }
.privacy-note span { color: var(--brand-2); }
.hero-features { display: flex; flex-wrap: wrap; gap: 24px; margin: 30px 0 0; padding: 0; list-style: none; color: var(--ink); font-size: 12px; font-weight: 700; }
.hero-features li::before { content: "✓"; margin-left: 7px; color: var(--brand-2); }
.hero-card { padding: 28px; border: 1px solid rgba(255,255,255,.8); border-radius: var(--radius-lg); background: rgba(255,255,255,.82); box-shadow: var(--shadow); backdrop-filter: blur(12px); transform: rotate(-1deg); }
.mini-card-heading { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.live-pill { padding: 4px 10px; color: var(--brand-2); background: var(--mint); border-radius: 999px; font-size: 10px; }
.live-pill::before { content: "●"; margin-left: 5px; }
.sample-chart { height: 205px; display: flex; align-items: end; justify-content: space-between; gap: 14px; padding: 30px 10px 10px; border-bottom: 1px dashed var(--line); }
.chart-bar { width: 100%; height: var(--height); display: flex; align-items: end; justify-content: center; color: var(--muted); background: #dceae6; border-radius: 9px 9px 2px 2px; }
.chart-bar.active { background: var(--brand-2); box-shadow: 0 10px 20px rgba(22,118,106,.2); }
.chart-bar span { transform: translateY(30px); font-size: 9px; }
.sample-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 34px; }
.sample-metrics div { display: grid; gap: 2px; padding: 12px; background: var(--mint-soft); border-radius: 12px; }
.sample-metrics span { color: var(--muted); font-size: 9px; }
.sample-metrics strong { font-size: 11px; }
.hero-card-caption { margin: 15px 0 0; color: var(--muted); font-size: 9px; text-align: center; }

.calculator-section { padding: 86px 0 100px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 26px; }
.section-heading h2, .methodology h2 { margin: 5px 0 0; font-family: var(--font-display); font-size: clamp(27px, 4vw, 40px); }
.autosave { color: var(--muted); font-size: 11px; }
.autosave span { width: 22px; height: 22px; display: inline-grid; place-items: center; margin-left: 5px; color: var(--brand-2); background: var(--mint); border-radius: 50%; }
.calculator-layout { display: grid; grid-template-columns: minmax(0, 1.48fr) minmax(330px, .82fr); gap: 28px; align-items: start; }
.input-panel { display: grid; gap: 18px; }
.form-card { padding: 30px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: 0 9px 28px rgba(15,60,53,.035); }
.card-title-row { display: flex; gap: 14px; align-items: start; padding-bottom: 22px; border-bottom: 1px solid #edf1ef; }
.step-number { min-width: 42px; height: 34px; display: grid; place-items: center; color: var(--brand-2); background: var(--mint); border-radius: 10px; font-size: 11px; font-weight: 800; }
.card-title-row h3 { margin: 0; font-family: var(--font-display); font-size: 18px; }
.card-title-row p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.field-grid { display: grid; gap: 18px; margin-top: 22px; }
.field-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-field { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; align-content: start; }
.field > span:first-child { font-size: 12px; font-weight: 700; }
.field small { min-height: 34px; color: var(--muted); font-size: 9px; line-height: 1.7; }
input, select { width: 100%; height: 48px; padding: 0 14px; color: var(--ink); border: 1px solid var(--line); border-radius: 11px; background: #fbfcfb; transition: border .2s, box-shadow .2s, background .2s; }
input:hover, select:hover { border-color: #b9ccc7; }
input:focus, select:focus { border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 4px rgba(22,118,106,.08); outline: none; }
input::placeholder { color: #a0aca9; }
input[type="number"] { direction: ltr; text-align: right; }
.input-wrap { position: relative; display: block; }
.input-wrap input { padding-left: 52px; }
.input-wrap b { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--brand-2); font-size: 10px; pointer-events: none; }
.percentage input { padding-left: 38px; }
.method-switch { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 22px 0 0; padding: 6px; border: 0; border-radius: 13px; background: #f2f5f4; }
.method-switch label { cursor: pointer; }
.method-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.method-switch span { display: block; padding: 10px; border-radius: 9px; color: var(--muted); text-align: center; font-size: 11px; font-weight: 700; }
.method-switch input:checked + span { color: var(--brand); background: #fff; box-shadow: 0 4px 14px rgba(15,60,53,.08); }
.method-switch input:focus-visible + span { outline: 3px solid rgba(22,118,106,.22); }
.method-fields { margin-top: 18px; }
.method-fields.field-grid { margin-top: 18px; }
.revenue-bottom { padding-top: 20px; border-top: 1px solid #edf1ef; }
.text-button { padding: 7px 0; color: var(--brand-2); border: 0; background: transparent; font-size: 11px; font-weight: 800; }
.custom-costs { display: grid; gap: 10px; margin-top: 15px; }
.custom-row { display: grid; grid-template-columns: 1fr 180px 38px; gap: 8px; align-items: center; }
.custom-row input { height: 42px; }
.remove-row { width: 38px; height: 38px; display: grid; place-items: center; color: var(--danger); border: 1px solid #f1d8d5; border-radius: 10px; background: #fff8f7; }
.form-footer-actions { display: flex; align-items: center; gap: 18px; padding: 8px 2px 0; }
.form-footer-actions p { margin: 0; color: var(--muted); font-size: 10px; }

.results-sticky { position: sticky; top: 98px; padding: 28px; color: #fff; border-radius: 24px; background: linear-gradient(160deg, #153d38 0%, #102f2b 100%); box-shadow: 0 24px 60px rgba(15,60,53,.22); }
.result-heading { display: flex; justify-content: space-between; align-items: start; gap: 14px; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,.12); }
.result-heading span:first-child { color: #a9c3bd; font-size: 10px; }
.result-heading h2 { margin: 2px 0 0; color: #fff; font-family: var(--font-display); font-size: 17px; }
.status-badge { padding: 6px 10px; border-radius: 999px; font-size: 9px; font-weight: 800; white-space: nowrap; }
.status-badge.neutral { color: #d8e6e2; background: rgba(255,255,255,.1); }
.status-badge.good { color: #113e36; background: #87dfca; }
.status-badge.warning { color: #4e3811; background: #f7d991; }
.status-badge.bad { color: #4b1917; background: #f2aaa5; }
.primary-result { display: grid; gap: 2px; padding: 22px 0 18px; }
.primary-result span { color: #b9ccc8; font-size: 10px; }
.primary-result strong { font-size: clamp(28px, 4vw, 38px); line-height: 1.3; direction: ltr; text-align: right; }
.primary-result small { color: #89aca5; font-size: 9px; }
.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.metric-card { min-height: 93px; display: grid; align-content: center; gap: 3px; padding: 12px; border: 1px solid rgba(255,255,255,.08); border-radius: 13px; background: rgba(255,255,255,.055); }
.metric-card.accent { border-color: rgba(135,223,202,.35); background: rgba(135,223,202,.10); }
.metric-card span, .metric-card small { color: #9bb7b1; font-size: 8px; }
.metric-card strong { font-size: 15px; direction: ltr; text-align: right; }
.health-card { margin-top: 14px; padding: 16px; border-radius: 14px; background: rgba(255,255,255,.07); }
.health-title { display: flex; justify-content: space-between; color: #c6d8d4; font-size: 9px; }
.health-title strong { color: #87dfca; }
.progress-track { height: 6px; margin: 9px 0 11px; overflow: hidden; background: rgba(255,255,255,.12); border-radius: 99px; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--amber), #87dfca); border-radius: inherit; transition: width .35s; }
.health-card p { margin: 0; color: #b7ccc7; font-size: 9px; line-height: 1.8; }
.annual-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.annual-summary div { display: grid; gap: 4px; padding: 11px; border-top: 1px solid rgba(255,255,255,.12); }
.annual-summary span { color: #9bb7b1; font-size: 8px; }
.annual-summary strong { font-size: 12px; direction: ltr; text-align: right; }
.export-actions { margin-top: 18px; }
.export-actions .button { flex: 1; min-width: 0; font-size: 10px; }
.export-actions .button-dark { color: var(--ink); background: #fff; }
.export-actions .button-outline { color: #fff; background: transparent; border-color: rgba(255,255,255,.22); }
.result-disclaimer { margin: 15px 0 0; color: #87a49e; font-size: 8px; line-height: 1.8; text-align: center; }

.methodology { padding: 76px 0; color: #fff; background: var(--brand); }
.methodology-grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: 100px; align-items: center; }
.methodology .section-kicker { color: #8bd3c2; }
.methodology h2 { color: #fff; }
.methodology p { color: #bed2cd; font-size: 12px; }
.formula-list { display: grid; gap: 10px; }
.formula-list > div { display: flex; align-items: center; gap: 14px; padding: 15px 18px; border: 1px solid rgba(255,255,255,.11); border-radius: 13px; background: rgba(255,255,255,.055); }
.formula-list span { min-width: 34px; color: #8bd3c2; font-weight: 800; }
.formula-list p { margin: 0; }
.formula-list strong { color: #fff; }
footer { padding: 28px 0; background: #0b2522; color: #aec1bd; }
.footer-wrap { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.footer-brand .brand-mark { background: #174640; box-shadow: none; }
.footer-brand strong { color: #fff; }
.footer-brand small { color: #8da9a3; }
footer p { margin: 0; font-size: 10px; }
footer > .container > a { color: #fff; font-size: 12px; font-weight: 700; }
.toast { position: fixed; z-index: 100; bottom: 22px; left: 50%; transform: translate(-50%, 130%); padding: 11px 18px; color: #fff; background: var(--ink); border-radius: 12px; box-shadow: var(--shadow); font-size: 11px; opacity: 0; transition: .25s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; gap: 46px; }
  .hero-card { max-width: 620px; width: 100%; margin-inline: auto; }
  .calculator-layout { grid-template-columns: 1fr; }
  .results-sticky { position: static; }
  .methodology-grid { grid-template-columns: 1fr; gap: 35px; }
}

@media (max-width: 640px) {
  .container { width: min(100% - 24px, 1180px); }
  .topbar .brand small, .nav-actions .button-ghost { display: none; }
  .nav-wrap { min-height: 68px; }
  .brand-mark { width: 40px; height: 40px; }
  .hero { padding: 58px 0 64px; }
  .hero h1 { font-size: 37px; }
  .hero-actions { align-items: stretch; flex-direction: column; }
  .privacy-note { text-align: center; }
  .hero-features { gap: 13px; justify-content: center; }
  .hero-card { padding: 20px; transform: none; }
  .sample-metrics { grid-template-columns: 1fr; }
  .sample-metrics div { grid-template-columns: 1fr 1fr; }
  .calculator-section { padding: 58px 0 70px; }
  .section-heading { align-items: start; flex-direction: column; gap: 8px; }
  .form-card { padding: 22px 16px; }
  .field-grid-2 { grid-template-columns: 1fr; }
  .full-field { grid-column: auto; }
  .method-switch { grid-template-columns: 1fr; }
  .custom-row { grid-template-columns: 1fr 110px 38px; }
  .form-footer-actions { flex-direction: column; align-items: stretch; text-align: center; }
  .results-sticky { padding: 22px 16px; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 88px; }
  .footer-wrap { flex-direction: column; text-align: center; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  body { color: #162a27; background: #fff; font-size: 11px; }
  .topbar, .hero, .input-panel, .methodology, .export-actions, .toast, .autosave { display: none !important; }
  .calculator-section { padding: 0; }
  .section-heading { margin: 0 0 12px; }
  .section-heading::before { content: "تقرير تقدير الجدوى الاقتصادية"; display: block; font-family: var(--font-display); font-size: 23px; }
  .section-heading > div { display: none; }
  .calculator-layout { display: block; }
  .results-sticky { position: static; padding: 24px; color: #162a27; border: 1px solid #ccd9d6; background: #fff; box-shadow: none; }
  .result-heading { border-color: #dfe8e5; }
  .result-heading span:first-child, .primary-result span, .primary-result small, .metric-card span, .metric-card small, .health-card p, .annual-summary span { color: #5c706c; }
  .result-heading h2, .primary-result, .metric-card strong, .annual-summary strong { color: #162a27; }
  .status-badge { border: 1px solid #b8cbc6; color: #162a27 !important; background: #eef6f3 !important; }
  .result-grid { grid-template-columns: repeat(4, 1fr); }
  .metric-card, .health-card { border: 1px solid #dfe8e5; background: #f8fbfa; break-inside: avoid; }
  .progress-track { background: #e4ecea; }
  .annual-summary div { border-color: #dfe8e5; }
  .result-disclaimer { color: #667773; }
  footer { margin-top: 20px; padding: 14px 0; color: #435955; border-top: 1px solid #dfe8e5; background: #fff; }
  .footer-brand { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
