/* ===== Money Dashboard — modern dark theme (RTL) ===== */
:root {
  --bg: #0b0f14;
  --bg-elev: #121821;
  --bg-elev-2: #1a2230;
  --border: #232c3b;
  --text: #e6ebf2;
  --text-dim: #a8b3c7;
  --text-mute: #6b7688;
  --accent: #2dd4bf;      /* teal/emerald accent */
  --accent-dark: #14b8a6;
  --accent-soft: rgba(45, 212, 191, .12);
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  font-family: "Vazirmatn", system-ui, -apple-system, Tahoma, Arial, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at 20% -10%, rgba(45,212,191,.06), transparent 40%),
                     radial-gradient(circle at 90% 10%, rgba(99,102,241,.06), transparent 35%);
  margin: 0;
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

/* ---------- Login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center; height: 100vh;
  background: radial-gradient(circle at 30% 20%, #14202b, var(--bg) 60%);
}
.login-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 2.5rem; border-radius: var(--radius); box-shadow: var(--shadow);
  width: 90%; max-width: 380px; text-align: center;
}
.login-box h1 { margin: 0 0 .2rem; font-size: 1.4rem; }
.login-box .sub { color: var(--text-dim); margin-bottom: 1.5rem; }
.login-box form { display: flex; flex-direction: column; gap: .6rem; text-align: right; }
.login-box label { font-size: .85rem; color: var(--text-dim); }

input, select, button, textarea {
  font-family: inherit; font-size: 1rem; padding: .65rem .8rem; border-radius: 10px;
  border: 1px solid var(--border); width: 100%;
  background: var(--bg-elev-2); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
button { cursor: pointer; border: none; }
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }

.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #062421; font-weight: 700; margin-top: .5rem; }
.btn-secondary { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); display:inline-block; text-align:center; text-decoration:none; }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: rgba(248,113,113,.15); color: var(--red); border: 1px solid rgba(248,113,113,.35); }
.btn-danger:hover { background: rgba(248,113,113,.25); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; width: auto; }
.btn-refresh { background: var(--bg-elev-2); color: var(--accent); border: 1px solid var(--accent-dark); width: auto; white-space: nowrap; font-size: .85rem; }
.btn-refresh:hover { background: var(--accent-soft); }
.btn-refresh:disabled { opacity: .6; cursor: default; }

/* ---------- Top bar ---------- */
.topbar {
  background: rgba(18, 24, 33, .9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  color: #fff; padding: .9rem 1rem; position: sticky; top: 0; z-index: 20;
}
.topbar-inner { max-width: 1150px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem;}
.topbar h1 { font-size: 1.15rem; margin: 0; font-weight: 700; }
.topbar nav a { color: var(--text-dim); text-decoration: none; margin-inline-start: 1.2rem; font-size: .92rem; transition: color .15s; }
.topbar nav a:hover { color: var(--accent); }

.container { max-width: 1150px; margin: 1.4rem auto; padding: 0 1rem 3rem; }

.flash { padding: .8rem 1.1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid transparent; font-size: .92rem; }
.flash-success { background: rgba(52,211,153,.1); color: var(--green); border-color: rgba(52,211,153,.3); }
.flash-error { background: rgba(248,113,113,.1); color: var(--red); border-color: rgba(248,113,113,.3); }

/* ---------- Balance card (the important number) ---------- */
.balance-card {
  border-radius: 18px; padding: 2rem 1.5rem; text-align: center; margin-bottom: 1.3rem;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  position: relative; overflow: hidden;
}
.balance-card.positive {
  border-color: rgba(52,211,153,.4);
  box-shadow: 0 0 0 1px rgba(52,211,153,.15) inset, 0 0 50px rgba(52,211,153,.15);
}
.balance-card.negative {
  border-color: rgba(248,113,113,.4);
  box-shadow: 0 0 0 1px rgba(248,113,113,.15) inset, 0 0 50px rgba(248,113,113,.15);
}
.balance-title { font-size: 1.05rem; margin-bottom: .5rem; color: var(--text-dim); }
.balance-amount { font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em; }
.balance-card.positive .balance-amount { color: var(--green); text-shadow: 0 0 30px rgba(52,211,153,.35); }
.balance-card.negative .balance-amount { color: var(--red); text-shadow: 0 0 30px rgba(248,113,113,.35); }

/* ---------- Stat cards ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: .9rem; margin-bottom: 1.3rem; }
.stat-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.1rem; text-align: center; transition: transform .15s, border-color .15s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--accent-dark); }
.stat-card span { display: block; color: var(--text-mute); font-size: .78rem; margin-bottom: .4rem; }
.stat-card b { font-size: 1.3rem; color: var(--text); }

/* ---------- Panels ---------- */
.panel {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.3rem; margin-bottom: 1.3rem; box-shadow: var(--shadow);
}
.panel h2 { margin-top: 0; font-size: 1.05rem; color: var(--text); }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .6rem; }
.panel-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.panel-controls select { width: auto; }
.panel-status { color: var(--text-dim); font-size: .88rem; margin-bottom: .6rem; }
.fetched-at { color: var(--text-mute); font-size: .78rem; margin-inline-start: auto; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-grid label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; color: var(--text-dim); }
.form-grid button { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.form-inline { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.form-inline label { display: flex; flex-direction: column; font-size: .85rem; color: var(--text-dim); gap: .3rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .65rem .7rem; text-align: right; white-space: nowrap; }
thead th {
  position: sticky; top: 0; background: var(--bg-elev-2); color: var(--text-dim);
  font-weight: 600; font-size: .8rem; border-bottom: 1px solid var(--border); z-index: 1;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
tbody tr:nth-child(even) { background: rgba(255,255,255,.02); }
tbody tr:hover { background: var(--accent-soft); }
.badge { background: rgba(251,191,36,.15); color: var(--amber); padding: .15rem .55rem; border-radius: 6px; font-size: .72rem; border: 1px solid rgba(251,191,36,.3); }
