:root {
    --bg: #070a10;
    --bg-soft: #0b1018;
    --panel: #101620;
    --panel-2: #151c29;
    --panel-3: #0c1118;
    --border: #243044;
    --border-soft: #1b2433;
    --text: #eef3ff;
    --muted: #95a0b4;
    --muted-2: #6f7a8f;
    --blue: #4f7cff;
    --cyan: #25c7f5;
    --green: #34d27d;
    --red: #ff6579;
    --amber: #f3be57;
    --violet: #7c5cff;
    --radius: 14px;
    --font: 'Noto Sans Arabic', Tahoma, sans-serif;
    --display: 'Rajdhani', 'Noto Sans Arabic', sans-serif;
    --shadow: 0 24px 70px -45px rgba(35, 129, 255, .55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 0 0, rgba(37, 199, 245, .08), transparent 34%),
        radial-gradient(circle at 70% 8%, rgba(124, 92, 255, .10), transparent 34%),
        var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { border: 0; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 288px;
}
.sidebar {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 16px;
    background: linear-gradient(180deg, rgba(13, 17, 26, .98), rgba(8, 11, 18, .98));
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.brand-block,
.side-user {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.brand-mark,
.avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--blue), var(--violet));
    color: #fff;
    font-family: var(--display);
    font-weight: 800;
    box-shadow: 0 14px 30px -18px var(--blue);
}
.brand-block strong {
    display: block;
    font-family: var(--display);
    font-size: 20px;
    letter-spacing: 0;
    line-height: 1.1;
}
.brand-block span,
.side-user span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 190px;
}
.side-user strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 190px;
}
.side-nav {
    display: grid;
    gap: 6px;
}
.side-nav a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 13px;
    border-radius: 11px;
    color: var(--muted);
    font-weight: 800;
    border: 1px solid transparent;
}
.side-nav a:hover,
.side-nav a.active {
    color: var(--text);
    background: #14213a;
    border-color: #213b68;
}
.side-user {
    margin-top: auto;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .035);
}

.main {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    width: 100%;
    max-width: 1280px;
    padding: 28px;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}
.eyebrow {
    color: var(--muted);
    margin: 0 0 4px;
    font-size: 13px;
}
h1, h2, h3 { margin: 0; line-height: 1.35; letter-spacing: 0; }
h1 { font-size: 30px; }
h2 { font-size: 18px; }

.grid { display: grid; gap: 16px; }
.stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 22px;
}
.compact-stats .card {
    min-height: 100px;
}
.compact-stats .card .value {
    font-size: 24px;
}
.card,
.panel,
.form-card {
    background: linear-gradient(180deg, rgba(16, 22, 32, .96), rgba(11, 16, 24, .96));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card {
    min-height: 118px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.card:after {
    content: '';
    position: absolute;
    inset: -72px auto auto -72px;
    width: 170px;
    height: 170px;
    background: radial-gradient(circle, rgba(37, 199, 245, .18), transparent 68%);
}
.card .label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}
.card .value {
    margin-top: 9px;
    font-family: var(--display);
    font-size: 30px;
    font-weight: 800;
}
.panel {
    padding: 20px;
    margin-bottom: 18px;
}
.period-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 16px;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}
.filters,
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.field {
    display: grid;
    gap: 7px;
    min-width: 0;
}
.wide-field { grid-column: span 2; }
.field label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}
.input,
input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 10px 12px;
    outline: none;
}
textarea { min-height: 96px; resize: vertical; }
input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(79, 124, 255, .16);
}
.btn {
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    cursor: pointer;
    background: var(--panel-2);
    color: var(--text);
    font-weight: 800;
    white-space: nowrap;
}
.btn.primary {
    background: linear-gradient(90deg, var(--blue), var(--violet));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 16px 34px -22px var(--blue);
}
.btn.good { background: rgba(52, 210, 125, .14); color: #7cf0aa; border-color: rgba(52, 210, 125, .28); }
.btn.bad { background: rgba(255, 101, 121, .12); color: #ff9aa6; border-color: rgba(255, 101, 121, .28); }
.btn.small {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 9px;
}
.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}
.alert.success { color: #8cf0b5; background: rgba(52, 210, 125, .12); border-color: rgba(52, 210, 125, .25); }
.alert.error { color: #ff9aa6; background: rgba(255, 101, 121, .12); border-color: rgba(255, 101, 121, .25); }

.table-wrap {
    overflow-x: auto;
    border-radius: 13px;
    border: 1px solid var(--border);
}
table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    background: var(--panel-3);
}
th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border-soft);
    text-align: start;
    vertical-align: top;
}
th {
    color: var(--muted);
    font-size: 12px;
    background: rgba(255, 255, 255, .025);
}
tr:last-child td { border-bottom: 0; }
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 12px;
}
.badge.good { background: rgba(52, 210, 125, .14); color: #78efaa; }
.badge.warn { background: rgba(243, 190, 87, .14); color: #ffd47c; }
.badge.blue { background: rgba(79, 124, 255, .16); color: #9cb7ff; }
.badge.bad { background: rgba(255, 101, 121, .14); color: #ff9aa6; }
.badge.neutral { background: rgba(149, 160, 180, .12); color: var(--muted); }
.copy-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}
.copy-row strong {
    color: var(--text);
    font-size: 13px;
    direction: ltr;
    unicode-bidi: plaintext;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-card {
    max-width: 440px;
    margin: 70px auto;
    padding: 28px;
}
.form-card h1 { text-align: center; margin-bottom: 8px; }
.form-card p { text-align: center; color: var(--muted); margin: 0 0 20px; }
.empty {
    padding: 42px;
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 13px;
    background: rgba(255, 255, 255, .018);
}
.chart {
    display: flex;
    align-items: end;
    gap: 8px;
    height: 210px;
    padding-top: 12px;
}
.bar {
    flex: 1;
    min-width: 18px;
    display: grid;
    align-items: end;
    gap: 4px;
    color: var(--muted);
    font-size: 10px;
    text-align: center;
}
.bar span {
    display: block;
    min-height: 3px;
    border-radius: 8px 8px 2px 2px;
    background: linear-gradient(180deg, var(--cyan), var(--blue));
}
.money-income { color: #78efaa; }
.money-expense { color: #ff9aa6; }
.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}
.money-chart {
    display: flex;
    align-items: end;
    gap: 12px;
    min-height: 250px;
    overflow-x: auto;
    padding: 16px 4px 8px;
}
.small-chart {
    min-height: 210px;
}
.money-bar {
    min-width: 58px;
    flex: 1;
    display: grid;
    align-items: end;
    justify-items: center;
    gap: 8px;
    color: var(--muted);
    text-align: center;
}
.money-bar strong {
    direction: ltr;
    font-family: var(--display);
    font-size: 13px;
    white-space: nowrap;
}
.money-bar small {
    color: var(--muted);
    font-size: 11px;
}
.bar-pair {
    height: 190px;
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 5px;
}
.small-chart .bar-pair {
    height: 160px;
}
.income-bar,
.expense-bar {
    width: 14px;
    min-height: 4px;
    display: block;
    border-radius: 9px 9px 3px 3px;
}
.income-bar {
    background: linear-gradient(180deg, #78efaa, var(--green));
}
.expense-bar {
    background: linear-gradient(180deg, #ff9aa6, var(--red));
}
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}
.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.chart-legend i {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
}
.legend-income { background: var(--green); }
.legend-expense { background: var(--red); }
.mini-list {
    display: grid;
    gap: 10px;
}
.mini-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    background: rgba(255, 255, 255, .025);
}
.mini-row span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mini-row span small {
    display: block;
    color: var(--muted);
    font-size: 11px;
}
.mini-row strong {
    direction: ltr;
    white-space: nowrap;
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar,
    .main {
        grid-column: 1;
        grid-row: auto;
    }
    .sidebar {
        position: static;
        height: auto;
        border-left: 0;
        border-bottom: 1px solid var(--border);
    }
    .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .side-user { margin-top: 0; }
    .stats,
    .two-col,
    .filters,
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wide-field { grid-column: span 2; }
}

@media (max-width: 620px) {
    .main { padding: 16px; }
    .topbar,
    .panel-head {
        align-items: stretch;
        flex-direction: column;
    }
    .stats,
    .two-col,
    .filters,
    .form-grid,
    .side-nav { grid-template-columns: 1fr; }
    .wide-field { grid-column: auto; }
    .btn { width: 100%; }
}
