:root {
    --brand: #0f4c5c;
    --brand-2: #16697a;
    --accent: #e9a03b;
    --bg: #f3f5f8;
    --sidebar-w: 260px;
    --bs-font-sans-serif: "Tajawal", system-ui, sans-serif;
    --bs-primary: #16697a;
    --bs-primary-rgb: 22, 105, 122;
    --bs-link-color: #16697a;
    --bs-link-color-rgb: 22, 105, 122;
}

body { font-family: "Tajawal", system-ui, sans-serif; background: var(--bg); }
.btn-primary { --bs-btn-bg: var(--brand-2); --bs-btn-border-color: var(--brand-2); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand-2); --bs-btn-border-color: var(--brand-2); --bs-btn-hover-bg: var(--brand-2); --bs-btn-hover-border-color: var(--brand-2); }
.text-bg-primary, .bg-primary { background-color: var(--brand-2) !important; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.text-credit { color: #198754; }
.text-debit { color: #dc3545; }

/* ============ الهيكل ============ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; background: linear-gradient(180deg, var(--brand) 0%, #0b3842 100%);
    color: #dfe9ec; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040;
}
.admin .sidebar { background: linear-gradient(180deg, #24324a 0%, #151e2e 100%); }
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; }
.brand-name { font-weight: 800; color: #fff; line-height: 1.2; }
.brand-sub { font-size: .78rem; opacity: .7; }
.sidebar .nav { padding: .5rem; }
.sidebar .nav-link { color: #cfe0e4; border-radius: 10px; padding: .55rem .8rem; display: flex; align-items: center; gap: .6rem; margin-bottom: 2px; }
.sidebar .nav-link i { font-size: 1.1rem; opacity: .85; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 700; box-shadow: inset -3px 0 0 var(--accent); }
.nav-section { font-size: .75rem; text-transform: uppercase; opacity: .55; padding: .9rem .8rem .3rem; font-weight: 700; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid #e6e9ee; padding: .6rem 1.25rem; display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 1030; }
.topbar-title { font-weight: 700; font-size: 1.1rem; }
.content { padding: 1.25rem; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; right: calc(-1 * var(--sidebar-w)); transition: right .2s; }
    body.sidebar-open .sidebar { right: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .content { padding: 1rem; }
}

/* ============ مكونات ============ */
.card { border: 0; border-radius: 14px; box-shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f3; font-weight: 700; border-radius: 14px 14px 0 0 !important; }
.stat { padding: 1rem 1.1rem; display: flex; align-items: center; gap: .9rem; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-value { font-size: 1.45rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: #6b7280; font-size: .88rem; }
a.stat-link { text-decoration: none; color: inherit; }
a.stat-link .card:hover { transform: translateY(-2px); transition: transform .15s; }

.table { --bs-table-bg: transparent; }
.table > thead th { background: #f7f8fa; color: #4b5563; font-weight: 700; font-size: .88rem; white-space: nowrap; border-bottom-width: 1px; }
.table td { vertical-align: middle; }
.table-card { overflow: hidden; }
.table-card .table { margin-bottom: 0; }
tfoot td, tfoot th { font-weight: 800; background: #fbfbfc; }

.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-actions h1 { font-size: 1.35rem; font-weight: 800; margin: 0; }
.filters { background: #fff; border-radius: 14px; padding: .9rem; margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(16,24,40,.06); }
.form-label { font-weight: 500; font-size: .9rem; margin-bottom: .25rem; }
.type-pill { font-weight: 700; }
.type-Buy { background: #e7f6ec; color: #157347; }
.type-Sell { background: #fdecec; color: #b02a37; }
.type-Transfer { background: #e8f0fe; color: #1a56db; }
.type-Receipt { background: #e7f6ec; color: #157347; }
.type-Payment { background: #fdecec; color: #b02a37; }

.ts-control { border-radius: var(--bs-border-radius); min-height: 38px; }
.ts-wrapper.single .ts-control { padding-left: 2rem; }
.ts-dropdown { text-align: right; }

.sub-warning { border-right: 5px solid #e0a800; }

/* ============ صفحات الدخول والتعريف ============ */
body.auth { background: radial-gradient(1200px 600px at 80% -10%, #1d7f93 0%, transparent 60%), linear-gradient(160deg, #0b3842 0%, #0f4c5c 55%, #12606f 100%); min-height: 100vh; color: #fff; display: flex; flex-direction: column; }
.auth-top { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; }
.auth-brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.2rem; display: flex; align-items: center; gap: .6rem; }
.auth-footer { text-align: center; padding: 1.5rem; opacity: .6; font-size: .85rem; margin-top: auto; }
.auth-card { background: #fff; color: #1f2937; border-radius: 18px; box-shadow: 0 25px 60px rgba(0,0,0,.25); padding: 2rem; }
.auth-card h1 { font-size: 1.5rem; font-weight: 800; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 800; line-height: 1.25; }
.hero .lead { opacity: .85; }
.feature { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); border-radius: 16px; padding: 1.25rem; height: 100%; }
.feature i { font-size: 1.8rem; color: var(--accent); }

/* ============ الطباعة ============ */
body.print-page { background: #e5e7eb; }
.print-toolbar { position: sticky; top: 0; background: #fff; padding: .6rem; display: flex; gap: .5rem; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.paper { background: #fff; max-width: 210mm; margin: 1rem auto; padding: 14mm; min-height: 140mm; box-shadow: 0 2px 10px rgba(0,0,0,.1); }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--brand); padding-bottom: .75rem; margin-bottom: 1rem; }
.print-head h2 { font-weight: 800; color: var(--brand); margin: 0; }
.print-box { border: 1px solid #d1d5db; border-radius: 8px; padding: .6rem .9rem; }
.print-foot { border-top: 1px solid #d1d5db; margin-top: 2rem; padding-top: .5rem; text-align: center; color: #6b7280; font-size: .85rem; }
.signs { display: flex; justify-content: space-around; margin-top: 3rem; }
.signs div { border-top: 1px dashed #9ca3af; padding-top: .3rem; width: 30%; text-align: center; color: #4b5563; }

@media print {
    .no-print, .sidebar, .topbar, .filters, .page-actions .btn, .sub-warning, .alert { display: none !important; }
    body, body.print-page { background: #fff !important; }
    .paper { box-shadow: none; margin: 0; padding: 0; max-width: none; }
    .content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    a { text-decoration: none; color: inherit; }
}
