:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e6e8ec;
  --text: #1c1f26;
  --text-muted: #6b7280;
  --accent: #2f6feb;
  --accent-dark: #1e4fb8;
  --danger: #e0453f;
  --danger-bg: #fdecec;
  --warning: #b3720a;
  --warning-bg: #fdf3e0;
  --ok: #1a8a5f;
  --ok-bg: #e7f7f0;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  direction: rtl;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Nav ---------- */
.nav {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}

.brand {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.nav-user {
  color: var(--text-muted);
  font-size: 14px;
  margin-left: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

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

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: #f0f1f3; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #f3c9c7;
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.hero-glow {
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 480px;
  background:
    radial-gradient(420px 260px at 30% 20%, rgba(47, 111, 235, 0.16), transparent 70%),
    radial-gradient(360px 240px at 75% 10%, rgba(26, 138, 95, 0.12), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hero-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 90px 0 60px;
  animation: heroRise 0.55s ease both;
}

.hero-title {
  font-size: 40px;
  line-height: 1.35;
  font-weight: 800;
  margin: 0 0 16px;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent) 60%, #1a8a5f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero .slogan {
  font-size: 18px;
  color: var(--text);
  font-weight: 600;
  margin: 0 0 10px;
}

.hero .tagline {
  font-size: 13.5px;
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 22px;
}

.hero p.desc {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 2;
  max-width: 520px;
  margin: 0 auto 34px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.hero-actions .btn-primary {
  box-shadow: 0 8px 20px rgba(47, 111, 235, 0.28);
}
.hero-actions .btn-primary:hover {
  transform: translateY(-1px);
}

.features {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 50px;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  width: 200px;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.feature:hover {
  transform: translateY(-3px);
  border-color: #d6ddec;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.06);
}

.feature .icon {
  font-size: 22px;
  margin: 0 auto 10px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(47, 111, 235, 0.1);
}
.feature .title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.feature .text { color: var(--text-muted); font-size: 12.5px; line-height: 1.8; }

@keyframes heroRise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Auth pages ---------- */
.auth-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
}

.auth-card .sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 22px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field .hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 5px;
}

input[type="text"],
input[type="password"],
input[type="tel"],
input[type="number"],
select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.error-box {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f3c9c7;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 18px;
}

.info-box {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid #f0dba8;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 18px;
}

.auth-footer {
  text-align: center;
  margin-top: 18px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Dashboard ---------- */
.page {
  flex: 1;
  padding: 32px 0 60px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-header h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

.page-header .sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0;
}

.limit-note {
  color: var(--text-muted);
  font-size: 13px;
}

.loan-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.loan-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.loan-bank {
  font-weight: 700;
  font-size: 15.5px;
}

.loan-meta {
  color: var(--text-muted);
  font-size: 12.5px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.loan-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }

.type-badge {
  display: inline-block;
  background: #eef2ff;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  vertical-align: middle;
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 50px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 34px; margin-bottom: 10px; }

form.inline {
  display: inline;
}

/* ---------- Loan form ---------- */
.form-wrap {
  flex: 1;
  padding: 32px 0 60px;
  display: flex;
  justify-content: center;
}

.form-card {
  width: 100%;
  max-width: 460px;
}

.form-row {
  display: flex;
  gap: 12px;
}
.form-row .field { flex: 1; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.custom-bank-field {
  display: none;
}

.optional-tag {
  color: #9ca3af;
  font-weight: 500;
  font-size: 12px;
}

/* ---------- Select (Bootstrap-like) ---------- */
.select-wrap {
  position: relative;
}

.select-bs {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  padding: 11px 12px 11px 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: 14px;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select-bs:hover { border-color: #c9d0dc; }
.select-bs:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 235, 0.15);
}

/* ---------- Day calendar (تقویم شمسی روز بازپرداخت) ---------- */
.day-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.05s;
}

.day-cell:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.day-cell:active { transform: scale(0.94); }

.day-cell.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 10px rgba(47, 111, 235, 0.3);
}

footer.site-footer {
  text-align: center;
  padding: 18px 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

/* ---------- Admin dashboard ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}

.stat-icon { font-size: 20px; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 800; }
.stat-label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

.admin-quicklinks {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.admin-quicklink {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.admin-quicklink:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.06);
}

.admin-quicklink .title { font-weight: 700; font-size: 14px; }
.admin-quicklink .text { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Mobile responsiveness ---------- */
@media (max-width: 640px) {
  .container { padding: 0 18px; }

  .auth-wrap .container,
  .form-wrap .container { padding: 0 20px; }

  .nav-inner {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
  }

  .nav-links {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-user { width: 100%; margin: 0 0 2px; }

  .btn {
    min-height: 44px;
    border-radius: 12px;
    transition: background 0.15s, transform 0.08s;
  }
  .btn:active { transform: scale(0.97); }
  .btn-sm { min-height: 38px; border-radius: 10px; }

  .btn-ghost {
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
  }

  .hero-inner { padding: 56px 0 40px; }
  .hero-title { font-size: 27px; }
  .hero .slogan { font-size: 16px; }
  .hero p.desc { font-size: 13.5px; line-height: 1.9; }

  .hero-actions { flex-direction: column; gap: 10px; }
  .hero-actions .btn { width: 100%; border-radius: 14px; }
  .hero-actions .btn-primary { box-shadow: 0 6px 16px rgba(47, 111, 235, 0.25); }

  .features { margin-top: 28px; gap: 10px; }
  .feature {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: right;
    padding: 16px 18px;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(16, 24, 40, 0.05);
  }
  .feature:hover { transform: none; }
  .feature .icon { margin: 0; flex-shrink: 0; }
  .feature-body { display: flex; flex-direction: column; gap: 2px; }
  .feature .title { margin-bottom: 0; }
  .feature .text { line-height: 1.6; }

  .card {
    padding: 22px;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(16, 24, 40, 0.05);
  }
  .form-card { max-width: 100%; }
  .form-row { flex-direction: column; gap: 0; }
  .form-row .field { max-width: 100% !important; }

  .form-actions { flex-direction: column; gap: 10px; }
  .form-actions .btn-ghost { width: 100%; }

  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header > form { width: 100%; }

  .loan-card {
    flex-direction: column;
    align-items: flex-start;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(16, 24, 40, 0.05);
    padding: 16px;
  }

  .loan-actions {
    width: 100%;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
  }
  .loan-actions .badge { width: 100%; order: -1; margin-bottom: 2px; }
  .loan-actions .btn-sm,
  .loan-actions form.inline { flex: 1; }
  .loan-actions form.inline .btn-sm { width: 100%; }

  .day-calendar { gap: 4px; padding: 8px; }
  .day-cell { font-size: 12px; border-radius: 6px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card { border-radius: 16px; box-shadow: 0 2px 10px rgba(16, 24, 40, 0.05); }
  .admin-quicklink { min-width: 100%; }
}

@media (max-width: 380px) {
  .hero-title { font-size: 23px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-value { font-size: 20px; }
}
