:root {
  --primary: #1f6f5c;
  --primary-dark: #14453a;
  --bg: #f5f6f4;
  --card-bg: #ffffff;
  --text: #1c1c1c;
  --muted: #6b7280;
  --danger: #c0392b;
  --green: #1f8a4c;
  --red: #c0392b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

input, select, button, textarea { font-family: inherit; font-size: 16px; }

.screen { min-height: 100%; }

/* ---- ورود ---- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.login-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 22px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-box h1 { margin: 0 0 4px; font-size: 22px; }
.login-box .sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #dcdcdc;
  border-radius: 10px;
  background: #fafafa;
}
button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  background: var(--primary);
  color: white;
  font-weight: 600;
}
button:disabled { opacity: 0.6; cursor: default; }
#login-form button { width: 100%; margin-top: 20px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---- هدر ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary);
  color: white;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
}
.topbar h2 { margin: 0; font-size: 18px; flex: 1; text-align: center; }
.icon-btn {
  background: transparent;
  color: white;
  padding: 4px 10px;
  font-size: 18px;
}

.drawer {
  position: absolute;
  left: 0; right: 0;
  background: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 20;
  padding: 8px;
}
.drawer button {
  display: block;
  width: 100%;
  text-align: right;
  background: transparent;
  color: var(--text);
  padding: 12px;
  border-radius: 8px;
}
.drawer button:hover { background: #f0f0f0; }
.drawer-user { padding: 10px 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid #eee; margin-bottom: 4px; }

main.view { padding: 14px; padding-bottom: 40px; max-width: 560px; margin: 0 auto; }

.fab-btn { display: block; width: 100%; margin-bottom: 14px; }

/* ---- کارت‌ها ---- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.card-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.card-sub { font-size: 13px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
}
.badge-green { background: #e3f6e9; color: var(--green); }
.badge-red { background: #fbe9e7; color: var(--red); }

.totals-row {
  display: flex;
  justify-content: space-between;
  text-align: center;
  margin: 10px 0;
}
.totals-row div { flex: 1; }
.totals-row b { display: block; font-size: 16px; }
.totals-row span { font-size: 11px; color: var(--muted); }

.switch-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.switch-row .badge { border: none; margin: 0; }

.full-width { width: 100%; margin-top: 10px; }
.btn-secondary { background: #eef1ef; color: var(--text); }
.btn-danger { background: #fbe9e7; color: var(--danger); }

.row-card { display: flex; align-items: center; justify-content: space-between; }
.row-main { display: flex; flex-direction: column; gap: 2px; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.row-actions .badge { border: none; }

/* ---- مودال ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
.modal-box {
  background: white;
  width: 100%; max-width: 480px;
  border-radius: 18px 18px 0 0;
  padding: 20px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button { flex: 1; }

.jalali-picker { display: flex; gap: 6px; }
.jalali-picker select { padding: 10px 6px; }

@media (min-width: 520px) {
  .modal-backdrop { align-items: center; }
  .modal-box { border-radius: 18px; }
}
