/** Money Manager Pro — responsive bilingual design system. */
:root {
    --ink: #172033;
    --ink2: #27334b;
    --paper: #f5f7fb;
    --surface: #ffffff;
    --surface2: #fafbfc;
    --line: #dfe4ec;
    --muted: #6e788b;
    --accent: #2c6bed;
    --accent2: #1d55c7;
    --green: #18875b;
    --red: #c94343;
    --amber: #d08a17;
    --purple: #7b61d1;
    --shadow: 0 18px 45px rgba(23, 32, 51, .09);
    --radius: 18px;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font-family: Inter, "Noto Kufi Arabic", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); line-height: 1.7; }
.warning-text { color: var(--red); line-height: 1.65; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 18%, transparent), transparent 35%), var(--paper); }
.auth-card { width: min(450px, 100%); padding: 38px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 10px 0 12px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(30px, 5vw, 42px); line-height: 1.05; }
.auth-card p { color: var(--muted); line-height: 1.7; margin-bottom: 24px; }
.brand-lockup { min-height: 64px; display: flex; align-items: center; }
.brand-mark { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: var(--accent); color: white; font-weight: 900; font-size: 30px; box-shadow: 0 12px 22px color-mix(in srgb, var(--accent) 28%, transparent); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 22px; box-shadow: none; flex: 0 0 auto; }
.brand-mark.large { width: 90px; height: 90px; border-radius: 24px; font-size: 45px; }
.auth-logo { max-width: 190px; max-height: 72px; object-fit: contain; }
.sidebar-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 12px; background: white; padding: 3px; }
.eyebrow { display: block; color: var(--accent); font-size: 11px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.fld { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; min-width: 0; }
.fld span, .group-label { color: var(--ink2); font-size: 13px; font-weight: 750; }
.fld input, .fld select, .fld textarea { width: 100%; min-height: 43px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); padding: 10px 12px; outline: none; transition: border .18s, box-shadow .18s; }
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); }
.fld input[type="color"] { padding: 5px; }
.fld.compact { width: 190px; margin: 0; }
.fld.wide { grid-column: span 2; }
.check { display: inline-flex; align-items: center; gap: 9px; color: var(--ink2); font-size: 13px; font-weight: 700; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 11px; padding: 10px 15px; min-height: 42px; font-weight: 800; text-decoration: none; transition: transform .15s, background .15s, border .15s; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent2); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-danger { background: color-mix(in srgb, var(--red) 10%, white); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, white); }
.btn-sm { min-height: 31px; padding: 5px 8px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.language-link { display: block; text-align: center; margin-top: 20px; color: var(--accent); text-decoration: none; font-weight: 800; }
.message { min-height: 20px; margin-top: 13px; font-size: 13px; line-height: 1.5; color: var(--red); white-space: pre-wrap; }
.message.success { color: var(--green); }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 258px; display: flex; flex-direction: column; background: var(--ink); color: white; padding: 22px 16px; z-index: 40; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 3px 8px 24px; }
.sidebar-brand strong { display: block; font-size: 16px; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand small { display: block; margin-top: 3px; color: rgba(255,255,255,.55); font-size: 11px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; color: rgba(255,255,255,.72); background: transparent; border: 0; text-align: start; padding: 11px 12px; border-radius: 11px; font-weight: 700; }
.nav-item span { width: 20px; text-align: center; font-size: 17px; }
.nav-item.active, .nav-item:hover { color: white; background: rgba(255,255,255,.09); }
.nav-divider { height: 1px; background: rgba(255,255,255,.11); margin: 8px 5px; }
.sidebar-bottom { margin-top: auto; padding-top: 18px; }
.sidebar-language { color: white; opacity: .84; margin-bottom: 10px; border-color: rgba(255,255,255,.18); }
.sidebar .btn-ghost { color: white; border-color: rgba(255,255,255,.18); }
.content { min-height: 100vh; margin-inline-start: 258px; }
.topbar { position: sticky; top: 0; z-index: 30; min-height: 84px; display: flex; align-items: center; gap: 16px; justify-content: space-between; padding: 14px 28px; background: rgba(245,247,251,.93); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar h1 { margin: 2px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 27px; }
.user-chip { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 9px 13px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; font-size: 13px; font-weight: 750; }
.menu-button { display: none; border: 0; background: transparent; font-size: 24px; color: var(--ink); }
.page-body { padding: 24px 28px 42px; }
.page { display: none; }
.page.active { display: block; animation: pageIn .16s ease; }
@keyframes pageIn { from { opacity: .55; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.page-actions { min-height: 46px; display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.button-row, .inline-fields, .filter-actions, .form-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; margin-bottom: 18px; }
.stat { position: relative; min-height: 116px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(23,32,51,.04); overflow: hidden; }
.stat::after { content: ''; position: absolute; width: 80px; height: 80px; border-radius: 50%; inset-inline-end: -28px; inset-block-start: -26px; background: color-mix(in srgb, var(--stat-color, var(--accent)) 11%, transparent); }
.stat span { color: var(--muted); font-size: 12px; font-weight: 750; }
.stat strong { display: block; margin-top: 12px; font-size: 25px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat small { display: block; margin-top: 6px; color: var(--muted); }
.dashboard-grid, .reports-grid, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; align-items: start; }
.span-2 { grid-column: span 2; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(23,32,51,.04); overflow: hidden; }
.panel-head { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 2px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 21px; }
.panel-body { padding: 20px; }
.filter-panel { margin-bottom: 16px; }
.filters-grid { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); align-items: end; gap: 0 12px; }
.filters-grid .fld { margin-bottom: 0; }
.filter-actions { min-height: 43px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: start; font-size: 12.5px; vertical-align: middle; }
th { color: var(--muted); background: var(--surface2); font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
tbody tr:hover { background: #fbfcff; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
.amount-positive { color: var(--green); font-weight: 850; }
.amount-negative { color: var(--red); font-weight: 850; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 850; white-space: nowrap; }
.badge.income, .badge.cleared, .badge.active, .badge.info { color: var(--green); background: color-mix(in srgb, var(--green) 11%, white); }
.badge.expense, .badge.inactive, .badge.critical { color: var(--red); background: color-mix(in srgb, var(--red) 11%, white); }
.badge.transfer { color: var(--purple); background: color-mix(in srgb, var(--purple) 11%, white); }
.badge.pending, .badge.warning { color: var(--amber); background: color-mix(in srgb, var(--amber) 12%, white); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.empty { text-align: center; padding: 34px !important; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 15px; }
.pagination span { color: var(--muted); font-size: 12px; font-weight: 700; }
.account-cards, .account-grid, .budget-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.account-tile, .budget-tile { position: relative; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); overflow: hidden; }
.account-tile::before { content: ''; position: absolute; inset-inline-start: 0; inset-block: 0; width: 5px; background: var(--tile-color, var(--accent)); }
.account-tile h3, .budget-tile h3 { margin: 0; font-size: 15px; }
.account-tile .balance { display: block; margin: 13px 0 6px; font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
.account-meta, .tile-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; }
.tile-actions { display: flex; gap: 6px; margin-top: 14px; }
.budget-tile .budget-values { display: flex; justify-content: space-between; gap: 15px; margin: 13px 0 8px; }
.budget-tile strong { font-size: 17px; }
.progress { height: 9px; border-radius: 999px; overflow: hidden; background: var(--line); }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--bar-color, var(--accent)); }
.progress.over > span { background: var(--red); }
.chart-list { display: grid; gap: 13px; }
.chart-row { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(140px, 2fr) auto; align-items: center; gap: 10px; }
.chart-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 750; }
.chart-track { position: relative; height: 9px; border-radius: 999px; background: var(--line); overflow: hidden; }
.chart-bar { height: 100%; border-radius: inherit; background: var(--bar-color, var(--accent)); }
.chart-value { text-align: end; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.trend-chart { min-height: 235px; display: flex; align-items: end; gap: 10px; padding-top: 20px; overflow-x: auto; }
.trend-group { min-width: 54px; flex: 1; height: 200px; display: grid; grid-template-rows: 1fr auto; gap: 8px; }
.trend-bars { display: flex; align-items: end; justify-content: center; gap: 5px; height: 100%; border-bottom: 1px solid var(--line); }
.trend-bar { width: min(18px, 38%); min-height: 2px; border-radius: 5px 5px 0 0; }
.trend-bar.income { background: var(--green); }
.trend-bar.expense { background: var(--red); }
.trend-label { text-align: center; color: var(--muted); font-size: 10px; white-space: nowrap; }
.due-pill { padding: 7px 10px; border-radius: 999px; background: color-mix(in srgb, var(--amber) 12%, white); color: var(--amber); font-size: 11px; font-weight: 800; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: transparent; padding: 12px 17px; color: var(--muted); font-weight: 800; border-bottom: 3px solid transparent; }
.tab.active { color: var(--accent); border-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.field-group { padding: 15px 0; border-top: 1px solid var(--line); margin-top: 8px; }
.checks-row { display: flex; gap: 13px; flex-wrap: wrap; margin-top: 12px; }
.permissions-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.permission-group { padding: 13px; border: 1px solid var(--line); border-radius: 12px; }
.permission-group h4 { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.permission-group .check { display: flex; margin: 8px 0; }
.logo-preview { min-height: 130px; display: grid; place-items: center; margin-bottom: 18px; border: 1px dashed var(--line); border-radius: 15px; background: var(--surface2); }
.logo-preview img { max-width: 220px; max-height: 100px; object-fit: contain; }
.backup-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; margin-bottom: 18px; }
.modal { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 20px; background: rgba(10,17,30,.58); backdrop-filter: blur(4px); }
.modal.open { display: grid; }
.modal-card { width: min(610px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border-radius: 20px; box-shadow: 0 28px 80px rgba(0,0,0,.24); }
.modal-card.wide-modal { width: min(880px, 100%); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 17px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.modal-head h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 22px; }
.modal-close { border: 0; background: transparent; color: var(--muted); font-size: 28px; line-height: 1; }
.modal-body, #roleForm { padding: 20px; }
.toast { position: fixed; inset-inline-end: 22px; inset-block-end: 22px; z-index: 150; max-width: min(380px, calc(100vw - 44px)); padding: 13px 16px; border-radius: 12px; background: var(--ink); color: white; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
[dir="rtl"] .eyebrow { letter-spacing: 0; }
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="number"], [dir="rtl"] input[type="date"], [dir="rtl"] input[type="month"], [dir="rtl"] input[type="time"] { direction: ltr; text-align: right; }
@media (max-width: 1280px) {
    .filters-grid { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
    .account-cards, .account-grid, .budget-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 1030px) {
    .cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .dashboard-grid, .reports-grid, .settings-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .permissions-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .sidebar { transform: translateX(-105%); transition: transform .2s; }
    [dir="rtl"] .sidebar { transform: translateX(105%); }
    .sidebar.open { transform: translateX(0); }
    .content { margin-inline-start: 0; }
    .menu-button { display: block; }
    .topbar { min-height: 74px; padding: 12px 16px; }
    .user-chip { display: none; }
    .page-body { padding: 17px 14px 32px; }
    .filters-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .fld.wide { grid-column: span 1; }
    .account-cards, .account-grid, .budget-grid { grid-template-columns: 1fr; }
    .backup-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .auth-card { padding: 28px 21px; }
    .cards { grid-template-columns: 1fr; gap: 10px; }
    .stat { min-height: 98px; }
    .filters-grid, .form-grid { grid-template-columns: 1fr; }
    .form-grid .full, .fld.wide { grid-column: auto; }
    .page-actions, .report-actions { align-items: stretch; flex-direction: column; }
    .page-actions > *, .page-actions .btn, .button-row { width: 100%; }
    .button-row .btn { flex: 1; }
    .fld.compact { width: 100%; }
    .inline-fields { width: 100%; }
    .inline-fields .fld { flex: 1; }
    .chart-row { grid-template-columns: minmax(80px, 1fr) minmax(100px, 1.5fr); }
    .chart-value { grid-column: 2; }
}
.block { display: block; }
.num { text-align: end; }
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 7px; vertical-align: middle; }
.clipped { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge.current { color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, white); }
