:root {
  --blue-700: #1D4ED8;
  --blue-600: #2563EB;
  --blue-50: #EFF4FE;
  --grey-900: #1E293B;
  --grey-700: #334155;
  --grey-500: #64748B;
  --grey-400: #94A3B8;
  --grey-200: #E2E8F0;
  --grey-100: #F1F5F9;
  --grey-50: #F8FAFC;
  --green-600: #16803C;
  --green-50: #E9F5EE;
  --amber-700: #B45309;
  --amber-50: #FDF3E3;
  --red-600: #DC2626;
  --red-50: #FDECEC;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 12px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Vazirmatn, 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--grey-100);
  color: var(--grey-900);
  font-size: 16px;
  line-height: 1.7;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}

/* ---------- هدر ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid var(--grey-200);
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.35; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 12px; color: var(--grey-500); }
.bell {
  position: relative; border: 1px solid var(--grey-200); background: var(--grey-50);
  color: var(--grey-700); width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer;
}
.bell-badge {
  position: absolute; top: -5px; inset-inline-start: -5px;
  background: var(--red-600); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 19px; height: 19px; border-radius: 10px; display: grid; place-items: center; padding: 0 4px;
}

/* ---------- بدنه ---------- */
.view { padding: 16px; max-width: 720px; margin: 0 auto; }
.page-title { font-size: 19px; font-weight: 800; margin: 4px 0 2px; }
.page-sub { color: var(--grey-500); font-size: 13px; margin: 0 0 14px; }

.card {
  background: #fff; border: 1px solid var(--grey-200); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; font-size: 15px; }
.muted { color: var(--grey-500); font-size: 13px; }
.small { font-size: 13px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-start { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- دکمه‌ها ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 700;
  min-height: 46px; padding: 0 18px;
  background: var(--blue-600); color: #fff;
}
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.secondary { background: #fff; color: var(--grey-700); border: 1px solid var(--grey-200); }
.btn.soft { background: var(--blue-50); color: var(--blue-700); }
.btn.danger { background: var(--red-50); color: var(--red-600); }
.btn.success { background: var(--green-50); color: var(--green-600); }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- فرم‌ها ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--grey-700); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px;
  border: 1px solid var(--grey-200); border-radius: 10px;
  padding: 11px 12px; background: #fff; color: var(--grey-900);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-600); outline-offset: 1px; border-color: var(--blue-600); }
textarea { min-height: 84px; resize: vertical; }
.hint { font-size: 12px; color: var(--grey-400); margin-top: 3px; }

/* ---------- برچسب وضعیت ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.pill.blue { background: var(--blue-50); color: var(--blue-700); }
.pill.grey { background: var(--grey-100); color: var(--grey-500); }
.pill.green { background: var(--green-50); color: var(--green-600); }
.pill.amber { background: var(--amber-50); color: var(--amber-700); }
.pill.red { background: var(--red-50); color: var(--red-600); }

/* ---------- آمار خانه ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: #fff; border: 1px solid var(--grey-200); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .num { font-size: 22px; font-weight: 800; color: var(--blue-700); }
.stat .lbl { font-size: 12.5px; color: var(--grey-500); }

/* ---------- تب و فیلتر ---------- */
.tabs { display: flex; gap: 6px; background: var(--grey-200); padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.tabs button {
  flex: 1; border: none; background: transparent; font: inherit; font-size: 14px; font-weight: 700;
  padding: 9px 4px; border-radius: 9px; color: var(--grey-500); cursor: pointer; min-height: 42px;
}
.tabs button.active { background: #fff; color: var(--blue-700); box-shadow: var(--shadow); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.chips button {
  border: 1px solid var(--grey-200); background: #fff; color: var(--grey-500);
  font: inherit; font-size: 13px; font-weight: 700; border-radius: 999px; padding: 7px 14px; white-space: nowrap; cursor: pointer;
}
.chips button.active { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }

/* ---------- لیست آیتم ---------- */
.list-card {
  background: #fff; border: 1px solid var(--grey-200); border-radius: var(--radius);
  padding: 13px 15px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer;
}
.list-card .title { font-weight: 800; font-size: 15px; }
.list-card .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--grey-500); font-size: 13px; margin-top: 5px; }
.divider { height: 1px; background: var(--grey-200); margin: 10px 0; border: 0; }

.empty { text-align: center; color: var(--grey-400); padding: 36px 12px; font-size: 14px; }
.empty .icon { font-size: 34px; margin-bottom: 6px; }

/* ---------- ناوبری پایین ---------- */
.bottomnav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--grey-200);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--grey-400); font-size: 11.5px; font-weight: 700;
  padding: 5px 10px; border-radius: 10px; min-width: 58px; min-height: 48px; justify-content: center;
}
.bottomnav a.active { color: var(--blue-700); background: var(--blue-50); }
.bottomnav svg { width: 22px; height: 22px; }

/* ---------- مودال ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 640px;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 18px; }
}
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }

/* ---------- توست ---------- */
#toast-root { position: fixed; bottom: calc(86px + env(safe-area-inset-bottom)); inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast {
  background: var(--grey-900); color: #fff; font-size: 14px; font-weight: 600;
  border-radius: 12px; padding: 11px 18px; max-width: 92vw; box-shadow: var(--shadow);
}
.toast.error { background: var(--red-600); }
.toast.success { background: var(--green-600); }

/* ---------- صفحه ورود ---------- */
.login-wrap { min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 380px; text-align: center; }
.login-box .logo { width: 84px; height: 84px; margin: 0 auto 14px; display: block; }
.login-box h1 { font-size: 21px; margin: 0 0 2px; }
.login-box .sub { color: var(--grey-500); font-size: 13.5px; margin-bottom: 22px; }
.login-box form { text-align: right; }

/* جدول کوچک گزارش */
.mini-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mini-table th { text-align: right; color: var(--grey-500); font-weight: 700; padding: 6px 4px; border-bottom: 1px solid var(--grey-200); }
.mini-table td { padding: 8px 4px; border-bottom: 1px solid var(--grey-100); }
.mini-table tr:last-child td { border-bottom: 0; }

.line-item { display: grid; grid-template-columns: 1fr 76px 110px 40px; gap: 6px; align-items: center; margin-bottom: 8px; }
.line-item .remove { border: none; background: var(--red-50); color: var(--red-600); border-radius: 9px; min-height: 44px; font-size: 18px; cursor: pointer; }

.fab-space { height: 8px; }

/* hidden attribute must always win */
[hidden] { display: none !important; }

/* hide horizontal scrollbars on chip/tab rows (mobile polish) */
.chips { scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
