:root {
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --primary: #1e6f5c;
  --primary-dark: #145045;
  --danger: #d64545;
  --danger-dark: #b53434;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --deposit: #1e8e5a;
  --expense: #d64545;
  --shadow: 0 2px 10px rgba(0,0,0,0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

.navbar {
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.brand { font-weight: 800; font-size: 1.2rem; color: #fff; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.nav-links a {
  color: #e8f5f0;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.95rem;
}

.nav-links a.active, .nav-links a:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

.nav-user { color: #fff; font-size: 0.9rem; opacity: 0.9; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  color: #fff;
}

.stat-card.balance-positive { background: linear-gradient(135deg, #1e8e5a, #14694a); }
.stat-card.balance-negative { background: linear-gradient(135deg, #d64545, #a83232); }
.stat-card.deposit { background: linear-gradient(135deg, #2f8fd1, #1f6aa0); }
.stat-card.expense { background: linear-gradient(135deg, #e08a2b, #b4691a); }

.stat-label { font-size: 0.9rem; opacity: 0.9; margin-bottom: 6px; }
.stat-value { font-size: 1.6rem; font-weight: 800; }

h1, h2, h3 { margin-top: 0; }

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  border-right: 4px solid var(--primary);
  padding-right: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 10px 8px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 600; background: #fafbfc; }

tr:hover td { background: #fafbfc; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-deposit { background: #e3f6ec; color: var(--deposit); }
.badge-expense { background: #fbe7e7; color: var(--expense); }

.amount-deposit { color: var(--deposit); font-weight: 700; }
.amount-expense { color: var(--expense); font-weight: 700; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  transition: 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-danger { background: var(--danger); color: #fff; padding: 6px 12px; font-size: 0.82rem; }
.btn-danger:hover { background: var(--danger-dark); }

.btn-ghost { background: rgba(255,255,255,0.15); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,0.3); }

.btn-secondary { background: #eef2f5; color: var(--text); }
.btn-secondary:hover { background: #e2e7eb; }

.inline-form { display: inline; margin: 0; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-weight: 600; font-size: 0.9rem; color: var(--muted); }

input[type=text], input[type=number], input[type=date], input[type=password], textarea, select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

textarea { resize: vertical; min-height: 70px; }

.type-toggle { display: flex; gap: 10px; }
.type-toggle label {
  flex: 1;
  text-align: center;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
.type-toggle input { display: none; }
.type-toggle input:checked + span { color: var(--primary); }
.type-toggle label:has(input:checked) { border-color: var(--primary); background: #eaf6f1; }

.error-box {
  background: #fbe7e7;
  color: var(--danger-dark);
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-weight: 600;
}

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(135deg, #1e6f5c, #0f2f27);
}

.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 36px 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}

.login-title { text-align: center; margin-bottom: 24px; }
.login-title .icon { font-size: 2.4rem; }

.filters-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 18px;
}

.invoice-thumb {
  width: 44px; height: 44px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border);
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.progress-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 10px;
}

.progress-date { color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 0.85rem; }

.table-wrap { overflow-x: auto; }

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin-top: 10px;
  }
  .nav-links.open { display: flex; }
  .nav-links a, .nav-user { width: 100%; }
}
