:root {
  --bg: #08100d;
  --surface: #0d1a14;
  --surface2: #152118;
  --surface3: #1b2a1f;
  --border: #243d2c;
  --border-light: #2f5238;
  --emerald: #10b981;
  --emerald-light: #34d399;
  --emerald-dim: #065f46;
  --emerald-glow: rgba(16,185,129,0.15);
  --gold: #c9a84c;
  --gold-light: #e6c96e;
  --gold-dim: #7a6030;
  --teal: #2dd4bf;
  --teal-dim: #134e47;
  --red: #f87171;
  --green: #34d399;
  --text: #e4ede8;
  --text-muted: #7a9e88;
  --text-dim: #4a6e58;
  --accent: #059669;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-gold: 0 0 30px rgba(201,168,76,0.10);
  --shadow-emerald: 0 0 30px rgba(16,185,129,0.10);
  --font-body: 'DM Sans', sans-serif;
  --font-display: 'Amiri', serif;
  --font-bn: 'Noto Serif Bengali', serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(16,185,129,0.07) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 50% -5%, rgba(201,168,76,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 80%, rgba(16,185,129,0.05) 0%, transparent 50%),
    radial-gradient(ellipse 30% 25% at 10% 90%, rgba(201,168,76,0.04) 0%, transparent 50%);
}

body.lang-bn { font-family: var(--font-bn); }

/* ─── GEOMETRIC PATTERN OVERLAY ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke-width='0.3' opacity='0.18'%3E%3Cpolygon points='30,5 55,20 55,40 30,55 5,40 5,20' stroke='%2310b981'/%3E%3Cpolygon points='30,15 45,22 45,38 30,45 15,38 15,22' stroke='%23c9a84c'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

.wrap { position: relative; z-index: 1; max-width: 900px; margin: 0 auto; padding: 0 16px; }

/* ─── HEADER ─── */
header {
  background: linear-gradient(180deg, rgba(17,24,39,0.98) 0%, rgba(17,24,39,0.85) 100%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.logo-block { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--emerald-dim), var(--emerald), var(--gold));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(16,185,129,0.25);
}
.logo-text h1 { font-family: var(--font-display); font-size: 18px; color: var(--gold-light); font-weight: 700; line-height: 1.2; }
.logo-text p { font-size: 11px; color: var(--text-muted); letter-spacing: 0.05em; }

.header-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pill-toggle {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 3px;
  gap: 2px;
}
.pill-toggle button {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}
.pill-toggle button.active {
  background: linear-gradient(135deg, var(--emerald-dim), var(--emerald));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(16,185,129,0.35);
}

.currency-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237a9e88'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
}

/* ─── HEADER ICON BUTTONS (Share) ─── */
.btn-icon-header {
  width: 36px;
  height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
  font-family: inherit;
}
.btn-icon-header:hover {
  border-color: var(--emerald-dim);
  color: var(--emerald-light);
  background: var(--emerald-glow);
}

/* ─── HERO SECTION ─── */
.hero {
  text-align: center;
  padding: 48px 16px 32px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.28);
  color: var(--emerald-light);
  padding: 5px 14px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 18px;
  letter-spacing: 0.03em;
  box-shadow: 0 0 20px rgba(16,185,129,0.08);
}
.hero h2 {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 44px);
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--emerald-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.25;
  margin-bottom: 12px;
}
.hero p {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 540px;
  margin: 0 auto 24px;
}
.security-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16,185,129,0.07);
  border: 1px solid rgba(16,185,129,0.22);
  color: var(--emerald-light);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
}

/* ─── NISAB SETTINGS CARD ─── */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-gold), var(--shadow-emerald);
}
.settings-card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px) { .settings-row { grid-template-columns: 1fr; } }
.setting-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

/* NISAB LIVE DISPLAY */
.nisab-display {
  margin-top: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  text-align: center;
}
@media (max-width: 420px) { .nisab-display { grid-template-columns: 1fr; text-align: left; } }
.nisab-stat-val { font-size: 15px; font-weight: 600; color: var(--gold-light); }
.nisab-stat-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ─── SECTION CARDS ─── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.section-card:focus-within {
  border-color: var(--emerald-dim);
  box-shadow: 0 0 0 2px rgba(16,185,129,0.08);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  background: var(--surface2);
  gap: 12px;
}
.section-header:hover { background: var(--surface3); }

.section-header-left { display: flex; align-items: center; gap: 12px; }
.section-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.icon-cash   { background: rgba(16,185,129,0.14); }
.icon-metals { background: rgba(201,168,76,0.15); }
.icon-invest { background: rgba(16,185,129,0.12); }
.icon-biz    { background: rgba(52,211,153,0.12); }
.icon-liab   { background: rgba(248,113,113,0.15); }

.section-title    { font-weight: 600; font-size: 15px; }
.section-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.section-total {
  font-weight: 600;
  font-size: 14px;
  color: var(--emerald-light);
  text-align: right;
  flex-shrink: 0;
}
.section-total.negative { color: var(--red); }

.chevron {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.25s;
  flex-shrink: 0;
  background: var(--surface);
}
.section-card.open .chevron {
  transform: rotate(180deg);
  border-color: var(--emerald-dim);
  color: var(--emerald);
}

.section-body {
  display: none;
  padding: 20px;
  border-top: 1px solid var(--border);
  animation: fadeSlide 0.2s ease;
}
.section-card.open .section-body { display: block; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── FIELD GROUPS ─── */
.field-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
@media (max-width: 540px) { .field-group { grid-template-columns: 1fr; } }
.field-group.triple { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) { .field-group.triple { grid-template-columns: 1fr 1fr; } }
@media (max-width: 400px) { .field-group.triple { grid-template-columns: 1fr; } }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ─── TOOLTIP ─── */
.field label .tooltip-icon {
  cursor: help;
  color: var(--text-dim);
  font-size: 11px;
  width: 16px; height: 16px;
  background: var(--surface3);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}
.field label .tooltip-icon:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a2236;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.5;
  white-space: normal;
  width: 220px;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  font-weight: 400;
  pointer-events: none;
  font-family: var(--font-body);
}
/* Flip tooltip to bottom when near top of viewport */
.field label .tooltip-icon.tip-down:hover::after {
  bottom: auto;
  top: calc(100% + 8px);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-prefix {
  position: absolute;
  left: 12px;
  color: var(--text-dim);
  font-size: 13px;
  pointer-events: none;
  font-weight: 500;
}
input[type="number"], input[type="text"], select.field-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px 9px 36px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type="number"]:focus, input[type="text"]:focus, select.field-select:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}
input.no-prefix { padding-left: 12px; }
select.field-select { padding-left: 12px; appearance: none; cursor: pointer; }

.field-note {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.4;
}

.sub-heading {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--emerald);
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sub-heading::before {
  content: '';
  display: block;
  width: 3px;
  height: 14px;
  background: linear-gradient(180deg, var(--emerald), var(--emerald-dim));
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(16,185,129,0.4);
}

.info-box {
  background: rgba(16,185,129,0.05);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--emerald-light);
  margin: 10px 0;
  line-height: 1.6;
}
.info-box.warning {
  background: rgba(248,113,113,0.06);
  border-color: rgba(248,113,113,0.2);
  color: #fca5a5;
}
.info-box.gold {
  background: rgba(201,168,76,0.07);
  border-color: rgba(201,168,76,0.22);
  color: var(--gold-light);
}

/* INVESTMENT METHOD RADIO */
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.radio-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  user-select: none;
}
.radio-btn input { display: none; }
.radio-btn.selected {
  border-color: var(--emerald-dim);
  background: rgba(16,185,129,0.08);
  color: var(--emerald-light);
}
.radio-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.radio-btn.selected .radio-dot { border-color: var(--emerald); background: var(--emerald); }
.radio-btn.selected .radio-dot::after {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #05130e;
}

/* ─── RESULTS PANEL ─── */
.results-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-gold), var(--shadow-emerald);
}
.results-header {
  background: linear-gradient(135deg, #0a1f14 0%, #101f18 50%, #0f1e10 100%);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.results-title {
  font-family: var(--font-display);
  font-size: 20px;
  background: linear-gradient(135deg, var(--gold-light), var(--emerald-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.results-eligible {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
}
.results-eligible.yes {
  background: rgba(16,185,129,0.15);
  color: var(--emerald-light);
  border: 1px solid rgba(16,185,129,0.35);
  box-shadow: 0 0 12px rgba(16,185,129,0.15);
}
.results-eligible.no  { background: rgba(248,113,113,0.15); color: var(--red);   border: 1px solid rgba(248,113,113,0.3); }

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}
@media (max-width: 540px) { .results-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 360px) { .results-grid { grid-template-columns: 1fr; } }

.result-stat {
  padding: 20px 24px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.result-stat:nth-child(3n) { border-right: none; }
@media (max-width: 540px) {
  .result-stat:nth-child(2n)  { border-right: none; }
  .result-stat:nth-child(3n)  { border-right: 1px solid var(--border); }
  .result-stat:nth-child(2n):last-child { border-right: none; }
}

.result-stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.result-stat-value { font-size: 20px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.result-stat-value.gold  { color: var(--gold-light); }
.result-stat-value.green { color: var(--emerald-light); }
.result-stat-value.red   { color: var(--red); }
.result-stat-value.big   { font-size: 26px; }
.result-stat-sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* BREAKDOWN TABLE */
.breakdown { padding: 20px 24px; border-top: 1px solid var(--border); }
.breakdown-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(36,61,44,0.6);
  font-size: 13px;
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-row-label { color: var(--text-muted); }
.breakdown-row-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.breakdown-row-val.pos   { color: var(--gold-light); }
.breakdown-row-val.neg   { color: var(--red); }
.breakdown-row-val.total { color: var(--emerald-light); font-size: 15px; }
.breakdown-row-val.zakah {
  color: var(--emerald-light);
  font-size: 17px;
  text-shadow: 0 0 10px rgba(16,185,129,0.3);
}
.breakdown-row.divider   { border-top: 2px solid var(--border); margin-top: 4px; padding-top: 12px; }
.breakdown-row.divider .breakdown-row-label { color: var(--text); font-weight: 600; }

/* NISAB BAR */
.nisab-bar-wrap { padding: 16px 24px; border-top: 1px solid var(--border); }
.nisab-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.nisab-bar-track { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.nisab-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-light) 40%, var(--emerald) 70%, var(--emerald-light));
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
  max-width: 100%;
  box-shadow: 0 0 8px rgba(16,185,129,0.25);
}

/* ─── ACTION BAR (PDF + Reset) ─── */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.btn-reset {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-reset:hover { border-color: var(--red); color: var(--red); }

/* PDF export button */
.btn-pdf {
  background: linear-gradient(135deg, var(--emerald-dim), var(--emerald) 40%, var(--gold) 100%);
  border: none;
  color: #03100a;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 12px rgba(16,185,129,0.25), 0 2px 12px rgba(201,168,76,0.15);
}
.btn-pdf:hover   { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 18px rgba(16,185,129,0.35), 0 4px 18px rgba(201,168,76,0.2); }
.btn-pdf:active  { transform: translateY(0); }
.btn-pdf:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-spin {
  display: none;
  width: 13px; height: 13px;
  border: 2px solid rgba(26,16,0,0.3);
  border-top-color: #03100a;
  border-radius: 50%;
  animation: spinBtn 0.7s linear infinite;
}
@keyframes spinBtn { to { transform: rotate(360deg); } }

/* ─── FOOTER ─── */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  z-index: 1;
}
.footer-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 16px;
  text-align: center;
}
.footer-logo    { font-family: var(--font-display); font-size: 16px; color: var(--emerald); margin-bottom: 6px; }
.footer-tagline { font-size: 12px; color: var(--text-dim); margin-bottom: 14px; }
.footer-copy    { font-size: 12px; color: var(--text-dim); }
.footer-copy span { color: var(--text-muted); }
.footer-links   { display: flex; justify-content: center; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.footer-links a { color: var(--text-dim); font-size: 12px; text-decoration: none; }
.footer-links a:hover { color: var(--emerald); }

/* ─── STEP PROGRESS ─── */
.progress-bar {
  background: var(--surface2);
  height: 3px;
  border-radius: 2px;
  margin-bottom: 24px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-light) 40%, var(--emerald));
  border-radius: 2px;
  transition: width 0.5s ease;
  box-shadow: 0 0 6px rgba(16,185,129,0.2);
}

/* MOBILE TWEAKS */
@media (max-width: 600px) {
  .hero          { padding: 32px 16px 24px; }
  .section-header { padding: 14px 16px; }
  .section-body   { padding: 16px; }
  .results-header { padding: 16px; }
  .result-stat    { padding: 16px; }
  .breakdown      { padding: 16px; }
  .nisab-bar-wrap { padding: 12px 16px; }
  .header-inner   { padding: 12px 16px; }
}

/* ANIMATE IN */
.fade-up {
  opacity: 0;
  transform: translateY(16px);
  animation: fadeUp 0.5s ease forwards;
}
@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}
.fade-up:nth-child(1) { animation-delay: 0.05s; }
.fade-up:nth-child(2) { animation-delay: 0.12s; }
.fade-up:nth-child(3) { animation-delay: 0.19s; }
.fade-up:nth-child(4) { animation-delay: 0.26s; }
.fade-up:nth-child(5) { animation-delay: 0.33s; }
.fade-up:nth-child(6) { animation-delay: 0.40s; }
.fade-up:nth-child(7) { animation-delay: 0.47s; }

/* QURAN BANNER */
.quran-banner {
  background: linear-gradient(135deg, rgba(6,95,70,0.12) 0%, rgba(16,185,129,0.06) 50%, rgba(201,168,76,0.06) 100%);
  border: 1px solid rgba(16,185,129,0.22);
  border-radius: var(--radius);
  padding: 20px 24px;
  text-align: center;
  margin-bottom: 24px;
  font-family: var(--font-display);
  box-shadow: 0 0 30px rgba(16,185,129,0.06);
}
.quran-arabic {
  font-size: 22px;
  background: linear-gradient(135deg, var(--gold-light), var(--emerald-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.9;
  direction: rtl;
}
.quran-trans  { font-size: 12px; color: var(--text-dim); margin-top: 6px; font-family: var(--font-body); }

.badge-small {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface3);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

/* PRINT */
@media print {
  header, .hero, .settings-card, .section-card, footer, .action-bar, .quran-banner, .progress-bar { display: none; }
  .results-panel { box-shadow: none; border: 1px solid #ccc; }
  body { background: white; color: black; }
}

/* SCROLLBAR */
::-webkit-scrollbar        { width: 6px; }
::-webkit-scrollbar-track  { background: var(--bg); }
::-webkit-scrollbar-thumb  { background: var(--emerald-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--emerald); }

/* ─── LIVE PRICE PANEL ─── */
.price-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.price-panel-header {
  background: var(--surface3);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.price-panel-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--emerald);
  display: flex;
  align-items: center;
  gap: 7px;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(16,185,129,0.5);
}
.live-dot.error   { background: var(--red); animation: none; box-shadow: none; }
.live-dot.loading { background: var(--gold); animation: pulse-dot 0.8s infinite; box-shadow: 0 0 6px rgba(201,168,76,0.5); }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}
.price-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.price-timestamp { font-size: 11px; color: var(--text-dim); }
.btn-refresh {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}
.btn-refresh:hover    { border-color: var(--emerald); color: var(--emerald); }
.btn-refresh:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-refresh .spin    { display: inline-block; transition: transform 0.3s; }
.btn-refresh.spinning .spin { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.price-grid {
  display: grid;
  gap: 0;
  background: var(--surface2);
}
.price-cell {
  padding: 14px 18px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.price-cell:last-child    { border-right: none; }
.price-cell:nth-last-child(-n+3):not(:nth-child(n+4)) { border-bottom: none; }
.price-cell-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.price-cell-usd  { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.price-cell-val  {
  font-size: 18px;
  font-weight: 600;
  color: var(--emerald-light);
  font-variant-numeric: tabular-nums;
  min-height: 24px;
}
.price-cell-val.loading-shimmer {
  background: linear-gradient(90deg, var(--surface3) 25%, var(--surface2) 50%, var(--surface3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  color: transparent;
  width: 80%;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.price-cell-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* API source badges */
.api-sources {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  align-items: center;
}
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface3);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  color: var(--text-dim);
}
.source-badge.active { border-color: rgba(16,185,129,0.3); color: var(--emerald); }
.source-badge.error  { border-color: rgba(248,113,113,0.3); color: var(--red); }

/* Manual fallback */
.manual-fallback {
  display: none;
  margin-top: 12px;
  background: rgba(248,113,113,0.05);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.manual-fallback.visible { display: block; }
.manual-fallback-header {
  font-size: 12px;
  font-weight: 600;
  color: #fca5a5;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* FX banner */
.fx-banner {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.fx-rates { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); }
.fx-rate-item { display: flex; align-items: center; gap: 4px; }
.fx-rate-item span { color: var(--emerald-light); font-weight: 600; }

/* Price disclaimer */
.price-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 12px 4px 0;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  opacity: 0.85;
}

/* ═══════════════════════════════════════════════════════════
   SHARE MODAL
   ═══════════════════════════════════════════════════════════ */
.share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 22, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.share-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.share-modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(201,168,76,0.12);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.share-overlay.open .share-modal {
  transform: translateY(0) scale(1);
}

.share-modal-header {
  background: linear-gradient(135deg, #1a2a1a, #162622);
  border-bottom: 1px solid var(--border);
  padding: 18px 20px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.share-modal-title-block { display: flex; align-items: center; gap: 12px; }
.share-modal-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--emerald-dim), var(--emerald));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(16,185,129,0.3);
}
.share-modal-title { font-family: var(--font-display); font-size: 17px; color: var(--emerald-light); line-height: 1.2; }
.share-modal-desc  { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.share-modal-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px; height: 30px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  font-family: inherit;
}
.share-modal-close:hover { border-color: var(--red); color: var(--red); }

.share-modal-body {
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.share-option {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
  text-align: center;
}
.share-option:hover { border-color: var(--border-light); background: var(--surface3); color: var(--text); }

.share-option .share-opt-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.share-opt--copy     .share-opt-icon { background: rgba(16,185,129,0.12); color: var(--emerald-light); }
.share-opt--facebook .share-opt-icon { background: rgba(59,89,152,0.18);    color: #7baaf7; }
.share-opt--whatsapp .share-opt-icon { background: rgba(37,211,102,0.15);   color: #4ade80; }
.share-opt--more     .share-opt-icon { background: rgba(201,168,76,0.15);   color: var(--gold-light); }

.share-opt--copy:hover     { border-color: rgba(16,185,129,0.4); }
.share-opt--facebook:hover { border-color: rgba(59,89,152,0.4);   }
.share-opt--whatsapp:hover { border-color: rgba(37,211,102,0.4);  }
.share-opt--more:hover     { border-color: rgba(201,168,76,0.4);  }

.share-opt--copy.copied {
  border-color: rgba(16,185,129,0.5);
  background: rgba(16,185,129,0.08);
  color: var(--emerald-light);
}
.share-opt--copy.copied .share-opt-icon { background: rgba(16,185,129,0.18); color: var(--emerald-light); }

/* ═══════════════════════════════════════════════════════════
   PWA INSTALL BANNER
   ═══════════════════════════════════════════════════════════ */
.pwa-banner {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 200;
  background: linear-gradient(135deg, #071410 0%, #0d1a14 100%);
  border-top: 1px solid rgba(16,185,129,0.3);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.5), 0 -1px 0 rgba(16,185,129,0.2);
  animation: slideUp 0.35s cubic-bezier(0.22,1,0.36,1);
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.pwa-banner-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.pwa-banner-left   { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.pwa-banner-icon   {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--emerald-dim), var(--emerald));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(16,185,129,0.3);
}
.pwa-banner-text         { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pwa-banner-text strong  { font-size: 14px; color: var(--emerald-light); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pwa-banner-text span    { font-size: 12px; color: var(--text-muted); }
.pwa-banner-actions      { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.pwa-btn-install {
  background: linear-gradient(135deg, var(--emerald-dim), var(--emerald));
  border: none;
  color: #03100a;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.15s;
  letter-spacing: 0.02em;
  box-shadow: 0 0 12px rgba(16,185,129,0.3);
}
.pwa-btn-install:hover  { opacity: 0.88; transform: translateY(-1px); }
.pwa-btn-install:active { transform: translateY(0); }
.pwa-btn-dismiss {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
.pwa-btn-dismiss:hover { border-color: var(--red); color: var(--red); }
.pwa-ios-hint {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.pwa-ios-hint strong { color: var(--emerald-light); }
body:has(.pwa-banner:not([hidden])) footer { padding-bottom: 100px; }

@media (max-width: 480px) {
  .pwa-banner-inner    { padding: 12px; }
  .pwa-banner-text strong { font-size: 13px; }
  .pwa-btn-install     { padding: 8px 14px; }
}

/* ═══════════════════════════════════════════════════════════
   LIGHT THEME — Illuminated Manuscript / Islamic Parchment
   FIX: Scoped to html.light-theme instead of body.light-theme
   so CSS variables resolve before <body> is painted, preventing
   the flash-of-wrong-theme on first load.
   ═══════════════════════════════════════════════════════════ */
html.light-theme {
  --bg:           #f0f7f2;
  --surface:      #f8fcf9;
  --surface2:     #e4f0e8;
  --surface3:     #d6e8dc;
  --border:       #a8ccb4;
  --border-light: #8ab89a;
  --gold:         #9a6f1a;
  --gold-light:   #7a5010;
  --gold-dim:     #c49a3a;
  --emerald:      #059669;
  --emerald-light:#047857;
  --emerald-dim:  #a7d7c4;
  --emerald-glow: rgba(5,150,105,0.12);
  --teal:         #0d9488;
  --teal-dim:     #ccebe8;
  --red:          #b83228;
  --green:        #065f46;
  --text:         #0a1f12;
  --text-muted:   #2d5c3a;
  --text-dim:     #527a5f;
  --accent:       #047857;
  --shadow:        0 4px 24px rgba(10,50,20,0.12);
  --shadow-gold:   0 0 30px rgba(154,111,26,0.08);
  --shadow-emerald:0 0 30px rgba(5,150,105,0.08);
}

html.light-theme body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(5,150,105,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 80%, rgba(154,111,26,0.06) 0%, transparent 50%);
}

/* Light theme — softer geometric pattern */
html.light-theme body::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke-width='0.4' opacity='0.22'%3E%3Cpolygon points='30,5 55,20 55,40 30,55 5,40 5,20' stroke='%23059669'/%3E%3Cpolygon points='30,15 45,22 45,38 30,45 15,38 15,22' stroke='%239a6f1a'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.3;
}

html.light-theme header {
  background: linear-gradient(180deg, rgba(250,245,233,0.98) 0%, rgba(250,245,233,0.88) 100%);
  border-bottom-color: var(--border);
}

html.light-theme .section-header         { background: var(--surface2); }
html.light-theme .section-header:hover   { background: var(--surface3); }
html.light-theme .results-header         { background: linear-gradient(135deg, #d4ead9, #cce4d2); }
html.light-theme .share-modal            { background: var(--surface); }
html.light-theme .share-modal-header     { background: linear-gradient(135deg, #d4ead9, #cce4d2); }
html.light-theme footer                  { background: var(--surface2); border-top-color: var(--border); }

html.light-theme .info-box               { background: rgba(5,150,105,0.06);  border-color: rgba(5,150,105,0.22); color: var(--emerald); }
html.light-theme .info-box.warning       { background: rgba(184,50,40,0.06);  border-color: rgba(184,50,40,0.2);   color: var(--red); }
html.light-theme .info-box.gold          { background: rgba(154,111,26,0.07); border-color: rgba(154,111,26,0.22); color: var(--gold); }
html.light-theme .quran-banner           {
  background: linear-gradient(135deg, rgba(5,150,105,0.08), rgba(154,111,26,0.06));
  border-color: rgba(5,150,105,0.25);
}
html.light-theme .price-panel-header     { background: var(--surface3); }
html.light-theme .price-grid             { background: var(--surface2); }
html.light-theme .pwa-banner             { background: linear-gradient(135deg, #d4ead9 0%, #f0f7f2 100%); border-top-color: rgba(5,150,105,0.3); }
html.light-theme .share-overlay          { background: rgba(5,20,10,0.5); }
html.light-theme .tooltip-icon:hover::after { background: #dff0e6; color: var(--text); border-color: var(--emerald-dim); }

html.light-theme input[type="number"],
html.light-theme input[type="text"],
html.light-theme select.field-select     { background: var(--surface); color: var(--text); }

html.light-theme .nisab-bar-track        { background: var(--surface3); }
html.light-theme .price-cell-val.loading-shimmer {
  background: linear-gradient(90deg, var(--surface3) 25%, var(--surface2) 50%, var(--surface3) 75%);
  background-size: 200% 100%;
}
html.light-theme ::-webkit-scrollbar-track { background: var(--bg); }
html.light-theme ::-webkit-scrollbar-thumb { background: var(--border); }

/* ═══════════════════════════════════════════════════════════
   THEME TOGGLE BUTTON — Artisan Islamic Icon
   ═══════════════════════════════════════════════════════════ */
.btn-theme-toggle {
  position: relative;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
  flex-shrink: 0;
  padding: 0;
}

/* Glow halo on hover */
.btn-theme-toggle:hover {
  border-color: var(--emerald-dim);
  background: var(--emerald-glow);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.10), 0 0 18px rgba(16,185,129,0.16);
}
html.light-theme .btn-theme-toggle:hover {
  box-shadow: 0 0 0 3px rgba(5,150,105,0.12), 0 0 18px rgba(5,150,105,0.14);
}

/* SVG icon container */
.theme-icon-wrap {
  width: 26px;
  height: 26px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The two icon states */
.theme-icon-wrap .icon-dark,
.theme-icon-wrap .icon-light {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.34,1.56,0.64,1);
}

/* Dark mode shows crescent; light mode hidden */
.theme-icon-wrap .icon-dark  {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
.theme-icon-wrap .icon-light {
  opacity: 0;
  transform: rotate(-60deg) scale(0.6);
}

/* Light theme: show shamsa, hide crescent */
html.light-theme .theme-icon-wrap .icon-dark  {
  opacity: 0;
  transform: rotate(60deg) scale(0.6);
}
html.light-theme .theme-icon-wrap .icon-light {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Click spin */
.btn-theme-toggle.spinning .theme-icon-wrap {
  animation: themeIconSpin 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes themeIconSpin {
  0%   { transform: rotate(0deg)   scale(1); }
  45%  { transform: rotate(150deg) scale(0.7); }
  100% { transform: rotate(360deg) scale(1); }
}

/* Ripple burst */
.btn-theme-toggle::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle, rgba(16,185,129,0.4) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0.3);
}
.btn-theme-toggle.ripple::after {
  animation: themeRipple 0.5s ease-out forwards;
}
@keyframes themeRipple {
  0%   { opacity: 0.8; transform: scale(0.3); }
  100% { opacity: 0;   transform: scale(2.5); }
}

/* Tooltip label */
.btn-theme-toggle::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  font-family: var(--font-body);
}
.btn-theme-toggle:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Smooth theme transitions across all elements */
body, header, footer,
.section-card, .section-header, .section-body,
.settings-card, .results-panel, .results-header,
.price-panel, .price-panel-header, .price-grid, .price-cell,
.share-modal, .share-modal-header,
.quran-banner, .info-box,
.pill-toggle, .currency-select,
input[type="number"], input[type="text"], select.field-select,
.badge-small, .source-badge, .fx-banner,
.chevron, .radio-btn {
  transition:
    background-color 0.32s ease,
    border-color 0.32s ease,
    color 0.32s ease,
    box-shadow 0.32s ease;
}
