:root {
    --green:   #1f9d55;
    --green-d: #157347;
    --bg:      #f6f8f7;
    --card:    #ffffff;
    --ink:     #1b2a24;
    --muted:   #6b7a72;
    --line:    #e3e9e6;
    --amber:   #c77700;
    --red:     #c0392b;
    --shadow:  0 6px 24px rgba(20, 60, 40, .08);
    --radius:  16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Cairo', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.7;
}

.container { max-width: 760px; margin: 0 auto; padding: 24px 18px 64px; }

/* الهيدر */
.topbar {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 18px; background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.logo { font-weight: 800; font-size: 22px; color: var(--green); }
.logo span { color: var(--ink); }
.tagline { color: var(--muted); font-size: 13px; margin-inline-start: auto; }

/* الكروت */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 20px; }
.card .sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

/* الحقول */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field input, .field select {
    width: 100%; padding: 12px 14px;
    border: 1px solid var(--line); border-radius: 12px;
    font-family: inherit; font-size: 15px; background: #fbfdfc;
}
.field input:focus, .field select:focus { outline: 2px solid var(--green); border-color: var(--green); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
    background: #fbfdfc; cursor: pointer; font-size: 14px; user-select: none;
}
.chip.on { background: var(--green); color: #fff; border-color: var(--green); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* الأزرار */
.btn {
    background: var(--green); color: #fff; border: 0;
    padding: 13px 22px; border-radius: 12px; font-family: inherit;
    font-size: 16px; font-weight: 700; cursor: pointer; transition: .15s;
}
.btn:hover { background: var(--green-d); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--green); border: 1px solid var(--green); }

/* خطوات */
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps i {
    height: 5px; flex: 1; border-radius: 3px; background: var(--line);
}
.steps i.on { background: var(--green); }

/* النتائج */
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.metric { background: #f1f7f3; border-radius: 12px; padding: 14px; text-align: center; }
.metric b { display: block; font-size: 26px; color: var(--green-d); }
.metric span { color: var(--muted); font-size: 13px; }

.banner { padding: 14px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.banner.approved     { background: #e7f6ee; color: var(--green-d); border: 1px solid #bfe6cf; }
.banner.needs_review { background: #fff5e6; color: var(--amber);  border: 1px solid #f3dca8; }
.banner.blocked      { background: #fdecea; color: var(--red);    border: 1px solid #f5c6bf; }

.reasons { margin: 8px 0 0; padding-inline-start: 20px; color: var(--ink); font-weight: 400; }
.reasons li { margin-bottom: 6px; }

.disclaimer {
    font-size: 13px; color: var(--muted); background: #f3f5f4;
    border-radius: 10px; padding: 12px 14px; margin-top: 16px;
}
.error { color: var(--red); font-size: 14px; margin-top: 8px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.ok-msg { color: var(--green-d); font-size: 13px; margin-top: 6px; }
.tagline { text-decoration: none; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-family: inherit; font-size: 13px; text-decoration: underline; }

/* ملاحظة الالتزام */
.adherence-note {
    background: #eef6f1; border: 1px solid #cfe7da; border-radius: 12px;
    padding: 12px 14px; font-size: 14px; margin-top: 14px; color: var(--green-d);
}

/* منحنى الوزن */
.chart { width: 100%; height: auto; background: #f7faf8; border-radius: 12px; margin-top: 6px; }

/* خطة الأكل */
.day-block { margin-bottom: 16px; }
.day-block h3 { margin: 0 0 8px; font-size: 16px; color: var(--green-d); }
.meal-row {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    background: #fbfdfc; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px;
}
.meal-tag {
    background: var(--green); color: #fff; border-radius: 8px; padding: 2px 9px;
    font-size: 12px; white-space: nowrap;
}
.meal-name { flex: 1; font-size: 14px; }
.meal-cal { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* الشات */
.chat-card { display: flex; flex-direction: column; }
.chat-box {
    background: #f7faf8; border: 1px solid var(--line); border-radius: 12px;
    padding: 14px; height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
    margin-bottom: 12px;
}
.bubble { max-width: 80%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.6; }
.bubble.me { align-self: flex-start; background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.bubble.coach { align-self: flex-end; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font-family: inherit; font-size: 15px; }

/* Health ring */
.ring-wrap { display: flex; align-items: center; gap: 14px; margin: 6px 0 14px; }
.ring { width: 116px; height: 116px; flex-shrink: 0; }
.ring-num { font-size: 30px; font-weight: 800; }
.ring-lbl { font-size: 9px; fill: var(--muted); }
.ring-side b { display: block; font-size: 18px; margin-bottom: 4px; }
.ring-side span { font-size: 13px; color: var(--muted); line-height: 1.6; }

/* شارات الإنجاز */
.ach-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.ach-badge { background: #fff5e6; color: var(--amber); border: 1px solid #f3dca8; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; }

/* درس اليوم */
.lesson-card { background: linear-gradient(160deg,#f1f7f3,#eaf6ef); border: 1px solid #cfe7da; border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.lesson-card.done { text-align: center; font-weight: 700; color: var(--green-d); }
.lesson-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.lesson-cat { color: var(--green-d); font-weight: 700; }
.lesson-card h3 { margin: 0 0 10px; font-size: 17px; }
.lesson-body { font-size: 14px; line-height: 1.9; color: var(--ink); margin: 0 0 12px; }

/* بحث الأكل */
.search-box { display: flex; gap: 6px; align-items: stretch; }
.search-box input { flex: 1; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font-family: inherit; font-size: 15px; background: #fbfdfc; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 12px; width: 46px; font-size: 20px; cursor: pointer; }
.icon-btn:hover { border-color: var(--green); }
.search-results { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 4px; }
.food-result { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.food-result:last-child { border-bottom: 0; }
.food-result:hover { background: #f7faf8; }
.dot2 { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.food-name { font-size: 14px; font-weight: 600; }
.add-plus { font-size: 22px; color: var(--green); font-weight: 700; }

/* تاجز */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag { background: #eef2f0; color: var(--ink); border-radius: 999px; padding: 3px 11px; font-size: 12px; }
.tag.on { background: var(--green); color: #fff; }

/* خريطة العضلات */
.muscle-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.muscle-cell { border: 2px solid var(--line); border-radius: 12px; padding: 10px 8px; text-align: center; background: #fff; }
.muscle-name { font-weight: 700; font-size: 14px; }
.muscle-status { font-size: 12px; margin-top: 2px; }

/* صف التمرين */
.ex-row { border-bottom: 1px solid var(--line); padding: 4px 0; }
.ex-video { text-decoration: none; font-size: 15px; color: var(--red); padding: 2px 6px; }
.ex-log-btn { background: none; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 15px; padding: 2px 8px; }
.ex-log { display: flex; gap: 6px; padding: 8px 4px; }
.ex-log input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 14px; min-width: 0; }
.ex-res { font-size: 13px; background: #f1f7f3; border-radius: 8px; padding: 8px 10px; margin: 4px 0 8px; color: var(--green-d); }
.ex-res.pr { background: #fff5e6; color: var(--amber); }

/* كروت البرامج */
.prog-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; cursor: pointer; background: #fbfdfc; transition: .15s; }
.prog-card:hover { border-color: var(--green); }
.prog-card.active { border-color: var(--green); background: #f1f7f3; }
.prog-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* شبكة الصور */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 16px; }
.photo-item { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #f4f4f4; }
.photo-item img { width: 100%; height: 150px; object-fit: cover; display: block; }
.photo-cap { display: flex; justify-content: space-between; padding: 6px 8px; font-size: 12px; font-weight: 700; color: var(--green-d); }
.photo-cap span { color: var(--muted); font-weight: 400; }

/* المياه */
.water { background: #eef6fb; border: 1px solid #cfe4f2; border-radius: 12px; padding: 14px; margin-top: 16px; }
.water-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; }
.water-top b { color: #1c6ea4; }
.cups { display: flex; gap: 4px; justify-content: center; margin-bottom: 10px; }
.cup { font-size: 22px; filter: grayscale(1) opacity(.4); cursor: pointer; transition: .1s; }
.cup.on { filter: none; }
.water-btns { display: flex; gap: 8px; justify-content: center; }

/* الناف السفلي */
.bottom-nav {
    position: sticky; bottom: 0; display: flex; background: var(--card);
    border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(20,60,40,.06);
}
.bottom-nav button {
    flex: 1; background: none; border: 0; padding: 10px 4px; cursor: pointer;
    font-family: inherit; font-size: 12px; color: var(--muted);
    display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bottom-nav button span { font-size: 20px; }
.bottom-nav button.on { color: var(--green); font-weight: 700; }

/* لوحة الرقابة */
.review-item {
    background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 12px;
}
.review-item .kind { font-size: 12px; padding: 3px 10px; border-radius: 999px; display: inline-block; margin-bottom: 8px; }
.kind.safety_gate { background: #fff5e6; color: var(--amber); }
.kind.escalation { background: #fdecea; color: var(--red); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

/* ===== الصفحة الرئيسية (Landing) ===== */
.landing { max-width: 100%; }
.hero {
    text-align: center; padding: 54px 20px 44px;
    background: linear-gradient(160deg, #eaf6ef 0%, #f6f8f7 60%);
    border-bottom: 1px solid var(--line);
}
.brand-huge { font-weight: 800; font-size: 40px; color: var(--green); margin-bottom: 18px; }
.brand-huge span { color: var(--ink); }
.hero h1 { font-size: 27px; line-height: 1.5; margin: 0 auto 14px; max-width: 620px; }
.hero p { color: var(--muted); font-size: 16px; max-width: 560px; margin: 0 auto 24px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn.big { padding: 15px 30px; font-size: 17px; }
.hero-badges { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 22px; color: var(--muted); font-size: 14px; }

.lsec { padding: 44px 20px; max-width: 900px; margin: 0 auto; }
.lsec.alt { background: #fbfdfc; max-width: 100%; }
.lsec.alt > * { max-width: 900px; margin-inline: auto; }
.lsec-title { text-align: center; font-size: 24px; margin: 0 0 28px; }

.feat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.feat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.feat-icon { font-size: 34px; margin-bottom: 10px; }
.feat-t { font-weight: 700; font-size: 17px; margin-bottom: 6px; }
.feat-d { color: var(--muted); font-size: 14px; line-height: 1.7; }

.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.step-card { text-align: center; padding: 22px; }
.step-num { width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center; }

.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; max-width: 640px; margin: 0 auto; }
.plan-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; text-align: center; position: relative; box-shadow: var(--shadow); }
.plan-card.featured { border-color: var(--green); border-width: 2px; }
.plan-badge { position: absolute; top: -12px; inset-inline-start: 50%; transform: translateX(50%); background: var(--green); color: #fff; font-size: 12px; padding: 3px 14px; border-radius: 999px; }
.plan-name { font-weight: 700; font-size: 18px; }
.plan-price { font-size: 26px; font-weight: 800; color: var(--green-d); margin: 8px 0 14px; }
.plan-card ul { list-style: none; padding: 0; margin: 0 0 18px; text-align: start; }
.plan-card li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.plan-card li::before { content: '✓ '; color: var(--green); font-weight: 700; }

.lcta { text-align: center; padding: 48px 20px; background: linear-gradient(160deg, #1f9d55 0%, #157347 100%); color: #fff; }
.lcta h2 { font-size: 24px; margin: 0 0 20px; }
.lcta .btn { background: #fff; color: var(--green-d); }
.lcta .btn:hover { background: #f0f0f0; }
.lfoot { text-align: center; padding: 22px; color: var(--muted); font-size: 13px; }

/* شاشة الدخول */
.auth-card { max-width: 420px; margin: 32px auto; }
.brand-big { font-weight: 800; font-size: 34px; color: var(--green); text-align: center; }
.brand-big span { color: var(--ink); }
.tabs2 { display: flex; gap: 6px; margin: 16px 0; background: #eef2f0; border-radius: 12px; padding: 4px; }
.tabs2 button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 9px; font-family: inherit; font-size: 15px; cursor: pointer; color: var(--muted); }
.tabs2 button.on { background: #fff; color: var(--green-d); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.btn.sm { padding: 7px 12px; font-size: 13px; }

/* فريق الأجينتس */
.agent-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: #fbfdfc; }
.agent-icon { font-size: 26px; }
.agent-name { font-weight: 700; }
.agent-desc { font-size: 13px; color: var(--muted); }
.agent-last { font-size: 12px; margin-top: 4px; color: var(--green-d); }
.agent-last.alert { color: var(--red); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }

/* لوحة المراقبة — صحة النظام */
.health-head { display: flex; align-items: center; gap: 14px; }
.health-emoji { font-size: 34px; }
.health-title { font-size: 20px; font-weight: 800; }
.card.health-healthy  { border-color: #bfe6cf; }
.card.health-warning  { border-color: #f3dca8; }
.card.health-critical { border-color: #f5c6bf; }

/* تنبيهات */
.alert-row { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.alert-sev { font-size: 18px; }

/* سجل نشاط الأجينتس */
.log-feed { max-height: 380px; overflow-y: auto; }
.log-line { display: flex; gap: 8px; align-items: baseline; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.log-line.alert { background: #fdecea; }
.log-line.warn { background: #fff8ee; }
.log-agent { background: var(--green); color: #fff; border-radius: 6px; padding: 1px 8px; font-size: 11px; white-space: nowrap; }
.log-line.alert .log-agent { background: var(--red); }
.log-action { color: var(--muted); font-size: 12px; }
.log-summary { flex: 1; min-width: 140px; }
.log-time { font-size: 11px; white-space: nowrap; }

.user-row { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }

/* ===== تخطيط الديسك توب (Sidebar + لوحة عريضة) ===== */
.sidebar { display: none; }
.side-link { text-decoration: none; }

@media (min-width: 900px) {
    .topbar { padding: 16px 32px; }
    .dash { display: flex; gap: 26px; max-width: 1240px; margin: 0 auto; padding: 26px 32px 48px; align-items: flex-start; }
    .sidebar {
        display: flex; flex-direction: column; width: 236px; flex-shrink: 0;
        position: sticky; top: 88px; background: var(--card); border: 1px solid var(--line);
        border-radius: 18px; box-shadow: var(--shadow); padding: 14px;
    }
    .side-nav { display: flex; flex-direction: column; gap: 4px; }
    .sidebar button, .side-link {
        display: flex; align-items: center; gap: 13px; width: 100%; text-align: start;
        background: none; border: 0; padding: 13px 15px; border-radius: 12px;
        font-family: inherit; font-size: 15px; color: var(--muted); cursor: pointer;
    }
    .sidebar button span { font-size: 21px; width: 26px; }
    .sidebar button:hover, .side-link:hover { background: #f4f7f5; }
    .sidebar button.on { background: #eef6f1; color: var(--green-d); font-weight: 800; }
    .side-link { color: var(--muted); font-size: 14px; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 14px; border-radius: 0; }
    .side-logout { color: var(--red) !important; margin-top: 4px; }

    .main { flex: 1; min-width: 0; }
    .main .container { max-width: 900px; padding: 0; margin: 0 auto; }

    .bottom-nav { display: none; }
    .mob-logout { display: none; }

    /* الشات أطول على الشاشة الكبيرة */
    .chat-box { height: 460px; }
    /* لوحة المراقبة: أعمدة على الديسك توب */
    body.admin .container { max-width: 1100px; }
    body.admin .container > .card { break-inside: avoid; }
}

/* شاشات كبيرة جداً: لوحة المراقبة عمودين */
@media (min-width: 1100px) {
    body.admin .container { columns: 2; column-gap: 22px; }
    body.admin .container > * { break-inside: avoid; margin-bottom: 22px; }
}
