/* تطبيق المندوبين: الجوال أولًا (ثم التابلت) - هوية ميزا كحلي وذهبي، أزرار كبيرة، بلا تكبير بالنقر المزدوج */
:root {
    --rep-navy: #121824;
    --rep-navy-2: #1c2534;
    --rep-gold: #c9a227;
    --rep-gold-light: #e7c869;
    --rep-bg: #f4f5f7;
    --rep-border: #e5e7eb;
    --rep-muted: #64748b;
    --rep-green: #14b869;
    --rep-red: #dc2626;
}

html, body { margin: 0; padding: 0; background: var(--rep-bg); font-family: Tahoma, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; touch-action: manipulation; color: #1f2937; }
* { box-sizing: border-box; }
button { font-family: inherit; touch-action: manipulation; }
a { color: inherit; }
.rep-shell { min-height: 100vh; min-height: 100dvh; }
.rep-muted { color: var(--rep-muted); font-size: .8rem; }
.rep-num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.rep-pos { color: var(--rep-red); }
.rep-neg { color: var(--rep-green); }

.rep-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; gap: 14px; color: #cbd5e1; background: var(--rep-navy); }
.rep-loading img { border-radius: 18px; }
.rep-spinner { width: 36px; height: 36px; border: 4px solid rgba(201, 162, 39, .25); border-top-color: var(--rep-gold); border-radius: 50%; animation: rep-spin 1s linear infinite; }
@keyframes rep-spin { to { transform: rotate(360deg); } }

#blazor-error-ui { display: none; position: fixed; bottom: 0; inset-inline: 0; padding: 12px; background: #fef2f2; color: #991b1b; z-index: 2000; text-align: center; }
#blazor-error-ui .reload { margin-inline-start: 12px; color: var(--rep-navy-2); }

.rep-center { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }

/* شاشة الدخول */
.rep-login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(600px 300px at 90% -10%, rgba(26, 115, 232, .22), transparent 60%), radial-gradient(500px 300px at 0% 110%, rgba(201, 162, 39, .2), transparent 60%), linear-gradient(160deg, var(--rep-navy) 0%, var(--rep-navy-2) 100%); }
.rep-login-card { width: min(420px, 100%); background: white; border-radius: 22px; padding: 26px 20px; box-shadow: 0 30px 60px -25px rgba(0, 0, 0, .6); }
.rep-login-logo { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 18px; }
.rep-login-logo img { width: 68px; height: 68px; border-radius: 18px; }
.rep-login-title { font-size: 1.25rem; font-weight: bold; color: var(--rep-navy-2); }

/* الشريط العلوي */
.rep-topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--rep-navy); color: white; min-height: 56px; }
.rep-topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.rep-topbar-title b { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-topbar-title span { color: var(--rep-gold-light); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-topbar .mud-icon-button { color: white; }

.rep-page { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); max-width: 900px; margin: 0 auto; }
.rep-page.no-nav { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* شريط التنقل السفلي */
.rep-bottomnav { position: fixed; bottom: 0; inset-inline: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); background: white; border-top: 1px solid var(--rep-border); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -8px 24px -18px rgba(0, 0, 0, .35); }
.rep-bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 6px; text-decoration: none; color: var(--rep-muted); font-size: .72rem; }
.rep-bottomnav a.active { color: var(--rep-navy-2); font-weight: bold; }
.rep-bottomnav a.active .mud-icon-root { color: var(--rep-gold); }

/* البطاقات والقوائم */
.rep-card { background: white; border-radius: 16px; border: 1px solid var(--rep-border); padding: 14px; margin-bottom: 10px; }
.rep-hero { background: linear-gradient(135deg, var(--rep-navy-2), var(--rep-navy)); color: white; border-radius: 18px; padding: 16px; margin-bottom: 12px; border: 1px solid rgba(201, 162, 39, .35); }
.rep-hero .name { font-size: 1.15rem; font-weight: bold; }
.rep-hero .sub { color: #cbd5e1; font-size: .8rem; }
.rep-hero .gold { color: var(--rep-gold-light); }

.rep-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .rep-tiles { grid-template-columns: repeat(3, 1fr); } }
.rep-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; border-radius: 16px; background: white; border: 1px solid var(--rep-border); text-decoration: none; color: inherit; min-height: 96px; cursor: pointer; text-align: start; }
.rep-tile:active { background: #fdf8e8; border-color: var(--rep-gold); }
.rep-tile .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--rep-gold-light), var(--rep-gold)); color: var(--rep-navy); }
.rep-tile .t { font-weight: bold; font-size: .95rem; }
.rep-tile .d { color: var(--rep-muted); font-size: .75rem; }
.rep-tile.disabled { opacity: .45; pointer-events: none; }

.rep-list { display: flex; flex-direction: column; gap: 8px; }
.rep-row { display: flex; align-items: center; gap: 10px; background: white; border: 1px solid var(--rep-border); border-radius: 14px; padding: 12px; text-decoration: none; color: inherit; cursor: pointer; width: 100%; text-align: start; font: inherit; }
.rep-row:active { background: #f8fafc; }
.rep-row .main { flex: 1; min-width: 0; }
.rep-row .title { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-row .sub { color: var(--rep-muted); font-size: .78rem; }
.rep-row .side { text-align: end; white-space: nowrap; }
.rep-row .side .amount { font-weight: bold; }

.rep-chip { display: inline-block; font-size: .7rem; border-radius: 999px; padding: 2px 8px; background: #f1f5f9; color: #475569; white-space: nowrap; }
.rep-chip.gold { background: #fdf3d6; color: #8a6d10; }
.rep-chip.green { background: #dcfce7; color: #15803d; }
.rep-chip.red { background: #fee2e2; color: #b91c1c; }
.rep-chip.blue { background: #dbeafe; color: #1d4ed8; }

.rep-section-title { font-weight: bold; color: var(--rep-navy-2); margin: 16px 2px 8px; display: flex; align-items: center; justify-content: space-between; }
.rep-empty { color: #94a3b8; text-align: center; padding: 28px 8px; }
.rep-search { margin-bottom: 10px; }

/* الطلب */
.rep-line { background: white; border: 1px solid var(--rep-border); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; }
.rep-line .head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.rep-line .name { font-weight: bold; }
.rep-line .fields { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 8px; align-items: end; }
.rep-line .fields > * { min-width: 0; }
.rep-line .total { text-align: end; font-weight: bold; margin-top: 4px; }
.rep-qty { display: flex; align-items: center; gap: 4px; direction: ltr; }
.rep-qty button { width: 32px; height: 38px; border-radius: 10px; border: 1px solid #d6dbe3; background: white; font-size: 1.2rem; cursor: pointer; padding: 0; }
.rep-qty input { width: 52px; height: 38px; text-align: center; border: 1px solid #d6dbe3; border-radius: 10px; font-size: 1rem; padding: 0 2px; }
/* حقلان في صف (التواريخ ومركز البيع والشيك) - min-width صفر حتى لا يوسّع حقل التاريخ الأصلي الصفحة في الجوال */
.rep-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: end; }
.rep-grid2 > * { min-width: 0; }
.rep-grid2 .full { grid-column: 1 / -1; }
.rep-input { min-width: 0; width: 100%; height: 38px; border: 1px solid #d6dbe3; border-radius: 10px; padding: 0 8px; font-size: .95rem; text-align: center; font-family: inherit; }
.rep-input:disabled { background: #f8fafc; color: #64748b; }
.rep-field-label { font-size: .7rem; color: var(--rep-muted); margin-bottom: 2px; }

.rep-totals { background: white; border: 1px solid var(--rep-border); border-radius: 14px; padding: 10px 14px; }
.rep-totals .r { display: flex; justify-content: space-between; padding: 3px 0; }
.rep-totals .r.big { font-size: 1.15rem; font-weight: bold; border-top: 1px dashed var(--rep-border); margin-top: 4px; padding-top: 8px; }

.rep-actionbar { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 15; display: flex; gap: 8px; padding: 10px 0; background: linear-gradient(to top, var(--rep-bg) 70%, transparent); }
.rep-page.no-nav .rep-actionbar { bottom: env(safe-area-inset-bottom); }

.rep-picker-item { display: flex; justify-content: space-between; gap: 8px; padding: 10px 4px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.rep-picker-item:active { background: #fdf8e8; }

/* كشف الحساب */
.rep-st-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; background: white; border: 1px solid var(--rep-border); border-radius: 12px; padding: 10px 12px; }
.rep-st-row .desc { font-weight: bold; font-size: .88rem; }
.rep-st-row .meta { color: var(--rep-muted); font-size: .75rem; }
.rep-st-row .amt { text-align: end; font-weight: bold; }
.rep-st-row .bal { text-align: end; color: var(--rep-muted); font-size: .78rem; }

/* شريط التثبيت */
.rep-install { display: flex; align-items: center; gap: 10px; background: #fdf8e8; border: 1px solid #f0dfa6; border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; color: #5b4a0e; }
.rep-install .txt { flex: 1; font-size: .82rem; line-height: 1.6; }
.rep-install.dark { background: rgba(255, 255, 255, .08); border-color: rgba(201, 162, 39, .45); color: #f6e7b4; }
.rep-ios-steps { display: flex; flex-direction: column; gap: 10px; }
.rep-ios-steps .s { display: flex; gap: 10px; align-items: center; }
.rep-ios-steps .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--rep-gold); color: var(--rep-navy); font-weight: bold; flex: none; }
