/* خط Cairo محفوظ داخل التطبيق (fonts/)، ما ينطلب من أي سيرفر خارجي */
@font-face { font-family: 'Cairo'; font-style: normal; font-display: swap; font-weight: 400;
  src: url(../fonts/cairo-arabic-400-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Cairo'; font-style: normal; font-display: swap; font-weight: 700;
  src: url(../fonts/cairo-arabic-700-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Cairo'; font-style: normal; font-display: swap; font-weight: 800;
  src: url(../fonts/cairo-arabic-800-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Cairo'; font-style: normal; font-display: swap; font-weight: 400;
  src: url(../fonts/cairo-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Cairo'; font-style: normal; font-display: swap; font-weight: 700;
  src: url(../fonts/cairo-latin-700-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Cairo'; font-style: normal; font-display: swap; font-weight: 800;
  src: url(../fonts/cairo-latin-800-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }


/* الأساس: data/design-research.md. خلفية محايدة، لون تمييز واحد، بدون تدرجات. */
:root {
  --bg: #f4f4f2;
  --card: #ffffff;
  --sunken: #efefec;
  --ink: #16181b;
  --ink-2: #3c4047;
  --muted: #6a6f77;
  --line: #e6e6e2;
  --accent: #0f7a5f;
  --on-accent: #ffffff;
  --pos: #1f7a4d;
  --warn: #9a6200;
  --warn-soft: #fbf1dc;
  --neg: #c0362c;
  --neg-soft: #fbe7e4;
  --c-groceries: #3f8f6f; --c-dining: #c07a3e; --c-transport: #4a77b8;
  --c-shopping: #a5668f; --c-subscriptions: #2f8a93; --c-fun: #7a6cbf; --c-other: #7d8288;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 18, 20, .04), 0 1px 1px rgba(16, 18, 20, .03);
  color-scheme: light;
}
:root[data-accent="blue"] { --accent: #2456c7; }
:root[data-accent="teal"] { --accent: #0b6f80; }
:root[data-accent="plum"] { --accent: #6a44a6; }
:root[data-accent="clay"] { --accent: #a8502c; }
:root[data-accent="graphite"] { --accent: #3b424d; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f11; --card: #17191c; --sunken: #1f2226; --ink: #f1f2f4; --ink-2: #c9ccd2; --muted: #9a9fa8; --line: #272a2f;
    --accent: #34c39a; --on-accent: #0b1210;
    --pos: #5fd19a; --warn: #f0b54d; --warn-soft: #2d2412; --neg: #ff8a7e; --neg-soft: #34191a;
    --c-groceries: #6cc49f; --c-dining: #e6a56b; --c-transport: #86aee6;
    --c-shopping: #d29abf; --c-subscriptions: #6cc3cb; --c-fun: #ab9fe8; --c-other: #a9aeb4;
    --shadow: none;
    color-scheme: dark;
  }
  :root[data-accent="blue"] { --accent: #7ea6ff; }
  :root[data-accent="teal"] { --accent: #45bfd0; }
  :root[data-accent="plum"] { --accent: #b49cf0; }
  :root[data-accent="clay"] { --accent: #ee9a72; }
  :root[data-accent="graphite"] { --accent: #c9cfd8; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  font-size: 16px; line-height: 1.55; -webkit-tap-highlight-color: transparent;
}
main { max-width: 480px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom)); }
h1 { font-size: 24px; line-height: 1.3; margin: 0; font-weight: 700; letter-spacing: -.2px; }
h2 { font-size: 15px; margin: 0; font-weight: 700; color: var(--ink-2); }
p { margin: 6px 0; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.cur { font-size: .6em; font-weight: 600; color: var(--muted); margin-inline-start: 4px; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.pagehead { padding: 8px 0 12px; }
.pagehead .sub, .sub { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.greet { font-size: 22px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }

/* الملخص: رقم واحد بطل */
.summary { padding: 18px 16px 16px; }
.eyebrow { font-size: 14px; color: var(--muted); font-weight: 600; }
.hero-num { font-size: 44px; font-weight: 700; line-height: 1.15; margin: 2px 0 12px; letter-spacing: -.5px; }
.hero-num .cur { font-size: 16px; }
.summary.is-over .hero-num { color: var(--neg); }
.meter { position: relative; height: 8px; border-radius: 99px; background: var(--sunken); }
.meter i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 99px; background: var(--accent); }
.summary.is-over .meter i { background: var(--neg); }
.pace-mark { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--ink); border-radius: 2px; transform: translateX(50%); opacity: .55; }
.meter-legend { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.meter-legend b { color: var(--ink-2); font-weight: 600; }
.status { font-size: 15px; color: var(--ink-2); margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.fine { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

/* أزرار */
button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px;
  border: 0; border-radius: 14px; background: var(--accent); color: var(--on-accent); font-size: 17px; font-weight: 700; margin: 12px 0;
  transition: opacity .15s, transform .1s;
}
.btn .ic { width: 20px; height: 20px; }
.btn:active { transform: scale(.985); opacity: .92; }
.btn:disabled { opacity: .35; cursor: default; }
.btn.quiet { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn.small { min-height: 48px; font-size: 15px; width: auto; padding: 0 16px; margin: 0; }
.iconbtn { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); }
.iconbtn .ic { width: 22px; height: 22px; }
.iconbtn.sm { width: 44px; height: 44px; border-radius: 12px; }
.iconbtn.sm .ic { width: 18px; height: 18px; }
.iconbtn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.iconbtn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.ic { width: 20px; height: 20px; display: block; }
.ic.sm { width: 15px; height: 15px; }

/* حقول */
label.field { display: block; margin: 18px 0 6px; font-weight: 600; font-size: 15px; }
.opt { font-weight: 400; color: var(--muted); font-size: 13px; margin-inline-start: 4px; }
input.in {
  width: 100%; height: 52px; font: inherit; font-size: 20px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; background: var(--card); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
input.in.in-text { font-size: 17px; font-weight: 500; }
input.in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.err { color: var(--neg); font-size: 14px; font-weight: 600; margin-top: 6px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--sunken); border-radius: 14px; }
.seg button { min-height: 48px; border: 0; border-radius: 10px; background: transparent; font-size: 17px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seg.sm { padding: 3px; border-radius: 12px; }
.seg.sm button { min-height: 44px; font-size: 14px; padding: 0 12px; }

.level { border-radius: 12px; padding: 10px 12px; margin-top: 8px; font-size: 14px; display: flex; gap: 10px; align-items: center; background: var(--sunken); color: var(--ink-2); }
.level .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.level.green .dot { background: var(--pos); }
.level.yellow { background: var(--warn-soft); } .level.yellow .dot { background: var(--warn); }
.level.red { background: var(--neg-soft); } .level.red .dot { background: var(--neg); }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.t-title { font-weight: 600; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { right: 25px; }
#savWrap { margin-top: 8px; }

.note { border-radius: 14px; padding: 12px 14px; margin: 12px 0; font-size: 14px; background: var(--sunken); color: var(--ink-2); }

/* القوائم */
.list .li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list .li:first-child { border-top: 0; padding-top: 4px; }
.li-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.li-t { font-weight: 600; font-size: 15px; }
.li-s { font-size: 13px; color: var(--muted); }
.li-v { font-weight: 600; white-space: nowrap; }
.li-v.neg { color: var(--neg); }
.li-end { display: flex; align-items: center; gap: 2px; }
.li.is-now .li-t { color: var(--accent); }
.badge { font-size: 11px; font-weight: 700; color: var(--accent); border: 1px solid currentColor; border-radius: 99px; padding: 0 7px; margin-inline-start: 4px; vertical-align: 2px; }
.amount-btn { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-weight: 600; }
.amount-btn .ic { color: var(--muted); }
.edit-row { display: flex; gap: 8px; padding-bottom: 10px; }
.edit-row input { flex: 1; height: 48px; font-size: 18px; }

/* أيقونة البند: خلفية خفيفة من لونه */
.cico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.cico .ic { width: 21px; height: 21px; }
.c-groceries { --c: var(--c-groceries); } .c-dining { --c: var(--c-dining); } .c-transport { --c: var(--c-transport); }
.c-shopping { --c: var(--c-shopping); } .c-subscriptions { --c: var(--c-subscriptions); } .c-fun { --c: var(--c-fun); } .c-other { --c: var(--c-other); } .c-accent { --c: var(--accent); }
.cico { color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }

/* أشرطة البنود */
.cat-li { align-items: flex-start; }
.bar { height: 6px; border-radius: 99px; background: var(--sunken); margin: 8px 0 6px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--c); transition: width .4s ease; }
.bar.lv-warn i { background: var(--warn); }
.bar.lv-over i { background: var(--neg); }

.flag { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; margin: 12px 0; font-size: 14px; color: var(--ink-2); }
.flag .cico { width: 32px; height: 32px; border-radius: 10px; }
.flag .cico .ic { width: 18px; height: 18px; }
.flag.warn { background: var(--warn-soft); }
.flag.over { background: var(--neg-soft); }

/* رسم الأيام */
svg.daily { display: block; overflow: visible; }
.daily .base { stroke: var(--line); stroke-width: 1; }
.daily .pace { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 4; }
.db rect { fill: color-mix(in srgb, var(--accent) 35%, var(--sunken)); }
.db.today rect { fill: var(--accent); }
.db.high rect { fill: var(--neg); opacity: .75; }
.db.future rect { fill: var(--sunken); }
.dv { font-size: 10.5px; font-weight: 600; fill: var(--ink-2); }
.dl { font-size: 10.5px; fill: var(--muted); }
.db.today .dl { fill: var(--ink); font-weight: 700; }
.legend-pace { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.legend-pace::before { content: ''; width: 16px; border-top: 1px dashed var(--muted); }

.goal { display: flex; align-items: center; gap: 12px; }

.streak-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 18px 0 4px; }
.streak-line .ic { width: 16px; height: 16px; }
.streak-line .ic.on { color: #d9822b; }
.dotsep { opacity: .5; }

/* التخصيص */
.customize { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.customize label.field:first-of-type { margin-top: 4px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff; position: relative; }
.sw .ic { width: 20px; height: 20px; opacity: 0; transition: opacity .15s; }
.sw[aria-checked="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink-2); }
.sw[aria-checked="true"] .ic { opacity: 1; }
.a-green { background: #0f7a5f; } .a-blue { background: #2456c7; } .a-teal { background: #0b6f80; }
.a-plum { background: #6a44a6; } .a-clay { background: #a8502c; } .a-graphite { background: #3b424d; }

/* التسجيل */
.add-tools { display: flex; gap: 8px; align-items: center; }
.textline { display: flex; gap: 8px; margin: 4px 0 8px; }
.textline[hidden] { display: none; }
.textline input { flex: 1; height: 48px; }
.amount { text-align: center; font-size: 52px; font-weight: 700; padding: 8px 0 4px; min-height: 84px; letter-spacing: -.5px; }
.amount .cur { font-size: 18px; }
.amount.empty { color: var(--muted); opacity: .55; }
.catzone { position: relative; min-height: 148px; margin: 4px 0 12px; }
.cat-hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; margin: 0; border: 1px dashed var(--line); border-radius: var(--radius); }
.cat-hint[hidden] { display: none; }
/* minmax(0, 1fr): اسم بند طويل بدون مسافات ما يوسّع العمود ويطلّع الشبكة برا الشاشة (مراجعة الثانية #11) */
.catgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.catgrid button span { overflow-wrap: anywhere; max-width: 100%; text-align: center; }
.catgrid button {
  min-height: 70px; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 4px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  opacity: 0; transform: translateY(6px); pointer-events: none; transition: opacity .2s ease, transform .2s ease, border-color .15s;
}
.catgrid button .cico { width: 32px; height: 32px; border-radius: 10px; }
.catgrid button .cico .ic { width: 18px; height: 18px; }
.catgrid.show button { opacity: 1; transform: none; pointer-events: auto; }
.catgrid.show button:active { border-color: var(--accent); background: var(--sunken); }
.catgrid button.suggest { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; direction: ltr; }
.pad button { height: 54px; font-size: 22px; font-weight: 600; border-radius: 14px; border: 0; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; }
.pad button .ic { width: 24px; height: 24px; color: var(--ink-2); }
.pad button:active { background: var(--sunken); }
@media (prefers-color-scheme: dark) { .pad button { background: var(--sunken); } .pad button:active { background: var(--line); } }

/* الشريط السفلي */
nav#nav {
  position: fixed; bottom: 0; inset-inline: 0; background: var(--card); background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); z-index: 5;
}
nav#nav[hidden] { display: none; }
nav#nav button { background: none; border: 0; min-height: 56px; font-size: 12px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
nav#nav button .ic { width: 22px; height: 22px; }
nav#nav button[aria-current="page"] { color: var(--accent); }
nav#nav .nav-add .plus { background: var(--accent); color: var(--on-accent); border-radius: 12px; width: 40px; height: 30px; display: grid; place-items: center; }
nav#nav .nav-add .plus .ic { width: 20px; height: 20px; }

#toast {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); inset-inline: 16px; max-width: 448px; margin: 0 auto;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 8px 8px 8px 14px; padding-inline-start: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 14px; font-weight: 600; z-index: 6; box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: toastIn .2s ease both;
}
#toast[hidden] { display: none; }
#toast .t-msg { display: flex; align-items: center; gap: 8px; }
#toast .t-ok { width: 18px; height: 18px; color: var(--accent); flex: none; }
#toast button { background: transparent; border: 1px solid color-mix(in srgb, var(--bg) 30%, transparent); color: var(--bg); font-weight: 700; min-height: 44px; padding: 0 14px; border-radius: 10px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* جولة الوضوح: مدة المبلغ، مجموعات البنود، حاسبة الالتزامات */
.per { font-size: 12px; font-weight: 500; color: var(--muted); margin-inline-start: 4px; }
.group-h { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.cm-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cm-row .cm-name { flex: 1.4; min-width: 0; }
.cm-row .cm-amt { flex: 1; min-width: 0; }
.addrow { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 52px; margin-top: 4px; padding: 0 16px; border: 0; border-radius: 14px; background: color-mix(in srgb, var(--accent) 12%, var(--card)); color: var(--accent); font-weight: 700; font-family: inherit; font-size: 16px; cursor: pointer; }
.addrow:active { transform: scale(.98); }
.addrow-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; }
.addrow-ic .ic { width: 18px; height: 18px; stroke-width: 2.25; }

/* الجولة الثانية: اقتراحات بضغطة، الأبناء، العد التنازلي للراتب */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 10px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink-2); font-family: inherit; font-size: 14px; font-weight: 600; }
.chip .ic { width: 16px; height: 16px; color: var(--accent); }
.chip:active { background: var(--sunken); }
.kids { margin-top: 10px; }
.kid-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.kid-name { flex: 1.8; font-weight: 600; font-size: 15px; min-width: 0; }
.kid-row .kid-amt { flex: 0 0 104px; min-width: 0; height: 48px; }
.kid-row .per { min-width: 44px; }
.madd { margin-top: 10px; }
.madd .cm-row #mName { flex: 1.4; min-width: 0; }
.madd .cm-row #mAmt { flex: 1; min-width: 0; }
.countdown { display: flex; align-items: center; gap: 16px; background: color-mix(in srgb, var(--accent) 9%, var(--card)); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.ring { flex: none; }
.ring-bg { fill: none; stroke: color-mix(in srgb, var(--accent) 18%, transparent); stroke-width: 6; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; }
.ring-n { font: 800 20px Cairo, sans-serif; fill: var(--ink); }
.ring-u { font: 600 10px Cairo, sans-serif; fill: var(--muted); }
.cd-main { font-size: 22px; font-weight: 800; line-height: 1.3; color: var(--ink); }

/* البيع: بوابة التثبيت، التفعيل، الخصوصية */
.install-head { text-align: center; display: flex; flex-direction: column; align-items: center; }
.app-ic { border-radius: 16px; margin-bottom: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.isteps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.istep { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 16px; counter-increment: s; }
.istep:last-child { border-bottom: 0; }
.istep::before { content: counter(s); min-width: 22px; height: 22px; border-radius: 50%; background: var(--sunken); color: var(--muted); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.istep-ic { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 12%, var(--card)); color: var(--accent); }
.istep-ic .ic { width: 22px; height: 22px; }
.isteps + .btn, .card > .btn + .btn { margin-top: 12px; }
.linkbtn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 44px; margin-top: 8px; border: 0; background: transparent; color: var(--muted); font-family: inherit; font-size: 14px; }
.linkbtn .ic { width: 16px; height: 16px; }
.code-in { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); width: 100%; height: auto; min-height: 96px; padding: 12px; font: 600 16px/1.5 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px; word-break: break-all; resize: none; text-align: left; }
.plist { margin: 0; padding-inline-start: 18px; display: grid; gap: 10px; font-size: 15px; line-height: 1.7; }
.li-btn { width: 100%; border: 0; background: transparent; font-family: inherit; font-size: 15px; color: var(--ink); text-align: start; cursor: pointer; }
.ic.flip { transform: scaleX(-1); color: var(--muted); }

/* الرئيسية الجديدة (19 نوفمبر): رقم واحد كبير، وتحته الأسبوع، وتحته ملخص للقراءة بس */
.hero { text-align: center; padding: 26px 16px 20px; margin: 4px 0 12px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 9%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line)); }
.hero-label { font-size: 17px; font-weight: 700; color: var(--ink-2); }
.hero-big { font-size: 56px; font-weight: 800; line-height: 1.1; letter-spacing: -1px; margin: 6px 0 8px; color: var(--ink); }
.hero-big .cur { font-size: 18px; }
.hero-days { font-size: 16px; font-weight: 600; color: var(--ink-2); }
.hero .fine { margin-top: 6px; }
.hero.is-over { background: var(--neg-soft); border-color: color-mix(in srgb, var(--neg) 35%, var(--line)); }
.hero.is-over .hero-big { color: var(--neg); }
/* v10: بدأ في نص الشهر وما كتب رصيده: سؤال بدل رقم مفترض */
.ask-balance .ask-q { font-size: 26px; font-weight: 800; line-height: 1.3; margin: 8px 0 6px; color: var(--ink); }
.ask-balance .fine { margin: 8px 0 14px; }
.ask-balance .btn { margin: 0; }

.week .week-num { font-size: 30px; font-weight: 800; line-height: 1.2; margin: 8px 0 12px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.week .week-word { font-size: 16px; font-weight: 700; color: var(--ink-2); }
.week .week-num .cur { font-size: 15px; }
.week.is-over { border-color: color-mix(in srgb, var(--neg) 40%, var(--line)); }
.week.is-over .week-num { color: var(--neg); }
.week.is-over .meter i { background: var(--neg); }

/* ملخص أسابيعك: عرض بس. بدون ظل ولا حدود أزرار ولا أسهم، وخلفية مسطحة */
.readout { margin: 18px 0 12px; padding: 14px 16px 6px; border-radius: var(--radius); background: var(--sunken); }
.readout-h { font-size: 16px; color: var(--ink); margin-bottom: 4px; }
.wk-list { list-style: none; margin: 0; padding: 0; }
.wk { padding: 12px 0; border-top: 1px solid var(--line); cursor: default; user-select: none; }
.wk:first-child { border-top: 0; }
.wk-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.wk-name { font-weight: 700; font-size: 15px; }
.wk-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.wk-dates { opacity: .8; }
.wk-tag { font-size: 13px; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.wk-tag .ic { width: 14px; height: 14px; }
.wk-tag.ok { color: var(--pos); }
.wk-tag.now { color: var(--accent); }
.wk-tag.over { color: var(--neg); }
.wk-bar { height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 8%, transparent); margin-top: 8px; overflow: hidden; }
.wk-bar i { display: block; height: 100%; border-radius: 99px; background: color-mix(in srgb, var(--accent) 60%, var(--muted)); }
.wk-now .wk-bar i { background: var(--accent); }
.wk-over { background: var(--neg-soft); margin: 0 -10px; padding-inline: 10px; border-radius: 12px; border-top-color: transparent; }
.wk-over + .wk { border-top-color: transparent; }
.wk-over .wk-name, .wk-over .wk-sub { color: var(--neg); }
.wk-over .wk-bar i { background: var(--neg); }
.wk-future .wk-name, .wk-before .wk-name { color: var(--muted); }
.li-s .neg { color: var(--neg); }

/* زر «أضف مصروف»: كبير وتحت، في متناول الإبهام، فوق الشريط السفلي */
.fab-wrap { position: fixed; inset-inline: 0; bottom: calc(74px + env(safe-area-inset-bottom)); padding: 0 16px; z-index: 4; pointer-events: none; }
.fab { pointer-events: auto; max-width: 448px; margin: 0 auto; min-height: 60px; font-size: 19px; font-weight: 800; border-radius: 16px; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.fab .ic { width: 24px; height: 24px; stroke-width: 2.4; }
body.has-fab main { padding-bottom: calc(176px + env(safe-area-inset-bottom)); }
body.has-fab #toast { bottom: calc(140px + env(safe-area-inset-bottom)); }
nav#nav { grid-template-columns: repeat(3, 1fr); }

/* v2 (19 نوفمبر): الإعداد بـ3 خطوات، الاقتراح وليش، أساسي/كمالي، كم معك الحين، التذكير */
.steps { display: flex; gap: 6px; padding: 6px 0 2px; }
.steps i { flex: 1; height: 4px; border-radius: 99px; background: var(--line); }
.steps i.on { background: var(--accent); }
.promise { color: var(--ink-2); font-weight: 600; line-height: 1.6; }
.sug-hero { padding: 20px 16px 16px; }
.sug { padding: 12px 0; border-top: 1px solid var(--line); }
.sug:first-child { border-top: 0; padding-top: 0; }
.sug-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sug-detail { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; line-height: 1.7; }
.sug-why { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.sug-why b { color: var(--accent); font-weight: 700; }
.proj { display: flex; align-items: flex-start; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line)); line-height: 1.6; }
.proj .ic { margin-top: 4px; flex: none; }
.proj.ok { color: var(--pos); }
.proj.bad { color: var(--neg); }
.linkbtn.tight { margin-top: 4px; min-height: 40px; color: var(--accent); font-weight: 700; }
.split { padding: 6px 0 4px; }
.split + .split { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.split .bar i { background: var(--accent); }
.split.is-over .bar i { background: var(--neg); }
.split.is-over .li-s { color: var(--neg); }
.nightcard { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
.catgrid-wrap .catgrid + .cat-h { margin-top: 8px; }
.cat-h { font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 2px 6px; opacity: 0; transition: opacity .2s; }
.catgrid-wrap .catgrid button { opacity: 0; transform: translateY(6px); pointer-events: none; }
.catgrid-wrap.show .catgrid button, .catgrid-wrap.show .cat-h { opacity: 1; transform: none; pointer-events: auto; }
.catgrid-wrap.show .catgrid button:active { border-color: var(--accent); background: var(--sunken); }
.catzone { min-height: 200px; }
.edit-box { padding-bottom: 10px; }
.edit-box .edit-row { padding-bottom: 6px; align-items: center; }
.unit-in { white-space: nowrap; }
.edit-more { display: flex; flex-wrap: wrap; gap: 6px; }
.edit-more .chip { min-height: 40px; font-size: 13px; }
.intro { background: color-mix(in srgb, var(--accent) 8%, var(--card)); color: var(--ink); font-size: 15px; line-height: 1.7; border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line)); }
.eq .total { font-size: 17px; }
.eq .total b { color: var(--pos); }
.eq .total.neg b { color: var(--neg); }
.newlimit { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 0 2px; margin-top: 8px; border-top: 1px solid var(--line); text-align: center; }
.newlimit > span:first-child { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.newlimit .big { font-size: 34px; font-weight: 800; line-height: 1.2; }
.newlimit .big .cur { font-size: 15px; }
.li-s.block { display: block; }
.wk-days { font-size: 12px; font-weight: 600; color: var(--muted); }
.note.ok { background: color-mix(in srgb, var(--pos) 12%, var(--card)); color: var(--ink); display: flex; gap: 6px; align-items: center; }
.preview-note { background: var(--sunken); box-shadow: none; }
.card-h .opt, .readout-h .opt { font-size: 12px; }

/* شاشات 320px (iPhone SE الأول وأندرويد الصغيرة): هيدر «مصروف جديد» يلتف بدل ما يطلع برا الشاشة (مراجعة 20 نوفمبر) */
@media (max-width: 340px) {
  .add-head { flex-wrap: wrap; row-gap: 8px; }
  .add-head h1 { min-width: 0; }
  .add-tools { gap: 6px; margin-inline-start: auto; }
  .seg.sm button { padding: 0 8px; }
}

/* خيار «جدول وزارة المالية» تحت يوم الراتب */
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 0; font-size: 14px; color: var(--ink-2); line-height: 1.6; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check[hidden] { display: none; }

/* المراجعة الثالثة #13: متصفحات قديمة بدون color-mix (Safari أقل من 16.2، Chrome أقل من 111). بدونها الخلفيات تختفي والحدود ترجع للافتراضي. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .hero, .countdown, .nightcard, .intro, .addrow, .istep-ic { background: var(--sunken); border-color: var(--line); }
  .hero.is-over { background: var(--neg-soft); border-color: var(--neg); }
  .week.is-over { border-color: var(--neg); }
  .customize, .proj { border-color: var(--line); }
  .cico { background: var(--sunken); }
  .wk-bar { background: var(--line); }
  .wk-bar i { background: var(--accent); }
  .note.ok { background: var(--sunken); }
  .db rect { fill: var(--accent); opacity: .4; }
  .ring-bg { stroke: var(--line); }
  input.in:focus { box-shadow: 0 0 0 3px var(--line); }
  #toast button { border-color: var(--muted); }
  .fab { box-shadow: var(--shadow); }
}
