@font-face{
  font-family:'Cairo';src:url('../fonts/cairo-arabic.woff2') format('woff2');
  font-weight:200 900;font-style:normal;font-display:swap;
}
:root{
  --brand:#12B981; --brand-600:#059669; --brand-700:#047857; --brand-soft:#E7F8F1;
  --accent:#F59E0B; --accent-soft:#FEF3C7;
  --danger:#EF4444; --danger-soft:#FEE2E2;
  --info:#3B82F6; --info-soft:#DBEAFE;
  --bg:#F4F7F5; --surface:#FFFFFF; --surface-2:#F8FAF9;
  --text:#0D1B16; --muted:#63776F; --line:#E3EAE6;
  --shadow:0 6px 24px rgba(13,27,22,.07);
  --shadow-lg:0 18px 44px rgba(13,27,22,.14);
  --r-lg:22px; --r-md:16px; --r-sm:12px;
  --tab-h:64px;
  --font:'Cairo',system-ui,-apple-system,'Segoe UI',Tahoma,sans-serif;
  color-scheme:light;
}
[data-theme="dark"]{
  --bg:#08110E; --surface:#111E1A; --surface-2:#16261F;
  --text:#EAF3EF; --muted:#93A8A0; --line:#22332C;
  --brand-soft:#123027; --accent-soft:#3A2B0B; --danger-soft:#3B1616; --info-soft:#14243F;
  --shadow:0 6px 24px rgba(0,0,0,.35); --shadow-lg:0 18px 44px rgba(0,0,0,.5);
  color-scheme:dark;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  font-family:var(--font);background:var(--bg);color:var(--text);
  font-size:15px;line-height:1.6;-webkit-font-smoothing:antialiased;
  overscroll-behavior-y:none;min-height:100dvh;
}
h1,h2,h3,h4{margin:0;line-height:1.35;font-weight:700}
p{margin:0}
button{font-family:inherit;font-size:inherit;cursor:pointer;border:0;background:none;color:inherit}
input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}
a{color:var(--brand-600);text-decoration:none}
::selection{background:var(--brand);color:#fff}

/* ============ shell ============ */
.app{max-width:520px;margin:0 auto;min-height:100dvh;position:relative;background:var(--bg)}
.topbar{
  position:sticky;top:0;z-index:30;display:flex;align-items:center;gap:10px;
  padding:calc(10px + env(safe-area-inset-top)) 16px 10px;
  background:color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter:saturate(180%) blur(14px);border-bottom:1px solid transparent;
  transition:border-color .2s;
}
.topbar.scrolled{border-bottom-color:var(--line)}
.brand{display:flex;align-items:center;gap:9px;font-weight:800;font-size:19px;letter-spacing:-.2px}
.brand-mark{width:34px;height:34px;border-radius:11px;display:grid;place-items:center;
  background:linear-gradient(145deg,var(--brand),var(--brand-700));box-shadow:0 6px 14px rgba(18,185,129,.35)}
.brand-mark svg{width:20px;height:20px}
.topbar .spacer{flex:1}
.chip-streak{display:flex;align-items:center;gap:5px;background:var(--accent-soft);color:#8A5A00;
  font-size:13px;font-weight:700;padding:5px 10px;border-radius:999px}
[data-theme="dark"] .chip-streak{color:#F5C46B}
.icon-btn{width:38px;height:38px;border-radius:12px;display:grid;place-items:center;background:var(--surface);
  border:1px solid var(--line);color:var(--muted)}
.icon-btn:active{transform:scale(.94)}
.icon-btn svg{width:19px;height:19px}

main{padding:4px 16px calc(var(--tab-h) + 92px + env(safe-area-inset-bottom));animation:fade .25s ease}
@keyframes fade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}

/* ============ bottom tabs ============ */
.tabbar{
  position:fixed;bottom:0;left:0;right:0;z-index:40;max-width:520px;margin:0 auto;
  display:grid;grid-template-columns:repeat(6,1fr);
  background:color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter:saturate(180%) blur(16px);
  border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom);
}
.tab{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
  height:var(--tab-h);color:var(--muted);font-size:11px;font-weight:600;position:relative}
.tab svg{width:23px;height:23px}
.tab.active{color:var(--brand-600)}
.tab.active svg{filter:drop-shadow(0 3px 8px rgba(18,185,129,.4))}
.tab.active::after{content:'';position:absolute;top:6px;width:26px;height:3px;border-radius:3px;background:var(--brand)}

/* ============ generic ============ */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:16px;box-shadow:var(--shadow)}
.card.flat{box-shadow:none}
.card + .card{margin-top:12px}
.section-title{display:flex;align-items:center;justify-content:space-between;margin:22px 2px 10px}
.section-title h3{font-size:16px}
.section-title .link{font-size:13px;font-weight:700;color:var(--brand-600)}
.muted{color:var(--muted)}
.small{font-size:13px}
.tiny{font-size:12px}
.center{text-align:center}
.row{display:flex;align-items:center;gap:10px}
.row.between{justify-content:space-between}
.col{display:flex;flex-direction:column}
.grow{flex:1;min-width:0}
.wrap{display:flex;flex-wrap:wrap;gap:8px}
.hide{display:none !important}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;
  background:var(--brand);color:#fff;font-weight:700;font-size:15px;
  padding:13px 18px;border-radius:15px;transition:transform .08s,filter .15s;width:100%}
.btn:active{transform:scale(.98)}
.btn.secondary{background:var(--brand-soft);color:var(--brand-700)}
[data-theme="dark"] .btn.secondary{color:#8BE7C3}
.btn.ghost{background:transparent;border:1px solid var(--line);color:var(--text)}
.btn.danger{background:var(--danger-soft);color:var(--danger)}
.btn.sm{padding:9px 13px;font-size:13px;border-radius:12px;width:auto}
.btn:disabled{opacity:.5}

.chips{display:flex;gap:8px;overflow-x:auto;padding:2px 0 6px;scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.chip{white-space:nowrap;padding:8px 14px;border-radius:999px;background:var(--surface);
  border:1px solid var(--line);font-size:13px;font-weight:600;color:var(--muted)}
.chip.on{background:var(--brand);border-color:var(--brand);color:#fff}
.segmented{display:grid;grid-auto-flow:column;gap:4px;background:var(--surface-2);
  border:1px solid var(--line);border-radius:14px;padding:4px;margin:6px 0 14px}
.segmented button{padding:9px 6px;border-radius:10px;font-size:13px;font-weight:700;color:var(--muted)}
.segmented button.on{background:var(--surface);color:var(--text);box-shadow:0 2px 8px rgba(0,0,0,.06)}

.field{display:flex;flex-direction:column;gap:6px;margin-bottom:14px}
.field label{font-size:13px;font-weight:700;color:var(--muted)}
.field input,.field select,.field textarea{
  width:100%;padding:13px 14px;border-radius:14px;border:1px solid var(--line);
  background:var(--surface);font-size:16px;outline:none;transition:border-color .15s}
.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--brand);box-shadow:0 0 0 3px var(--brand-soft)}
.field .hint{font-size:12px;color:var(--muted)}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.option-card{border:1.5px solid var(--line);border-radius:16px;padding:13px;background:var(--surface);
  display:flex;flex-direction:column;gap:2px;text-align:right;transition:.15s}
.option-card.on{border-color:var(--brand);background:var(--brand-soft)}
.option-card .t{font-weight:700;font-size:14px}
.option-card .d{font-size:12px;color:var(--muted)}

/* ============ home ============ */
.hero{position:relative;border-radius:26px;padding:18px;overflow:hidden;color:#fff;
  background:linear-gradient(150deg,#0EA371 0%,#0B8F66 45%,#075E45 100%);
  box-shadow:0 16px 34px rgba(6,95,68,.3)}
.hero::after{content:'';position:absolute;width:220px;height:220px;border-radius:50%;
  background:radial-gradient(circle,rgba(255,255,255,.22),transparent 65%);top:-90px;left:-60px}
.hero-top{display:flex;justify-content:space-between;align-items:flex-start;position:relative;z-index:1}
.hero h2{font-size:19px}
.hero .sub{font-size:13px;opacity:.85}
.ring-wrap{display:flex;align-items:center;gap:16px;margin-top:12px;position:relative;z-index:1}
.ring{position:relative;width:132px;height:132px;flex:none}
.ring svg{transform:rotate(-90deg)}
.ring-center{position:absolute;inset:0;display:grid;place-content:center;text-align:center}
.ring-center .big{font-size:26px;font-weight:800;line-height:1}
.ring-center .lbl{font-size:11px;opacity:.85;margin-top:3px}
.hero-stats{display:flex;flex-direction:column;gap:8px;flex:1}
.hero-stat{background:rgba(255,255,255,.14);border-radius:13px;padding:8px 11px;font-size:13px;
  display:flex;justify-content:space-between;gap:8px}
.hero-stat b{font-weight:800}
.macro-row{display:flex;gap:10px;margin-top:14px;position:relative;z-index:1}
.macro{flex:1;background:rgba(255,255,255,.13);border-radius:14px;padding:9px 11px}
.macro .n{font-size:12px;opacity:.85}
.macro .v{font-size:14px;font-weight:800}
.bar{height:5px;border-radius:5px;background:rgba(255,255,255,.25);margin-top:6px;overflow:hidden}
.bar > i{display:block;height:100%;background:#fff;border-radius:5px;transition:width .4s}

.quick-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-top:14px}
.quick{background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:12px 6px;
  display:flex;flex-direction:column;align-items:center;gap:6px;font-size:11.5px;font-weight:700;color:var(--text);
  box-shadow:var(--shadow)}
.quick .ic{width:38px;height:38px;border-radius:12px;display:grid;place-items:center;background:var(--brand-soft);color:var(--brand-600)}
.quick .ic svg{width:20px;height:20px}
.quick:active{transform:scale(.96)}

.stat-line{display:flex;align-items:center;gap:12px;padding:11px 0;border-bottom:1px solid var(--line)}
.stat-line:last-child{border-bottom:0;padding-bottom:0}
.stat-line .ic{width:36px;height:36px;border-radius:11px;display:grid;place-items:center;background:var(--surface-2);font-size:17px}
.stat-line .v{margin-right:auto;font-weight:800}

.alert{border-radius:16px;padding:12px 14px;display:flex;gap:10px;align-items:flex-start;font-size:13.5px}
.alert.high{background:var(--danger-soft);color:#9B1C1C}
.alert.mid{background:var(--accent-soft);color:#8A5A00}
.alert.low,.alert.info{background:var(--info-soft);color:#1E40AF}
[data-theme="dark"] .alert.high{color:#FCA5A5}
[data-theme="dark"] .alert.mid{color:#FCD34D}
[data-theme="dark"] .alert.low,[data-theme="dark"] .alert.info{color:#93C5FD}
.alert .fix{font-size:12.5px;opacity:.92;margin-top:3px}
.alert + .alert{margin-top:8px}

/* ============ food ============ */
.meal-item{display:flex;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid var(--line)}
.meal-item:last-child{border-bottom:0}
.meal-thumb{width:44px;height:44px;border-radius:13px;background:var(--surface-2);display:grid;place-items:center;font-size:20px;flex:none}
.meal-item .name{font-weight:700;font-size:14.5px}
.meal-item .meta{font-size:12px;color:var(--muted)}
.meal-item .kcal{font-weight:800;font-size:14px;white-space:nowrap}
.meal-item .del{width:32px;height:32px;border-radius:10px;display:grid;place-items:center;color:var(--muted);background:var(--surface-2)}
.slot-head{display:flex;align-items:center;justify-content:space-between;margin:16px 2px 4px;font-size:13px;font-weight:800;color:var(--muted)}
.slot-head .add{color:var(--brand-600);font-weight:800}

.plan-day{border:1px solid var(--line);border-radius:18px;padding:13px;margin-bottom:10px;background:var(--surface)}
.plan-day .head{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}
.plan-meal{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:7px 0;font-size:13.5px;border-bottom:1px dashed var(--line)}
.plan-meal:last-child{border-bottom:0}
.plan-meal .swap{font-size:11.5px;font-weight:800;color:var(--brand-600);background:var(--brand-soft);padding:5px 9px;border-radius:9px}
.pill{display:inline-flex;align-items:center;gap:5px;font-size:11.5px;font-weight:700;padding:4px 9px;border-radius:999px;background:var(--surface-2);color:var(--muted)}
.pill.good{background:var(--brand-soft);color:var(--brand-700)}
[data-theme="dark"] .pill.good{color:#8BE7C3}
.pill.warn{background:var(--accent-soft);color:#8A5A00}
.pill.bad{background:var(--danger-soft);color:#9B1C1C}

/* ============ charts ============ */
.chart{width:100%;height:auto;display:block;overflow:visible}
.legend{display:flex;gap:14px;font-size:12px;color:var(--muted);margin-top:8px;flex-wrap:wrap}
.legend i{display:inline-block;width:9px;height:9px;border-radius:3px;margin-left:5px}

/* ============ sheets & modal ============ */
.scrim{position:fixed;inset:0;background:rgba(4,12,9,.55);backdrop-filter:blur(3px);z-index:60;
  opacity:0;pointer-events:none;transition:opacity .22s}
.scrim.show{opacity:1;pointer-events:auto}
.sheet{position:fixed;left:0;right:0;bottom:0;z-index:61;max-width:520px;margin:0 auto;
  background:var(--surface);border-radius:26px 26px 0 0;padding:10px 18px calc(20px + env(safe-area-inset-bottom));
  transform:translateY(102%);transition:transform .28s cubic-bezier(.2,.8,.2,1);
  max-height:92dvh;overflow-y:auto;box-shadow:var(--shadow-lg)}
.sheet.show{transform:translateY(0)}
.sheet .handle{width:42px;height:4px;border-radius:4px;background:var(--line);margin:4px auto 14px}
.sheet h3{font-size:17px;margin-bottom:4px}
.sheet .close{position:absolute;top:14px;left:16px;color:var(--muted)}
.sheet-actions{display:flex;gap:10px;margin-top:16px}
.sheet-actions .btn{flex:1}

.toast{position:fixed;bottom:calc(var(--tab-h) + 86px + env(safe-area-inset-bottom));left:50%;transform:translate(-50%,20px);
  background:#0D1B16;color:#fff;padding:11px 18px;border-radius:14px;font-size:13.5px;font-weight:600;
  z-index:80;opacity:0;pointer-events:none;transition:.25s;max-width:88%;text-align:center;box-shadow:var(--shadow-lg)}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* ============ onboarding ============ */
.onb{min-height:100dvh;display:flex;flex-direction:column;padding:calc(22px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  max-width:520px;margin:0 auto;background:var(--bg)}
.onb .progress{height:6px;border-radius:6px;background:var(--line);overflow:hidden;margin:14px 0 22px}
.onb .progress > i{display:block;height:100%;background:linear-gradient(90deg,var(--brand),var(--brand-600));border-radius:6px;transition:width .3s}
.onb h1{font-size:26px;letter-spacing:-.4px}
.onb .lead{color:var(--muted);margin-top:6px;font-size:14.5px}
.onb .body{flex:1;padding-top:18px}
.onb .foot{display:flex;gap:10px;padding-top:14px}
.onb .foot .btn{flex:1}
.onb .art{display:grid;place-items:center;margin:26px 0}
.onb .art .blob{width:190px;height:190px;border-radius:50%;display:grid;place-items:center;
  background:radial-gradient(circle at 30% 25%,#34D399,#059669 55%,#065F46);box-shadow:0 24px 50px rgba(5,150,105,.35)}
.onb .art svg{width:96px;height:96px}
.big-num{font-size:40px;font-weight:800;letter-spacing:-1px;line-height:1.1}
.big-num span{font-size:15px;font-weight:700;color:var(--muted);letter-spacing:0}

/* ============ coach ============ */
.chat{display:flex;flex-direction:column;gap:10px;padding-bottom:8px}
.msg{max-width:86%;padding:11px 14px;border-radius:18px;font-size:14px;line-height:1.65;white-space:pre-wrap}
.msg.bot{background:var(--surface);border:1px solid var(--line);border-bottom-right-radius:6px;align-self:flex-start}
.msg.me{background:var(--brand);color:#fff;border-bottom-left-radius:6px;align-self:flex-end}
.fab{position:fixed;bottom:calc(var(--tab-h) + 14px + env(safe-area-inset-bottom));left:calc(50% - 244px + 16px);
  z-index:45;width:54px;height:54px;border-radius:19px;background:linear-gradient(150deg,var(--brand),var(--brand-700));
  color:#fff;display:grid;place-items:center;box-shadow:0 12px 26px rgba(5,150,105,.42)}
.fab svg{width:25px;height:25px}
@media (max-width:540px){.fab{left:16px}}

/* ============ misc ============ */
.badge{display:flex;flex-direction:column;align-items:center;gap:6px;padding:12px 6px;border-radius:16px;
  background:var(--surface-2);border:1px solid var(--line);font-size:11.5px;font-weight:700;text-align:center;opacity:.55}
.badge.got{opacity:1;background:var(--brand-soft);border-color:transparent;color:var(--brand-700)}
[data-theme="dark"] .badge.got{color:#8BE7C3}
.badge .e{font-size:22px}
.demo-tag{background:var(--accent-soft);color:#8A5A00;font-size:10.5px;font-weight:800;padding:2px 7px;border-radius:7px;margin-right:6px}
[data-theme="dark"] .demo-tag{color:#FCD34D}
.list-row{display:flex;align-items:center;gap:12px;padding:13px 0;border-bottom:1px solid var(--line);font-size:14px}
.list-row:last-child{border-bottom:0}
.list-row .ic{width:36px;height:36px;border-radius:11px;background:var(--surface-2);display:grid;place-items:center}
.skeleton{background:linear-gradient(90deg,var(--surface-2),var(--line),var(--surface-2));background-size:200% 100%;
  animation:sk 1.2s infinite;border-radius:12px;height:16px}
@keyframes sk{0%{background-position:200% 0}100%{background-position:-200% 0}}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}

/* ===== v1.1: المزيد والإضافات ===== */
.tab{font-size:10.5px}
.demo-banner{background:var(--accent-soft);color:#8A5A00;border-radius:12px;padding:10px 12px;font-size:13px;font-weight:700}
[data-theme="dark"] .demo-banner{color:#F5C46B}
.mock{margin-top:10px;padding:12px;border:1px dashed var(--line);border-radius:14px;opacity:.75;background:var(--surface-2)}
.ex-anim .f1,.ex-anim .f2{position:absolute;inset:0}
.ex-anim .f2{animation:exf 1.6s steps(1) infinite}
.ex-anim .f1{animation:exf2 1.6s steps(1) infinite}
@keyframes exf{0%{opacity:0}50%{opacity:1}}
@keyframes exf2{0%{opacity:1}50%{opacity:0}}
@media (prefers-reduced-motion:reduce){.ex-anim .f2{animation:none;opacity:0}.ex-anim .f1{animation:none}}
.pill.info{background:var(--info-soft);color:var(--info)}
.sheet-body textarea,.sheet-body input[type=time],.sheet-body input[type=date]{width:100%;padding:10px 12px;border-radius:12px;border:1px solid var(--line);background:var(--surface)}
/* سمات موسمية */
[data-season="ramadan"]{--brand:#C99A2E;--brand-600:#A87A12;--brand-700:#6B4F0E;--brand-soft:#FBF1D6;--bg:#F8F4EA}
[data-season="ramadan"][data-theme="dark"]{--bg:#120E1F;--surface:#1D1730;--surface-2:#241C3B;--brand-soft:#2E2448;--brand:#E0B44A;--line:#33284F}
[data-season="summer"]{--brand:#0EA5E9;--brand-600:#0284C7;--brand-700:#075985;--brand-soft:#E0F4FD;--accent:#F97316;--bg:#F2F8FB}
[data-season="summer"][data-theme="dark"]{--bg:#07131A;--surface:#0E1F29;--surface-2:#122A37;--brand-soft:#0F2C3B}
/* لغة إنجليزية */
html[dir="ltr"] body{font-family:var(--font)}
/* طباعة التقرير */
#print-root{display:none}
@media print{
  body.printing .app,body.printing .scrim,body.printing .sheet,body.printing .toast{display:none!important}
  body.printing #print-root{display:block;font-family:var(--font);color:#000;background:#fff;padding:12mm}
  #print-root table{width:100%;border-collapse:collapse;margin:8px 0}
  #print-root th,#print-root td{border:1px solid #999;padding:4px 6px;font-size:12px;text-align:center}
  #print-root h1{font-size:22px}#print-root h2{font-size:16px;margin-top:14px}
  #print-root .foot{font-size:11px;color:#555;margin-top:16px}
}
