:root {
  --primary:       #16a34a;
  --primary-dark:  #15803d;
  --primary-light: #dcfce7;
  --accent:        #d97706;
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --muted:         #64748b;
  --radius:        8px;
  --shadow:        0 1px 4px rgba(0,0,0,.08);
}

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

[dir="rtl"] body {
  font-family: 'Segoe UI', Tahoma, 'Cairo', 'Noto Sans Arabic', sans-serif;
}

.container { max-width: 820px; margin: 0 auto; padding: 0 1rem; }

/* ── Header ─────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.logo {
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}

/* ── Language Switcher ──────────────────────────────────── */
.lang-switch { display: flex; gap: .25rem; flex-wrap: wrap; }

.lang-switch a {
  padding: .25rem .55rem;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--border);
  transition: all .15s;
}

.lang-switch a:hover,
.lang-switch a.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
  font-size: .82rem;
  color: var(--muted);
  padding: .65rem 0;
}

.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb span { margin: 0 .3rem; }

/* ── Hero ───────────────────────────────────────────────── */
.hero { padding: 1.75rem 0 .75rem; }

.hero h1 {
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  line-height: 1.25;
  margin-bottom: .5rem;
}

.hero p { color: var(--muted); font-size: .95rem; max-width: 600px; }

[dir="rtl"] .hero p { max-width: 100%; }

/* ── Calculator Card ────────────────────────────────────── */
.calc-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.09);
  margin: 1.25rem 0;
  overflow: hidden;
}

/* ── Tabs ───────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 1;
  min-width: 110px;
  padding: .8rem .5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
  white-space: nowrap;
}

.tab-btn:hover  { color: var(--primary); background: var(--primary-light); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Tab Panels ─────────────────────────────────────────── */
.tab-panel { padding: 1.5rem; }

/* ── Form ───────────────────────────────────────────────── */
.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-bottom: 1.25rem;
}

@media (min-width: 520px) { .form-grid { grid-template-columns: 1fr 1fr; } }

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

input[type="number"] {
  width: 100%;
  padding: .65rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  transition: border .15s;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

/* ── Result Box ─────────────────────────────────────────── */
.result-box {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: white;
}

.result-primary { text-align: center; margin-bottom: 1rem; }

.result-label {
  font-size: .8rem;
  opacity: .85;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.result-value {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.15;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem;
}

.result-item {
  background: rgba(255,255,255,.15);
  border-radius: 6px;
  padding: .55rem .75rem;
}

.result-item .label  { font-size: .72rem; opacity: .8; }
.result-item .value  { font-weight: 700; font-size: .92rem; }

.share-row { margin-top: 1rem; text-align: center; }

#share-btn {
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.4);
  color: white;
  padding: .45rem 1.25rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  transition: background .15s;
}

#share-btn:hover { background: rgba(255,255,255,.28); }

/* ── Explanation ────────────────────────────────────────── */
.explanation {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
}

.explanation h2 { font-size: 1.2rem; margin-bottom: .75rem; }
.explanation p  { color: var(--muted); font-size: .93rem; margin-bottom: .7rem; }
.explanation p:last-child { margin-bottom: 0; }

.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
  margin: 1rem 0;
}

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

.type-card {
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  border-left: 3px solid var(--primary);
}

[dir="rtl"] .type-card { border-left: none; border-right: 3px solid var(--primary); }

.type-card h3 { font-size: .9rem; color: var(--primary-dark); margin-bottom: .25rem; }
.type-card p  { font-size: .8rem; color: var(--muted); margin: 0; }

/* ── FAQ ────────────────────────────────────────────────── */
.faq-section {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
}

.faq-section h2 { font-size: 1.2rem; margin-bottom: 1rem; }

details {
  border-bottom: 1px solid var(--border);
  padding: .7rem 0;
}

details:last-of-type { border-bottom: none; }

summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .93rem;
  list-style: none;
  padding-right: 1.5rem;
  position: relative;
}

summary::-webkit-details-marker { display: none; }

summary::after {
  content: '+';
  position: absolute;
  right: 0;
  top: 0;
  color: var(--primary);
  font-size: 1.1rem;
  line-height: 1;
}

[dir="rtl"] summary { padding-right: 0; padding-left: 1.5rem; }
[dir="rtl"] summary::after { right: auto; left: 0; }

details[open] summary::after { content: '−'; }

details p {
  margin-top: .5rem;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.65;
}

/* ── Affiliate ──────────────────────────────────────────── */
.affiliate-section {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--accent);
}

.affiliate-section h2 { font-size: 1.1rem; color: var(--accent); margin-bottom: .4rem; }

.affiliate-section > p { font-size: .83rem; color: var(--muted); margin-bottom: .9rem; }

.affiliate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

@media (max-width: 420px) { .affiliate-grid { grid-template-columns: 1fr; } }
@media (max-width: 380px) { .result-grid { grid-template-columns: 1fr; } }

.affiliate-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
}

.affiliate-card h3 { font-size: .88rem; margin-bottom: .25rem; }
.affiliate-card p  { font-size: .75rem; color: var(--muted); margin-bottom: .6rem; }

.affiliate-btn {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: .4rem .9rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}

.affiliate-btn:hover { background: var(--primary-dark); }
.affiliate-btn::after { content: ' →'; }

[dir="rtl"] .affiliate-btn::after  { content: ''; }
[dir="rtl"] .affiliate-btn::before { content: '← '; }

/* ── Footer ─────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: .83rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

footer a { color: var(--primary); text-decoration: none; }

/* ── Utility ────────────────────────────────────────────── */
.hidden { display: none !important; }
