:root {
    --brand: #6c4bd8;
    --brand-dark: #5539b0;
    --bg: #f6f5fb;
    --sidebar-w: 240px;
    color-scheme: light;
}

body {
    font-family: 'Tajawal', 'Cairo', system-ui, sans-serif;
    background: var(--bg);
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6, .sidebar-brand, .btn { font-family: 'Cairo', sans-serif; }

/* ---------- Sidebar ---------- */
.app-sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 1030;
}
.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    border-bottom: 1px solid rgba(255,255,255,.15);
}
.brand-icon { font-size: 1.6rem; }
.sidebar-nav { list-style: none; padding: .75rem 0; margin: 0; flex: 1; overflow-y: auto; }
.sidebar-nav a {
    color: rgba(255,255,255,.9);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem 1.5rem;
    font-size: .95rem;
    transition: background .15s;
}
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(255,255,255,.15); color: #fff; }
.sidebar-footer { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,.15); }

.app-main { margin-right: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; width: calc(100% - var(--sidebar-w)); }
.topbar {
    background: #fff;
    padding: .75rem 1.5rem;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.page-title { color: var(--brand-dark); }
.content-area { flex: 1; }

/* ---------- Cards / KPI ---------- */
.kpi-card {
    background: #fff;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 2px 10px rgba(80, 60, 160, .07);
    border: 1px solid #efeaff;
    height: 100%;
}
.kpi-card .kpi-value { font-size: 1.65rem; font-weight: 700; color: var(--brand-dark); }
.kpi-card .kpi-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    background: #efeaff; color: var(--brand);
}
.card { border: none; border-radius: 1rem; box-shadow: 0 2px 10px rgba(80,60,160,.06); }

/* ---------- Allergy alert ---------- */
.allergy-alert {
    background: #fde8e8;
    color: #b02a37;
    border: 1px solid #f5b9bb;
    border-radius: .5rem;
    padding: .35rem .6rem;
    font-size: .85rem;
    font-weight: 600;
}

/* ---------- Tables ---------- */
.table thead th { color: var(--brand-dark); font-family: 'Cairo', sans-serif; }

/* ---------- Ratio warning ---------- */
.ratio-warn { color: #b02a37; font-weight: 700; }
.ratio-ok { color: #198754; }

/* ---------- Print ---------- */
@media print {
    .app-sidebar, .topbar, .no-print, .btn, nav { display: none !important; }
    .app-main { margin: 0 !important; width: 100% !important; }
    body { background: #fff !important; }
    .card, .kpi-card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .print-header { display: block !important; }
}
.print-header { display: none; text-align: center; margin-bottom: 1rem; }

/* ---------- Responsive sidebar ---------- */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(100%); transition: transform .25s; }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-right: 0; width: 100%; }
}

/* ---------- Parent PWA mobile shell ---------- */
.parent-mobile-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}
.parent-topbar {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
    padding-top: env(safe-area-inset-top);
}
.parent-topbar .brand-icon { font-size: 1.4rem; }
.parent-content {
    flex: 1;
    padding-bottom: 5.5rem; /* room for bottom nav */
}
.parent-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e3e1ef;
    display: flex;
    justify-content: space-around;
    padding: 0.4rem 0 calc(0.4rem + env(safe-area-inset-bottom));
    z-index: 1030;
    box-shadow: 0 -2px 10px rgba(85, 57, 176, 0.08);
}
.parent-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #8b87a0;
    font-size: 0.72rem;
    gap: 2px;
    min-width: 64px;
    padding: 4px 0;
    border-radius: 10px;
}
.parent-bottom-nav a i { font-size: 1.25rem; }
.parent-bottom-nav a.active { color: var(--brand-dark); font-weight: 700; }
.parent-bottom-nav a.active i { transform: scale(1.1); }

@media print {
    .parent-bottom-nav, .parent-topbar { display: none !important; }
    .parent-content { padding: 0 !important; }
}
