/* =========================================================
   سامانه مدیریت تنخواه — استایل کامل
   راست‌چین · فونت وزیرمتن · جداول وسط‌چین · استایل چاپ
   ========================================================= */

@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --border: #e3eae6;
  --border-strong: #cfdad4;
  --text: #1e2b26;
  --text-2: #45564e;
  --muted: #6b7f75;
  --primary: #047857;
  --primary-strong: #065f46;
  --primary-soft: #ecfdf5;
  --primary-soft-2: #d1fae5;
  --accent: #0d9488;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --in: #059669;
  --in-soft: #ecfdf5;
  --out: #e11d48;
  --out-soft: #fff1f2;
  --sidebar-bg: #0c221b;
  --sidebar-text: #c7d9d0;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(10, 40, 28, 0.06);
  --shadow-md: 0 6px 22px rgba(10, 40, 28, 0.10);
  --shadow-lg: 0 18px 50px rgba(10, 40, 28, 0.18);
  --font: 'Vazirmatn', 'Tahoma', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
}

[hidden] { display: none !important; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
code {
  font-family: 'Vazirmatn', monospace;
  background: var(--primary-soft-2);
  color: var(--primary-strong);
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 0.92em;
  direction: ltr;
  display: inline-block;
}

/* دکمه‌ها */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px 16px;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
  min-height: 40px;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-outline { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-soft-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.btn-soft-danger:hover { background: #fee2e2; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(4, 120, 87, 0.08); color: var(--primary); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; min-height: 32px; font-size: 0.85rem; border-radius: 9px; }

.mini-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  display: inline-block;
  animation: miniSpin 0.7s linear infinite;
  flex-shrink: 0;
}
.btn-outline .mini-spinner, .btn-ghost .mini-spinner, .btn-soft-danger .mini-spinner {
  border-color: rgba(4, 120, 87, 0.25);
  border-top-color: var(--primary);
}
@keyframes miniSpin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

.row-actions { display: inline-flex; gap: 6px; }
.row-actions .icon-btn { width: 32px; height: 32px; border-radius: 8px; }
.row-actions .icon-btn svg { width: 15px; height: 15px; }
.row-actions .edit:hover { color: var(--primary); border-color: var(--primary); }
.row-actions .del:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

/* =========================================================
   صفحه ورود
   ========================================================= */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(140deg, #06231b 0%, #0c3d2e 45%, #065f46 100%);
  overflow: hidden;
}
.login-bg-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
  pointer-events: none;
}
.login-bg-shape.s1 { width: 420px; height: 420px; background: #10b981; top: -120px; right: -80px; }
.login-bg-shape.s2 { width: 360px; height: 360px; background: #0d9488; bottom: -100px; left: -60px; }
.login-bg-shape.s3 { width: 220px; height: 220px; background: #fbbf24; bottom: 12%; right: 14%; opacity: 0.16; }

.login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 22px;
  padding: 38px 34px 30px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.45s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-brand { text-align: center; margin-bottom: 26px; }
.brand-badge {
  width: 74px;
  height: 74px;
  margin: 0 auto 14px;
  border-radius: 22px;
  background: linear-gradient(140deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(4, 120, 87, 0.35);
}
.brand-badge svg { width: 42px; height: 42px; }
.login-brand h1 { font-size: 1.35rem; color: var(--text); }
.login-brand p { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }

.field { display: block; margin-bottom: 15px; position: relative; }
.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field-icon {
  position: absolute;
  top: 37px;
  right: 12px;
  width: 20px;
  height: 20px;
  color: var(--muted);
  pointer-events: none;
}
.field-icon svg { width: 20px; height: 20px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  border: 1.5px solid var(--border-strong);
  border-radius: 11px;
  padding: 9px 40px 9px 14px;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: #fbfdfc;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 42px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(4, 120, 87, 0.13);
  background: #fff;
}
input::placeholder, textarea::placeholder { color: #a3b3aa; }
input[type="number"] { direction: ltr; text-align: center; }
.eye-btn {
  position: absolute;
  top: 33px;
  left: 8px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.eye-btn svg { width: 19px; height: 19px; }
.eye-btn:hover { color: var(--primary); }

.login-error {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 0.86rem;
  font-weight: 500;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.login-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-strong);
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
}

/* =========================================================
   پوسته برنامه
   ========================================================= */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 242px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  margin-bottom: 14px;
}
.side-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.side-logo svg { width: 30px; height: 30px; }
.side-titles { display: flex; flex-direction: column; line-height: 1.45; min-width: 0; }
.side-titles strong {
  color: #fff;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-titles small { color: rgba(255, 255, 255, 0.55); font-size: 0.72rem; }

.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--sidebar-text);
  padding: 10px 13px;
  border-radius: 11px;
  font-size: 0.93rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-nav a.active {
  background: linear-gradient(120deg, var(--primary), #059669);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(4, 120, 87, 0.4);
}
.nav-ico {
  width: 22px;
  height: 22px;
  display: inline-flex;
  flex-shrink: 0;
}
.nav-ico svg { width: 21px; height: 21px; }

.side-bottom { border-top: 1px solid rgba(255, 255, 255, 0.09); padding-top: 12px; margin-top: 12px; }
.side-help {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 9px 13px;
  border-radius: 11px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.15s, color 0.15s;
}
.side-help:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  margin-bottom: 8px;
}
.side-user-meta { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.side-user-meta strong { color: #fff; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-meta small { color: rgba(255, 255, 255, 0.55); font-size: 0.72rem; }
.side-logout {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  background: rgba(225, 29, 72, 0.12);
  border: 1px solid rgba(225, 29, 72, 0.25);
  color: #fda4af;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 9px 13px;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.15s;
}
.side-logout:hover { background: rgba(225, 29, 72, 0.22); color: #fff; }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar.small { width: 30px; height: 30px; font-size: 0.82rem; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 26, 19, 0.5);
  z-index: 40;
  backdrop-filter: blur(2px);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 26px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.menu-btn { display: none; }
.page-title { font-size: 1.13rem; color: var(--text); }
.topbar-side { margin-right: auto; display: flex; align-items: center; gap: 12px; }
.today-chip {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border: 1px solid var(--primary-soft-2);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 99px;
  white-space: nowrap;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  padding: 4px 13px 4px 6px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.user-chip:hover { border-color: var(--primary); color: var(--primary); }

.view {
  flex: 1;
  padding: 24px 26px 30px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 13px 26px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.footer-dot { color: var(--border-strong); }

/* =========================================================
   کارت‌ها و اجزای عمومی
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}
.card-title svg { width: 19px; height: 19px; color: var(--primary); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.section-head h3 { font-size: 1.05rem; }
.section-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}
.stat-ico {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-ico svg { width: 25px; height: 25px; }
.stat-ico.balance { background: var(--primary-soft-2); color: var(--primary-strong); }
.stat-ico.in { background: var(--in-soft); color: var(--in); }
.stat-ico.out { background: var(--out-soft); color: var(--out); }
.stat-ico.count { background: #f5f7f6; color: var(--text-2); }
.stat-ico.warn { background: var(--warning-soft); color: var(--warning); }
.stat-meta { min-width: 0; }
.stat-meta small { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 500; }
.stat-meta strong {
  display: block;
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.stat-meta strong.pos { color: var(--in); }
.stat-meta strong.neg { color: var(--out); }

/* =========================================================
   جداول — همه وسط‌چین
   ========================================================= */
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
table.tbl {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.88rem;
}
.tbl th, .tbl td {
  text-align: center;
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.tbl th {
  background: #eef5f1;
  color: var(--primary-strong);
  font-weight: 700;
  font-size: 0.82rem;
  position: sticky;
  top: 0;
  z-index: 2;
}
.tbl tbody tr:nth-child(even) { background: #f8fbf9; }
.tbl tbody tr:hover { background: #f1f7f3; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl td.num, .tbl th.num { font-variant-numeric: tabular-nums; }
.tbl td.money { font-weight: 600; color: var(--text); }
.tbl td.money.in { color: var(--in); }
.tbl td.money.out { color: var(--out); }
.tbl tfoot td {
  background: #eef5f1;
  font-weight: 700;
  color: var(--primary-strong);
  border-top: 2px solid var(--primary-soft-2);
  border-bottom: none;
}
.tbl .cell-main { font-weight: 600; color: var(--text); }
.tbl .cell-sub { color: var(--muted); font-size: 0.76rem; }
.tbl-empty {
  padding: 44px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.tbl-empty svg { width: 40px; height: 40px; color: var(--border-strong); display: block; margin: 0 auto 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-in { background: var(--in-soft); color: var(--in); border: 1px solid #a7f3d0; }
.badge-out { background: var(--out-soft); color: var(--out); border: 1px solid #fecdd3; }
.badge-role { background: #f0f4f2; color: var(--text-2); border: 1px solid var(--border-strong); }
.badge-role.admin { background: var(--primary-soft-2); color: var(--primary-strong); border-color: #a7f3d0; }
.badge-role.keeper { background: var(--warning-soft); color: var(--warning); border-color: #fde68a; }
.cat-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

/* =========================================================
   نوار ابزار و فیلترها
   ========================================================= */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.toolbar .field-inline { display: flex; flex-direction: column; gap: 4px; }
.toolbar .field-inline > span { font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.toolbar input[type="text"], .toolbar select {
  min-width: 130px;
  padding: 7px 12px;
  min-height: 38px;
  font-size: 0.86rem;
}
.toolbar .jalali-input { cursor: pointer; min-width: 118px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }
.quick-links { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 30px;
}
.chip-btn:hover, .chip-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-strong);
}

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-soft-2);
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--primary-strong);
  font-weight: 600;
}
.result-bar .sums { display: flex; gap: 16px; flex-wrap: wrap; }
.result-bar .sums .in { color: var(--in); }
.result-bar .sums .out { color: var(--out); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.pagination .pg-btn {
  min-width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}
.pagination .pg-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .pg-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .pg-info { color: var(--muted); font-size: 0.8rem; margin: 0 8px; }

/* =========================================================
   فرم‌ها و پنجره‌ها
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 26, 19, 0.45);
  backdrop-filter: blur(3px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: 18px;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: rise 0.22s ease;
}
.modal.wide { max-width: 640px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 17px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1.02rem; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot {
  padding: 15px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.form-hint { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }
.form-error {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.82rem;
  margin-bottom: 12px;
}
.amount-wrap { position: relative; }
.amount-unit {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  pointer-events: none;
}
.type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-toggle button {
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  border-radius: 11px;
  padding: 9px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.type-toggle button.active-out {
  border-color: var(--out);
  background: var(--out-soft);
  color: var(--out);
}
.type-toggle button.active-in {
  border-color: var(--in);
  background: var(--in-soft);
  color: var(--in);
}

/* =========================================================
   توست‌ها
   ========================================================= */
.toast-root {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(420px, calc(100vw - 36px));
}
.toast {
  background: #10201a;
  color: #ecfdf5;
  border-radius: 13px;
  padding: 12px 17px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s ease;
  border-inline-start: 4px solid var(--primary);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.toast.success { border-color: #10b981; }
.toast.error { border-color: #ef4444; }
.toast.warn { border-color: #f59e0b; }
.toast svg { width: 19px; height: 19px; flex-shrink: 0; }
.toast.out-anim { opacity: 0; transform: translateY(8px); transition: all 0.3s; }

/* =========================================================
   تقویم شمسی (Datapicker)
   ========================================================= */
.jdp {
  position: fixed;
  z-index: 80;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 15px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  width: 288px;
  user-select: none;
  animation: jdpIn 0.16s ease;
}
@keyframes jdpIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.jdp-head { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.jdp-nav {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font);
}
.jdp-nav:hover { color: var(--primary); border-color: var(--primary); }
.jdp-selects { flex: 1; display: flex; gap: 5px; }
.jdp-selects select {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  min-height: 34px;
  font-size: 0.82rem;
  text-align: center;
  border: 1px solid var(--border-strong);
  background: #fbfdfc;
}
.jdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.jdp-dow {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  padding: 5px 0;
}
.jdp-day {
  height: 35px;
  border: none;
  background: transparent;
  border-radius: 9px;
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.12s;
}
.jdp-day:hover { background: var(--primary-soft); color: var(--primary-strong); }
.jdp-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--primary-strong); font-weight: 700; }
.jdp-day.selected { background: var(--primary); color: #fff; font-weight: 700; }
.jdp-day.empty { visibility: hidden; }
.jdp-day.fri { color: var(--out); }
.jdp-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
}
.jdp-foot .btn { min-height: 34px; font-size: 0.82rem; padding: 6px 13px; }

/* =========================================================
   نمودار داشبورد
   ========================================================= */
.chart-legend { display: flex; gap: 16px; justify-content: center; margin-top: 10px; font-size: 0.8rem; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.chart-legend .lg-in i { background: var(--in); }
.chart-legend .lg-out i { background: var(--out); }

.activity-list { display: flex; flex-direction: column; gap: 2px; }
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
  border-bottom: 1px dashed var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-ico {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-ico svg { width: 19px; height: 19px; }
.activity-ico.in { background: var(--in-soft); color: var(--in); }
.activity-ico.out { background: var(--out-soft); color: var(--out); }
.activity-meta { flex: 1; min-width: 0; }
.activity-meta strong { display: block; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-meta small { color: var(--muted); font-size: 0.75rem; }
.activity-amount { font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.activity-amount.in { color: var(--in); }
.activity-amount.out { color: var(--out); }

/* نوار درصد در گزارش دسته‌ها */
.pct-bar {
  position: relative;
  background: #edf2ef;
  border-radius: 99px;
  height: 8px;
  min-width: 90px;
  overflow: hidden;
}
.pct-bar i {
  position: absolute;
  inset-block: 0;
  right: 0;
  border-radius: 99px;
  background: var(--primary);
}

/* =========================================================
   تنظیمات
   ========================================================= */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.danger-zone { border-color: #fecaca; }
.danger-zone .card-title svg { color: var(--danger); }

/* =========================================================
   چاپ — برگه گزارش
   ========================================================= */
#print-area { display: none; }

@media print {
  @page { size: A4; margin: 12mm 10mm; }
  html, body { background: #fff !important; font-size: 12.5px; }
  .app-shell, .login-screen, .toast-root, .modal-overlay, .jdp, .overlay { display: none !important; }
  #print-area { display: block !important; }
}

.print-doc { color: #111; direction: rtl; }
.print-head { text-align: center; border-bottom: 2.5px solid #14532d; padding-bottom: 10px; margin-bottom: 14px; }
.print-head .ph-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #14532d;
  margin-bottom: 6px;
}
.print-head .ph-logo svg { width: 28px; height: 28px; }
.print-head h1 { font-size: 1.5rem; color: #14532d; }
.print-head h2 { font-size: 0.98rem; font-weight: 600; color: #333; margin-top: 3px; }
.print-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px 18px;
  font-size: 0.86rem;
  color: #444;
  margin: 10px 0 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 9px 14px;
  background: #f7faf8;
}
.print-meta b { color: #14532d; }
.print-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.print-summary .ps-box {
  flex: 1;
  min-width: 130px;
  border: 1px solid #d8e5dd;
  border-radius: 9px;
  padding: 8px 10px;
  text-align: center;
  background: #fbfdfc;
}
.print-summary .ps-box small { display: block; color: #666; font-size: 0.78rem; margin-bottom: 2px; }
.print-summary .ps-box b { font-size: 1rem; color: #14532d; }
.print-summary .ps-box b.out { color: #9f1239; }
.print-summary .ps-box b.in { color: #166534; }
table.p-tbl { width: 100%; border-collapse: collapse; text-align: center; font-size: 0.85rem; }
.p-tbl th, .p-tbl td {
  border: 1px solid #cfdad4;
  text-align: center;
  padding: 6px 5px;
  vertical-align: middle;
}
.p-tbl th { background: #e8f2ec !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; color: #14532d; font-weight: 700; }
.p-tbl tbody tr:nth-child(even) { background: #f7faf8; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.p-tbl tfoot td { background: #e8f2ec !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-weight: 700; color: #14532d; }
.print-words {
  margin-top: 12px;
  border: 1px dashed #9db8a8;
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 0.9rem;
  background: #fbfdfc;
}
.print-words b { color: #14532d; }
.print-sig {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  padding: 0 30px;
  font-size: 0.92rem;
}
.print-sig .sig-box { text-align: center; min-width: 200px; }
.print-sig .sig-box .sig-line { margin-top: 48px; border-top: 1.5px dotted #777; padding-top: 5px; color: #555; }
.print-foot { margin-top: 22px; text-align: center; color: #888; font-size: 0.74rem; border-top: 1px solid #e5e5e5; padding-top: 8px; }

/* =========================================================
   واکنش‌گرایی
   ========================================================= */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset-block: 0;
    right: 0;
    z-index: 50;
    transform: translateX(105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 11px 15px; }
  .view { padding: 16px 14px 24px; }
  .today-chip { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .stat-meta strong { font-size: 1.05rem; }
  .user-chip span#top-user-name { display: none; }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 20px 24px; }
  .toolbar { padding: 13px 14px; }
  .toolbar input[type="text"], .toolbar select { min-width: 0; flex: 1; }
  .toolbar .field-inline { width: 100%; }
  .toolbar .jalali-input { min-width: 0; width: 100%; }
}

/* اسکرول‌بار ظریف */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4d2ca; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #a8bab0; }

/* =========================================================
   پیوست عکس رسیدها
   ========================================================= */
.att-box { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 12px; background: #fafcfa; }
.att-thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.att-empty { font-size: 0.82rem; color: var(--muted); display: inline-block; padding: 4px 2px; }
.att-thumb { position: relative; width: 92px; height: 92px; border-radius: 10px; overflow: hidden; border: 1.5px solid var(--border-strong); background: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.att-thumb.is-new { border-color: var(--primary); }
.att-x { position: absolute; top: 5px; left: 5px; width: 22px; height: 22px; border-radius: 7px; border: none; background: rgba(15, 23, 20, 0.72); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.att-x:hover { background: var(--danger); }
.att-x svg { width: 13px; height: 13px; }
.att-new-tag { position: absolute; bottom: 5px; right: 5px; background: var(--primary); color: #fff; font-size: 0.66rem; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.att-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 10px; }
.att-btn { padding: 7px 13px; font-size: 0.85rem; }
.att-chip { display: inline-flex; align-items: center; gap: 3px; background: var(--primary-soft); color: var(--primary-strong); border: 1px solid #cfe8dc; border-radius: 999px; padding: 1px 8px; font-size: 0.74rem; font-weight: 600; cursor: pointer; margin-inline-start: 7px; vertical-align: middle; }
.att-chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.att-chip svg { width: 12px; height: 12px; }

/* لایت‌باکس نمایش بزرگ عکس */
.lightbox { position: fixed; inset: 0; z-index: 1200; background: rgba(9, 14, 12, 0.93); display: flex; align-items: center; justify-content: center; animation: lbIn 0.15s ease; }
@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }
.lb-fig { margin: 0; max-width: 92vw; text-align: center; }
.lb-fig img { max-width: 92vw; max-height: 78vh; border-radius: 12px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5); background: #fff; }
.lb-fig figcaption { color: #d6e2db; font-size: 0.85rem; margin-top: 10px; direction: rtl; }
.lb-btn { position: absolute; width: 42px; height: 42px; border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.14); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.lb-btn:hover { background: rgba(255, 255, 255, 0.28); }
.lb-close { top: 16px; left: 16px; }
.lb-del { top: 16px; right: 16px; background: rgba(225, 29, 72, 0.85); }
.lb-del:hover { background: #b91c1c; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.lb-nav:hover { background: rgba(255, 255, 255, 0.3); }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }

/* نشانگر عکس در برگه چاپ */
.p-att { display: inline-block; background: #eef5f1; border: 1px solid #d8e6de; border-radius: 6px; padding: 0 6px; margin-inline-start: 6px; font-size: 0.68rem; color: #14532d; font-weight: 700; white-space: nowrap; }
