:root {
    --ip-bg: #f5f6f8;
    --ip-surface: #ffffff;
    --ip-ink: #16202c;
    --ip-muted: #6b7785;
    --ip-line: #e3e7ec;
    --ip-brand: #0f6b4f;        /* أخضر هادئ بدل الأحمر — الأحمر في واجهة مالية يعني خطأً أو تأخراً */
    --ip-brand-soft: #e7f2ee;
    --ip-danger: #b3261e;
    --ip-warn: #9a6700;
    --ip-ok: #1a7f4b;
}

* { font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif; }

html, body {
    background: var(--ip-bg);
    color: var(--ip-ink);
    font-size: 15px;
}

h1, h2, h3, h4 { font-weight: 700; }
h1 { font-size: 1.5rem; }

/* ── الهيكل ───────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 260px;
    flex: 0 0 260px;
    background: var(--ip-surface);
    border-inline-start: 1px solid var(--ip-line);
    padding: 1rem .75rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand { display: flex; align-items: center; gap: .65rem; padding: .5rem .5rem 1.25rem; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--ip-brand); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 1.1rem;
}
.brand-name { font-weight: 700; line-height: 1.1; }
.brand-sub { font-size: .75rem; color: var(--ip-muted); }

.nav-section {
    font-size: .7rem; font-weight: 700; letter-spacing: .04em;
    color: var(--ip-muted); text-transform: uppercase;
    padding: 1rem .75rem .35rem;
}

.app-sidebar .nav-link {
    color: var(--ip-ink);
    border-radius: 8px;
    padding: .5rem .75rem;
    margin-bottom: .1rem;
    font-size: .92rem;
}
.app-sidebar .nav-link:hover { background: #f0f2f5; }
.app-sidebar .nav-link.active { background: var(--ip-brand-soft); color: var(--ip-brand); font-weight: 600; }

.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1.25rem;
    background: var(--ip-surface);
    border-bottom: 1px solid var(--ip-line);
}

.app-content { padding: 1.25rem; flex: 1 1 auto; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }

/* ── البطاقات والجداول ─────────────────────────────── */
.card { border: 1px solid var(--ip-line); border-radius: 12px; box-shadow: none; }
.card-header { background: transparent; border-bottom: 1px solid var(--ip-line); font-weight: 600; }

.stat-card { padding: 1rem 1.1rem; }
.stat-label { font-size: .8rem; color: var(--ip-muted); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.stat-sub { font-size: .78rem; color: var(--ip-muted); }

.table { --bs-table-bg: transparent; font-size: .9rem; }
.table > thead th {
    font-size: .78rem; font-weight: 700; color: var(--ip-muted);
    text-transform: uppercase; letter-spacing: .03em;
    border-bottom: 1px solid var(--ip-line);
    white-space: nowrap;
}
.table > tbody td { vertical-align: middle; }

/* المبالغ بأرقام مصفوفة عمودياً حتى تُقارَن بالنظر */
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.btn-primary { background: var(--ip-brand); border-color: var(--ip-brand); }
.btn-primary:hover, .btn-primary:focus { background: #0c5a42; border-color: #0c5a42; }
.btn-outline-primary { color: var(--ip-brand); border-color: var(--ip-brand); }
.btn-outline-primary:hover { background: var(--ip-brand); border-color: var(--ip-brand); }

.badge-soft { font-weight: 600; padding: .3rem .55rem; border-radius: 6px; font-size: .75rem; }
.badge-due { background: #eef1f4; color: #44515e; }
.badge-paid { background: #e6f4ec; color: var(--ip-ok); }
.badge-partial { background: #fff4e0; color: var(--ip-warn); }
.badge-overdue { background: #fdeceb; color: var(--ip-danger); }
.badge-waived { background: #eee9f7; color: #5b4b8a; }

.empty-state { padding: 3rem 1rem; text-align: center; color: var(--ip-muted); }

.form-label { font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
.form-text { font-size: .78rem; }
.required::after { content: " *"; color: var(--ip-danger); }

.validation-message { color: var(--ip-danger); font-size: .8rem; }

@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; height: 100%; }
}

/* ── طباعة الوصل ───────────────────────────────────── */
@media print {
    .app-sidebar, .app-topbar, .no-print { display: none !important; }
    .app-content { padding: 0; }
    .card { border: none; }
    body { background: #fff; }
}

#blazor-error-ui {
    color-scheme: light only;
    background: #ffe9e7;
    border-top: 1px solid #f3b7b2;
    bottom: 0;
    display: none;
    left: 0;
    padding: .7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; left: 1rem; top: .6rem; }
