:root {
    --brand: #166534;
    --brand-dark: #14532d;
    --brand-soft: #dcfce7;
    --gold: #b7791f;
    --bg: #f4f6f3;
    --card: #ffffff;
    --text: #1f2a24;
    --muted: #6b7a71;
    --border: #e4e9e5;
    --radius: 14px;
    --sidebar-w: 260px;
}

html, body { font-family: "Tajawal", system-ui, sans-serif; background: var(--bg); color: var(--text); }
body { -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); }
h1:focus { outline: none; }
.tiny { font-size: .75rem; }

/* ---------- shell ---------- */
.app-shell { min-height: 100vh; }
.app-sidebar {
    position: fixed; inset: 0 0 0 auto; width: var(--sidebar-w); z-index: 1040;
    background: linear-gradient(180deg, var(--brand-dark), #0f3d22); color: #fff;
    display: flex; flex-direction: column; transition: transform .25s ease;
}
.app-main { margin-right: var(--sidebar-w); min-height: 100vh; }
.app-content { padding: 1.5rem; max-width: 1400px; }
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; background: var(--gold); display: grid; place-items: center; font-size: 1.3rem; }
.brand-title { font-weight: 800; font-size: 1.15rem; }
.brand-sub { font-size: .8rem; opacity: .75; }
.side-nav { flex: 1; overflow-y: auto; padding: .75rem .5rem; }
.side-nav a { display: flex; align-items: center; gap: .65rem; color: rgba(255,255,255,.85); text-decoration: none; padding: .6rem .8rem; border-radius: 10px; margin-bottom: 2px; }
.side-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav a.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 700; box-shadow: inset -3px 0 0 var(--gold); }
.side-nav i { font-size: 1.1rem; }
.nav-section { font-size: .72rem; opacity: .55; padding: .9rem .8rem .3rem; }
.side-user { display: flex; align-items: center; gap: .5rem; padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,.1); font-size: .9rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }

.app-topbar {
    position: sticky; top: 0; z-index: 1030; background: var(--brand-dark); color: #fff;
    display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem;
    padding-top: calc(.7rem + env(safe-area-inset-top));
}
.bottom-nav {
    position: fixed; bottom: 0; inset-inline: 0; z-index: 1030; background: #fff; border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; padding: .35rem 0 calc(.35rem + env(safe-area-inset-bottom));
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; font-size: .7rem; color: var(--muted); text-decoration: none; padding: .2rem .5rem; }
.bottom-nav a i { font-size: 1.25rem; }
.bottom-nav a.active { color: var(--brand); font-weight: 700; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(100%); }
    .app-sidebar.open { transform: none; }
    .app-main { margin-right: 0; }
    .app-content { padding: 1rem 1rem 5.5rem; }
}

/* ---------- page parts ---------- */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 800; margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.crumbs a { text-decoration: none; }
.crumbs i { font-size: .7rem; }

.card-app { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; }
.card-app-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .9rem; gap: .5rem; }
.card-app-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.card-app-head h2 i { color: var(--brand); }

.stat-card { display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: var(--text); position: relative; overflow: hidden; transition: transform .15s; }
a.stat-card:hover { transform: translateY(-2px); }
.stat-card > i { position: absolute; left: .9rem; top: .9rem; font-size: 1.6rem; color: var(--brand); opacity: .25; }
.stat-card .v { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.stat-card .v.small-v { font-size: 1.1rem; }
.stat-card .l { font-size: .82rem; color: var(--muted); }

.mini-stat { display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
.mini-stat b { font-size: 1.15rem; }
.mini-stat span { font-size: .75rem; color: var(--muted); }

.filter-bar { display: grid; grid-template-columns: 1fr 220px; gap: .5rem; margin-bottom: 1rem; }
@media (max-width: 575.98px) { .filter-bar { grid-template-columns: 1fr; } }

.family-card, .case-card { display: flex; gap: .8rem; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; color: var(--text); text-decoration: none; height: 100%; transition: border-color .15s, box-shadow .15s; }
.case-card { display: block; }
.family-card:hover, .case-card:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(22,101,52,.08); }
.family-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }

.info-row { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px dashed var(--border); font-size: .92rem; }
.info-row:last-child { border-bottom: 0; }
.info-row span:first-child { color: var(--muted); }

.table-app { margin: 0; }
.table-app thead th { font-size: .8rem; color: var(--muted); font-weight: 500; background: #fafbfa; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-app td, .table-app th { padding: .65rem .75rem; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state > i { font-size: 2.6rem; opacity: .4; display: block; margin-bottom: .5rem; }

.timeline { border-right: 2px solid var(--brand-soft); padding-right: 1rem; }
.timeline-item { position: relative; padding-bottom: 1rem; }
.timeline-item::before { content: ""; position: absolute; right: calc(-1rem - 7px); top: .35rem; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }

.chip { border: 1px solid var(--border); border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; cursor: pointer; user-select: none; background: #fff; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.badge { font-weight: 600; }
.badge-soft-primary { background: #e0ecff; color: #1d4ed8; }
.badge-soft-success { background: var(--brand-soft); color: var(--brand); }
.badge-soft-warning { background: #fef3c7; color: #92400e; }
.badge-soft-info { background: #e0f2fe; color: #0369a1; }
.badge-soft-secondary { background: #eef0ef; color: #57635c; }

.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(22,101,52,.15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-size: .88rem; font-weight: 500; margin-bottom: .3rem; }

.app-modal { background: transparent; }
.modal-backdrop { z-index: 1050; }
.app-modal.modal { z-index: 1055; }

/* ---------- auth ---------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
    background: radial-gradient(circle at 20% 10%, #1f7a43 0, transparent 45%), linear-gradient(160deg, var(--brand-dark), #0b2e19); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 20px; padding: 2rem 1.75rem; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 20px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 2rem; box-shadow: 0 8px 20px rgba(22,101,52,.35); }

/* ---------- framework ---------- */
.valid.modified:not([type=checkbox]) { outline: none; }
.invalid { outline: 1px solid #dc3545; }
.validation-message { color: #dc3545; font-size: .85rem; }
#blazor-error-ui { background: #fff3cd; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; right: 0; left: 0; padding: .6rem 1.25rem; position: fixed; z-index: 2000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; left: .75rem; top: .5rem; }
