:root {
    --teal: #0d9488;
    --teal-dark: #0f766e;
    --teal-light: #14b8a6;
    --emerald: #10b981;
    --mint: #34d399;
    --ink: #0f172a;
    --slate: #1e293b;
    --muted: #64748b;
    --bg: #f6faf9;
    --card: #ffffff;
    --line: #e6eeec;
    --grad: linear-gradient(135deg, #0d9488 0%, #10b981 55%, #34d399 100%);
    --grad-dark: linear-gradient(150deg, #0f766e 0%, #0b3b38 100%);
    --shadow-sm: 0 1px 3px rgba(15,23,42,.06);
    --shadow: 0 10px 30px rgba(13,148,136,.12);
    --shadow-lg: 0 24px 60px rgba(13,148,136,.18);
}

* { font-family: 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif; box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); margin: 0; }
h1:focus { outline: none; }
.validation-message { color: #e11d48; }

/* ===== Animations ===== */
@keyframes fadeUp { from { opacity:0; transform: translateY(18px); } to { opacity:1; transform:none; } }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes blob { 0%,100% { border-radius: 42% 58% 60% 40%/45% 45% 55% 55%; } 50% { border-radius: 58% 42% 40% 60%/55% 60% 40% 45%; } }
@keyframes shimmer { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
@keyframes pop { from { transform: scale(.96); opacity:0; } to { transform: scale(1); opacity:1; } }
.fade-up { animation: fadeUp .6s ease both; }

/* ===== التخطيط (لوحة التطبيق) ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 256px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
    background: var(--grad-dark); color: #d6f5ef; display: flex; flex-direction: column;
    box-shadow: 4px 0 30px rgba(11,59,56,.25); z-index: 30;
}
.sidebar .brand {
    padding: 22px 20px; font-size: 1.3rem; font-weight: 900; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.1); letter-spacing: .5px;
}
.sidebar .brand .logo { font-size: 1.7rem; filter: drop-shadow(0 2px 6px rgba(0,0,0,.3)); }
.sidebar nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.sidebar .nav-link {
    color: #c9efe8; border-radius: 12px; padding: 12px 15px; margin: 4px 0; display: flex; align-items: center; gap: 11px;
    font-weight: 600; transition: .2s; text-decoration: none; position: relative;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.12); color: #fff; transform: translateX(-3px); }
.sidebar .nav-link.active { background: #fff; color: var(--teal-dark); box-shadow: 0 6px 18px rgba(0,0,0,.18); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    background: rgba(255,255,255,.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
    padding: 13px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20;
}
.topbar .user { display: flex; align-items: center; gap: 12px; }
.topbar .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; box-shadow: var(--shadow); }
.content { padding: 26px; flex: 1; }
.content > * { animation: fadeUp .5s ease both; }

/* ===== البطاقات ===== */
.card-c {
    background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 22px;
    box-shadow: var(--shadow-sm); transition: .25s;
}
.card-c:hover { box-shadow: var(--shadow); }
.page-title { font-weight: 800; font-size: 1.6rem; margin: 0 0 20px; letter-spacing: -.5px; }
.page-title::after { content: ""; display: block; width: 54px; height: 4px; border-radius: 4px; background: var(--grad); margin-top: 8px; }

/* بطاقات الإحصائيات */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px;
    position: relative; overflow: hidden; transition: .25s; animation: pop .4s ease both;
}
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--grad); }
.stat:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.stat .ic { font-size: 1.9rem; filter: drop-shadow(0 4px 8px rgba(13,148,136,.25)); }
.stat .val { font-size: 2rem; font-weight: 900; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat .lbl { color: var(--muted); font-weight: 600; font-size: .92rem; }

/* أزرار */
.btn-teal { background: var(--grad); border: none; color: #fff; font-weight: 700; box-shadow: 0 8px 20px rgba(13,148,136,.3); transition: .2s; }
.btn-teal:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 12px 28px rgba(13,148,136,.4); }
.btn { border-radius: 12px; }

/* جداول */
.table thead th { background: #f0fdfa; color: var(--teal-dark); font-weight: 700; border-bottom: 2px solid var(--line); }
.table td { vertical-align: middle; }
.table tbody tr { transition: .15s; }
.table tbody tr:hover { background: #f0fdfa; }

/* شارات */
.badge-soft { padding: 5px 12px; border-radius: 20px; font-weight: 700; font-size: .8rem; }
.b-green { background: #d1fae5; color: #065f46; }
.b-amber { background: #fef3c7; color: #92400e; }
.b-red { background: #fee2e2; color: #991b1b; }
.b-blue { background: #dbeafe; color: #1e40af; }
.b-gray { background: #eef2f5; color: #475569; }

/* ===== الدخول (زجاجي) ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden;
    background: radial-gradient(circle at 15% 20%, #10b981 0%, transparent 45%), radial-gradient(circle at 85% 80%, #0d9488 0%, transparent 45%), #0b1f1d; padding: 20px; }
.login-wrap::before, .login-wrap::after { content: ""; position: absolute; width: 420px; height: 420px; background: var(--grad); opacity: .35; filter: blur(20px); animation: blob 14s ease-in-out infinite, floaty 10s ease-in-out infinite; }
.login-wrap::before { top: -120px; right: -100px; }
.login-wrap::after { bottom: -140px; left: -120px; animation-delay: -4s; }
.login-box { position: relative; z-index: 2; background: rgba(255,255,255,.95); backdrop-filter: blur(16px); border: 1px solid rgba(255,255,255,.6);
    border-radius: 26px; padding: 42px 36px; width: 100%; max-width: 410px; box-shadow: 0 30px 80px rgba(0,0,0,.4); text-align: center; animation: pop .5s ease both; }
.login-box .logo { font-size: 3.4rem; filter: drop-shadow(0 6px 14px rgba(13,148,136,.4)); }
.login-box h2 { font-weight: 900; margin: 10px 0 2px; font-size: 2rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.login-box .sub { color: var(--muted); margin-bottom: 24px; }
.login-box .form-control { padding: 13px 15px; border-radius: 12px; border: 1.5px solid #e2e8f0; transition: .2s; }
.login-box .form-control:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(13,148,136,.12); }
.login-error { background: #fee2e2; color: #991b1b; padding: 11px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }

/* ===== صفحة الهبوط (Landing) ===== */
.lp { color: var(--ink); overflow-x: hidden; }
.lp-nav { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
    padding: 16px 6vw; background: rgba(246,250,249,.8); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.lp-nav .brand { font-weight: 900; font-size: 1.5rem; display: flex; align-items: center; gap: 8px; color: var(--teal-dark); }
.lp-nav .brand .logo { font-size: 1.8rem; }
.lp-nav .links { display: flex; gap: 10px; align-items: center; }
.lp-btn { padding: 11px 22px; border-radius: 12px; font-weight: 700; text-decoration: none; transition: .2s; border: none; cursor: pointer; display: inline-block; }
.lp-btn.solid { background: var(--grad); color: #fff; box-shadow: 0 10px 24px rgba(13,148,136,.32); }
.lp-btn.solid:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(13,148,136,.42); color:#fff; }
.lp-btn.ghost { background: #fff; color: var(--teal-dark); border: 1.5px solid var(--line); }
.lp-btn.ghost:hover { border-color: var(--teal); color: var(--teal-dark); }

.hero { position: relative; padding: 70px 6vw 90px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
.hero::before { content: ""; position: absolute; top: -80px; left: -100px; width: 520px; height: 520px; background: var(--grad); opacity: .14; filter: blur(10px); animation: blob 16s ease-in-out infinite; z-index: 0; }
.hero-text { position: relative; z-index: 2; animation: fadeUp .7s ease both; }
.hero .pill { display: inline-block; background: #d1fae5; color: #065f46; padding: 7px 16px; border-radius: 30px; font-weight: 700; font-size: .9rem; margin-bottom: 18px; }
.hero h1 { font-size: 3.2rem; font-weight: 900; line-height: 1.2; margin: 0 0 18px; letter-spacing: -1px; }
.hero h1 .grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { font-size: 1.2rem; color: var(--muted); line-height: 1.9; margin: 0 0 28px; max-width: 540px; }
.hero .cta { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-visual { position: relative; z-index: 2; display: grid; place-items: center; animation: fadeUp .9s ease both; }
.hero-card { background: #fff; border-radius: 28px; box-shadow: var(--shadow-lg); padding: 26px; width: 100%; max-width: 380px; animation: floaty 6s ease-in-out infinite; border: 1px solid var(--line); }
.hero-card .hc-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.hero-card .hc-avatar { width: 52px; height: 52px; border-radius: 16px; background: var(--grad); display: grid; place-items: center; font-size: 1.6rem; }
.hero-card .hc-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.hero-card .hc-row span:last-child { font-weight: 800; color: var(--teal-dark); }
.hero-mini { position: absolute; background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 14px 18px; font-weight: 800; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); }
.hero-mini.m1 { top: 6%; left: -4%; animation: floaty 5s ease-in-out infinite; }
.hero-mini.m2 { bottom: 4%; right: -2%; animation: floaty 7s ease-in-out infinite reverse; }
.hero-mini .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(52,211,153,.25); }

.section { padding: 70px 6vw; }
.section-title { text-align: center; font-size: 2.2rem; font-weight: 900; margin: 0 0 8px; letter-spacing: -.5px; }
.section-sub { text-align: center; color: var(--muted); font-size: 1.1rem; margin: 0 0 44px; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; }
.feat { background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 28px; transition: .25s; }
.feat:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: transparent; }
.feat .fi { width: 58px; height: 58px; border-radius: 16px; background: #d1fae5; display: grid; place-items: center; font-size: 1.7rem; margin-bottom: 16px; }
.feat h3 { font-weight: 800; font-size: 1.25rem; margin: 0 0 8px; }
.feat p { color: var(--muted); line-height: 1.8; margin: 0; }

.steps-wrap { background: var(--grad-dark); border-radius: 32px; padding: 56px 6vw; color: #fff; margin: 0 6vw; }
.steps-wrap .section-title, .steps-wrap .section-sub { color: #fff; }
.steps-wrap .section-sub { color: #b9e8e0; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; }
.step { text-align: center; }
.step .num { width: 64px; height: 64px; border-radius: 20px; background: rgba(255,255,255,.14); display: grid; place-items: center; font-size: 1.6rem; font-weight: 900; margin: 0 auto 16px; border: 1px solid rgba(255,255,255,.25); }
.step h4 { font-weight: 800; margin: 0 0 6px; }
.step p { color: #b9e8e0; line-height: 1.7; margin: 0; }

.cta-band { text-align: center; padding: 80px 6vw; }
.cta-band h2 { font-size: 2.4rem; font-weight: 900; margin: 0 0 14px; }
.cta-band p { color: var(--muted); font-size: 1.15rem; margin: 0 0 28px; }
.lp-foot { text-align: center; padding: 36px; color: var(--muted); border-top: 1px solid var(--line); }

@media (max-width: 900px) {
    .hero { grid-template-columns: 1fr; text-align: center; padding-top: 40px; }
    .hero p { margin-inline: auto; }
    .hero .cta { justify-content: center; }
    .hero h1 { font-size: 2.4rem; }
    .lp-nav .links .hide-sm { display: none; }
}

@media (max-width: 1199.98px) {
    .sidebar { position: fixed; right: 0; transform: translateX(100%); transition: transform .25s ease; }
    .sidebar.open { transform: translateX(0); }
}
@media print { .sidebar, .topbar, .no-print { display: none !important; } .content { padding: 0; } body { background: #fff; } }

/* ===== ألوان الأطباء (ثابتة لكل طبيب) ===== */
.dc-0 { --dc: #0d9488; } .dc-1 { --dc: #2563eb; } .dc-2 { --dc: #f97316; } .dc-3 { --dc: #7c3aed; }
.dc-4 { --dc: #db2777; } .dc-5 { --dc: #ca8a04; } .dc-6 { --dc: #0891b2; } .dc-7 { --dc: #64748b; }

/* ===== الاستقبال ===== */
.rc-wrap { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }
.rc-search { border-radius: 14px; font-size: 1.15rem; }
.rc-matches { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.rc-chip { border: 1.5px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 12px; font-weight: 700; cursor: pointer; }
.rc-chip small { color: var(--muted); margin-inline-start: 6px; }
.rc-chip.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.rc-chip.on small { color: #d1fae5; }
.rc-picked { background: #f0fdfa; border-radius: 12px; padding: 10px 12px; font-weight: 700; margin-top: 8px; }
.rc-docs { display: flex; flex-wrap: wrap; gap: 8px; }
.rc-doc { border: 2px solid var(--dc); color: var(--dc); background: #fff; border-radius: 14px; padding: 10px 14px; font-weight: 800; cursor: pointer; transition: .15s; }
.rc-doc.on { background: var(--dc); color: #fff; box-shadow: 0 8px 18px rgba(0,0,0,.15); }
.rc-go { font-size: 1.3rem; padding: 14px; }
.rc-result { margin-top: 12px; display: flex; align-items: center; gap: 14px; background: var(--dc); color: #fff; border-radius: 16px; padding: 12px 16px; animation: pop .35s ease both; }
.rc-num { font-size: 2.6rem; font-weight: 900; line-height: 1; }
.rc-pay { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.rc-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.rc-col { background: #fff; border: 1px solid var(--line); border-top: 6px solid var(--dc); border-radius: 18px; padding: 14px; }
.rc-col-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; color: var(--dc); }
.rc-col-count { font-size: .78rem; color: var(--muted); font-weight: 600; }
.rc-current { background: #f8fafc; border-radius: 12px; padding: 10px; margin: 10px 0; display: flex; align-items: center; gap: 10px; min-height: 58px; }
.rc-cur-num { font-size: 2rem; font-weight: 900; color: var(--dc); }
.rc-cur-name { font-weight: 800; }
.rc-next { background: var(--dc); color: #fff; font-weight: 700; border: none; }
.rc-wait { margin-top: 8px; max-height: 260px; overflow-y: auto; }
.rc-w { padding: 5px 8px; border-bottom: 1px dashed var(--line); font-size: .95rem; }
.rc-w b { display: inline-block; min-width: 28px; color: var(--dc); }

/* ===== مكتب الطبيب ===== */
.dk-top { display: flex; gap: 22px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 18px; margin-bottom: 14px; font-weight: 600; }
.dk-top b { color: var(--teal-dark); font-size: 1.15rem; }
.dk-wrap { display: grid; grid-template-columns: 240px 1fr 1.1fr; gap: 16px; align-items: start; }
.dk-cur { background: #f0fdfa; border-radius: 12px; padding: 10px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.dk-alert { background: #fee2e2; color: #7f1d1d; border: 1.5px solid #fca5a5; border-radius: 12px; padding: 10px 12px; font-size: 1rem; line-height: 1.8; }
.dk-visit { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .93rem; }
.dk-rx { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 8px; align-items: center; margin-bottom: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: #fbfefe; }
.dk-rx > :first-child { grid-column: 1 / -1; }
.dk-rx > button { grid-column: 1 / -1; justify-self: stretch; min-height: 44px; }

/* ===== شاشة الانتظار (TV) ===== */
.bd-wrap { min-height: 100vh; background: #0b1f1d; color: #fff; padding: 24px; }
.bd-head { display: flex; justify-content: space-between; font-size: 1.6rem; font-weight: 900; margin-bottom: 18px; }
.bd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.bd-col { background: var(--dc); border-radius: 26px; padding: 26px; text-align: center; }
.bd-doc { font-size: 1.7rem; font-weight: 900; }
.bd-label { opacity: .85; margin-top: 10px; }
.bd-num { font-size: 7rem; font-weight: 900; line-height: 1; }
.bd-name { font-size: 1.5rem; font-weight: 800; min-height: 2.2rem; }
.bd-wait { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.bd-chip { background: rgba(255,255,255,.22); border-radius: 12px; padding: 6px 14px; font-weight: 800; font-size: 1.2rem; }


/* ══════════════════════════════════════════════════════════════
   طبقة الموبايل/التاب — أولاً (تُطبَّق فوق ما سبق)
   ══════════════════════════════════════════════════════════════ */


/* زر القائمة: هدف لمس كبير */
.nav-toggle {
    font-size: 1.5rem; line-height: 1; min-width: 48px; min-height: 48px;
    border: 1px solid var(--line); background: #fff; border-radius: 14px; color: var(--teal-dark);
}
.nav-toggle:active { background: #e6fffb; transform: scale(.96); }

/* طبقة تعتيم خلف القائمة المنزلقة */
.nav-scrim {
    position: fixed; inset: 0; background: rgba(8,32,30,.5); backdrop-filter: blur(2px);
    z-index: 29; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.nav-scrim.on { opacity: 1; pointer-events: auto; }
body.nav-open { overflow: hidden; }

/* ===== أهداف لمس آمنة + منع تكبير iOS التلقائي ===== */
@media (max-width: 1199.98px) {
    .form-control, .form-select, .form-control-sm, .form-select-sm,
    input, select, textarea { font-size: 16px; }
    .form-control, .form-select, .form-control-sm, .form-select-sm { min-height: 46px; padding: .55rem .75rem; }
    textarea.form-control { min-height: 84px; }

    .btn { min-height: 46px; padding-inline: 16px; }
    .btn-sm { min-height: 42px; font-size: .95rem; }
    .btn-lg { min-height: 56px; font-size: 1.15rem; }

    .sidebar .nav-link { padding: 15px 16px; font-size: 1.05rem; }
    .content { padding: 16px; }
    .card-c { padding: 16px; border-radius: 18px; }
    .page-title { font-size: 1.35rem; margin-bottom: 14px; }
    .topbar { padding: 10px 14px; }
    .stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .stat { padding: 14px; }
    .stat .val { font-size: 1.6rem; }

    /* لا اعتماد على hover باللمس */
    .card-c:hover, .stat:hover, .btn-teal:hover { transform: none; }
    .btn-teal:active, .rc-doc:active, .rc-chip:active { transform: scale(.97); }
}

/* ===== الجداول: تمرير داخل البطاقة لا كسر الصفحة ===== */
.table-responsive { -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) { .hide-phone { display: none !important; } }

/* ═══════════ الاستقبال: تاب/هاتف ═══════════ */
@media (max-width: 1100px) {
    .rc-wrap { grid-template-columns: 1fr; gap: 14px; }
    .rc-search { font-size: 1.2rem; min-height: 56px; }
    .rc-chip { min-height: 48px; font-size: 1rem; padding: 10px 16px; }
    .rc-doc { min-height: 56px; font-size: 1.05rem; flex: 1 1 45%; }
    .rc-go { font-size: 1.35rem; min-height: 62px; }
    .rc-num { font-size: 3rem; }
    .rc-next { min-height: 52px !important; font-size: 1.05rem; }

    /* لوحة الطوابير: صفوف رأسية — كل الأطباء مرئيون بلا إيماءة */
    .rc-board { display: grid; grid-template-columns: 1fr; gap: 12px; overflow: visible; }
    .rc-col { flex: none; }
    .rc-wait { max-height: none; }
    .rc-w { padding: 10px 8px; font-size: 1.02rem; }
}

/* ═══════════ مكتب الطبيب: تاب/هاتف ═══════════ */
@media (max-width: 1400px) {
    .dk-wrap { grid-template-columns: 230px 1fr; }
    .dk-form { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
    .dk-wrap { grid-template-columns: 1fr; gap: 12px; }
    .dk-top { gap: 10px 18px; font-size: .95rem; padding: 10px 14px; }
    .dk-alert { font-size: 1.05rem; }
}

/* شريط الإجراء الأساسي ملتصق بالأسفل (تحت الإبهام) */
@media (max-width: 900px) {
    .sticky-action {
        position: sticky; bottom: 0; z-index: 10; margin: 12px -16px -16px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
        background: rgba(255,255,255,.94); backdrop-filter: blur(10px);
        border-top: 1px solid var(--line);
    }
    .sticky-action .btn { width: 100%; }
}

/* ═══════════ شاشة الانتظار على تاب ═══════════ */
@media (max-width: 900px) {
    .bd-grid { grid-template-columns: 1fr; gap: 14px; }
    .bd-num { font-size: 5rem; }
    .bd-col { padding: 18px; }
}

/* ═══════════ إعادة الاتصال (بديل عربي لمربّع Blazor) ═══════════ */
#components-reconnect-modal { display: none; }
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: grid; place-items: center; position: fixed; inset: 0; z-index: 2000;
    background: rgba(8,32,30,.72); backdrop-filter: blur(6px); padding: 22px;
}
.rc-modal-card {
    background: #fff; border-radius: 22px; padding: 30px 24px; max-width: 380px; width: 100%;
    text-align: center; box-shadow: 0 30px 70px rgba(0,0,0,.4);
}
.rc-modal-card .ic { font-size: 3rem; }
.rc-modal-card h3 { font-weight: 900; color: var(--teal-dark); margin: 10px 0 6px; font-size: 1.3rem; }
.rc-modal-card p { color: var(--muted); margin: 0; line-height: 1.9; }
.rc-spin {
    width: 42px; height: 42px; margin: 14px auto 0; border-radius: 50%;
    border: 4px solid #d1fae5; border-top-color: var(--teal); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* رسائل تتبدّل حسب حالة Blazor */
.only-retry, .only-failed { display: none; }
.components-reconnect-show .only-retry { display: block; }
.components-reconnect-failed .only-failed,
.components-reconnect-rejected .only-failed { display: block; }
.components-reconnect-failed .only-retry,
.components-reconnect-rejected .only-retry { display: none; }
.components-reconnect-failed .rc-spin,
.components-reconnect-rejected .rc-spin { display: none; }

/* ═══════════ زر تثبيت التطبيق ═══════════ */
.install-btn {
    display: none; align-items: center; gap: 6px; background: var(--grad); color: #fff;
    border: 0; border-radius: 12px; padding: 9px 14px; font-weight: 700; min-height: 44px;
}
.install-btn.show { display: inline-flex; }

/* ══════════════════════════════════════════════════════════
   طبقة الإنقاذ (من تحكيم فريق الخبراء)
   ══════════════════════════════════════════════════════════ */

/* ١) منع السحب-للتحديث الذي يقتل دائرة Blazor ويضيّع الكشف المكتوب */
html, body { overscroll-behavior-y: contain; }
.rc-wait, .table-responsive, .sidebar nav { overscroll-behavior: contain; }

/* ٢) لمس فوري بلا تأخير ٣٠٠ مللي وبلا وميض أزرق */
* { -webkit-tap-highlight-color: transparent; }
.btn, .rc-chip, .rc-doc, .rc-w, .nav-link, .nav-toggle, .install-btn { touch-action: manipulation; }

/* ٣) ارتفاعات ديناميكية: شريط سفاري المتحرّك كان يقصّ آخر رابط بالقائمة */
@supports (height: 100dvh) {
    .app-shell  { min-height: 100dvh; }
    .sidebar    { height: 100dvh; }
    .login-wrap { min-height: 100dvh; }
    .bd-wrap    { min-height: 100dvh; }
}
.sidebar nav { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }

/* ٤) منطقة الأمان في مكانها الصحيح (بدل body) */
.topbar     { padding-top: calc(13px + env(safe-area-inset-top, 0px)); }
.content    { padding-bottom: calc(26px + env(safe-area-inset-bottom, 0px)); }
.login-wrap { padding-top: calc(20px + env(safe-area-inset-top, 0px));
              padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.bd-wrap    { padding-top: calc(24px + env(safe-area-inset-top, 0px));
              padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }

/* ٥) السبب الجذري للفيضان الأفقي: أبناء الشبكات لا تنكمش تحت عرض محتواها */
.rc-wrap > *, .dk-wrap > *, .rc-board > *, .bd-grid > *, .stat-grid > *, .card-c { min-width: 0; }
.dk-top { flex-wrap: wrap; }

/* ٦) الأرقام لا ترتجف مع كل تحديث */
.rc-num, .rc-cur-num, .bd-num, .bd-chip, .stat .val, .dk-top b {
    font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
}

/* ٧) ارتداد فوري عند الضغط: يعوّض تأخير SignalR ويمنع النقر المزدوج */
.btn:active, .rc-chip:active, .rc-doc:active, .rc-next:active, .rc-w:active, .nav-link:active {
    transform: scale(.97); filter: brightness(.95); transition: transform .05s ease;
}
@media (hover: none) {
    .sidebar .nav-link:hover, .feat:hover, .lp-btn.solid:hover { transform: none; }
    .table tbody tr:hover { background: transparent; }
}

/* ٨) أداء التابات الرخيصة */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important; animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
@media (max-width: 1199.98px) {
    .login-wrap::before, .login-wrap::after { animation: none; filter: blur(40px); opacity: .28; }
    .topbar { backdrop-filter: none; background: #fff; }
    .content > * { animation: none; }
}

/* ٩) مكتب الطبيب: تحذير الحساسية قبل الطابور — خطر سريري لا تخطيطي */
@media (max-width: 1199.98px) {
    .dk-wrap    { display: flex; flex-direction: column; }
    .dk-patient { order: 1; }
    .dk-form    { order: 2; }
    .dk-queue   { order: 3; position: static; }
    .dk-alert   { position: sticky; top: 0; z-index: 6; box-shadow: 0 6px 18px rgba(220,38,38,.18); }
}

/* ١٠) الاستقبال: صفوف المنتظرين قابلة للّمس */
@media (max-width: 1199.98px) {
    .rc-wait { max-height: none; overflow: visible; }
    .rc-w    { min-height: 44px; display: flex; align-items: center; gap: 8px;
               padding: 11px 10px; font-size: 1rem; border-radius: 10px; }
}

/* ١١) الشريط العلوي على الهاتف */
@media (max-width: 767.98px) {
    .topbar .user > .fw-bold { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ١٢) شريط خطأ Blazor (منقول من MainLayout.razor.css وإلا ظهر دائماً) */
#blazor-error-ui {
    color-scheme: light only; background: #7f1d1d; color: #fff; font-weight: 700;
    position: fixed; bottom: 0; left: 0; width: 100%; box-sizing: border-box;
    display: none; z-index: 1000;
    padding: .7rem 1.25rem calc(.7rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
}
#blazor-error-ui .reload  { color: #fecaca; font-weight: 900; text-decoration: underline; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; inset-inline-end: .75rem; top: .5rem; }

/* ١٣) «انتهت الجلسة» نصّ مختلف عن «تعذّر الاتصال» */
.only-rejected { display: none; }
.components-reconnect-rejected .only-rejected { display: block; }
.components-reconnect-rejected .only-failed   { display: none; }
