:root {
    --bg: #111317;
    --surface: #1b1e23;
    --surface-2: #22262c;
    --input: #121418;
    --border: #2a2e35;
    --text: #f1f2f4;
    --muted: #8a909a;
    --gold: #eda21f;
    --gold-hover: #f6b43c;
    --gold-soft: #c9a24a;
    --danger: #e5534b;
    --ok: #3fb950;
    --radius: 10px;
    --font: "IBM Plex Sans Arabic", system-ui, sans-serif;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-hover); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.3; }

/* ---------------- حقول ونماذج ---------------- */
.field { display: block; margin-bottom: 1rem; }
.field > span:first-child { display: block; font-size: 13px; color: #c4c8cf; margin-bottom: 6px; }
.field .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input:not([type]), input[type=file], input[type=date], input[type=number], input[type=search], select, textarea {
    width: 100%;
    background: var(--input);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(237, 162, 31, .15);
}
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; min-width: 0; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 0; }
.check input { accent-color: var(--gold); width: 17px; height: 17px; }

/* ---------------- أزرار ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent; border-radius: 8px;
    padding: 9px 16px; font: inherit; font-weight: 600; font-size: 14px;
    cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--gold); color: #1a1406; }
.btn-primary:hover { background: var(--gold-hover); color: #1a1406; }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: #3a3f47; color: var(--text); }
.btn-danger { background: transparent; border-color: rgba(229, 83, 75, .4); color: var(--danger); }
.btn-danger:hover { background: rgba(229, 83, 75, .1); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 11px; }

/* ---------------- تنبيهات ---------------- */
.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 1rem; font-size: 14px; border: 1px solid; }
.alert-error { background: rgba(229, 83, 75, .1); border-color: rgba(229, 83, 75, .35); color: #ff8f88; }
.alert-ok { background: rgba(63, 185, 80, .1); border-color: rgba(63, 185, 80, .35); color: #7ee28a; }

/* ---------------- شاشة الدخول ---------------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
    width: 100%; max-width: 340px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--gold);
    border-radius: 12px;
    padding: 34px 20px 22px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
}
.auth-logo { text-align: center; margin-bottom: 30px; min-height: 48px; }
.auth-logo img { max-height: 70px; max-width: 220px; object-fit: contain; }
.logo-text {
    font-family: "Playfair Display", Georgia, serif;
    font-size: 38px; font-weight: 700; letter-spacing: 1px;
    background: linear-gradient(180deg, #e2c27a, #b88a2e);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-title { text-align: center; font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.auth-footer { text-align: center; color: #5d636c; font-size: 13px; margin: 28px 0 0; }

/* ---------------- الهيكل العام ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; flex-shrink: 0;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 18px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.brand img { max-height: 56px; max-width: 180px; object-fit: contain; }
.brand .logo-text { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; color: var(--muted); padding: 14px 10px 6px; letter-spacing: .5px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    color: #c4c8cf; font-size: 14px; margin-bottom: 2px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: rgba(237, 162, 31, .12); color: var(--gold); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav .soon { margin-inline-start: auto; font-size: 10px; background: var(--surface-2); color: var(--muted); padding: 1px 7px; border-radius: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 60px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--bg);
    position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 17px; margin: 0; }
.user-box { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.user-box .role { font-size: 11px; color: var(--muted); display: block; line-height: 1.2; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(237, 162, 31, .15); color: var(--gold);
    display: grid; place-items: center; font-weight: 700;
}
.menu-btn { display: none; background: none; border: 0; color: var(--text); cursor: pointer; padding: 6px; }
.content { padding: 24px; max-width: 1200px; width: 100%; }

/* ---------------- مكونات ---------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-head h2 { font-size: 16px; margin: 0; }
.panel.empty { text-align: center; padding: 50px 20px; }
.panel.empty p { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 20px; color: var(--text); display: block; transition: border-color .15s, transform .15s;
}
a.card:hover { border-color: rgba(237, 162, 31, .5); color: var(--text); transform: translateY(-2px); }
.card .ic { width: 42px; height: 42px; border-radius: 10px; background: rgba(237, 162, 31, .12); color: var(--gold); display: grid; place-items: center; margin-bottom: 14px; }
.card .ic svg { width: 22px; height: 22px; }
.card h3 { font-size: 15px; margin-bottom: 4px; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 20px; background: var(--surface-2); color: #c4c8cf; border: 1px solid var(--border); }
.badge-gold { background: rgba(237, 162, 31, .12); color: var(--gold); border-color: rgba(237, 162, 31, .3); }
.badge-ok { background: rgba(63, 185, 80, .1); color: #7ee28a; border-color: rgba(63, 185, 80, .3); }
.badge-off { background: rgba(229, 83, 75, .1); color: #ff8f88; border-color: rgba(229, 83, 75, .3); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.logo-preview {
    background: var(--input); border: 1px dashed var(--border); border-radius: 10px;
    min-height: 110px; display: grid; place-items: center; padding: 16px; margin-bottom: 10px;
}
.logo-preview img { max-height: 80px; max-width: 100%; }
.perm-box { background: var(--input); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; }

/* ---------------- الجوال ---------------- */
@media (max-width: 900px) {
    .sidebar { position: fixed; right: 0; top: 0; z-index: 20; transform: translateX(100%); transition: transform .2s; box-shadow: -10px 0 30px rgba(0,0,0,.5); }
    .sidebar.open { transform: none; }
    .menu-btn { display: block; }
    .content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .grid-2 { grid-template-columns: 1fr; }
    .user-box .name-wrap { display: none; }
}

/* ================================================================
   قسم المحاسبة والمالية
   ================================================================ */
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.pos { color: #7ee28a; }
.neg { color: #ff8f88; }
.gold { color: var(--gold); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn svg { width: 16px; height: 16px; }
.icon-btn {
    display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
    background: transparent; border: 1px solid transparent; color: var(--muted); cursor: pointer;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(229, 83, 75, .4); }
.icon-btn[disabled] { opacity: .3; cursor: not-allowed; }
.inline-form { display: inline; margin: 0; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
.field-check { display: flex; align-items: flex-end; padding-bottom: 1rem; }

/* فلترة متقدمة */
.filter-panel { display: none; }
.filter-panel.open { display: block; }
.filter-panel .grid-4 { align-items: end; }

/* قائمة منسدلة لزر الإضافة */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 30; min-width: 170px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .45); display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 8px 12px; border-radius: 6px; color: var(--text); font-size: 14px; }
.dropdown-menu a:hover { background: rgba(237, 162, 31, .12); color: var(--gold); }

/* الجداول */
.table td.wrap { white-space: normal; min-width: 200px; }
.table tr.sub-row td { background: var(--input); padding: 0; }
.table tr.sub-row .table { margin: 0; }
.table tr.sub-row .table td, .table tr.sub-row .table th { padding: 8px 14px; font-size: 13px; }
.expand-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; transition: transform .15s; }
.expand-btn svg { width: 16px; height: 16px; }
.expand-btn.open { transform: rotate(-90deg); color: var(--gold); }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--border); border-bottom: 0; }
.clickable { cursor: pointer; user-select: none; }
.clickable:hover { color: var(--text); }
.sort-asc::after { content: " ▲"; font-size: 9px; }
.sort-desc::after { content: " ▼"; font-size: 9px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-links a, .pager-links span {
    min-width: 34px; height: 34px; padding: 0 10px; display: inline-grid; place-items: center;
    border-radius: 8px; border: 1px solid var(--border); font-size: 13px; color: #c4c8cf;
}
.pager-links a:hover { border-color: var(--gold); color: var(--gold); }
.pager-links .current { background: var(--gold); color: #1a1406; border-color: var(--gold); font-weight: 700; }
.table-tools { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.table-tools input { max-width: 260px; }
.table-tools select { width: auto; }

/* بطاقات المجاميع */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px; }
.total-card { border-radius: 12px; padding: 18px 20px; border: 1px solid var(--border); background: var(--surface); }
.total-card .t-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.total-card .t-value { font-size: 22px; font-weight: 700; }
.total-card.credit { border-color: rgba(63, 185, 80, .35); background: linear-gradient(180deg, rgba(63, 185, 80, .08), transparent); }
.total-card.credit .t-value { color: #7ee28a; }
.total-card.debit { border-color: rgba(229, 83, 75, .35); background: linear-gradient(180deg, rgba(229, 83, 75, .08), transparent); }
.total-card.debit .t-value { color: #ff8f88; }
.total-card.diff { border-color: rgba(237, 162, 31, .35); background: linear-gradient(180deg, rgba(237, 162, 31, .08), transparent); }
.total-card.diff .t-value { color: var(--gold); }
.total-card .t-note { font-size: 13px; margin-top: 4px; }

/* شجرة الحسابات */
.tree { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.tree ul { list-style: none; margin: 0; padding-inline-start: 26px; border-inline-start: 1px dashed var(--border); margin-inline-start: 10px; }
.tree li > ul { display: none; }
.tree li.open > ul { display: block; }
.tree-row {
    display: grid; grid-template-columns: minmax(200px, 1fr) 120px 150px 190px; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 8px; cursor: default;
}
.tree-row:hover, .tree-row.selected { background: var(--surface-2); }
.tree-row.selected { outline: 1px solid rgba(237, 162, 31, .4); }
.tree-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tree-name .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-name .code { color: var(--gold); font-size: 12px; }
.tree-toggle { width: 20px; height: 20px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; flex-shrink: 0; transition: transform .15s; }
.tree-toggle svg { width: 14px; height: 14px; }
li.open > .tree-row .tree-toggle { transform: rotate(-90deg); color: var(--gold); }
.tree-toggle.leaf { visibility: hidden; }
.tree-kids { font-size: 12px; color: #6cb6ff; white-space: nowrap; }
.tree-final { font-size: 12px; color: var(--gold-soft); text-align: start; white-space: nowrap; }
.tree-bal { text-align: end; font-weight: 600; }
.tree-more { opacity: 0; }
.tree-row:hover .tree-more { opacity: 1; }
.tree-head { font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); border-radius: 0; margin-bottom: 6px; }
.tree-head:hover { background: none; }

.ctx-menu {
    position: fixed; z-index: 50; min-width: 190px; display: none;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, .55);
}
.ctx-menu.open { display: block; }
.ctx-menu .ctx-title { font-size: 12px; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ctx-menu a, .ctx-menu button {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 6px;
    background: none; border: 0; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-align: start;
}
.ctx-menu svg { width: 16px; height: 16px; color: var(--muted); }
.ctx-menu a:hover, .ctx-menu button:hover { background: rgba(237, 162, 31, .12); color: var(--gold); }
.ctx-menu button.danger:hover { background: rgba(229, 83, 75, .1); color: var(--danger); }
.ctx-menu [disabled] { opacity: .35; pointer-events: none; }

/* سطور السند */
.lines-box { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-top: 8px; }
.lines-box .table th { background: var(--surface-2); }
.lines-box .table td { padding: 8px; }
.lines-box input, .lines-box select { padding: 8px 10px; }
.entry-input-row td { background: rgba(237, 162, 31, .04); }
.lines-box .w-amt { width: 120px; }
.lines-box .w-cur { width: 110px; }
.lines-box .w-rate { width: 100px; }
.lines-box .w-acc { min-width: 220px; }
.lines-box .w-act { width: 110px; }
.lines-sum { display: grid; grid-template-columns: 1fr 1fr 1fr; border-top: 1px solid var(--border); }
.lines-sum > div { padding: 14px 18px; border-inline-start: 1px solid var(--border); }
.lines-sum > div:first-child { border-inline-start: 0; }
.lines-sum .t-label { font-size: 13px; color: var(--muted); }
.lines-sum .t-value { font-size: 18px; font-weight: 700; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* بطاقة سند القبض/الدفع */
.voucher-flow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: end; }
.voucher-flow .arrow { padding-bottom: 1.6rem; color: var(--gold); font-size: 22px; }

/* القائمة المنسدلة مع بحث (Tom Select) بنفس ألوان النظام */
.ts-wrapper .ts-control, .ts-wrapper.single.input-active .ts-control, .ts-wrapper.single .ts-control {
    background: var(--input) !important; border: 1px solid var(--border); color: var(--text);
    border-radius: 8px; padding: 10px 12px; box-shadow: none; font: inherit; min-height: 44px;
}
.lines-box .ts-wrapper .ts-control { padding: 8px 10px; min-height: 38px; }
.ts-wrapper.focus .ts-control { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(237, 162, 31, .15); }
.ts-control input, .ts-control .item { color: var(--text) !important; font: inherit; }
.ts-control input::placeholder { color: var(--muted); }
.ts-dropdown { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; margin-top: 4px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.ts-dropdown .option, .ts-dropdown .no-results, .ts-dropdown .optgroup-header { padding: 8px 12px; }
.ts-dropdown .optgroup-header { background: var(--surface); color: var(--gold); font-size: 12px; }
.ts-dropdown .active { background: rgba(237, 162, 31, .15); color: var(--text); }
.ts-dropdown .option .sub { font-size: 12px; color: var(--muted); }
.ts-wrapper.single .ts-control::after { border-color: var(--muted) transparent transparent; }
.ts-wrapper.rtl.single .ts-control::after { left: 12px; right: auto; }

/* كشف الحساب والطباعة */
.statement-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.statement-head h2 { font-size: 18px; }
.print-only { display: none; }
@media print {
    body { background: #fff; color: #000; }
    .sidebar, .topbar, .no-print, .toolbar, .pager, .filter-panel { display: none !important; }
    .content { padding: 0; max-width: none; }
    .panel { border: 0; padding: 0; background: #fff; }
    .table th, .table td { border-color: #ccc; color: #000; }
    .print-only { display: block; }
    .pos, .neg, .gold { color: #000; }
}

@media (max-width: 900px) {
    .grid-3, .grid-4, .totals, .voucher-flow, .lines-sum { grid-template-columns: 1fr; }
    .voucher-flow .arrow { display: none; }
    .tree-row { grid-template-columns: 1fr auto; }
    .tree-row .tree-kids, .tree-row .tree-final { display: none; }
    .tree-more { opacity: 1; }
}

/* ================================================================
   صفحة الإحصائيات
   ================================================================ */
.chips { gap: 6px; }
.chip {
    padding: 7px 14px; border-radius: 20px; border: 1px solid var(--border);
    background: var(--surface); color: #c4c8cf; font-size: 13px; font-weight: 500;
}
.chip:hover { border-color: var(--gold); color: var(--gold); }
.chip.active, .active-chip { background: rgba(237, 162, 31, .12); border-color: rgba(237, 162, 31, .5); color: var(--gold); }

.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.dash-grid .widget { margin: 0; min-width: 0; }
.dash-grid .w-wide { grid-column: span 2; }
.dash-grid .w-full { grid-column: 1 / -1; }
.dash-grid .w-tall { grid-row: span 2; }
.widget .panel-head { margin-bottom: 14px; }
.widget .panel-head h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.widget .panel-head h2 svg { width: 18px; height: 18px; color: var(--gold); }

.box-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.box-item {
    display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center;
    padding: 12px; border-radius: 10px; background: var(--input); border: 1px solid var(--border); color: var(--text);
}
.box-item:hover { border-color: rgba(237, 162, 31, .45); color: var(--text); }
.box-ic { width: 38px; height: 38px; border-radius: 10px; background: rgba(237, 162, 31, .12); color: var(--gold); display: grid; place-items: center; }
.box-ic svg { width: 19px; height: 19px; }
.box-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.box-val { text-align: end; font-weight: 700; display: flex; flex-direction: column; }
.box-total { display: flex; justify-content: space-between; border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }

.profit-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.donut-box { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.donut { width: 100%; height: 100%; }
.donut circle { transition: stroke-width .15s; }
.donut circle:hover { stroke-width: 22; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut-center strong { font-size: 15px; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 180px; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; font-size: 14px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; }
.legend .legend-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; }

.stat-list { display: flex; flex-direction: column; gap: 14px; }
.stat { display: flex; gap: 12px; align-items: center; }
.stat-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex-shrink: 0; }
.stat-ic svg { width: 18px; height: 18px; }
.stat-ic.in { background: rgba(63, 185, 80, .1); color: #7ee28a; }
.stat-ic.out { background: rgba(229, 83, 75, .1); color: #ff8f88; }
.stat-v { font-size: 20px; font-weight: 700; margin: 0; }

.legend-inline { display: flex; gap: 14px; font-size: 13px; color: #c4c8cf; }
.legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }
.bars { width: 100%; height: auto; display: block; direction: ltr; }
.bars .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.bar-g:hover rect[fill="transparent"] { fill: rgba(255, 255, 255, .03); }
.table-view { margin-top: 10px; }
.table-view summary { cursor: pointer; color: var(--muted); }
.table-view .table { margin-top: 8px; }

.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { border-bottom: 1px solid var(--border); }
.recent-list li:last-child { border-bottom: 0; }
.recent-list a { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 0; color: var(--text); }
.recent-list a:hover { color: var(--gold); }
.recent-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c4c8cf; }
.recent-list .num { text-align: end; font-size: 14px; }

.widget-order { list-style: none; margin: 0; padding: 6px 10px; background: var(--input); border: 1px solid var(--border); border-radius: 8px; }
.widget-order li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding: 2px 0; }
.widget-order li:last-child { border-bottom: 0; }
.order-btns { display: flex; gap: 2px; }
.ts-wrapper.multi .ts-control > .item { background: rgba(237, 162, 31, .15) !important; border: 1px solid rgba(237, 162, 31, .4); color: var(--text) !important; border-radius: 6px; padding: 2px 6px; }
.ts-wrapper.plugin-remove_button .item .remove { border-color: rgba(237, 162, 31, .3) !important; color: var(--gold); }

@media (max-width: 1100px) {
    .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-grid .w-tall { grid-row: auto; }
}
@media (max-width: 700px) {
    .dash-grid { grid-template-columns: 1fr; }
    .dash-grid .w-wide { grid-column: auto; }
}

/* شريط المسار */
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; margin: -4px 0 18px; color: var(--muted); }
.breadcrumb a { color: #c4c8cf; }
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb .sep { color: #4b5058; }
.breadcrumb .current { color: var(--gold); font-weight: 600; }
.panel-head h2 svg { width: 18px; height: 18px; vertical-align: -3px; }
@media print { .breadcrumb { display: none; } }

/* ================================================================
   كشف الحساب
   ================================================================ */
.nowrap { white-space: nowrap; }
.st-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.st-summary > div { background: var(--input); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.st-panel { padding: 0; overflow: hidden; }
.st-panel > .table-wrap, .st-panel > p, .st-panel > .pager { padding-inline: 18px; }
.st-panel > p { padding-bottom: 16px; }
.st-table th { background: var(--surface-2); text-align: center; vertical-align: middle; line-height: 1.3; padding: 12px 8px; }
.st-table th svg { width: 14px; height: 14px; vertical-align: -2px; }
.st-table th small { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.st-table td { text-align: center; padding: 9px 8px; }
.st-table td.st-note { text-align: start; min-width: 220px; }
.st-table tbody tr { cursor: pointer; }
.st-table tbody tr:hover td { background: rgba(255, 255, 255, .02); }
.st-table tbody tr.selected td { background: rgba(237, 162, 31, .07); }
.st-table td.st-orig, .st-table th.st-orig { background: rgba(255, 255, 255, .015); }
.st-table input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; cursor: pointer; }
.st-opening td { background: var(--input) !important; cursor: default; }
.arrow-up, .arrow-down { display: block; font-size: 13px; font-weight: 700; }
.arrow-up { color: #7ee28a; }
.arrow-down { color: #ff8f88; }

.pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 20px;
    font-size: 13px; font-weight: 600; border: 1px solid transparent; min-width: 74px; justify-content: center;
}
.pill i { font-style: normal; width: 15px; height: 15px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; line-height: 1; }
.pill-d { background: rgba(63, 185, 80, .12); border-color: rgba(63, 185, 80, .35); color: #7ee28a; }
.pill-d i { background: #3fb950; color: #0d1f10; }
.pill-c { background: rgba(229, 83, 75, .12); border-color: rgba(229, 83, 75, .35); color: #ff8f88; }
.pill-c i { background: #e5534b; color: #2a0d0b; }
.pill-zero { background: transparent; border-color: var(--border); color: #4b5058; font-weight: 400; }
.pill-bal { background: rgba(63, 185, 80, .16); border-color: rgba(63, 185, 80, .5); color: #7ee28a; min-width: 110px; font-size: 14px; }
.pill-bal-neg { background: rgba(229, 83, 75, .16); border-color: rgba(229, 83, 75, .5); color: #ff8f88; min-width: 110px; font-size: 14px; }
.pill-bal-zero { border-color: var(--border); color: var(--muted); min-width: 110px; }

.cur-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; background: rgba(237, 162, 31, .1); border: 1px solid rgba(237, 162, 31, .35); color: var(--gold); white-space: nowrap; }
.cur-badge svg { width: 13px; height: 13px; }
.cur-badge.other { background: rgba(57, 135, 229, .1); border-color: rgba(57, 135, 229, .4); color: #8ab8f0; }
.type-ic svg { width: 14px; height: 14px; vertical-align: -2px; margin-inline-end: 4px; color: var(--muted); }
.date-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; border: 1px solid var(--border); background: var(--input); font-size: 12px; }

.sel-bar {
    position: fixed; bottom: 18px; left: 50%; transform: translate(-50%, 150%); z-index: 40;
    display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: center;
    background: var(--surface-2); border: 1px solid rgba(237, 162, 31, .45); border-radius: 14px;
    padding: 10px 18px; box-shadow: 0 16px 40px rgba(0, 0, 0, .55); font-size: 14px; transition: transform .2s;
}
.sel-bar.open { transform: translate(-50%, 0); }

.acc-summary { margin: 18px 0 0; border-top: 1px solid var(--border); }
.acc-summary-head { display: flex; align-items: center; gap: 8px; padding: 16px 18px; font-size: 16px; font-weight: 700; background: linear-gradient(90deg, rgba(237, 162, 31, .1), transparent); }
.acc-summary-head svg { width: 18px; height: 18px; color: var(--gold); }
.acc-summary-table th { text-align: center; background: var(--surface-2); }
.acc-summary-table th:first-child, .acc-summary-table td:first-child { text-align: start; }
.acc-summary-table td { text-align: center; }
.acc-summary-table tr.is-acc-cur td { background: rgba(237, 162, 31, .05); }
.sum-h { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-weight: 700; margin-inline-end: 4px; }
.sum-h.d { background: rgba(63, 185, 80, .2); color: #7ee28a; }
.sum-h.c { background: rgba(229, 83, 75, .2); color: #ff8f88; }
.sum-h.b { background: rgba(237, 162, 31, .2); color: var(--gold); }
.sum-h svg { width: 12px; height: 12px; }
.cur-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-inline-end: 8px; }

@media (max-width: 900px) { .st-summary { grid-template-columns: repeat(2, 1fr); } }
@media print {
    .pill, .cur-badge, .date-badge { border-color: #999 !important; background: none !important; color: #000 !important; }
    .pill i { display: none; }
    .acc-summary-head { background: none; }
}

/* عرض جميع الحسابات */
.accounts-table th { background: var(--surface-2); }
.accounts-table td { padding: 10px 12px; }
.acc-code { font-size: 11px; color: var(--muted); }
.status-btn {
    min-width: 92px; padding: 7px 14px; border-radius: 8px; border: 0; cursor: pointer;
    font: inherit; font-size: 13px; font-weight: 700; transition: filter .15s, transform .1s;
}
.status-btn:hover { filter: brightness(1.12); }
.status-btn:active { transform: scale(.97); }
.status-btn.on { background: #2ea043; color: #fff; }
.status-btn.off { background: #e8721c; color: #fff; }
