/* ───────────────────────── سامانه فرم درخواست و پرداخت وجه — نسخه PHP ─────────────────────────
   تم سبز هم‌سان با نسخه اصلی + استایل چاپ A5 و چاپ فیش بانکی */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.ttf') format('truetype');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.ttf') format('truetype');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.ttf') format('truetype');
  font-weight: 700 800; font-display: swap;
}

:root {
  /* رنگ‌های سازمانی — استخراج‌شده از لوگو: سرخ لاکی #72000e روی سفید #f9f9f9 */
  --org-950: #3f0007; --org-900: #56000a; --org-800: #72000e; --org-700: #8c1220; --org-600: #a52737; --org-500: #bd4553;
  --org-200: #eecdd1; --org-100: #f7e0e3; --org-50: #fcf2f3; --org-white: #f9f9f9;
  --indigo-700: #4338ca; --sky-700: #0369a1; --sky-50: #f0f9ff;
  --amber-500: #f59e0b; --amber-600: #d97706; --amber-700: #b45309; --amber-50: #fffbeb;
  --red-600: #dc2626; --red-700: #b91c1c; --red-50: #fef2f2;
  --text: #1f2937; --muted: #6b7280; --border: #e5e7eb; --bg: #f8f5f5; --card: #ffffff;
  --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Vazirmatn, Tahoma, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; direction: rtl; min-height: 100vh;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--org-800); }
img { max-width: 100%; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; width: 100%; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.ltr { direction: ltr; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grow { flex: 1; }
.center { text-align: center; }
.mono { font-family: Vazirmatn, monospace; }
.spin { width: 18px; height: 18px; border: 2px solid var(--org-200, #eecdd1); border-top-color: var(--org-800); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───── سربرگ — طیف رنگی سازمانی (سرخ لاکی لوگو) ───── */
.app-header {
  background: linear-gradient(to left, var(--org-900) 0%, var(--org-800) 45%, var(--org-700) 75%, var(--org-600) 100%);
  color: #fff; box-shadow: 0 4px 14px rgba(114,0,14,.28);
}
.app-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; }
.logo-box { width: 48px; height: 48px; border-radius: 12px; background: var(--org-white); display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.logo-box img { width: 44px; height: 44px; object-fit: contain; }
.app-title { font-size: 19px; font-weight: 800; line-height: 1.5; margin: 0; }
.app-sub { font-size: 12px; color: var(--org-200); margin: 2px 0 0; }
.header-side { margin-inline-start: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chip {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px; padding: 5px 10px; font-size: 12px; color: #fff;
}
.user-chip { background: rgba(255,255,255,.1); display: flex; align-items: center; gap: 6px; }
.user-chip b { font-size: 13px; }
.user-chip .role { color: var(--org-200); font-size: 11px; }

/* ───── تب‌ها ───── */
.tabs { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.tabs .wrap { display: flex; gap: 2px; overflow-x: auto; }
.tab-btn {
  display: flex; align-items: center; gap: 7px; padding: 12px 16px; font-size: 13.5px; font-weight: 500;
  border: none; background: none; border-bottom: 2px solid transparent; color: var(--muted);
  cursor: pointer; white-space: nowrap; font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--org-900); border-bottom-color: var(--org-800); font-weight: 700; }
.tab-count { background: var(--amber-500); color: #fff; border-radius: 6px; font-size: 11px; padding: 0 6px; height: 18px; line-height: 18px; }

.alert-bar { background: #fffbeb; border-bottom: 1px solid #fcd34d; }
.alert-bar .wrap { padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 13.5px; color: #78350f; }

main.content { flex: 1; padding: 22px 0 30px; }

/* ───── پانویس ───── */
.app-footer { border-top: 1px solid var(--border); background: rgba(255,255,255,.8); }
.app-footer .wrap { padding: 10px 16px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); }

/* ───── کارت ───── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card-pad { padding: 16px 18px; }
.card-title { font-weight: 800; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.card-teal { border-color: #99f6e4; }

/* ───── فرم ───── */
label.lbl { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.inp, select.inp, textarea.inp {
  width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 7px 10px; font-size: 13.5px;
  font-family: inherit; background: #fff; color: var(--text); outline: none;
}
.inp:focus { border-color: var(--org-700); box-shadow: 0 0 0 2px rgba(5,150,105,.15); }
.inp:disabled, .inp[readonly].dis { background: #f3f4f6; color: #6b7280; }
textarea.inp { resize: vertical; min-height: 52px; line-height: 1.7; }
select.inp { height: 36px; padding: 4px 8px; }
.inp-num { text-align: left; direction: ltr; font-weight: 600; letter-spacing: .3px; }
.field { margin-bottom: 4px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.hint { font-size: 11.5px; color: var(--muted); line-height: 1.7; margin-top: 4px; }

/* ───── چک‌لیست قدرت رمز عبور ───── */
.pw-rules { display: flex; flex-wrap: wrap; gap: 3px 14px; margin-top: 6px; }
.pw-rule { font-size: 11px; color: var(--red-600); transition: color .15s; }
.pw-rule.ok { color: var(--org-800); }
.pw-rules.all-ok .pw-rule { color: var(--org-800); }
.pw-confirm { font-size: 11.5px; color: var(--red-600); margin-top: 5px; min-height: 16px; }
.pw-confirm.ok { color: var(--org-800); }

/* ───── دکمه‌ها ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 16px;
  background: var(--org-800); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--org-900); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--text); border-color: #d1d5db; }
.btn-outline:hover { background: #f9fafb; }
.btn-ghost { background: transparent; color: var(--org-800); }
.btn-ghost:hover { background: var(--org-50); }
.btn-danger { background: var(--red-600); } .btn-danger:hover { background: var(--red-700); }
.btn-outline-danger { background: #fff; color: var(--red-700); border-color: #f87171; }
.btn-outline-danger:hover { background: var(--red-50); }
.btn-teal { background: var(--org-600); } .btn-teal:hover { background: var(--org-700); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn-ico { padding: 5px; width: 30px; height: 30px; border-radius: 7px; }
.btn svg { flex-shrink: 0; }

/* ───── بج ───── */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; }
.badge-em { background: var(--org-800); color: #fff; }
.badge-indigo { background: var(--indigo-700); color: #fff; }
.badge-sky { background: var(--sky-700); color: #fff; }
.badge-amber { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-500); }
.badge-green { background: var(--org-50); color: var(--org-900); border-color: #e8b4ba; }
.badge-red { background: var(--red-50); color: var(--red-700); border-color: #fca5a5; }
.badge-teal { background: var(--org-50); color: var(--org-600); border-color: #d9959d; }
.badge-gray { background: #f3f4f6; color: var(--muted); border-color: #e5e7eb; }

/* ───── جدول ───── */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 760px; }
.tbl th { background: #f9fafb; font-size: 12px; color: var(--muted); font-weight: 700; padding: 9px 10px; text-align: center; border-bottom: 1px solid var(--border); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .cell-c { text-align: center; }
.tbl .cell-r { text-align: right; }
.tbl .amount { font-weight: 700; white-space: nowrap; }
.tbl tr.voided-row { background: #fef2f2aa; }
.tbl tfoot td, .tbl tr.sum td { background: #f9fafb; font-weight: 800; }

.pager { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); padding: 10px 16px; font-size: 13px; color: var(--muted); }
.empty-state { padding: 40px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ───── بنر و هشدار ───── */
.banner { border-radius: 10px; padding: 13px 15px; font-size: 13px; line-height: 1.9; margin-bottom: 16px; display: flex; gap: 9px; align-items: flex-start; }
.banner svg { margin-top: 3px; flex-shrink: 0; }
.banner-green { background: var(--org-50); border: 1px solid #e8b4ba; color: var(--org-900); }
.banner-sky { background: var(--sky-50); border: 1px solid #7dd3fc; color: #0c4a6e; }
.banner-red { background: var(--red-50); border: 1px solid #fca5a5; color: #7f1d1d; }

.errlist { border: 1px solid #fca5a5; background: #fef2f2; border-radius: 10px; padding: 13px 16px; margin-bottom: 16px; }
.errlist .t { color: var(--red-700); font-weight: 800; display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.errlist ul { margin: 0; padding-inline-start: 22px; color: var(--red-700); font-size: 13px; line-height: 2; }

/* ───── جعبه‌های امضا ───── */
.sign-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 860px) { .sign-grid { grid-template-columns: 1fr; } }
.sign-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.sign-box.mine { border-color: var(--org-700); background: var(--org-50); }
.sign-box .head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.sign-box .title { font-size: 13px; font-weight: 800; color: var(--org-900); }
.sign-box .opinion { font-size: 12px; min-height: 34px; line-height: 1.8; }
.sign-box .sigimg { height: 40px; max-width: 110px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 1px 4px; }
.sign-box .nosig { height: 40px; border: 1px dashed #d1d5db; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 11.5px; color: var(--muted); }
.sign-box .who { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.sign-box .wait { display: flex; gap: 5px; align-items: center; font-size: 11px; color: var(--amber-700); border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }

/* ───── نوع پرداخت فرم جدید ───── */
.kind-box { border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.kind-box.noncorp { border-color: #7dd3fc; background: #f0f9ff88; }
.kind-box.corp { border-color: #a5b4fc; background: #eef2ff66; }
.kind-btn { border-radius: 7px; font-size: 12px; padding: 6px 12px; cursor: pointer; font-family: inherit; border: 1px solid transparent; font-weight: 600; }
.kind-btn.active-noncorp { background: var(--sky-700); color: #fff; }
.kind-btn.noncorp { background: transparent; color: #0c4a6e; border-color: #38bdf8; }
.kind-btn.active-corp { background: var(--indigo-700); color: #fff; }
.kind-btn.corp { background: transparent; color: #3730a3; border-color: #818cf8; }
.kind-btn:disabled { opacity: .6; cursor: not-allowed; }
.acc-info { font-size: 12px; line-height: 1.9; color: #312e81; background: #ffffffbb; border: 1px solid #c7d2fe; border-radius: 8px; padding: 8px 10px; margin-top: 8px; }

/* ───── مودال ───── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 14px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 780px; box-shadow: 0 20px 60px rgba(0,0,0,.3); direction: rtl; animation: pop .15s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: .4; } }
.modal.sm { max-width: 430px; }
.modal .m-head { padding: 16px 20px 6px; }
.modal .m-title { font-size: 15.5px; font-weight: 800; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.modal .m-desc { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.8; }
.modal .m-body { padding: 10px 20px; }
.modal .m-foot { padding: 12px 20px 16px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; }
.modal .m-body.scroll { max-height: 64vh; overflow-y: auto; }

/* ───── توست ───── */
#toast-root { position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1f2937; color: #fff; border-radius: 10px; padding: 11px 16px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: slideup .2s ease-out; max-width: 420px; line-height: 1.8; }
.toast.ok { background: var(--org-900); }
.toast.err { background: var(--red-700); }
@keyframes slideup { from { transform: translateY(10px); opacity: 0; } }

/* ───── ورود ───── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--org-50), #fff, #fdf6f7); padding: 16px; }
.login-card { background: #fff; border: 1px solid var(--org-200); border-radius: 16px; box-shadow: 0 20px 50px rgba(114,0,14,.12); width: 100%; max-width: 410px; padding: 30px 28px; }
.login-card .llogo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 22px; }
.login-card .llogo img { width: 66px; height: 66px; object-fit: contain; border: 1px solid var(--border); background: #fff; border-radius: 14px; padding: 6px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 17px; color: var(--org-900); margin: 0; }
.login-card .sub { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.9; margin: 4px 0 0; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: 9px; color: var(--muted); }
.input-icon .inp { padding-inline-end: 32px; }

/* ───── صفحه لاگین نیست؛ بارگذاری ───── */
.boot-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--muted); gap: 10px; font-size: 14px; }

/* ───── چاپ فیش — پیش‌نمایش ───── */
.fish-layout { display: grid; grid-template-columns: 5fr 7fr; gap: 16px; }
@media (max-width: 1000px) { .fish-layout { grid-template-columns: 1fr; } }
.fish-preview-wrap { border: 1px solid var(--border); border-radius: 8px; background: #fff; overflow: hidden; direction: ltr; width: 100%; }
.fish-canvas { position: relative; background: #fff; }
.fish-canvas img.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; user-select: none; -webkit-user-drag: none; }
.fish-field {
  position: absolute; white-space: nowrap; line-height: 1.15; color: #111;
  direction: ltr; text-align: left; font-family: Vazirmatn, Tahoma, sans-serif;
  user-select: none; border: 1px dashed transparent; padding: 0 2px;
}
.fish-field.rtl { direction: rtl; }
.fish-field.calib { cursor: move; background: rgba(16,185,129,.16); border-color: rgba(5,150,105,.9); }
.calib-grid { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.calib-row { display: grid; grid-template-columns: 6fr 2fr 2fr 1.4fr 28px; gap: 4px; align-items: center; margin-bottom: 5px; }
.calib-row .lbl { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calib-row .inp { height: 26px; padding: 1px 4px; font-size: 11.5px; }
.acc-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.8; margin-bottom: 5px; }

/* ───── پد امضا ───── */
.sig-canvas { width: 100%; height: 170px; border: 2px dashed #cbd5e1; border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; display: block; }

/* ───── لاگ کاربر ───── */
.log-user .n { font-weight: 600; }
.log-user .u { direction: ltr; text-align: left; font-family: monospace; font-size: 11.5px; color: var(--muted); }

/* ───────────── چاپ ───────────── */
#print-root, #fish-print-root { display: none; }

@media print {
  @page { size: A5 portrait; margin: 6mm; }
  html, body { background: #fff !important; }
  body > *:not(#print-root):not(#fish-print-root) { display: none !important; }
  body:not(.fish-printing) #print-root { display: block !important; }
  body.fish-printing #print-root { display: none !important; }
  body.fish-printing #fish-print-root { display: block !important; }
}

/* چاپ A5 — فرم کاغذی (عرض محتوا ۱۳۶ میلی‌متر) */
.a5 { width: 136mm; min-height: 192mm; background: #fff; color: #000; position: relative; font-family: Vazirmatn, Tahoma, sans-serif; direction: rtl; }
.a5 table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.a5 td, .a5 th { border: 0.35mm solid #000; padding: 1.4mm 2mm; vertical-align: middle; word-break: break-word; }
.a5 .void-stamp {
  position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg);
  border: 1.2mm solid #dc2626; color: #dc2626; font-size: 34pt; font-weight: 800;
  padding: 2mm 8mm; opacity: .45; white-space: nowrap; z-index: 10;
}
.a5 .ser { font-size: 15pt; font-weight: 800; line-height: 1.2; }
.a5 .kind-note { font-size: 7.5pt; font-weight: 700; margin-top: .6mm; }
.a5 .co-en { font-size: 12pt; font-weight: 800; letter-spacing: .5mm; line-height: 1.3; }
.a5 .co-fa { font-size: 9.5pt; font-weight: 700; }
.a5 .form-t { font-size: 9pt; margin-top: .6mm; }
.a5 .doc-code { font-size: 9pt; font-weight: 700; }
.a5 .rev { font-size: 8pt; margin-top: .8mm; }
.a5 .amt-box { display: inline-block; min-width: 55mm; text-align: center; border: .35mm solid #000; padding: .8mm 2mm; font-size: 11.5pt; font-weight: 800; letter-spacing: .2mm; }
.a5 .chk { display: inline-block; width: 3.2mm; height: 3.2mm; border: .35mm solid #000; position: relative; vertical-align: middle; margin-left: 1.4mm; }
.a5 .chk i { position: absolute; inset: .55mm; background: #000; }
.a5 .sig-cell { border: .35mm solid #000; height: 13mm; display: flex; align-items: center; justify-content: center; background: #fff; overflow: hidden; }
.a5 .sig-cell img { max-height: 12mm; max-width: 34mm; object-fit: contain; }
.a5 .sig-cell span { font-size: 7.5pt; color: #555; }
.a5 .sig-name { font-size: 7.5pt; margin-top: .8mm; min-height: 3.5mm; text-align: center; }
.a5 .fs75 { font-size: 7.5pt; } .a5 .fs8 { font-size: 8pt; } .a5 .fs85 { font-size: 8.5pt; } .a5 .fs9 { font-size: 9pt; } .a5 .fs95 { font-size: 9.5pt; }
.a5 .dots { color: #444; }
.a5 .flexline { display: flex; justify-content: space-between; align-items: center; gap: 2mm; }
.a5 .checks-inner { width: 100%; border-collapse: collapse; table-layout: fixed; }
.a5 .checks-inner td, .a5 .checks-inner th { font-size: 8.5pt; border: .35mm solid #000; padding: 1.2mm 1.5mm; text-align: center; }
.a5 .checks-inner td.blank { height: 6.2mm; }
.a5 .footer-line { margin-top: 1.8mm; text-align: center; font-size: 7.5pt; color: #333; direction: rtl; }
