/* ═══════════════════════════════════════════════════════
   نظام مؤسسة الأربعين — Light Theme (Mourning Palette)
   خلفية بيضاء ناصعة + أحمر دموي + تفاصيل سوداء
   RTL Arabic — Eye-Comfortable Premium Design
   ═══════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root {
    --sidebar-w: 270px;
    --topbar-h:  68px;

    /* ── Mourning Palette ── */
    --blood-red:       #C8102E;
    --blood-red-dark:  #a00d24;
    --blood-red-glow:  rgba(200, 16, 46, 0.20);
    --blood-red-soft:  rgba(200, 16, 46, 0.07);
    --ink-black:       #1a1a1a;
    --ink-soft:        #2d2d2d;
    --gold:            #8B6914;

    /* ── Surfaces (White) ── */
    --bg-page:         #f5f5f5;
    --surface-white:   #ffffff;
    --surface-off:     #fafafa;
    --surface-subtle:  #f0f0f0;

    /* ── Text ── */
    --text-primary:    #1a1a1a;
    --text-secondary:  #4a4a4a;
    --text-muted:      #8a8a8a;

    /* ── Borders ── */
    --border-soft:     #e8e8e8;
    --border-medium:   #d4d4d4;
    --border-red:      rgba(200, 16, 46, 0.25);

    /* ── Radius ── */
    --r-xs:   6px;
    --r-sm:   10px;
    --r-md:   14px;
    --r-lg:   18px;
    --r-xl:   24px;
    --r-full: 9999px;

    /* ── Shadows ── */
    --shadow-xs:   0 1px 4px rgba(0,0,0,0.06);
    --shadow-soft: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-md:   0 4px 24px rgba(0,0,0,0.10);
    --shadow-red:  0 4px 20px var(--blood-red-glow);

    /* ── States ── */
    --success: #16a34a;
    --danger:  #C8102E;
    --warning: #b45309;
    --info:    #0369a1;
}

/* ════════════ RESET & BASE ════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    direction: rtl;
    font-family: 'Cairo', sans-serif;
    font-size: 15px;
    background: var(--bg-page);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Subtle red vignette top edge */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ink-black), var(--blood-red), var(--ink-black));
    z-index: 9999;
    pointer-events: none;
}

/* ════════════ TOPBAR ════════════ */
.admin-topbar {
    position: fixed;
    top: 3px; right: var(--sidebar-w); left: 0;
    height: var(--topbar-h);
    background: var(--surface-white);
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 1050;
    box-shadow: var(--shadow-xs);
    transition: right .4s cubic-bezier(0.16, 1, 0.3, 1);
}

.topbar-start { display: flex; align-items: center; gap: 1rem; }
.topbar-brand { display: none; }

.topbar-toggle {
    width: 38px; height: 38px;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    background: var(--surface-off);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all .2s ease;
    font-size: 1.15rem;
}
.topbar-toggle:hover {
    background: var(--blood-red);
    border-color: var(--blood-red);
    color: #fff;
}

.topbar-user { display: flex; align-items: center; gap: .9rem; }
.topbar-user-name {
    font-size: .88rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.topbar-notifications { position: relative; }
.notification-button {
    width: 38px; height: 38px;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    background: var(--surface-off);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all .2s ease;
    font-size: 1.05rem;
}
.notification-button:hover,
.notification-button[aria-expanded="true"] {
    background: var(--ink-black);
    border-color: var(--ink-black);
    color: #fff;
}
.notification-badge {
    position: absolute;
    top: -6px;
    inset-inline-end: -7px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: var(--r-full);
    background: var(--blood-red);
    color: #fff;
    border: 2px solid var(--surface-white);
    display: flex; align-items: center; justify-content: center;
    font-size: .68rem;
    font-weight: 900;
    line-height: 1;
}
.notification-menu {
    width: min(380px, calc(100vw - 1.5rem));
    max-height: 70vh;
    overflow-y: auto;
    padding: .65rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
}
.notification-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    padding: .35rem .45rem .65rem;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: .45rem;
    color: var(--text-primary);
}
.notification-menu-head > div {
    display: flex;
    align-items: center;
    gap: .45rem;
}
.notification-menu-head strong { font-size: .9rem; }
.notification-menu-head span {
    min-width: 26px;
    height: 26px;
    border-radius: var(--r-full);
    background: var(--blood-red-soft);
    color: var(--blood-red);
    display: flex; align-items: center; justify-content: center;
    font-size: .76rem;
    font-weight: 900;
}
.notification-read-all {
    border: 1px solid rgba(22, 163, 74, .22);
    background: rgba(22, 163, 74, .08);
    color: var(--success);
    border-radius: var(--r-full);
    padding: .25rem .62rem;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .74rem;
    font-weight: 900;
    transition: all .18s ease;
}
.notification-read-all:hover {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.notification-read-all:disabled {
    opacity: .65;
    cursor: wait;
}
.notification-empty {
    padding: 1.2rem .6rem;
    text-align: center;
    color: var(--text-muted);
    font-size: .86rem;
}
.notification-item {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border-soft);
    background: transparent;
    padding: .8rem .45rem;
    text-align: start;
    display: grid;
    gap: .22rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all .18s ease;
    text-decoration: none;
}
.notification-main {
    display: grid;
    gap: .22rem;
}
.notification-mark-read {
    margin-top: .15rem;
    width: fit-content;
    border-radius: var(--r-full);
    padding: .16rem .5rem;
    background: rgba(22, 163, 74, .08);
    color: var(--success);
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .72rem;
    font-weight: 900;
}
.notification-item:hover {
    background: var(--surface-off);
    border-radius: var(--r-sm);
    padding-inline: .65rem;
}
.notification-item.urgent {
    border-inline-start: 4px solid var(--blood-red);
    background: var(--blood-red-soft);
    border-radius: var(--r-sm);
    margin-bottom: .35rem;
    padding-inline: .65rem;
}
.notification-item.request {
    border-inline-start: 4px solid var(--info);
    background: rgba(3,105,161,0.07);
    border-radius: var(--r-sm);
    margin-bottom: .35rem;
    padding-inline: .65rem;
}
.notification-item.request .notification-type {
    background: var(--info);
    color: #fff;
}
.notification-item.request .notification-mark-read {
    background: rgba(3,105,161,0.08);
    color: var(--info);
}
.notification-type {
    width: fit-content;
    border-radius: var(--r-full);
    padding: .12rem .5rem;
    background: var(--surface-subtle);
    color: var(--text-secondary);
    font-size: .7rem;
    font-weight: 900;
}
.notification-item.urgent .notification-type {
    background: var(--blood-red);
    color: #fff;
}
.notification-title {
    font-size: .88rem;
    font-weight: 800;
    line-height: 1.45;
}
.notification-source {
    color: var(--text-muted);
    font-size: .76rem;
    font-weight: 700;
}
.notification-read-form.is-hiding {
    opacity: 0;
    transform: translateY(-6px);
    transition: all .2s ease;
}

.user-avatar {
    width: 38px; height: 38px;
    border-radius: var(--r-sm);
    background: var(--blood-red);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem;
    font-weight: 900;
    box-shadow: var(--shadow-red);
}

.topbar-logout {
    width: 38px; height: 38px;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all .2s ease;
    font-size: 1.05rem;
}
.topbar-logout:hover {
    background: var(--blood-red-soft);
    border-color: var(--border-red);
    color: var(--blood-red);
}

/* ════════════ SIDEBAR ════════════ */
.admin-sidebar {
    position: fixed;
    top: 3px; right: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--ink-black);
    border-left: 1px solid rgba(255,255,255,0.06);
    overflow-y: auto; overflow-x: hidden;
    transition: transform .4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1060;
    display: flex;
    flex-direction: column;
    padding-bottom: 1.5rem;
}
.admin-sidebar::-webkit-scrollbar { width: 3px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(200,16,46,0.3); border-radius: 4px; }
.admin-sidebar.collapsed { transform: translateX(calc(100% + 1px)); }

/* ── Logo ── */
.sidebar-logo-wrap {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 1.4rem 1.4rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    margin-bottom: .4rem;
}
.sidebar-logo-icon {
    width: 36px; height: 36px;
    border-radius: var(--r-sm);
    background: var(--blood-red);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 10px var(--blood-red-glow);
}
.sidebar-logo-text {
    font-size: .95rem;
    font-weight: 900;
    color: #ffffff;
    line-height: 1.2;
    letter-spacing: -.2px;
}

.sidebar-section-label {
    padding: .9rem 1.4rem .35rem;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .12em;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
}

.sidebar-nav { list-style: none; padding: 0 .7rem; }
.sidebar-nav .nav-item { margin-bottom: .15rem; }
.sidebar-nav .nav-item a {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .68rem .95rem;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    border-radius: var(--r-sm);
    font-size: .88rem;
    font-weight: 600;
    transition: all .2s ease;
}
.sidebar-nav .nav-item a .nav-icon {
    font-size: 1rem;
    color: rgba(255,255,255,0.3);
    transition: color .2s;
    flex-shrink: 0;
}
.sidebar-nav .nav-item a:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.9);
}
.sidebar-nav .nav-item a:hover .nav-icon { color: var(--blood-red); }

.sidebar-nav .nav-item a.active {
    background: var(--blood-red);
    color: #fff;
    box-shadow: 0 2px 12px var(--blood-red-glow);
}
.sidebar-nav .nav-item a.active .nav-icon { color: #fff; }

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.07);
    margin: .6rem 1.4rem;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.4rem 0;
    border-top: 1px solid rgba(255,255,255,0.07);
    text-align: center;
    font-size: .75rem;
    color: rgba(255,255,255,0.25);
    font-weight: 600;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1055;
}
.sidebar-overlay.visible { display: block; }

/* ════════════ MAIN AREA ════════════ */
.admin-main {
    margin-top: calc(var(--topbar-h) + 3px);
    margin-right: var(--sidebar-w);
    min-height: calc(100vh - var(--topbar-h) - 3px);
    padding: 1.8rem;
    transition: margin-right .4s cubic-bezier(0.16, 1, 0.3, 1);
}
.admin-main.expanded { margin-right: 0; }
.admin-content-wrap { max-width: 1600px; margin-inline: auto; }

/* ════════════ PAGE HEADER ════════════ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.8rem;
    background: var(--surface-white);
    padding: 1.3rem 1.8rem;
    border-radius: var(--r-lg);
    border: 1px solid var(--border-soft);
    border-right: 4px solid var(--blood-red);
    box-shadow: var(--shadow-xs);
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--ink-black);
    margin: 0 0 .2rem;
    display: flex;
    align-items: center;
    gap: .7rem;
}
.page-header h1 i { color: var(--blood-red); }
.stat-label { font-size: .84rem; color: var(--text-muted); font-weight: 600; }

/* ════════════ STAT CARDS ════════════ */
.stat-card {
    background: var(--surface-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-xs);
    transition: all .25s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}
a.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-red);
}
/* Top accent bar */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--blood-red);
    opacity: .5;
}
a.stat-card:hover::before { opacity: 1; }

.stat-body { z-index: 1; }
.stat-body h5 {
    margin: 0 0 .4rem;
    font-size: .84rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .01em;
}
.stat-body .stat-number {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--ink-black);
    line-height: 1;
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    z-index: 1;
    flex-shrink: 0;
}
.stat-icon.users  { background: rgba(200,16,46,0.08);  color: var(--blood-red); }
.stat-icon.groups { background: rgba(139,105,20,0.08); color: var(--gold); }
.stat-icon.admin  { background: rgba(3,105,161,0.08);  color: var(--info); }
.stat-icon.staff  { background: rgba(22,163,74,0.08);  color: var(--success); }

/* ════════════ CARDS & TABLES ════════════ */
.admin-card {
    background: var(--surface-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    margin-bottom: 1.8rem;
}

.card-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-off);
}
.card-action-title {
    font-size: .98rem;
    font-weight: 800;
    color: var(--ink-black);
    display: flex; align-items: center; gap: .7rem;
}
.card-action-title i { color: var(--blood-red); font-size: 1.1rem; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table thead th {
    background: var(--surface-off);
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 800;
    padding: .9rem 1.5rem;
    border-bottom: 1px solid var(--border-soft);
    text-align: right;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.admin-table tbody td {
    padding: .95rem 1.5rem;
    color: var(--text-primary);
    font-size: .9rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.admin-table tbody tr { transition: background .15s; }
.admin-table tbody tr:hover { background: #fdf5f6; }
.admin-table tbody tr:last-child td { border-bottom: none; }

/* ════════════ BUTTONS ════════════ */
.btn-admin-primary {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .7rem 1.6rem;
    background: var(--blood-red);
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
    border: none;
    border-radius: var(--r-sm);
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s ease;
    box-shadow: 0 2px 10px var(--blood-red-glow);
}
.btn-admin-primary:hover {
    background: var(--blood-red-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-red);
    color: #fff;
}

.btn-admin-outline {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .7rem 1.4rem;
    border: 1px solid var(--border-medium);
    border-radius: var(--r-sm);
    background: var(--surface-white);
    color: var(--text-secondary);
    font-weight: 700;
    font-family: 'Cairo', sans-serif;
    font-size: .88rem;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s ease;
}
.btn-admin-outline:hover {
    border-color: var(--blood-red);
    color: var(--blood-red);
    background: var(--blood-red-soft);
}

.act-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem .85rem;
    font-size: .8rem;
    font-weight: 700;
    border-radius: var(--r-xs);
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s ease;
    border: 1px solid transparent;
    white-space: nowrap;
}
.act-btn.blue {
    background: var(--blood-red-soft);
    color: var(--blood-red);
    border-color: var(--border-red);
}
.act-btn.blue:hover {
    background: var(--blood-red);
    color: #fff;
    border-color: var(--blood-red);
    transform: translateY(-1px);
    box-shadow: var(--shadow-red);
}
.act-btn.green {
    background: rgba(22,163,74,0.07);
    color: var(--success);
    border-color: rgba(22,163,74,0.2);
}
.act-btn.green:hover {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
    transform: translateY(-1px);
}
.act-btn.slate {
    background: var(--surface-off);
    color: var(--text-secondary);
    border-color: var(--border-soft);
}
.act-btn.slate:hover {
    background: var(--ink-black);
    color: #fff;
    border-color: var(--ink-black);
    transform: translateY(-1px);
}
.act-btn.red {
    background: rgba(200,16,46,0.06);
    color: var(--blood-red);
    border-color: var(--border-red);
}
.act-btn.red:hover {
    background: var(--blood-red);
    color: #fff;
    border-color: var(--blood-red);
    transform: translateY(-1px);
    box-shadow: var(--shadow-red);
}

.act-btn-group { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ════════════ TAGS & BADGES ════════════ */
.tag {
    display: inline-flex; align-items: center;
    padding: .22rem .65rem;
    border-radius: var(--r-full);
    font-size: .75rem; font-weight: 700;
}
.tag.blue {
    background: var(--blood-red-soft);
    color: var(--blood-red);
    border: 1px solid var(--border-red);
}
.tag.green {
    background: rgba(22,163,74,0.07);
    color: var(--success);
    border: 1px solid rgba(22,163,74,0.2);
}
.tag.red {
    background: rgba(200,16,46,0.08);
    color: var(--blood-red);
    border: 1px solid var(--border-red);
}

/* ════════════ CLAIM CHIP ════════════ */
.claim-chip {
    display: inline-flex; align-items: center;
    background: var(--blood-red-soft);
    color: var(--blood-red);
    border: 1px solid var(--border-red);
    border-radius: var(--r-full);
    padding: .18rem .65rem;
    font-size: .75rem; font-weight: 700;
}

/* ════════════ FORMS ════════════ */
.admin-form .form-label {
    font-size: .88rem; font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: .45rem; display: block;
}
.admin-form .form-control,
.admin-form .form-select {
    border: 1px solid var(--border-medium);
    border-radius: var(--r-md);
    padding: .72rem 1rem;
    font-size: .92rem; font-family: 'Cairo', sans-serif;
    background: var(--surface-white);
    transition: all .2s ease;
    color: var(--text-primary);
    font-weight: 600;
}
.admin-form .form-control::placeholder { color: var(--text-muted); }
.admin-form .form-control:focus,
.admin-form .form-select:focus {
    border-color: var(--blood-red);
    box-shadow: 0 0 0 3px rgba(200,16,46,0.10);
    outline: none;
    background: var(--surface-white);
}
.admin-form .form-check-input:checked {
    background-color: var(--blood-red);
    border-color: var(--blood-red);
}

/* ════════════ ALERTS ════════════ */
.admin-alert {
    display: flex; align-items: center; gap: .9rem;
    padding: .95rem 1.3rem;
    border-radius: var(--r-md);
    font-size: .88rem; font-weight: 700;
    margin-bottom: 1.5rem;
    border-right: 3px solid;
}
.admin-alert.success {
    background: rgba(22,163,74,0.07);
    color: var(--success);
    border-color: var(--success);
}
.admin-alert.danger {
    background: var(--blood-red-soft);
    color: var(--blood-red);
    border-color: var(--blood-red);
}

/* ════════════ LOGIN PAGE ════════════ */
.public-shell { background: var(--bg-page); }
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-page);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--ink-black), var(--blood-red), var(--ink-black));
}
.login-card {
    position: relative; z-index: 10;
    width: min(440px, 90%);
    background: var(--surface-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-xl);
    padding: 3rem;
    box-shadow: var(--shadow-md);
}
.login-logo { text-align: center; margin-bottom: 2.5rem; }
.login-logo i {
    font-size: 2.5rem; color: var(--blood-red);
    display: block; margin-bottom: 1rem;
}
.login-logo h4 { font-size: 1.5rem; font-weight: 900; color: var(--ink-black); margin: 0; }
.login-logo p { color: var(--text-muted); font-size: .9rem; font-weight: 600; margin-top: .4rem; }
.login-submit-btn {
    width: 100%; padding: .85rem;
    background: var(--blood-red);
    color: #fff; font-size: .95rem; font-weight: 800;
    border: none; border-radius: var(--r-md);
    cursor: pointer; transition: all .2s;
    box-shadow: var(--shadow-red);
    font-family: 'Cairo', sans-serif;
}
.login-submit-btn:hover {
    background: var(--blood-red-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--blood-red-glow);
}

/* ════════════ EMPTY STATE ════════════ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 3rem;
    color: var(--border-medium);
    display: block;
    margin-bottom: 1rem;
}
.empty-state p { font-size: 1rem; font-weight: 600; }

/* ════════════ TREE — VERTICAL EXPAND ════════════ */
.admin-tree-container {
    background: var(--surface-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.tree-node {
    border-bottom: 1px solid var(--border-soft);
}
.tree-node:last-child { border-bottom: none; }

.tree-node-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1.2rem;
    background: transparent;
    transition: background .15s ease;
}
.tree-node-content:hover { background: #fdf5f6; }

.tree-node-info {
    display: flex;
    align-items: center;
    gap: .7rem;
    flex: 1;
    min-width: 0;
}

/* زر التوسع — يدور للأسفل عند الفتح */
.tree-toggle-btn {
    width: 30px; height: 30px;
    border: 1px solid var(--border-soft);
    background: var(--surface-off);
    color: var(--text-muted);
    border-radius: var(--r-xs);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all .25s ease;
    flex-shrink: 0;
}
.tree-toggle-btn i {
    font-size: .8rem;
    /* الأيقونة الافتراضية bi-chevron-left → تدور -90deg للأسفل عند الفتح */
    transition: transform .3s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-block;
}
/* عند الإغلاق → السهم يشير يسار (RTL → أسفل الشجرة) */
.tree-toggle-btn i { transform: rotate(0deg); }
/* عند الفتح → يشير للأسفل */
.tree-toggle-btn.open i { transform: rotate(-90deg); }

.tree-toggle-btn:hover {
    background: var(--blood-red);
    border-color: var(--blood-red);
    color: #fff;
}

.tree-spacer { width: 30px; height: 30px; flex-shrink: 0; }

.tree-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    color: var(--text-primary);
    font-weight: 700;
    flex-wrap: wrap;
}
.tree-title .bi { color: var(--blood-red); font-size: 1rem; }

.tree-node-actions { flex-shrink: 0; }

/* الأبناء — عرض رأسي للأسفل مع خط رابط */
.tree-children {
    /* padding-right مرتبط بالمستوى عبر inline style */
    border-right: 2px solid var(--blood-red-soft);
    margin-right: 2.4rem;
    margin-top: 0;
    margin-bottom: 0;
    /* Animation smooth */
    overflow: hidden;
    transition: all .3s ease;
}
.tree-children .tree-node {
    border-bottom: 1px solid var(--border-soft);
    position: relative;
}
.tree-children .tree-node:last-child { border-bottom: none; }

/* خط أفقي يربط الابن بالخط العمودي */
.tree-children .tree-node-content::before {
    content: '';
    position: absolute;
    right: -1.2rem;
    top: 50%;
    width: 1.2rem;
    height: 1px;
    background: var(--blood-red-soft);
}

/* ════════════ PERMISSIONS / CHECKBOXES ════════════ */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .8rem;
}

/* Operational requests */
.requests-hero {
    min-height: 210px;
    border-radius: var(--r-lg);
    padding: 1.8rem;
    margin-bottom: 1rem;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(26,26,26,.96), rgba(200,16,46,.88)),
        radial-gradient(circle at 15% 20%, rgba(255,255,255,.16), transparent 28%);
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1.2rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}
.requests-hero::after {
    content: '';
    position: absolute;
    inset-inline-start: -40px;
    bottom: -70px;
    width: 220px;
    height: 220px;
    border: 26px solid rgba(255,255,255,.08);
    border-radius: 50%;
}
.requests-hero > * { position: relative; z-index: 1; }
.requests-kicker {
    display: inline-flex;
    width: fit-content;
    padding: .24rem .7rem;
    border: 1px solid rgba(255,255,255,.24);
    border-radius: var(--r-full);
    color: rgba(255,255,255,.86);
    font-size: .78rem;
    font-weight: 800;
    margin-bottom: .65rem;
}
.requests-hero h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 900;
}
.requests-hero p {
    max-width: 660px;
    margin: .45rem 0 0;
    color: rgba(255,255,255,.78);
    font-weight: 700;
    line-height: 1.8;
}
.requests-hero-actions {
    display: flex;
    gap: .65rem;
    flex-wrap: wrap;
}
.requests-hero .btn-admin-outline {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.28);
    color: #fff;
}
.requests-hero .btn-admin-primary {
    background: #fff;
    color: var(--blood-red);
    box-shadow: none;
}
.request-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .8rem;
    margin-bottom: 1.4rem;
}
.request-stat {
    background: var(--surface-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow-xs);
}
.request-stat span {
    display: block;
    color: var(--blood-red);
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1;
}
.request-stat label {
    margin-top: .35rem;
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 800;
}
.request-catalog {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    padding: 1.2rem;
}
.request-tile { margin: 0; }
.request-tile button {
    width: 100%;
    min-height: 178px;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    background: linear-gradient(180deg, #fff, #fff8f8);
    padding: 1.05rem;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "icon body"
        "action action";
    gap: .85rem;
    text-align: start;
    cursor: pointer;
    transition: all .22s ease;
}
.request-tile button:hover {
    transform: translateY(-4px);
    border-color: var(--border-red);
    box-shadow: var(--shadow-md);
}
.request-tile-icon {
    grid-area: icon;
    width: 48px;
    height: 48px;
    border-radius: var(--r-md);
    background: var(--blood-red);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.28rem;
    box-shadow: var(--shadow-red);
}
.request-tile-body {
    grid-area: body;
    display: grid;
    gap: .38rem;
}
.request-tile-body strong {
    color: var(--ink-black);
    font-size: 1rem;
    font-weight: 900;
}
.request-tile-body small {
    color: var(--text-secondary);
    line-height: 1.65;
    font-weight: 700;
}
.request-tile-body em {
    color: var(--text-muted);
    font-size: .78rem;
    font-style: normal;
    font-weight: 800;
}
.request-tile-action {
    grid-area: action;
    justify-self: end;
    margin-top: .2rem;
    border-radius: var(--r-full);
    padding: .35rem .8rem;
    background: var(--blood-red-soft);
    color: var(--blood-red);
    font-size: .78rem;
    font-weight: 900;
}
.request-note-modal .modal-content {
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.request-note-modal .modal-header {
    align-items: flex-start;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-off);
    padding: 1.1rem 1.25rem;
}
.request-note-modal .modal-title {
    color: var(--ink-black);
    font-size: 1rem;
    font-weight: 900;
}
.request-modal-subtitle {
    display: block;
    margin-top: .25rem;
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 800;
}
.request-note-modal .modal-body {
    padding: 1.25rem;
}
.request-note-modal .form-label {
    color: var(--text-secondary);
    font-weight: 800;
    margin-bottom: .5rem;
}
.request-note-modal textarea {
    border: 1px solid var(--border-medium);
    border-radius: var(--r-md);
    padding: .8rem 1rem;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    resize: vertical;
}
.request-note-modal textarea:focus {
    border-color: var(--blood-red);
    box-shadow: 0 0 0 3px rgba(200,16,46,0.10);
}
.request-note-modal .modal-footer {
    border-top: 1px solid var(--border-soft);
    background: var(--surface-off);
    padding: .95rem 1.25rem;
}
.request-decision {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) auto auto;
    gap: .45rem;
    align-items: center;
    min-width: 380px;
}
.request-template-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
    gap: 1rem;
    align-items: stretch;
}
.request-template-preview {
    min-height: 100%;
    border-radius: var(--r-lg);
    padding: 1.6rem;
    background: var(--ink-black);
    color: #fff;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.request-preview-mark {
    width: 52px;
    height: 52px;
    border-radius: var(--r-md);
    background: var(--blood-red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 1rem;
}
.request-template-preview h3 {
    font-size: 1.25rem;
    font-weight: 900;
    margin-bottom: .55rem;
}
.request-template-preview p {
    color: rgba(255,255,255,.72);
    line-height: 1.8;
    font-weight: 700;
}
.request-flow {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    align-items: center;
    margin-top: 1rem;
}
.request-flow span {
    border: 1px solid rgba(255,255,255,.18);
    border-radius: var(--r-full);
    padding: .32rem .72rem;
    color: rgba(255,255,255,.88);
    font-size: .78rem;
    font-weight: 900;
}
.request-flow i { color: var(--blood-red); }

/* ════════════ RESPONSIVE ════════════ */
@media (max-width: 991px) {
    .admin-topbar {
        right: 0;
        padding: 0 1rem;
    }
    .admin-sidebar {
        transform: translateX(110%);
        width: 275px;
        top: 0; right: 0; bottom: 0;
        z-index: 1060;
    }
    .admin-sidebar.open { transform: translateX(0); }
    .topbar-brand {
        display: flex; align-items: center; gap: .5rem;
        text-decoration: none;
    }
    .topbar-brand i { font-size: 1.2rem; color: var(--blood-red); }
    .topbar-brand span { font-weight: 900; font-size: 1rem; color: var(--ink-black); }
    .admin-main, .admin-main.expanded {
        margin-top: calc(var(--topbar-h) + 3px);
        margin-right: 0;
        padding: 1rem;
    }
    .page-header { flex-direction: column; align-items: flex-start; gap: .7rem; }
    .requests-hero { align-items: flex-start; flex-direction: column; }
    .request-stats { grid-template-columns: 1fr; }
    .request-template-layout { grid-template-columns: 1fr; }
    .request-decision { min-width: 0; grid-template-columns: 1fr; }
}
@media (max-width: 575px) {
    .admin-table thead { display: none; }
    .admin-table tbody td {
        display: block; padding: .65rem 1.2rem; text-align: right;
    }
    .admin-table tbody td::before {
        content: attr(data-label);
        font-weight: 800; color: var(--text-muted);
        font-size: .75rem; display: block; margin-bottom: .2rem;
    }
}
/* Medical detachment approval QR */
.approval-qr{display:flex;align-items:center;gap:1rem;padding:1rem;border:1px solid #b8dfc9;border-radius:14px;background:#f1fbf5}.approval-qr img{width:132px;height:132px;border-radius:8px;background:#fff;padding:6px}.approval-qr h5{color:#187447}.approval-qr p{color:var(--text-muted);font-size:.82rem}

/* Modern operational UI layer */
.ux-page {
    display: grid;
    gap: 1rem;
}

.ux-hero,
.page-header {
    background:
        linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.88)),
        linear-gradient(135deg, rgba(200,16,46,.08), rgba(3,105,161,.06));
    border: 1px solid rgba(15,23,42,.08);
    border-right: 4px solid var(--blood-red);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(15,23,42,.07);
}

.ux-hero {
    padding: 1.35rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.ux-hero h1,
.page-header h1 {
    letter-spacing: 0;
}

.ux-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: .8rem;
}

.ux-kpi,
.staff-insight,
.staff-account-insight {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid rgba(15,23,42,.08);
    background:
        linear-gradient(180deg, #fff, #fbfdff);
    box-shadow: 0 10px 26px rgba(15,23,42,.06);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.ux-kpi:hover,
.staff-insight:hover,
.staff-account-insight:hover {
    transform: translateY(-2px);
    border-color: rgba(200,16,46,.22);
    box-shadow: 0 18px 42px rgba(15,23,42,.10);
}

.ux-kpi::before,
.staff-insight::before,
.staff-account-insight::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--blood-red), #0369a1);
}

.admin-card,
.staff-panel,
.staff-account-panel {
    border-radius: 8px !important;
    border: 1px solid rgba(15,23,42,.08) !important;
    box-shadow: 0 14px 34px rgba(15,23,42,.06) !important;
}

.card-action-bar,
.staff-panel-head,
.staff-account-panel-header {
    background:
        linear-gradient(180deg, #fff, #f8fafc) !important;
    border-bottom: 1px solid rgba(15,23,42,.08) !important;
}

.admin-table {
    border-collapse: separate;
    border-spacing: 0;
}

.admin-table thead th {
    background: #f8fafc;
    color: #475569;
    letter-spacing: 0;
    text-transform: none;
}

.admin-table tbody tr {
    transition: background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.admin-table tbody tr:hover {
    background: #fff7f8;
    box-shadow: inset 4px 0 0 rgba(200,16,46,.34);
}

.form-control,
.form-select,
.staff-form .form-control,
.staff-form .form-select,
.filter-field input,
.filter-field select {
    border-radius: 8px !important;
    border-color: #dbe3ef !important;
    min-height: 44px;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.form-control:focus,
.form-select:focus,
.staff-form .form-control:focus,
.staff-form .form-select:focus,
.filter-field input:focus,
.filter-field select:focus {
    border-color: var(--blood-red) !important;
    box-shadow: 0 0 0 4px rgba(200,16,46,.10) !important;
}

.modal-content {
    border: 0;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(15,23,42,.28);
    overflow: hidden;
}

.modal {
    z-index: 2055 !important;
}

.modal-backdrop {
    z-index: 2050 !important;
}

.modal-header,
.modal-footer {
    background: #f8fafc;
    border-color: rgba(15,23,42,.08);
}

.act-btn,
.btn-admin-primary,
.btn-admin-outline {
    border-radius: 8px;
}

.act-btn:focus-visible,
.btn-admin-primary:focus-visible,
.btn-admin-outline:focus-visible {
    outline: 3px solid rgba(200,16,46,.22);
    outline-offset: 2px;
}

.ux-fade-in {
    animation: uxFadeIn .22s ease both;
}

@keyframes uxFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Patient workflow */
.patient-workflow {
    display: grid;
    gap: 1rem;
}

.patient-hero {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(15,23,42,.08);
    border-right: 4px solid var(--blood-red);
    border-radius: 8px;
    padding: 1.25rem;
    background:
        linear-gradient(135deg, rgba(255,255,255,.96), rgba(248,250,252,.94)),
        radial-gradient(circle at 8% 15%, rgba(200,16,46,.12), transparent 32%),
        radial-gradient(circle at 90% 0%, rgba(3,105,161,.10), transparent 30%);
    box-shadow: 0 16px 38px rgba(15,23,42,.08);
}

.patient-hero-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.patient-stage {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    width: fit-content;
    padding: .32rem .7rem;
    border-radius: 999px;
    background: rgba(200,16,46,.08);
    color: var(--blood-red);
    font-size: .78rem;
    font-weight: 900;
}

.patient-hero h1 {
    margin: .55rem 0 .25rem;
    color: var(--ink-black);
    font-size: clamp(1.35rem, 2vw, 2rem);
    font-weight: 900;
    letter-spacing: 0;
}

.patient-hero p {
    margin: 0;
    color: var(--text-muted);
    font-size: .92rem;
    font-weight: 700;
}

.patient-hero-actions {
    display: flex;
    gap: .55rem;
    flex-wrap: wrap;
}

.patient-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .7rem;
}

.patient-step {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-height: 68px;
    padding: .85rem;
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15,23,42,.05);
}

.patient-step span {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #64748b;
    font-weight: 900;
}

.patient-step strong {
    display: block;
    color: var(--ink-black);
    font-size: .9rem;
    font-weight: 900;
}

.patient-step small {
    color: var(--text-muted);
    font-weight: 700;
}

.patient-step.active {
    border-color: rgba(200,16,46,.24);
    background: linear-gradient(180deg, #fff, #fff7f8);
}

.patient-step.active span {
    background: var(--blood-red);
    color: #fff;
    box-shadow: var(--shadow-red);
}

.patient-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1rem;
    align-items: start;
}

.patient-card {
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15,23,42,.06);
    overflow: hidden;
}

.patient-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid rgba(15,23,42,.08);
    background: linear-gradient(180deg, #fff, #f8fafc);
}

.patient-card-title {
    display: flex;
    align-items: center;
    gap: .65rem;
}

.patient-card-title i {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(200,16,46,.09);
    color: var(--blood-red);
    font-size: 1.05rem;
}

.patient-card-title h2,
.patient-card-title h3 {
    margin: 0;
    color: var(--ink-black);
    font-size: 1rem;
    font-weight: 900;
}

.patient-card-title small {
    color: var(--text-muted);
    font-weight: 700;
}

.patient-card-body {
    padding: 1.1rem;
}

.patient-field {
    position: relative;
}

.patient-field .form-label,
.patient-choice-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    color: #334155;
    font-size: .86rem;
    font-weight: 900;
}

.patient-required,
.patient-optional {
    border-radius: 999px;
    padding: .15rem .5rem;
    font-size: .68rem;
    font-weight: 900;
}

.patient-required {
    background: rgba(200,16,46,.09);
    color: var(--blood-red);
}

.patient-optional {
    background: #f1f5f9;
    color: #64748b;
}

.patient-field.is-filled .form-control,
.patient-field.is-filled .form-select {
    border-color: rgba(22,163,74,.45) !important;
    background: linear-gradient(180deg, #fff, #fbfffd);
}

.patient-entry-grid {
    display: grid;
    gap: 1rem;
}

.patient-entry-section {
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 10px;
    padding: 1rem;
    background: linear-gradient(180deg, #fff, #fbfdff);
}

.patient-entry-section-title {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: .9rem;
}

.patient-entry-section-title i {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(3,105,161,.08);
    color: #0369a1;
    font-size: 1.05rem;
}

.patient-entry-section-title h3 {
    margin: 0;
    color: var(--ink-black);
    font-size: .98rem;
    font-weight: 900;
}

.patient-entry-section-title span {
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 800;
}

.gender-toggle-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
    padding: .25rem;
    border: 1px solid rgba(15,23,42,.10);
    border-radius: 12px;
    background: #f8fafc;
}

.gender-toggle {
    position: relative;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    margin: 0;
    border-radius: 9px;
    color: #475569;
    cursor: pointer;
    font-weight: 900;
    transition: background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.gender-toggle:hover {
    background: #fff;
    transform: translateY(-1px);
}

.gender-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.gender-toggle i {
    font-size: 1rem;
}

.gender-toggle.is-selected {
    background: #fff;
    color: var(--blood-red);
    box-shadow: 0 8px 20px rgba(15,23,42,.08);
}

.chronic-disease-grid .choice-card {
    min-height: 58px;
    padding-block: .75rem;
}

.patient-summary {
    position: sticky;
    top: calc(var(--topbar-h) + 1rem);
    display: grid;
    gap: 1rem;
}

.patient-summary-card {
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15,23,42,.06);
    padding: 1rem;
}

.patient-progress {
    height: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.patient-progress span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--blood-red), #0369a1);
    transition: width .2s ease;
}

.patient-mini-list {
    display: grid;
    gap: .55rem;
    margin: .85rem 0 0;
}

.patient-mini-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 800;
}

.patient-mini-item i {
    color: var(--blood-red);
}

.vital-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: .8rem;
}

.vital-card {
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 8px;
    padding: .9rem;
    background: linear-gradient(180deg, #fff, #f8fafc);
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.vital-card:hover,
.vital-card:focus-within {
    transform: translateY(-2px);
    border-color: rgba(3,105,161,.24);
    box-shadow: 0 14px 28px rgba(15,23,42,.08);
}

.vital-card label {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .55rem;
    color: var(--ink-black);
    font-size: .86rem;
    font-weight: 900;
}

.vital-card small {
    color: var(--text-muted);
    font-weight: 800;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: .75rem;
}

.choice-card {
    position: relative;
    display: block;
    min-height: 92px;
    border: 1px solid rgba(15,23,42,.10);
    border-radius: 8px;
    padding: .9rem 2.2rem .9rem .9rem;
    background: #fff;
    cursor: pointer;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

[dir="ltr"] .choice-card,
html:not([dir="rtl"]) .choice-card {
    padding: .9rem .9rem .9rem 2.2rem;
}

.choice-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(15,23,42,.08);
}

.choice-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice-card strong {
    display: block;
    color: var(--ink-black);
    font-size: .95rem;
    font-weight: 900;
}

.choice-card span {
    display: block;
    margin-top: .25rem;
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.6;
}

.choice-card::before {
    content: "";
    position: absolute;
    inset-inline-start: .9rem;
    top: .9rem;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #cbd5e1;
}

.choice-card.is-selected {
    border-color: rgba(200,16,46,.32);
    background: linear-gradient(180deg, #fff, #fff7f8);
    box-shadow: 0 16px 34px rgba(15,23,42,.08);
}

.choice-card.is-selected::after {
    content: "\F26A";
    font-family: "bootstrap-icons";
    position: absolute;
    inset-inline-start: .8rem;
    bottom: .65rem;
    color: var(--blood-red);
}

.choice-card.triage-green::before { background: #16a34a; }
.choice-card.triage-yellow::before { background: #eab308; }
.choice-card.triage-red::before { background: #dc2626; }

.diagnosis-tree {
    display: grid;
    gap: .85rem;
}

.diagnosis-group {
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.diagnosis-group-title {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .9rem 1rem;
    background: linear-gradient(180deg, #f8fafc, #fff);
    border-bottom: 1px solid rgba(15,23,42,.08);
}

.diagnosis-group-title i {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(3,105,161,.08);
    color: #0369a1;
}

.diagnosis-group-title strong {
    display: block;
    color: var(--ink-black);
    font-weight: 900;
}

.diagnosis-group-title span {
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 800;
}

.diagnosis-children,
.diagnosis-grandchildren {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .65rem;
    padding: .85rem;
}

.diagnosis-grandchildren {
    grid-column: 1 / -1;
    margin-inline-start: 1rem;
    padding-top: 0;
    border-inline-start: 2px solid rgba(3,105,161,.16);
}

.diagnosis-subcategory-card {
    grid-column: 1 / -1;
    padding: .75rem .9rem;
    border: 1px dashed rgba(3,105,161,.24);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(3,105,161,.05), #fff);
}

.diagnosis-subcategory-card strong {
    display: block;
    color: var(--ink-black);
    font-weight: 900;
}

.diagnosis-subcategory-card span {
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 800;
}

.diagnosis-choice {
    min-height: 78px;
    margin: 0;
}

.compact-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-choice-grid .choice-card {
    min-height: 58px;
    padding-block: .75rem;
}

.diagnosis-chip-board {
    display: grid;
    gap: 1.1rem;
}

.diagnosis-chip-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: .85rem;
    align-items: start;
}

.diagnosis-chip-label {
    color: var(--text-secondary);
    font-weight: 900;
    padding-top: .55rem;
    text-align: left;
}

.diagnosis-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
}

.diagnosis-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: .55rem 1rem;
    border: 1px solid var(--border-medium);
    border-radius: 10px;
    background: #fff;
    color: var(--text-primary);
    font-weight: 900;
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    transition: all .18s ease;
}

.diagnosis-chip:hover {
    border-color: rgba(13, 110, 253, .35);
    transform: translateY(-1px);
}

.diagnosis-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.diagnosis-chip.is-selected,
.diagnosis-chip:has(input:checked) {
    border-color: rgba(220, 38, 38, .45);
    background: rgba(220, 38, 38, .06);
    color: var(--blood-red);
}

.diagnosis-chip.has-children::after {
    content: "\F282";
    font-family: "bootstrap-icons";
    font-size: .72rem;
    margin-inline-start: .45rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .diagnosis-chip-row {
        grid-template-columns: 1fr;
    }

    .diagnosis-chip-label {
        text-align: right;
        padding-top: 0;
    }
}

.patient-vital-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin: .2rem;
    padding: .42rem .65rem;
    border-radius: 999px;
    border: 1px solid rgba(15,23,42,.08);
    background: #f8fafc;
    color: #334155;
    font-size: .8rem;
    font-weight: 900;
}

.patient-history-list {
    display: grid;
    gap: .65rem;
}

.patient-history-item {
    display: grid;
    gap: .25rem;
    padding: .7rem;
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 8px;
    background: #f8fafc;
}

.patient-history-item strong {
    color: var(--ink-black);
    font-size: .82rem;
    font-weight: 900;
}

.patient-history-item span,
.patient-history-item small {
    color: var(--text-muted);
    font-size: .76rem;
    font-weight: 800;
    line-height: 1.6;
}

.patient-records-page {
    display: grid;
    gap: 1rem;
}

.medical-records-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.medical-record-patient-card,
.medical-record-profile,
.medical-record-visit {
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(15,23,42,.06);
}

.medical-record-patient-card {
    display: grid;
    gap: .9rem;
    padding: 1rem;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.medical-record-patient-card:hover {
    transform: translateY(-2px);
    border-color: rgba(3,105,161,.22);
    box-shadow: 0 18px 38px rgba(15,23,42,.10);
}

.medical-record-patient-main {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.medical-record-avatar {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(200,16,46,.08);
    color: var(--blood-red);
    font-size: 1.25rem;
    flex: 0 0 auto;
}

.medical-record-patient-card h2,
.medical-record-profile h2 {
    margin: 0;
    color: var(--ink-black);
    font-size: 1.05rem;
    font-weight: 900;
}

.medical-record-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .7rem;
    margin-top: .35rem;
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 800;
}

.medical-record-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .55rem;
}

.medical-record-summary div {
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 8px;
    padding: .55rem;
    background: #f8fafc;
}

.medical-record-summary span,
.medical-record-profile > div > span,
.medical-record-chronic > span,
.medical-record-visit-body span {
    display: block;
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 900;
    margin-bottom: .2rem;
}

.medical-record-summary strong {
    display: block;
    color: var(--ink-black);
    font-size: .84rem;
    font-weight: 900;
    line-height: 1.5;
}

.medical-record-diagnoses,
.medical-record-chronic div {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.medical-record-diagnoses span,
.medical-record-chronic strong {
    border-radius: 999px;
    padding: .28rem .6rem;
    background: rgba(3,105,161,.08);
    color: #0369a1;
    font-size: .76rem;
    font-weight: 900;
}

.medical-record-actions {
    display: flex;
    justify-content: flex-end;
}

.medical-record-profile {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.1rem;
}

.medical-record-timeline {
    display: grid;
    gap: .85rem;
}

.medical-record-visit {
    overflow: hidden;
}

.medical-record-visit-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1rem;
    background: linear-gradient(180deg, #fff, #f8fafc);
    border-bottom: 1px solid rgba(15,23,42,.08);
}

.medical-record-visit-head strong {
    display: block;
    color: var(--ink-black);
    font-weight: 900;
}

.medical-record-visit-head span {
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 800;
}

.medical-record-visit-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: .75rem;
    padding: 1rem;
}

.medical-record-visit-body div {
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 8px;
    padding: .7rem;
    background: #fff;
}

.medical-record-visit-body p {
    margin: 0;
    color: var(--ink-black);
    font-weight: 800;
    line-height: 1.7;
}

.patient-action-bar {
    display: flex;
    justify-content: flex-end;
    gap: .65rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid rgba(15,23,42,.08);
}

.treatment-row {
    border: 1px solid rgba(15,23,42,.08);
    border-right: 4px solid rgba(3,105,161,.35);
    border-radius: 8px;
    background: linear-gradient(180deg, #fff, #f8fafc);
    padding: .9rem;
    margin-bottom: .75rem;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.treatment-row:hover {
    transform: translateY(-2px);
    border-color: rgba(3,105,161,.22);
    box-shadow: 0 12px 28px rgba(15,23,42,.08);
}

.treatment-row label {
    color: #334155;
    font-size: .8rem;
    font-weight: 900;
    margin-bottom: .35rem;
}

.referral-panel {
    display: none;
}

.referral-panel.is-visible {
    display: block;
}

.patient-sheet-page {
    display: grid;
    gap: 1rem;
}

.patient-sheet-toolbar {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
}

.medical-sheet {
    width: min(100%, 210mm);
    margin: 0 auto;
    background: #fff;
    border: 1px solid rgba(15,23,42,.10);
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(15,23,42,.10);
    padding: 14mm;
    color: #111827;
}

.medical-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding-bottom: .8rem;
    border-bottom: 2px solid #111827;
}

.medical-sheet-header span,
.medical-sheet-header p,
.medical-sheet-meta span {
    color: #475569;
    font-size: .82rem;
    font-weight: 800;
}

.medical-sheet-header h1 {
    margin: .25rem 0;
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: 0;
}

.medical-sheet-meta {
    display: grid;
    gap: .25rem;
    min-width: 210px;
    text-align: end;
}

.medical-sheet-verification {
    display: grid;
    justify-items: center;
    gap: .25rem;
    min-width: 92px;
}

.medical-sheet-verification img {
    width: 82px;
    height: 82px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px;
    background: #fff;
}

.medical-sheet-verification small {
    color: #475569;
    font-size: .68rem;
    font-weight: 900;
}

.sheet-section {
    padding: .8rem 0;
    border-bottom: 1px solid #dbe3ef;
    break-inside: avoid;
}

.sheet-section h2 {
    margin: 0 0 .65rem;
    color: #111827;
    font-size: .98rem;
    font-weight: 900;
}

.sheet-grid {
    display: grid;
    gap: .55rem;
}

.sheet-grid-four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sheet-grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sheet-grid > div,
.sheet-note,
.sheet-vitals > div {
    border: 1px solid #dbe3ef;
    border-radius: 6px;
    padding: .55rem .7rem;
    background: #fff;
}

.sheet-grid span,
.sheet-note span,
.sheet-vitals span {
    display: block;
    color: #64748b;
    font-size: .72rem;
    font-weight: 900;
    margin-bottom: .2rem;
}

.sheet-grid strong,
.sheet-vitals strong {
    display: block;
    color: #111827;
    font-size: .88rem;
    font-weight: 900;
    line-height: 1.65;
}

.sheet-note {
    margin-top: .55rem;
}

.sheet-note p {
    margin: 0;
    color: #111827;
    font-weight: 800;
    line-height: 1.8;
    white-space: pre-wrap;
}

.sheet-vitals {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .55rem;
}

.sheet-diagnosis-list {
    display: grid;
    gap: .55rem;
}

.sheet-diagnosis-group {
    border: 1px solid #dbe3ef;
    border-radius: 6px;
    overflow: hidden;
}

.sheet-diagnosis-group h3 {
    margin: 0;
    padding: .45rem .65rem;
    background: #f8fafc;
    border-bottom: 1px solid #dbe3ef;
    font-size: .86rem;
    font-weight: 900;
}

.sheet-diagnosis-group ul {
    margin: 0;
    padding: .5rem 1.35rem .6rem .65rem;
}

.sheet-diagnosis-group li {
    margin-bottom: .35rem;
    color: #111827;
    font-weight: 800;
}

.sheet-diagnosis-group li span {
    color: #64748b;
    font-size: .78rem;
    font-weight: 800;
    margin-inline-start: .4rem;
}

.sheet-table {
    width: 100%;
    margin-top: .55rem;
    border-collapse: collapse;
    font-size: .84rem;
}

.sheet-table th,
.sheet-table td {
    border: 1px solid #cbd5e1;
    padding: .45rem .55rem;
    vertical-align: top;
}

.sheet-table th {
    background: #f8fafc;
    font-weight: 900;
}

.sheet-empty {
    margin: 0;
    color: #64748b;
    font-weight: 800;
}

.medical-sheet-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding-top: 1.2rem;
}

.medical-sheet-footer div {
    min-height: 58px;
    border-top: 1px solid #111827;
    padding-top: .45rem;
    color: #475569;
    font-weight: 900;
}

@media (max-width: 991px) {
    .patient-hero-main,
    .patient-layout {
        grid-template-columns: 1fr;
    }

    .patient-hero-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .patient-steps {
        grid-template-columns: 1fr;
    }

    .patient-summary {
        position: static;
    }

    .sheet-grid-four,
    .sheet-grid-two,
    .sheet-vitals {
        grid-template-columns: 1fr;
    }
}

@page {
    size: A4 portrait;
    margin: 10mm;
}

@media print {
    html,
    body {
        background: #fff !important;
        font-size: 11pt;
        overflow: visible !important;
    }

    body::before,
    .admin-sidebar,
    .admin-topbar,
    .admin-alert,
    .alert,
    .no-print,
    .patient-sheet-toolbar {
        display: none !important;
    }

    .admin-main,
    .admin-main.expanded {
        margin: 0 !important;
        padding: 0 !important;
    }

    .patient-sheet-page,
    .medical-sheet {
        display: block;
        width: 100%;
        margin: 0;
    }

    .medical-sheet {
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
    }

    .medical-sheet-header {
        padding-bottom: 6mm;
        margin-bottom: 2mm;
    }

    .medical-sheet-header h1 {
        font-size: 16pt;
    }

    .medical-sheet-verification img {
        width: 24mm;
        height: 24mm;
        padding: 1mm;
    }

    .sheet-section {
        padding: 4mm 0;
    }

    .sheet-section h2 {
        font-size: 11pt;
    }

    .sheet-grid-four {
        grid-template-columns: repeat(4, 1fr);
    }

    .sheet-grid-two {
        grid-template-columns: repeat(2, 1fr);
    }

    .sheet-vitals {
        grid-template-columns: repeat(5, 1fr);
    }

    .sheet-grid > div,
    .sheet-note,
    .sheet-vitals > div,
    .sheet-diagnosis-group,
    .sheet-table th,
    .sheet-table td {
        border-color: #9ca3af;
    }

    .medical-sheet,
    .sheet-section,
    .sheet-diagnosis-group,
    .sheet-table,
    .medical-sheet-footer {
        break-inside: avoid;
    }
}
