/* ---------- پایه ---------- */
:root {
    --bg: #eceff3;
    --ink: #151a22;
    --muted: #6b7380;
    --line: #dde1e7;
    --panel: #ffffff;
    --navy: #1f3a5f;
    --navy-2: #2b4a75;
    --green: #1e7f5c;
    --red: #c0392b;
    --amber: #d98a1c;
    --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Vazirmatn", "IRANSansX", "Vazir", Tahoma, "Segoe UI", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    font-variant-numeric: tabular-nums;
}
a { color: inherit; text-decoration: none; }
p { margin: .4em 0; }
h1, h2, h3 { line-height: 1.4; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 17px; margin-bottom: 12px; }
h3.sub { font-size: 14px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
:focus-visible { outline: 3px solid #7aa2e3; outline-offset: 2px; }

/* ---------- سربرگ ---------- */
.top {
    background: var(--ink);
    color: #fff;
    padding: 12px max(14px, calc((100% - 1100px) / 2));
    display: flex;
    align-items: center;
    gap: 16px;
}
.top .brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.top nav a { padding: 7px 12px; border-radius: 9px; font-size: 14px; color: #c3cad5; }
.top nav a:hover { background: #262d38; color: #fff; }
.top nav a.active { background: #fff; color: var(--ink); font-weight: 600; }
.logout { margin: 0; }
.linkbtn { background: none; border: 0; color: #c3cad5; font: inherit; font-size: 14px; cursor: pointer; padding: 7px 10px; border-radius: 9px; }
.linkbtn:hover { color: #fff; background: #262d38; }

.container { max-width: 1100px; margin: 0 auto; padding: 18px; }

/* ---------- کارت‌ها و پنل‌ها ---------- */
.hero {
    background: var(--ink);
    color: #fff;
    border-radius: 20px;
    padding: 22px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 14px;
}
.muted-light { color: #aab3c0; margin: 2px 0 12px; }
.daily { background: #232a35; border-radius: 14px; padding: 14px 18px; font-size: 13px; color: #c3cad5; }
.daily strong { display: block; font-size: 22px; margin-top: 4px; color: #fff; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.card, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
}
.card span { font-size: 13px; color: var(--muted); }
.card b { display: block; font-size: 22px; margin-top: 4px; }
.green { color: var(--green); }
.red { color: var(--red); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.panel { margin-bottom: 14px; }
.grid2 .panel { margin-bottom: 0; }
.panel.narrow { max-width: 640px; margin-inline: auto; }
.panelhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panelhead h2 { margin: 0; }
.center-text { text-align: center; }
.small-text { font-size: 13px; }
.muted { color: var(--muted); }

/* ---------- ناوبری ماه ---------- */
.monthnav { display: inline-flex; align-items: center; gap: 8px; }
.monthnav strong { min-width: 110px; text-align: center; font-size: 15px; }
.hero .monthnav .btn.ghost { color: #fff; border-color: #3a4351; }
.hero .monthnav .btn.ghost:hover { background: #2a323e; }

/* ---------- فرم‌ها ---------- */
label { display: block; font-size: 13px; color: #4a525e; }
input, select {
    width: 100%;
    margin-top: 5px;
    padding: 10px 12px;
    border: 1px solid #ccd2da;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}
input:focus, select:focus { border-color: var(--navy); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .full { grid-column: 1 / -1; }
.stack { display: grid; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 140px; margin: 0; flex: 1; }
.inline, .inlineform { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
.inlineform { display: flex; margin-top: 10px; }
.inlineform input { margin: 0; }
.acc { display: grid; grid-template-columns: 1.4fr 1fr auto auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.acc input { margin: 0; }
details { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details .form { margin-top: 10px; }
.delform { margin-top: 10px; }

/* ---------- دکمه‌ها ---------- */
.btn, button.btn {
    display: inline-block;
    border: 1px solid var(--navy);
    background: var(--navy);
    color: #fff;
    border-radius: 10px;
    padding: 10px 16px;
    font: inherit;
    cursor: pointer;
    text-align: center;
    line-height: 1.5;
}
.btn:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; color: var(--ink); border-color: #ccd2da; }
.btn.ghost:hover { background: #f1f3f6; }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.danger:hover { background: #a93226; }
.btn.small { padding: 5px 11px; font-size: 13px; }

/* ---------- وضعیت بودجه ---------- */
.progress { height: 10px; background: #e6e9ee; border-radius: 20px; overflow: hidden; margin: 6px 0; }
.progress i { display: block; height: 100%; background: var(--navy); border-radius: 20px; }
.progress.warn i { background: var(--amber); }
.progress.over i { background: var(--red); }
.status { padding: 11px 13px; background: #f3f5f8; border-radius: 12px; margin: 8px 0; font-size: 14px; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #eef0f3; }
.plain li.total { border-bottom: 0; font-weight: 700; }

/* ---------- جدول ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
th, td { padding: 10px 8px; border-bottom: 1px solid #edf0f3; text-align: right; vertical-align: middle; }
td.num { white-space: nowrap; font-weight: 600; }
td.desc { min-width: 140px; }
td.actions { white-space: nowrap; text-align: left; }
.nowrap { white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 20px; }
.tag.in { background: #e3f3ec; color: var(--green); }
.tag.out { background: #fbe9e6; color: var(--red); }
.sumline { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 4px 0 10px; font-size: 13px; color: var(--muted); }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- نمودارها ---------- */
.donutwrap { display: grid; grid-template-columns: 190px 1fr; gap: 18px; align-items: center; }
.donut { width: 100%; max-width: 190px; height: auto; }
.donut-num { font-size: 17px; font-weight: 700; fill: var(--ink); font-family: inherit; }
.donut-cap { font-size: 10px; fill: var(--muted); font-family: inherit; }
.legend { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 8px; align-items: center; padding: 4px 0; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.legend small { color: var(--muted); min-width: 78px; text-align: left; }
.chartscroll { overflow-x: auto; margin-bottom: 12px; }
.bars { width: 100%; min-width: 560px; height: auto; }
.bars .grid { stroke: #e6e9ee; stroke-width: 1; }
.bars .axis { font-size: 11px; fill: var(--muted); font-family: inherit; }
.bars .axis.dim { font-size: 9px; opacity: .7; }
.bars .b-in { fill: var(--green); }
.bars .b-out { fill: var(--red); }
.legend-inline { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 4px; }
.dot.in { background: var(--green); }
.dot.out { background: var(--red); }
.hbars { display: grid; gap: 10px; margin-top: 10px; }
.hbar { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hb-track { height: 10px; background: #e6e9ee; border-radius: 20px; overflow: hidden; }
.hb-track i { display: block; height: 100%; background: var(--navy); border-radius: 20px; }
.hb-val small { color: var(--muted); }

/* ---------- اهداف و تکرارشونده ---------- */
.goal { padding: 14px 0; border-bottom: 1px solid #edf0f3; }
.goal:last-child { border-bottom: 0; }
.goalhead { display: flex; justify-content: space-between; align-items: baseline; }
.rec { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid #edf0f3; }
.rec:last-child { border-bottom: 0; }
.rec.off { opacity: .55; }
.rec .actions { display: flex; gap: 6px; }

/* ---------- پیام‌ها ---------- */
.alert { padding: 11px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 14px; }
.alert.ok { background: #e3f3ec; color: #14573f; }
.alert.danger { background: #fbe9e6; color: #8c2a1f; }
.alert.warn { background: #fdf1dc; color: #7a4f0d; }

/* ---------- ورود و ثبت‌نام ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 28px; width: min(420px, 100%); }
.auth-brand { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.auth h1 { margin-bottom: 16px; }

/* ---------- واکنش‌گرا ---------- */
@media (max-width: 800px) {
    .cards { grid-template-columns: 1fr 1fr; }
    .grid2 { grid-template-columns: 1fr; }
    .hero { flex-direction: column; align-items: stretch; }
    .container { padding: 12px; }
    .donutwrap { grid-template-columns: 1fr; justify-items: center; }
    .legend { width: 100%; }
    .top { gap: 8px; padding: 10px 12px; }
    .top .brand { display: none; }
}
@media (max-width: 520px) {
    .form { grid-template-columns: 1fr; }
    .form .full { grid-column: auto; }
    .acc { grid-template-columns: 1fr 1fr; }
    .hbar { grid-template-columns: 90px 1fr; }
    .hbar .hb-val { grid-column: 1 / -1; }
    .card b { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
