@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700&display=swap');

:root {
    --sidebar-width: 230px;
    --topbar-height: 60px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #15803d;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --primary: #15803d;
    --primary-dark: #166534;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #10b981;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --radius: 10px;
    --radius-sm: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    font-family: 'Tajawal', 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    height: 100%;
}

/* ===== LAYOUT ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0d1b2e 0%, #0f172a 60%, #131f35 100%);
    height: 100vh;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: width .28s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
    border-left: 1px solid rgba(255,255,255,0.06);
}

.sb-collapsed .sidebar {
    width: 0 !important;
    min-width: 0 !important;
}

/* ── Logo ── */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 18px;
    height: var(--topbar-height);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.logo-circle {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #15803d 0%, #10b981 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(21,128,61,.35);
}
/* I Salle ERP monogram mark inside brand badges */
.logo-circle svg, .lp-logo-circle svg { width: 58%; height: 58%; display: block; }
.logo-text[dir="ltr"] { letter-spacing: .3px; font-weight: 800; }

.logo-text {
    font-size: 16px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: .2px;
    white-space: nowrap;
}

/* ── Sidebar footer (logout) — shown on mobile only ── */
.sidebar-foot { display: none; flex-shrink: 0; padding: 12px 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.sb-foot-user { display: flex; align-items: center; gap: 8px; color: #94a3b8; font-size: 13px; margin-bottom: 10px; padding: 0 2px; }
.sb-foot-user svg { width: 16px; height: 16px; flex-shrink: 0; }
.sb-foot-user span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-foot-logout { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); color: #f87171; border-radius: 10px; padding: 11px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; transition: background .15s; }
.sb-foot-logout:hover { background: rgba(239,68,68,.2); }
.sb-foot-logout svg { width: 17px; height: 17px; }

/* ── Nav scroll area ── */
.sb-nav {
    padding: 10px 8px 16px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-track { background: transparent; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ── Nav item link ── */
.nav-item-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 14px 8px 10px;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    text-decoration: none;
    margin-bottom: 1px;
    transition: background .14s ease, color .14s ease, border-color .14s ease;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    border-right: 3px solid transparent;
    background: none;
    width: 100%;
    text-align: right;
    white-space: nowrap;
}

.nav-item-link:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
    border-right-color: rgba(21,128,61,0.4);
}

.nav-item-link.active {
    background: rgba(21,128,61,0.14);
    color: #86efac;
    border-right-color: #15803d;
    font-weight: 600;
}

.nav-item-link svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    opacity: .65;
}

.nav-item-link:hover svg { opacity: .9; }
.nav-item-link.active svg { opacity: 1; }

.sidebar-footer {
    padding: 10px 8px;
    border-top: 1px solid rgba(255,255,255,0.07);
}

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    gap: 12px;
}

.topbar-start {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

/* Sidebar toggle button */
.sb-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: all .15s ease;
}
.sb-toggle:hover {
    background: var(--bg);
    color: var(--primary);
    border-color: var(--primary);
}

.topbar-brand {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.topbar-logout-form { display:inline-flex; margin:0; position:static; }
.topbar-logout { position:static; display:inline-flex; align-items:center; min-height:34px; padding:6px 11px; border-radius:8px; border:1px solid #ef4444; background:transparent; color:#dc2626; font:700 12px inherit; white-space:nowrap; }
.topbar-logout:hover { background:#fee2e2; }

.topbar-user {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== PAGE CONTENT ===== */
.page-content {
    padding: 24px;
    flex: 1;
}

/* ===== CARDS ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: none;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s, transform .2s;
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 26px; height: 26px; }

.stat-icon.blue   { background: #eff6ff; color: #15803d; }
.stat-icon.green  { background: #f0fdf4; color: #10b981; }
.stat-icon.yellow { background: #fffbeb; color: #f59e0b; }
.stat-icon.purple { background: #f5f3ff; color: #8b5cf6; }
.stat-icon.red    { background: #fef2f2; color: #ef4444; }

.stat-info { flex: 1; }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== TABLES ===== */
.table {
    font-size: 13.5px;
    color: var(--text-primary);
}

.table thead th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 2px solid var(--border);
    padding: 10px 14px;
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
    border-color: #f1f5f9;
}

.table tbody tr:hover { background: #f8fafc; }

.table-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-card .table { margin-bottom: 0; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h4 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.page-header .subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== BADGES ===== */
.badge { font-weight: 600; font-size: 11px; padding: 4px 8px; border-radius: 20px; }

/* ===== FORMS ===== */
.form-control, .form-select {
    border-color: var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 13.5px;
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,128,61,.15);
}

/* ===== BUTTONS ===== */
.btn {
    font-family: 'Tajawal', sans-serif;
    font-weight: 500;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ===== PAGINATION ===== */
.page-link { font-family: 'Tajawal', sans-serif; font-size: 13px; }

/* ===== FILTERS BAR ===== */
.filters-bar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ===== BLAZOR ERROR ===== */
#blazor-error-ui {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 9999;
    display: none;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

#blazor-error-ui.blazor-error-boundary { display: flex; }

#blazor-error-ui .reload {
    color: #dc2626;
    font-weight: 600;
    margin-right: auto;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    opacity: .7;
}

/* ===== LOGIN PAGE ===== */
.lp-root {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background:
        radial-gradient(900px 520px at 88% -8%,  rgba(21,128,61,.30), transparent 58%),
        radial-gradient(820px 640px at 4% 108%,  rgba(16,185,129,.20), transparent 55%),
        radial-gradient(700px 700px at 50% 46%,  rgba(6,78,59,.34),   transparent 72%),
        linear-gradient(160deg, #06140d 0%, #04110b 55%, #020906 100%);
    position: relative;
    overflow: hidden;
    font-family: 'Tajawal', sans-serif;
    direction: rtl;
    box-sizing: border-box;
}
.lp-root *, .lp-root *::before, .lp-root *::after { box-sizing: border-box; }
/* professional fine-dot texture, fading toward the edges */
.lp-root::before {
    content: "";
    position: absolute; inset: 0; pointer-events: none;
    background-image: radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 22px 22px;
    mask-image: radial-gradient(130% 110% at 50% 0%, #000 42%, transparent 82%);
    -webkit-mask-image: radial-gradient(130% 110% at 50% 0%, #000 42%, transparent 82%);
}
/* soft aurora ribbon behind the card */
.lp-root::after {
    content: "";
    position: absolute; width: 70vw; height: 70vw; max-width: 900px; max-height: 900px;
    right: -12%; top: -22%; pointer-events: none;
    background: conic-gradient(from 210deg at 50% 50%, rgba(16,185,129,.16), rgba(21,128,61,.05), transparent 55%);
    filter: blur(40px);
    border-radius: 50%;
}

/* Full-screen split: image (right) + form (left), each full height */
.lp-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: none;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(8, 22, 15, .74);
    border: none;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    backdrop-filter: blur(22px);
}

/* ── Brand / hero panel ── */
.lp-aside {
    position: relative;
    overflow: hidden;
    padding: 48px 44px;
    display: flex;
    background:
        linear-gradient(150deg, #15803d 0%, #14532d 42%, #052e16 100%);
    color: #eaf1ff;
}
.lp-aside-grid {
    position: absolute; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2772%27%20height%3D%2772%27%20viewBox%3D%270%200%2072%2072%27%3E%3Cg%20fill%3D%27none%27%20stroke%3D%27%23ffffff%27%20stroke-width%3D%271%27%3E%3Cpath%20d%3D%27M36%201L71%2036L36%2071L1%2036Z%27%2F%3E%3Crect%20x%3D%2711%27%20y%3D%2711%27%20width%3D%2750%27%20height%3D%2750%27%2F%3E%3Cpath%20d%3D%27M36%201L36%2071M1%2036L71%2036%27%20stroke-width%3D%270.6%27%20opacity%3D%270.55%27%2F%3E%3Ccircle%20cx%3D%2736%27%20cy%3D%2736%27%20r%3D%276%27%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
    background-size: 72px 72px;
    mask-image: radial-gradient(130% 120% at 80% 4%, #000 8%, transparent 74%);
    -webkit-mask-image: radial-gradient(130% 120% at 80% 4%, #000 8%, transparent 74%);
    opacity: .16;
}
.lp-aside-glow { position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; }
.lp-aside-glow-1 { width: 320px; height: 320px; background: rgba(52,211,153,.45); top: -90px; left: -70px; opacity: .5; }
.lp-aside-glow-2 { width: 260px; height: 260px; background: rgba(22,101,52,.6);  bottom: -80px; right: -50px; opacity: .45; }
.lp-aside-inner {
    position: relative; z-index: 1;
    display: flex; flex-direction: column;
    gap: 30px; width: 100%;
}
.lp-aside-hero h2 {
    margin: 0;
    font-size: 27px; font-weight: 800; line-height: 1.45;
    letter-spacing: -.01em;
    color: #ffffff;
}
.lp-aside-hero p {
    margin: 14px 0 0;
    font-size: 14px; line-height: 1.9;
    color: rgba(219,232,255,.72);
    max-width: 34ch;
}
.lp-aside-features { list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.lp-aside-features li {
    display: flex; align-items: center; gap: 12px;
    font-size: 13.5px; font-weight: 600; color: rgba(233,241,255,.9);
}
.lp-feat-ico {
    width: 26px; height: 26px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.2);
    color: #eaf6ff;
}
.lp-feat-ico svg { width: 14px; height: 14px; }

/* ── Form panel ── */
.lp-main {
    display: flex; align-items: center; justify-content: center;
    padding: 48px 44px;
}
.lp-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 360px;
}

.lp-brand {
    display: flex;
    align-items: center;
    gap: 13px;
}
.lp-brand-mobile { display: none; margin-bottom: 26px; }

.lp-logo-circle {
    width: 46px; height: 46px;
    border-radius: 13px;
    background: linear-gradient(135deg, #15803d, #10b981);
    display: flex; align-items: center; justify-content: center;
    font-size: 21px; font-weight: 800; color: white;
    box-shadow: 0 8px 22px rgba(21,128,61,.45);
    flex-shrink: 0;
}
.lp-aside .lp-logo-circle {
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.28);
    box-shadow: 0 8px 22px rgba(0,0,0,.25);
}

.lp-app-name { font-size: 20px; font-weight: 800; color: #f1f5f9; line-height: 1.2; }
.lp-aside .lp-app-name { color: #fff; }
.lp-app-sub { font-size: 12px; color: #64748b; margin-top: 3px; }
.lp-aside .lp-app-sub { color: rgba(219,232,255,.6); }

.lp-head { margin-bottom: 26px; }
.lp-heading {
    font-size: 26px; font-weight: 800; color: #f8fafc;
    margin: 0; letter-spacing: -.01em;
}
.lp-subheading {
    font-size: 13.5px; color: #7c8aa5;
    margin: 8px 0 0;
}

.lp-error {
    display: flex; align-items: center; gap: 8px;
    background: rgba(239,68,68,.12);
    border: 1px solid rgba(239,68,68,.25);
    color: #fca5a5;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.lp-field { margin-bottom: 18px; }

.lp-label {
    display: block;
    font-size: 13px; font-weight: 600; color: #94a3b8;
    margin-bottom: 7px;
}

.lp-input-wrap {
    position: relative;
}

.lp-input-icon {
    position: absolute;
    right: 12px; top: 50%; transform: translateY(-50%);
    width: 17px; height: 17px;
    color: #475569;
    pointer-events: none;
}

.lp-input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 11px 40px 11px 14px;
    color: #e2e8f0;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.lp-input:focus {
    border-color: #15803d;
    box-shadow: 0 0 0 3px rgba(21,128,61,.18);
    background: rgba(255,255,255,0.07);
}

.lp-input::placeholder { color: #334155; }

.lp-val {
    display: block;
    font-size: 12px; color: #f87171;
    margin-top: 5px;
}

.lp-remember {
    margin-bottom: 22px;
}
.lp-remember label {
    display: flex; align-items: center; gap: 8px;
    color: #64748b; font-size: 13px; cursor: pointer;
}
.lp-remember input[type=checkbox] {
    width: 15px; height: 15px; accent-color: #15803d;
}

.lp-btn {
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 9px;
    background: linear-gradient(135deg, #15803d, #166534);
    border: none; border-radius: 12px;
    color: white;
    font-family: 'Tajawal', sans-serif;
    font-size: 15px; font-weight: 700;
    padding: 13px;
    cursor: pointer;
    transition: filter .15s, transform .12s, box-shadow .15s;
    box-shadow: 0 10px 26px rgba(22,101,52,.4);
    position: relative; overflow: hidden;
}
.lp-btn::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,.18), transparent 45%);
    pointer-events: none;
}
.lp-btn:hover { filter: brightness(1.07); transform: translateY(-1px); box-shadow: 0 14px 32px rgba(22,101,52,.5); }
.lp-btn:active { transform: translateY(0); box-shadow: 0 8px 20px rgba(22,101,52,.4); }

.lp-footer {
    text-align: center;
    color: #334155;
    font-size: 11px;
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.lp-version {
    font-size: 10.5px;
    font-weight: 700;
    color: #475569;
    letter-spacing: .04em;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.07);
    padding: 2px 10px;
    border-radius: 20px;
    direction: rtl;
}

/* Login — responsive: collapse to a single centered card, hide the hero panel */
@media (max-width: 860px) {
    .lp-shell {
        grid-template-columns: 1fr;
        min-height: 100vh;
    }
    .lp-aside { display: none; }
    .lp-brand-mobile { display: flex; }
    .lp-main { padding: 40px 26px; }
    .lp-card { max-width: 100%; }
}
@media (max-width: 420px) {
    .lp-main { padding: 34px 20px; align-items: flex-start; padding-top: 52px; }
}

/* ===== VALID / INVALID ===== */
.valid.modified:not([type=checkbox]) { outline: 2px solid var(--success); }
.invalid { outline: 2px solid var(--danger); }
.validation-message { color: var(--danger); font-size: 12px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── PWA / Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .page-container { padding: 8px !important }
    .top-row { padding: 4px 8px !important }

    /* ── Mobile sidebar: slide-in drawer ── */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100vh !important;
        z-index: 400;
        width: var(--sidebar-width) !important;
        min-width: var(--sidebar-width) !important;
        transform: translateX(0);
        transition: transform .28s cubic-bezier(.4,0,.2,1) !important;
        box-shadow: 6px 0 28px rgba(0,0,0,.45);
    }
    /* Collapsed on mobile → slide completely out to the left */
    .sb-collapsed .sidebar {
        width: var(--sidebar-width) !important;
        min-width: var(--sidebar-width) !important;
        transform: translateX(calc(-1 * var(--sidebar-width) - 8px));
    }
    /* Main content always fills full width on mobile */
    .main-wrapper { width: 100%; }
    .page-content { padding: 14px 12px; }

    /* Show logout at the bottom of the mobile sidebar */
    .sidebar-foot { display: block; }
}

/* ── Mobile sidebar overlay backdrop ── */
.sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.52);
    z-index: 399;
    animation: fadeInOverlay .18s;
}
@media (max-width: 768px) {
    .sb-overlay { display: block; }
}

/* ═══════════ Mobile bottom tab bar (PWA) ═══════════ */
.mtab { display: none; }
@media (max-width: 768px) {
    .mtab {
        display: flex;
        position: fixed; left: 0; right: 0; bottom: 0;
        z-index: 350;
        background: linear-gradient(180deg, #12203a, #0c1626);
        border-top: 1px solid rgba(255,255,255,.09);
        box-shadow: 0 -6px 22px rgba(0,0,0,.42);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        direction: rtl;
    }
    .mtab-item {
        flex: 1 1 0; min-width: 0;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        padding: 8px 3px 9px;
        color: #93a3b8; text-decoration: none;
        font-size: 10.5px; font-weight: 700; font-family: 'Tajawal', sans-serif;
        -webkit-tap-highlight-color: transparent; transition: color .12s;
    }
    .mtab-item svg { width: 22px; height: 22px; opacity: .85; }
    .mtab-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    .mtab-item.on { color: #4ade80; }
    .mtab-item.on svg { opacity: 1; }
    .mtab-item:active { background: rgba(255,255,255,.06); }

    /* Reserve space so the fixed bar never covers content (only while the bar is shown) */
    body.mtab-on .page-content,
    body.mtab-on .orders-body {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ═══════════ PWA / mobile sizing foundation ═══════════ */
/* Dynamic viewport height so mobile browser chrome never overflows the shell */
@supports (height: 100dvh) {
    .app-wrapper  { min-height: 100dvh; }
    .main-wrapper { min-height: 100dvh; }
    .orders-shell { min-height: 100dvh; }
    .sidebar      { height: 100dvh; }
}
/* Notch-safe top bars — env() is 0 on non-notch devices, so desktop is unchanged */
.topbar { height: auto; min-height: var(--topbar-height); padding-top: env(safe-area-inset-top, 0px); }
.orders-account-bar { padding-top: calc(6px + env(safe-area-inset-top, 0px)); }
/* Keep everything within the viewport width on phones (kills accidental sideways scroll) */
@media (max-width: 768px) {
    html, body { overflow-x: hidden; }
    .page-content, .orders-body, .card, .stat-card { max-width: 100%; }
}

/* Safe area insets for notched phones */
body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Prevent text selection on buttons (feels more native) */
button { -webkit-tap-highlight-color: transparent; user-select: none }

/* Smooth scrolling everywhere */
html { scroll-behavior: smooth }

/* Better touch targets */
@media (hover: none) and (pointer: coarse) {
    button, a, select, input[type="checkbox"], input[type="radio"] {
        min-height: 44px;
    }
}

/* ===== SHARED ADMIN PAGE SHELL ===== */
.page-shell {
    padding: 24px 28px;
    direction: rtl;
}
.screen-area {
    min-height: calc(100vh - var(--topbar-height));
}
.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

/* ===== DATA TABLE ===== */
.data-table-wrap,
.table-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.data-table thead th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-align: right;
}
.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .12s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody td {
    padding: 10px 14px;
    color: var(--text-primary);
    vertical-align: middle;
    text-align: right;
}
.empty-row,
.loading-row {
    text-align: center !important;
    color: var(--text-muted);
    padding: 32px !important;
    font-size: 13px;
}
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== DRAWER ===== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 900;
    animation: fadeInOverlay .15s;
}
@keyframes fadeInOverlay { from { opacity: 0 } to { opacity: 1 } }

.drawer-right {
    position: fixed;
    top: 0;
    left: 0;
    width: 420px;
    max-width: 95vw;
    height: 100vh;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    z-index: 901;
    display: flex;
    flex-direction: column;
    box-shadow: 6px 0 32px rgba(0, 0, 0, .14);
    animation: slideInDrawer .2s cubic-bezier(.22,1,.36,1);
}
@keyframes slideInDrawer {
    from { transform: translateX(-28px); opacity: 0 }
    to   { transform: translateX(0);     opacity: 1 }
}
.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.drawer-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.drawer-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ===== FORM GROUPS (inside drawers / forms) ===== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.form-field-check,
.form-check-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-field-check label,
.form-check-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}
.form-control,
.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 13.5px;
    color: var(--text-primary);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,128,61,.15);
}

/* ===== SHARED BUTTONS ===== */
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 15px;
    transition: background .12s, color .12s;
}
.btn-icon:hover { background: #f1f5f9; color: var(--text-primary); }

.btn-icon-sm {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    border-radius: var(--radius-sm);
    transition: background .12s, color .12s;
}
.btn-icon-sm:hover { background: #f1f5f9; }
.btn-icon-sm.danger,
.btn-icon-sm.danger:hover { color: var(--danger); background: rgba(239,68,68,.08); }

.btn-danger,
.btn-danger-sm {
    background: var(--danger);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-danger:hover,
.btn-danger-sm:hover { background: #dc2626; }

.btn-del {
    background: none;
    border: 1px solid rgba(239,68,68,.3);
    color: var(--danger);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: background .12s;
}
.btn-del:hover { background: rgba(239,68,68,.08); }

/* ===== STATUS BADGES ===== */
.badge-active {
    display: inline-block;
    background: rgba(16,185,129,.1);
    color: #059669;
    border: 1px solid rgba(16,185,129,.25);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
}
.badge-inactive {
    display: inline-block;
    background: rgba(239,68,68,.1);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,.25);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
}

/* ===== FILTER BAR ===== */
.filter-select {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    background: #fff;
    cursor: pointer;
}


/* Maintenance tab */
.rpt-table tr.row-error td { background: rgba(229,57,53,.08); color: #f44336; }


/* ═══════════════════════════════════════════════════════════════════
   THEME: Modern sidebar — SHELL only (item styling lives in the scoped
   NavMenu.razor.css so it wins over the base scoped rules).
   The .app-wrapper.sb-modern class is set by MainLayout.
   ═══════════════════════════════════════════════════════════════════ */
.sb-modern .sidebar {
    background: linear-gradient(180deg, #101a2e 0%, #0b1220 55%, #0a1019 100%) !important;
    border: 1px solid rgba(255,255,255,.07);
}
/* Floating rounded panel (desktop): curved inner corners */
@media (min-width: 769px) {
    .sb-modern .sidebar {
        margin: 12px;
        height: calc(100vh - 24px);
        border-radius: 22px;
        overflow: hidden;
        box-shadow: 0 24px 60px -24px rgba(0,0,0,.65), inset 0 1px 0 rgba(255,255,255,.04);
    }
    /* keep the content flush against the floating panel */
    .sb-modern .main-wrapper { min-height: 100vh; }
}
.sb-modern .sidebar-logo {
    height: 62px;
    border-bottom: 1px solid rgba(255,255,255,.05);
}
.sb-modern .logo-circle {
    width: 38px; height: 38px; border-radius: 12px;
    box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--primary, #15803d) 60%, transparent);
}
.sb-modern .logo-text { font-size: 17px; font-weight: 800; }

/* ═══════════════════════════════════════════════════════════════════
   THEME: Modern login  (applied when admin sets theme:login=modern)
   ═══════════════════════════════════════════════════════════════════ */
/* Recolors the split layout with the site's --primary accent (no layout changes). */
.lp-modern .lp-aside {
    background: linear-gradient(150deg,
        var(--primary, #166534) 0%,
        color-mix(in srgb, var(--primary, #166534) 68%, #0b1220) 52%,
        #0b1220 100%);
}
.lp-modern .lp-logo-circle {
    background: linear-gradient(135deg, var(--primary, #15803d), color-mix(in srgb, var(--primary, #15803d) 55%, #10b981));
}
.lp-modern .lp-aside .lp-logo-circle {
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.28);
}
.lp-modern .lp-input:focus {
    border-color: var(--primary, #15803d);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #15803d) 22%, transparent);
}
.lp-modern .lp-btn {
    background: linear-gradient(135deg, var(--primary, #15803d), color-mix(in srgb, var(--primary, #15803d) 60%, #000));
    box-shadow: 0 10px 26px -6px color-mix(in srgb, var(--primary, #15803d) 60%, transparent);
}

/* ═══════════════════ Login — animations (shared) ═══════════════════ */
@keyframes lp-rise    { from { opacity:0; transform: translateY(18px) scale(.985); } to { opacity:1; transform:none; } }
@keyframes lp-float   { 0%,100% { transform: translateY(0); }        50% { transform: translateY(-22px); } }
@keyframes lp-float2  { 0%,100% { transform: translate(0,0); }       50% { transform: translate(16px,20px); } }
@keyframes lp-twinkle { 0%,100% { opacity:.35; }                     50% { opacity:.85; } }
@keyframes lp-drift   { from { background-position: 0 0; }           to { background-position: 130px 130px; } }
@keyframes lp-sheen   { 0% { transform: translateX(-140%); }         55%,100% { transform: translateX(260%); } }
@keyframes lp-fieldin { from { opacity:0; transform: translateY(9px); } to { opacity:1; transform:none; } }
@keyframes lp-logo    { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(-3deg); } }

.lp-card         { animation: lp-rise .55s cubic-bezier(.2,.7,.2,1) both; }
.lp-aside-inner  { animation: lp-rise .62s cubic-bezier(.2,.7,.2,1) both; }
.lp-aside-grid   { animation: lp-drift 34s linear infinite; }
.lp-aside-glow-1 { animation: lp-float 9s ease-in-out infinite; }
.lp-aside-glow-2 { animation: lp-float2 12s ease-in-out infinite; }
.lp-logo-circle  { animation: lp-logo 6s ease-in-out infinite; }
.lp-field, .lp-remember, .lp-btn { animation: lp-fieldin .5s ease both; }
.lp-field:nth-of-type(1) { animation-delay:.06s; }
.lp-field:nth-of-type(2) { animation-delay:.13s; }
.lp-remember { animation-delay:.19s; }
.lp-btn      { animation-delay:.24s; }
.lp-btn::before {
    content:""; position:absolute; top:0; bottom:0; left:0; width:45%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.38), transparent);
    transform: translateX(-140%);
    animation: lp-sheen 5s ease-in-out 1.4s infinite;
    pointer-events:none;
}
@media (prefers-reduced-motion: reduce) {
    .lp-card, .lp-aside-inner, .lp-aside-grid, .lp-aside-glow-1, .lp-aside-glow-2, .lp-logo-circle,
    .lp-field, .lp-remember, .lp-btn, .lp-btn::before { animation: none !important; }
}

/* ═══════════════════ THEME: Light (Cloudflare-style) ═══════════════════ */
.lp-light { background: linear-gradient(180deg, #ffffff, #eef1f5); }
.lp-light::before { opacity: .04; }
.lp-light .lp-shell {
    background:#ffffff;
    border:1px solid #e6e8eb;
    box-shadow: 0 30px 80px -34px rgba(15,23,42,.30), 0 2px 8px rgba(15,23,42,.05);
    backdrop-filter:none;
}
.lp-light .lp-main { background:#ffffff; }

/* Orange promotional panel with animated dot field */
.lp-light .lp-aside {
    background: linear-gradient(160deg, #f6821f 0%, #ea580c 55%, #c2410c 100%);
    color:#fff8f2;
}
.lp-light .lp-aside-grid {
    background-image: radial-gradient(rgba(255,255,255,.92) 1.6px, transparent 1.8px);
    background-size: 15px 15px;
    -webkit-mask-image: radial-gradient(130% 120% at 80% 14%, #000 6%, transparent 60%);
    mask-image: radial-gradient(130% 120% at 80% 14%, #000 6%, transparent 60%);
    opacity: .55;
    animation: lp-drift 26s linear infinite, lp-twinkle 5.5s ease-in-out infinite;
}
.lp-light .lp-aside-glow-1 { background: rgba(255,225,180,.7); }
.lp-light .lp-aside-glow-2 { background: rgba(255,255,255,.4); }
.lp-light .lp-aside-hero h2 { color:#ffffff; }
.lp-light .lp-aside-hero p  { color: rgba(255,246,238,.92); }
.lp-light .lp-aside-features li { color: rgba(255,249,244,.96); }
.lp-light .lp-feat-ico { background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.42); color:#fff; }
.lp-light .lp-aside .lp-logo-circle { background: rgba(255,255,255,.2); border:1px solid rgba(255,255,255,.5); box-shadow:none; }
.lp-light .lp-aside .lp-app-name { color:#fff; }
.lp-light .lp-aside .lp-app-sub  { color: rgba(255,246,238,.78); }

/* Form side (light) */
.lp-light .lp-logo-circle { background: linear-gradient(135deg, #f6821f, #ea580c); box-shadow: 0 8px 22px rgba(234,88,12,.42); }
.lp-light .lp-heading    { color:#0f172a; }
.lp-light .lp-subheading { color:#64748b; }
.lp-light .lp-label      { color:#334155; }
.lp-light .lp-input      { background:#f8fafc; border:1px solid #dfe3e8; color:#0f172a; }
.lp-light .lp-input::placeholder { color:#9aa4b2; }
.lp-light .lp-input:focus { border-color:#2563eb; background:#fff; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.lp-light .lp-input-icon { color:#94a3b8; }
.lp-light .lp-remember label { color:#64748b; }
.lp-light .lp-remember input[type=checkbox] { accent-color:#2563eb; }
.lp-light .lp-btn { background: linear-gradient(135deg, #2563eb, #1d4ed8); box-shadow: 0 10px 24px rgba(37,99,235,.32); }
.lp-light .lp-footer  { color:#94a3b8; }
.lp-light .lp-version { color:#64748b; background:#f1f5f9; border-color:#e5e7eb; }
.lp-light .lp-error   { background:#fef2f2; border-color:#fecaca; color:#b91c1c; }
.lp-light .lp-brand-mobile .lp-app-name { color:#0f172a; }
.lp-light .lp-brand-mobile .lp-app-sub  { color:#64748b; }
