/*
 * Theme: warm cream canvas, midnight-navy ink, violet-blue brand, lime call-to-action, mint for money.
 * Inspired by friendly consumer-finance apps; colours and fonts are our own (Figtree + Readex Pro, both open source).
 */
:root {
  --bg: #fdf8ec; --card: #ffffff; --ink: #1b1f5a; --muted: #5a5e7a; --line: #ece5d3;
  --brand: #5a5cf6; --brand-ink: #fdf8ec; --brand-soft: #eff0ff; --brand-deep: #3c3fb8;
  --cta: #b5ec6c; --cta-ink: #1b1f5a; --cta-hover: #9fdc4f;
  --accent: #23b47e; --warn-bg: #fff3cf; --warn-ink: #6a4a00;
  --bar-target: #cfd2f5; --bar-pension: #3ee0a0; --bar-gap: #ffa55e;
  --shadow: 0 1px 0 rgba(27, 31, 90, .05), 0 8px 24px rgba(27, 31, 90, .07);
  --radius: 16px; --radius-sm: 10px;
  --ok-bg: #d9f7e9; --ok-ink: #0f6b47; --cut-bg: #fff1c7; --cut-ink: #7a5600; --late-bg: #ffe3cc; --late-ink: #8a4510; --lump-bg: #ffdbe1; --lump-ink: #9b1c33;
  color-scheme: light;
  --font: "Figtree", "Readex Pro", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}
:root[data-theme="dark"] {
    --bg: #11133a; --card: #1b1e50; --ink: #f6f1e4; --muted: #b1b4d6; --line: #2c3070;
    --brand: #6d70ff; --brand-ink: #fdf8ec; --brand-soft: #262a6e; --brand-deep: #4b4fe0;
    --cta: #b5ec6c; --cta-ink: #11133a; --cta-hover: #c8f38c;
    --accent: #4fe0a6; --warn-bg: #3b3214; --warn-ink: #f4dc93;
    --bar-target: #3a3f86; --bar-pension: #4fe0a6; --bar-gap: #ffb47a;
    --shadow: 0 1px 0 rgba(0, 0, 0, .25), 0 10px 28px rgba(0, 0, 0, .3);
    --ok-bg: #1d4d3c; --ok-ink: #8ff0c4; --cut-bg: #4a3d12; --cut-ink: #ffe08a; --late-bg: #4f2f15; --late-ink: #ffc08f; --lump-bg: #521f2c; --lump-ink: #ffa3b4;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11133a; --card: #1b1e50; --ink: #f6f1e4; --muted: #b1b4d6; --line: #2c3070;
    --brand: #6d70ff; --brand-ink: #fdf8ec; --brand-soft: #262a6e; --brand-deep: #4b4fe0;
    --cta: #b5ec6c; --cta-ink: #11133a; --cta-hover: #c8f38c;
    --accent: #4fe0a6; --warn-bg: #3b3214; --warn-ink: #f4dc93;
    --bar-target: #3a3f86; --bar-pension: #4fe0a6; --bar-gap: #ffb47a;
    --shadow: 0 1px 0 rgba(0, 0, 0, .25), 0 10px 28px rgba(0, 0, 0, .3);
    --ok-bg: #1d4d3c; --ok-ink: #8ff0c4; --cut-bg: #4a3d12; --cut-ink: #ffe08a; --late-bg: #4f2f15; --late-ink: #ffc08f; --lump-bg: #521f2c; --lump-ink: #ffa3b4;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html[lang="ar"] { --font: "Readex Pro", "Figtree", system-ui, Tahoma, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---- header + wave ---- */
.top { background: var(--brand); color: var(--brand-ink); padding: 26px 0 10px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.top h1 { margin: 0 0 6px; font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.top .sub { margin: 0; font-size: 1.05rem; opacity: .95; max-width: 640px; }
.top .proto { margin: 10px 0 0; font-size: .78rem; opacity: .8; }
.langbtn { flex: none; padding: 8px 16px; border: 2px solid currentColor; background: transparent; color: inherit;
  border-radius: 999px; font: inherit; font-weight: 700; cursor: pointer; }
.langbtn:hover { background: rgba(255, 255, 255, .12); }
.wave { display: block; width: 100%; height: 46px; margin-top: -1px; }
.wave path { fill: var(--brand); }

/* ---- tabs (segmented pill) ---- */
.tabs { display: flex; gap: 6px; margin: 4px 0 18px; padding: 6px; background: var(--card); border-radius: 999px;
  box-shadow: var(--shadow); flex-wrap: wrap; }
.tabs button { flex: 1 1 200px; padding: 11px 16px; border: 0; background: transparent; color: var(--muted);
  border-radius: 999px; font: inherit; font-weight: 700; cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); }

.grid { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start; }
[hidden] { display: none !important; }
.stack { display: grid; gap: 18px; }

/* ---- cards ---- */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 14px; font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; }
.card h2:not(:first-child) { margin-top: 26px; }
.card h3 { margin: 0 0 10px; font-size: 1rem; font-weight: 800; }

/* ---- form ---- */
form label { display: block; margin: 0 0 14px; font-weight: 600; font-size: .92rem; }
form small { display: block; font-weight: 400; color: var(--muted); margin-top: 5px; font-size: .8rem; }
input, select, input[type=text] { width: 100%; margin-top: 6px; padding: 11px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1.5px solid var(--line); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover { border-color: var(--bar-target); }
input[type=range] { padding: 0; border: 0; background: transparent; accent-color: var(--brand); }
input:focus-visible, select:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
button:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--brand-soft), 0 0 0 2px var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }
.hint { color: var(--muted); font-size: .85rem; margin: -4px 0 12px; }
output { color: var(--brand); font-weight: 800; }

fieldset.seg { border: 0; padding: 0; margin: 0 0 16px; display: flex; gap: 8px; flex-wrap: wrap; }
fieldset.seg legend { font-weight: 600; font-size: .92rem; margin-bottom: 8px; padding: 0; }
fieldset.seg label { flex: 1 1 140px; margin: 0; }
fieldset.seg input { position: absolute; opacity: 0; width: 0; }
fieldset.seg span { display: block; text-align: center; padding: 11px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; background: var(--bg); font-weight: 700; transition: background .15s, color .15s; }
fieldset.seg input:checked + span { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
fieldset.seg input:focus-visible + span { box-shadow: 0 0 0 4px var(--brand-soft); }

label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
label.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); }

/* ---- work history: company cards with salary rows ---- */
.job { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; border: 1.5px solid var(--line);
  border-radius: 14px; margin-bottom: 12px; background: var(--bg); }
.job label { margin: 0; font-size: .82rem; }
.job .full, .job .j-info { grid-column: 1 / -1; }
.job .j-info { color: var(--muted); font-size: .8rem; min-height: 1em; }
.job .j-info.bad { color: #d6455d; font-weight: 700; }
.job .dim { opacity: .5; }
.job .rm { grid-column: 1 / -1; justify-self: end; }
.job label.check { margin: 0; }
.job .addRow { justify-self: start; }
.periods { display: grid; gap: 8px; }
.period { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; background: var(--card); border-radius: var(--radius-sm); }
.period label { margin: 0; font-size: .8rem; }
.period input { background: var(--bg); }
.period .p-until { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; }
.period .rmRow { grid-column: 1 / -1; justify-self: end; padding: 4px 12px; font-size: .78rem; }

/* ---- buttons ---- */
button.primary { width: 100%; margin-top: 10px; padding: 14px; border: 0; border-radius: var(--radius-sm);
  background: var(--cta); color: var(--cta-ink); font: inherit; font-weight: 800; font-size: 1rem; cursor: pointer;
  transition: background .15s, transform .05s; }
button.primary:hover { background: var(--cta-hover); }
button.primary:active { transform: translateY(1px); }
button.ghost { padding: 8px 14px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; }
button.ghost:hover { border-color: var(--brand); color: var(--brand); }

/* ---- results ---- */
.results { display: grid; gap: 18px; }
.empty { color: var(--muted); text-align: center; padding: 34px 20px; }
.hero { text-align: center; background: var(--brand); color: var(--brand-ink); }
.hero .label { opacity: .85; font-size: .95rem; font-weight: 600; }
.hero .big { font-size: clamp(2.6rem, 7vw, 3.6rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; margin: 6px 0; }
.hero .real { opacity: .92; font-size: .92rem; }
.hero .kpis { margin-top: 18px; }
.hero .kpi { background: rgba(255, 255, 255, .13); color: var(--brand-ink); }
.hero .kpi span { color: inherit; opacity: .8; }
.hero .warn { text-align: start; }
.hero .hint { color: var(--brand-ink); opacity: .8; margin: 12px 0 0; text-align: start; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.kpi { background: var(--bg); border-radius: 12px; padding: 12px 14px; text-align: start; }
.kpi b { display: block; font-size: 1.2rem; font-weight: 800; }
.kpi span { color: var(--muted); font-size: .8rem; }
.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 14px; font-size: .88rem; margin: 10px 0 0; }
.notice { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; font-size: .9rem; }

.svc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (max-width: 560px) { .svc { grid-template-columns: 1fr; } }
.svc .kpi { background: var(--brand-soft); }
.svc .kpi b { font-size: 1.05rem; margin: 3px 0; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 9px 8px; text-align: end; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: start; }
th { color: var(--muted); font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
html[lang="ar"] th { text-transform: none; letter-spacing: 0; font-size: .8rem; }
tr.sel td { font-weight: 800; background: var(--brand-soft); }
td.note { color: var(--muted); font-size: .8rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 700px) { .two { grid-template-columns: 1fr; } }

/* ---- gap bar ---- */
.bars { margin-top: 14px; }
.bar { height: 14px; border-radius: 999px; margin: 6px 0 4px; display: flex; overflow: hidden; background: rgba(255, 255, 255, .2); }
.bar i { display: block; height: 100%; }
.bar .p { background: var(--bar-pension); } .bar .g { background: var(--bar-gap); } .bar .t { background: var(--bar-target); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.hero .legend { color: var(--brand-ink); opacity: .9; justify-content: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }
.legend i.dotted { background: none; border-top: 3px dotted var(--accent); border-radius: 0; height: 0; width: 18px; }

/* ---- salary chart ---- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .axl { stroke: var(--bar-target); stroke-width: 1; }
.chart .conn { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 3 3; opacity: .5; }
.chart .seg { stroke-width: 5; stroke-linecap: round; }
.chart .hit { stroke: transparent; stroke-width: 18; fill: none; cursor: pointer; }
.chart .dot { stroke: var(--card); stroke-width: 2.5; cursor: pointer; }
.chart .dot.hollow { fill: var(--card); stroke: var(--accent); stroke-width: 3; }
.chart .mark { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; }
.tip { position: absolute; z-index: 5; max-width: 260px; pointer-events: none; background: var(--ink); color: var(--bg);
  padding: 10px 12px; border-radius: 12px; font-size: .8rem; line-height: 1.5; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }

/* ---- footer ---- */
.foot { margin: 34px auto 44px; color: var(--muted); font-size: .85rem; }
.foot summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.foot ul { padding-inline-start: 18px; }
.foot a { color: var(--ink); font-weight: 600; }
[dir=rtl] input[type=number], [dir=rtl] input[type=month], [dir=rtl] input[type=date] { text-align: right; }
[dir=rtl] input[data-typed] { text-align: right; }
[dir=rtl] .tag { letter-spacing: 0; }

/* ---- status pills ---- */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: .74rem; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill.max { background: var(--brand-soft); color: var(--brand); }
.pill.cut { background: var(--cut-bg); color: var(--cut-ink); }
.pill.late { background: var(--late-bg); color: var(--late-ink); }
.pill.lump { background: var(--lump-bg); color: var(--lump-ink); }

/* ================= responsive: phones, foldables, iPad, desktop ================= */
.wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.tops { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tw table { min-width: 0; }                  /* tables fit a phone; .tw scrolls only if one still cannot */
td.num { white-space: nowrap; }
.narrow-only { display: none; }
@media (max-width: 560px) {
  table { font-size: .84rem; }
  th, td { padding: 8px 4px; }
  th { letter-spacing: 0; font-size: .68rem; }
  .agetbl .c-svc, .agetbl .c-cash, .vtbl .c-gain, .c-pot, .wide-only { display: none; }
  .narrow-only { display: block; margin-top: 2px; font-size: .76rem; font-weight: 600; color: var(--muted); white-space: normal; }
  .agetbl td.note .pill { white-space: normal; }
}
/* iPhone Safari gives date fields a fixed minimum width that spills out of the card */
@supports (-webkit-touch-callout: none) {
  input[type=date] { -webkit-appearance: none; appearance: none; min-width: 0; display: block; }
  input[type=date]::-webkit-date-and-time-value { text-align: start; }
}

/* phone result bar: keeps the answer in view while filling the form */
.mbar { position: fixed; inset-inline: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 16px;
  background: var(--ink); color: var(--bg); border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .28); }
.mbar small { display: block; font-size: .72rem; opacity: .8; }
.mbar b { font-size: 1.2rem; font-weight: 800; }
.mbar button { flex: none; background: var(--cta); color: var(--cta-ink); border: 0; border-radius: 10px; padding: 11px 14px;
  font: inherit; font-weight: 800; cursor: pointer; min-height: 44px; }
@media (max-width: 899px) { body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); } }

/* large phones landscape, iPad mini/Air portrait, Surface Duo single screen */
@media (min-width: 600px) and (max-width: 899px) { .wrap { max-width: 760px; } }

/* iPad landscape, laptops, desktops: form stays in view while results scroll */
@media (min-width: 900px) {
  .grid { grid-template-columns: minmax(330px, 420px) 1fr; }
  #form1, #form2 { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; }
  .mbar { display: none !important; }
}
@media (min-width: 1440px) { .wrap { max-width: 1280px; } .grid { grid-template-columns: 440px 1fr; } }

/* phones */
@media (max-width: 480px) {
  .card { padding: 16px; border-radius: 14px; }
  .tabs button { flex: 1 1 0; padding: 10px 8px; font-size: .86rem; }
  .top { padding-top: 18px; }
  .top .sub { font-size: .95rem; }
  .job, .period { grid-template-columns: 1fr; }
}
/* very small: iPhone SE 1st gen, Galaxy Fold folded */
@media (max-width: 340px) {
  .wrap { padding-left: 10px; padding-right: 10px; }
  .topbar { flex-direction: column; }
  .tops { justify-content: flex-start; }
  .kpis { grid-template-columns: 1fr; }
  .hero .big { font-size: 2.1rem; }
}
/* touch screens: 44px targets */
@media (pointer: coarse) {
  input, select, button.ghost, .langbtn { min-height: 44px; }
  fieldset.seg span { padding: 13px; }
  label.check input { width: 24px; height: 24px; }
}
/* Surface Duo / foldables spanning two screens: form on one screen, results on the other */
@media (horizontal-viewport-segments: 2) {
  .wrap { max-width: none; }
  .grid { grid-template-columns: calc(env(viewport-segment-width 0 0) - 32px) 1fr;
    column-gap: calc(env(viewport-segment-left 1 0) - env(viewport-segment-right 0 0) + 32px); }
  #form1, #form2 { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
  .mbar { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---- folded detail cards ---- */
details.more > summary { cursor: pointer; font-weight: 800; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: '+'; font-size: 1.3rem; color: var(--brand); line-height: 1; }
details.more[open] > summary::after { content: '–'; }
details.more[open] > summary { margin-bottom: 12px; }
#results1 > button.primary { margin-top: 0; }

/* ================= guided first run ================= */
.linkbtn { background: none; border: 0; color: var(--brand); font: inherit; font-weight: 700; cursor: pointer; padding: 4px 6px; }
.wiz-top { max-width: 680px; margin: 0 auto 16px; }
.wiz-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 4px 0 16px; }
.wiz-steps li { flex: 1; height: 6px; border-radius: 999px; background: var(--line); transition: background .2s; }
.wiz-steps li.done { background: var(--accent); }
.wiz-steps li.on { background: var(--brand); }
.wiz-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.wiz-top h2 { margin: 0; font-size: clamp(1.5rem, 4.5vw, 2rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.wiz-meta { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.wiz .tabs, .wiz #go2, .wiz .gh, .wiz .mbar { display: none !important; }
.wiz #panel-1, .wiz #panel-2 { grid-template-columns: 1fr; max-width: 680px; margin-inline: auto; }
.wiz #form1, .wiz #form2 { position: static; max-height: none; overflow: visible; }
.wiz[data-step="1"] #form1 [data-step="2"], .wiz[data-step="2"] #form1 [data-step="1"] { display: none; }
.wiz[data-step="1"] #results1, .wiz[data-step="2"] #results1, .wiz[data-step="3"] #form1 { display: none; }
.wiz main { padding-bottom: 110px; }
.wiz-nav { position: fixed; inset-inline: 0; bottom: 0; z-index: 25; background: var(--card); box-shadow: 0 -6px 24px rgba(27, 31, 90, .1);
  padding: 10px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-right)); }
.wiz-nav .in { max-width: 680px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.wiz-nav .primary { margin: 0; flex: 1; }
.wiz-nav .ghost { flex: none; min-height: 48px; padding-inline: 20px; }
#wizMsg { max-width: 680px; margin: 0 auto 8px; color: #d6455d; font-weight: 700; font-size: .85rem; }
#wizMsg:empty { display: none; }
#form1 [data-step="2"] h2:not(.gh) { margin-top: 26px; }

/* grid/flex children may shrink below their widest content (tables scroll inside .tw instead of widening the page) */
.grid > *, .results > *, .stack > *, .two > * { min-width: 0; }

fieldset.seg.nat label { flex: 1 1 90px; }

/* ---- export ---- */
.exportbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.exportbar .exsp { flex: 1; }
.exportbar .remember { font-size: .85rem; font-weight: 600; color: var(--muted); }
.allowpick { margin: 4px 0 14px; font-weight: 600; }
.hero .allow small { opacity: .85; }
.print-only { display: none; }
@media print {
  @page { margin: 14mm; }
  :root, :root[data-theme], :root:not([data-theme="light"]) {
    --bg: #ffffff; --card: #ffffff; --ink: #1b1f5a; --muted: #5a5e7a; --line: #e6e0d0;
    --brand: #5a5cf6; --brand-ink: #ffffff; --brand-soft: #eff0ff; --accent: #23b47e;
    --warn-bg: #fff3cf; --warn-ink: #6a4a00; --bar-target: #cfd2f5; color-scheme: light;
  }
  body { background: #fff !important; padding: 0 !important; }
  .tops, .top .sub, .wave, .tabs, #form1, #form2, .mbar, .wiz-nav, .wiz-top, #go2, .exportbar, .foot details, #need1 { display: none !important; }
  .top { background: none !important; color: var(--ink); padding: 0; }
  .top h1 { font-size: 20pt; margin: 0; }
  .print-only { display: block; color: var(--muted); margin: 2px 0 14px; font-size: 9pt; }
  .wrap { max-width: none !important; padding: 0 !important; }
  .grid, .wiz #panel-1, .wiz #panel-2 { display: block !important; max-width: none !important; }
  .printing #results1, .printing #results2 { display: grid !important; gap: 10px; }
  .card { box-shadow: none !important; border: 1px solid var(--line); break-inside: avoid; margin-bottom: 10px; }
  .hero, .pill, tr.sel td, .svc .kpi, .bar i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tw { overflow: visible; }
  .tw table { min-width: 0; }
  details.more > summary::after { display: none; }
  .foot { margin: 10px 0 0; font-size: 8pt; }
}

label.pick { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; }
label.pick input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }

/* export appears only after the guide is finished */
.wiz .exportbar { display: none !important; }

td .split { color: var(--muted); font-size: .76rem; font-weight: 400; white-space: nowrap; }

/* =====================================================================
   Theme v2: closer to the friendly-finance look (studied on ynab.com):
   midnight nav, violet hero with a big semibold display headline and an
   italic subline, buttermilk canvas, flat white cards with 12px corners,
   lime 6px buttons, semibold (not heavy) type. Colours/fonts are our own.
   ===================================================================== */
:root {
  --bg: #fef9ed; --bg-2: #fdf3d2; --card: #ffffff; --ink: #1c1f58; --muted: #5d607c; --line: #ece4cf;
  --brand: #565cfb; --brand-ink: #fef9ed; --brand-soft: #eef0ff; --brand-deep: #383ca3;
  --cta: #b2e86b; --cta-ink: #1c1f58; --cta-hover: #9ddb4c; --accent: #2fbf86;
  --nav: #1c1f58; --nav-ink: #fef9ed;
  --radius: 12px; --radius-sm: 6px;
  --shadow: none;
  --display: "Bricolage Grotesque", "Readex Pro", "Figtree", system-ui, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #13153f; --bg-2: #191c4f; --card: #1d2058; --ink: #f6f1e4; --muted: #b4b7d8; --line: #2b2f72;
  --brand: #6e73ff; --brand-ink: #fef9ed; --brand-soft: #262a72; --nav: #0d0f30; --nav-ink: #fef9ed;
  --cta: #b2e86b; --cta-ink: #13153f; --cta-hover: #c6f08e; --accent: #4fe0a6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13153f; --bg-2: #191c4f; --card: #1d2058; --ink: #f6f1e4; --muted: #b4b7d8; --line: #2b2f72;
    --brand: #6e73ff; --brand-ink: #fef9ed; --brand-soft: #262a72; --nav: #0d0f30; --nav-ink: #fef9ed;
    --cta: #b2e86b; --cta-ink: #13153f; --cta-hover: #c6f08e; --accent: #4fe0a6;
  }
}
html[lang="ar"] { --display: "Readex Pro", "Bricolage Grotesque", system-ui, sans-serif; }
body { font-size: 16px; line-height: 1.5; }

/* nav: 64px midnight bar */
.top { background: var(--nav); color: var(--nav-ink); padding: 0; }
.navin { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; }
.mark { width: 22px; height: 22px; border-radius: 50%; background: var(--cta); box-shadow: inset -6px -6px 0 var(--brand); flex: none; }
.navbtn { background: transparent; color: var(--nav-ink); border: 0; padding: 8px 12px; border-radius: 8px; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; min-height: 40px; }
.navbtn:hover { background: rgba(255, 255, 255, .1); }
#langBtn { border: 1.5px solid rgba(254, 249, 237, .5); }

/* hero band: violet, big semibold display headline, italic subline, one lime button */
.heroband { background: var(--brand); color: var(--brand-ink); padding: 44px 0 6px; }
.heroband h1 { font-family: var(--display); font-weight: 600; font-size: clamp(2.1rem, 6vw, 3.6rem); line-height: 1.08; letter-spacing: -.02em; margin: 0 0 12px; max-width: 760px; }
.heroband .sub { font-style: italic; font-weight: 500; font-size: clamp(1.05rem, 2.4vw, 1.3rem); margin: 0 0 22px; max-width: 620px; opacity: .95; }
html[lang="ar"] .heroband .sub { font-style: normal; }
.cta { background: var(--cta); color: var(--cta-ink); border: 2px solid var(--cta); border-radius: var(--radius-sm); padding: 12px 20px;
  font: inherit; font-weight: 600; cursor: pointer; min-height: 48px; }
.cta:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
.wave { height: 60px; }
.wiz .heroband { display: none; }
.wiz .wave { height: 24px; }

/* canvas + flat cards */
.card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: none; border: 1px solid var(--line); }
@media (max-width: 480px) { .card { padding: 18px; } }
.card h2, .wiz-top h2 { font-family: var(--display); font-weight: 600; letter-spacing: -.015em; }
.card h2 { font-size: 1.35rem; }
.card h3 { font-family: var(--display); font-weight: 600; font-size: 1.12rem; letter-spacing: -.01em; }
.wiz-top h2 { font-size: clamp(1.7rem, 5vw, 2.4rem); }

/* tabs: midnight pill when selected */
.tabs { background: var(--card); border: 1px solid var(--line); box-shadow: none; }
.tabs button { font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--nav); color: var(--nav-ink); }

/* inputs: white, 6px, calm border, violet focus */
input, select, input[type=text] { background: var(--card); border: 1.5px solid #ddd5c1; border-radius: var(--radius-sm); min-height: 46px; }
:root[data-theme="dark"] input, :root[data-theme="dark"] select { border-color: var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) input, :root:not([data-theme="light"]) select { border-color: var(--line); } }
input[type=range] { min-height: 0; }
form label { font-weight: 600; }
fieldset.seg span { border-radius: var(--radius-sm); font-weight: 600; background: var(--card); }
.job { background: var(--bg); border-radius: var(--radius); }
.period { border-radius: 10px; }
.period input { background: var(--card); }

/* buttons: lime primary, 6px, semibold; ghost = navy outline */
button.primary { border-radius: var(--radius-sm); font-weight: 600; font-size: 1rem; }
button.ghost { border: 1.5px solid var(--ink); color: var(--ink); background: transparent; border-radius: var(--radius-sm); font-weight: 600; }
button.ghost:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* results: violet answer card with a big display number */
.hero { background: var(--brand); color: var(--brand-ink); border: 0; padding: 30px 24px; }
.hero .label { font-weight: 600; opacity: .9; }
.hero .big { font-family: var(--display); font-weight: 600; font-size: clamp(2.8rem, 8vw, 4rem); letter-spacing: -.03em; }
.hero .real { font-size: .95rem; }
.svc .kpi { background: var(--bg-2); }
.kpi { border-radius: 10px; }
.kpi b { font-family: var(--display); font-weight: 600; }
tr.sel td { background: var(--bg-2); }
td, th { font-variant-numeric: tabular-nums; }
.exportbar button.ghost { padding: 6px 12px; font-size: .85rem; }
.empty { background: var(--bg-2); border: 0; }

/* guide nav bar matches the flat style */
.wiz-nav { box-shadow: 0 -1px 0 var(--line); }

/* print: hide the nav buttons and hero band */
@media print {
  .heroband, .tops { display: none !important; }
  .top { background: none !important; color: var(--ink) !important; }
  .mark { display: none; }
}
@media (max-width: 480px) {
  .navin { min-height: 56px; }
  .brand { font-size: .98rem; line-height: 1.15; gap: 8px; }
  .mark { width: 18px; height: 18px; box-shadow: inset -5px -5px 0 var(--brand); }
  .tops { gap: 2px; flex-wrap: nowrap; }
  .navbtn { padding: 6px 8px; font-size: .82rem; min-height: 36px; }
  .heroband { padding-top: 28px; }
}
.navbtn { white-space: nowrap; }

/* ---- hero art: our own phone mockup with the live answer, floating cards, blob, sparkles ---- */
.heroin { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: center; }
.heroart { display: none; }
@media (min-width: 900px) {
  .heroin { grid-template-columns: 1.15fr 1fr; }
  .heroart { display: block; position: relative; height: 420px; margin-bottom: -70px; z-index: 2; }
}
.blob { position: absolute; inset: 10px 20px auto auto; width: 380px; height: 380px; }
.blob path { fill: var(--cta); opacity: .9; }
.spark { position: absolute; width: 34px; height: 34px; fill: none; stroke: var(--cta); stroke-width: 2.5; stroke-linecap: round; }
.spark circle { fill: none; stroke: var(--cta); }
.spark.s1 { top: 30px; inset-inline-start: 6%; }
.spark.s2 { bottom: 70px; inset-inline-end: 2%; }
.phone { position: absolute; top: 0; inset-inline-end: 90px; width: 236px; height: 440px; border-radius: 38px;
  background: var(--nav); padding: 10px; box-shadow: 0 0 0 4px var(--accent), 0 24px 50px rgba(17, 19, 60, .35); transform: rotate(-4deg); }
.island { position: absolute; top: 18px; left: 50%; width: 76px; height: 22px; margin-left: -38px; border-radius: 12px; background: #0b0d27; z-index: 2; }
.screen { height: 100%; border-radius: 29px; background: #fbf6ea; color: #1c1f58; padding: 52px 16px 16px; overflow: hidden; text-align: start; }
.ph-label { font-size: .7rem; font-weight: 700; color: #565cfb; }
.ph-big { font-family: var(--display); font-weight: 700; font-size: 1.55rem; letter-spacing: -.02em; margin: 4px 0 10px; white-space: nowrap; }
.ph-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #e7e1d1; margin-bottom: 14px; }
.ph-bar i { display: block; height: 100%; }
.ph-bar .a { background: #565cfb; } .ph-bar .b { background: #9ad94b; }
.ph-row { display: flex; justify-content: space-between; gap: 8px; font-size: .74rem; padding: 8px 0; border-bottom: 1px solid #ece4cf; }
.ph-row b { font-weight: 700; white-space: nowrap; }
.chip { position: absolute; background: #ffffff; color: #1c1f58; border-radius: 10px; padding: 10px 12px; box-shadow: 0 12px 28px rgba(17, 19, 60, .22);
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 14px; font-size: .8rem; font-weight: 700; min-width: 190px; }
.chip.c1 { top: 70px; inset-inline-start: 0; transform: rotate(-2deg); }
.chip.c2 { bottom: 40px; inset-inline-end: 0; transform: rotate(2deg); }
.mpill { background: var(--cta); color: #1c1f58; border-radius: 999px; padding: 2px 10px; font-weight: 800; font-size: .78rem; white-space: nowrap; }
.mpill.alt { background: #ffe08a; }
.chipline { grid-column: 1 / -1; display: block; height: 5px; border-radius: 999px; background: #ece4cf; overflow: hidden; }
.chipline i { display: block; height: 100%; background: #9ad94b; }
@media print { .heroart { display: none !important; } }
@media (prefers-reduced-motion: no-preference) {
  .phone { transition: transform .4s ease; }
  .heroart:hover .phone { transform: rotate(-2deg) translateY(-4px); }
}
@media (min-width: 900px) {
  .heroart { height: 380px; margin-bottom: -16px; }
  .phone { height: 392px; top: -8px; }
  .blob { width: 340px; height: 340px; inset: 6px 30px auto auto; }
  .chip.c2 { bottom: 34px; }
}

/* ---- investment pot chart + what-if slider ---- */
.sim { display: grid; gap: 8px; margin-bottom: 6px; }
.sim label { font-weight: 600; font-size: .92rem; }
.simrow { display: grid; grid-template-columns: 1fr 130px; gap: 12px; align-items: center; }
.simrow input[type=range] { margin: 0; }
.simrow input[type=number] { margin: 0; }
.sim .linkbtn { justify-self: start; padding: 2px 0; }
.simline { margin: 8px 0 4px; font-weight: 700; }
.simline.good { color: var(--accent); }
.simline.bad { color: #d6455d; }
.chart .dep { fill: #d6455d; stroke: var(--card); stroke-width: 2.5; }
.chart .dep-t { fill: #d6455d; font-weight: 700; }

/* ---- chart kit: tabbed cards, areas, dashed forecasts, bars, hover guide ---- */
.ccard { --c-brand: var(--brand); --c-acc: var(--accent); --c-bad: #d6455d; --c-cut: #ff9f5a; }
.ctabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; overflow-x: auto; scrollbar-width: none; }
.ctabs::-webkit-scrollbar { display: none; }
.ctabs button { background: none; border: 0; padding: 8px 0 10px; font: inherit; font-family: var(--display, inherit); font-weight: 600; font-size: 1.02rem;
  color: var(--muted); cursor: pointer; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.ctabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }
.ctabs button:hover { color: var(--ink); }
.cnote { color: var(--muted); font-size: .82rem; margin: 0 0 6px; }
.chart .area { stroke: none; }
.chart .area.soft { fill: var(--c-brand); opacity: .16; }
.chart .ln { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln.brand { stroke: var(--c-brand); }
.chart .ln.acc { stroke: var(--c-acc); }
.chart .ln.ink { stroke: var(--ink); stroke-width: 1.5; }
.chart .ln.nol { display: none; }
.chart .ln.dash { stroke-dasharray: 8 6; stroke-width: 3; }
.chart .ln.faint { opacity: .45; }
.chart .seg { stroke-width: 3.5; stroke-linecap: round; }
.chart .conn { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 3 4; opacity: .5; }
.chart .hdot { fill: var(--card); stroke: var(--c-brand); stroke-width: 2.5; }
.chart .hdot.alt { stroke: var(--c-brand); stroke-dasharray: 3 2; }
.chart .pdot { fill: var(--card); stroke-width: 2; }
.chart .pdot.ink { stroke: var(--ink); }
.chart .cbar { fill: var(--c-brand); }
.chart .cbar.b-ok, .chart .cbar.b-max { fill: var(--c-brand); opacity: .85; }
.chart .cbar.b-cut { fill: var(--c-cut); opacity: .9; }
.chart .cbar.b-late { fill: var(--bar-target); }
.chart .cbar.sel { opacity: 1; fill: var(--brand-deep, var(--brand)); }
.chart .cbar.b-cut.sel { fill: #f07f2c; }
.chart .cbar.selband { fill: var(--brand); opacity: .09; }
.chart .cbar.b-pen { fill: var(--c-acc); }
.chart .cbar.b-drw { fill: var(--c-brand); }
.chart .ref { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; opacity: .7; }
.chart .ref.top { stroke: var(--c-acc); opacity: 1; }
.chart .ln.tgt { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 8 6; opacity: .8; }
.chart .ref-t { font-size: 10.5px; font-weight: 600; }
.chart .ax2 { text-anchor: start; }
.chart .mark-t { font-weight: 600; }
.chart .dep { fill: var(--c-bad); stroke: var(--card); stroke-width: 2.5; }
.chart .hover { fill: transparent; cursor: crosshair; }
.chart.pickable .hover { cursor: pointer; }
.chart .guide { stroke: var(--ink); stroke-width: 1; opacity: .35; pointer-events: none; }
.chart .gdot { fill: var(--card); stroke: var(--c-brand); stroke-width: 3; pointer-events: none; }
.chart .gdot.g2 { stroke: var(--c-acc); }
.chart .tip { min-width: 150px; }
/* legend swatches like the reference: short lines, dashes, blocks */
.legend .sw { display: inline-block; width: 18px; height: 0; border-radius: 2px; margin-inline-end: 7px; vertical-align: middle; background: none; }
.legend .sw.solid { height: 4px; background: var(--brand); }
.legend .sw.solid.brand { background: var(--brand); }
.legend .sw.dash { border-top: 3px dashed var(--brand); width: 20px; }
.legend .sw.dash.acc { border-top-color: var(--accent); }
.legend .sw.dash.ink { border-top-color: var(--ink); }
.legend .sw.bar { width: 11px; height: 11px; border-radius: 3px; background: var(--brand); }
.legend .sw.bar.b-cut { background: #ff9f5a; } .legend .sw.bar.b-late { background: var(--bar-target); }
.legend .sw.bar.b-pen { background: var(--accent); } .legend .sw.bar.b-drw { background: var(--brand); }
.legend .sw.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); background: var(--card); }
.legend .sw.dot.bad { border-color: #d6455d; background: #d6455d; }
@media (prefers-reduced-motion: no-preference) {
  .chart.anim .reveal { animation: c-reveal .9s cubic-bezier(.3, .7, .3, 1) both; }
  @keyframes c-reveal { from { width: 0; } }
}
@media print {
  .ctabs, .cnote, .chart .guide, .chart .gdot, .chart .tip { display: none !important; }
  .cpane[hidden] { display: block !important; }
  .cpane { break-inside: avoid; margin-bottom: 8px; }
  .chart .reveal { animation: none !important; }
  .chart { max-width: 600px; margin: 0 auto; }
  .ptitle { font-size: 10pt; font-weight: 700; color: var(--ink); margin: 6px 0 2px; }
}
