/* فونت وزیرمتن: اول از روی سرور خودت (public/fonts)، اگر نبود از گوگل */
@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/Vazirmatn[wght].woff2") format("woff2-variations"), url("/fonts/Vazirmatn[wght].woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --sea: #0d3b56;
  --sea-2: #155e80;
  --sea-3: #e3eff5;
  --sand: #f7f2e8;
  --sand-2: #efe6d4;
  --card: #ffffff;
  --ink: #1d2a33;
  --muted: #6b7a85;
  --line: #e8e0cf;
  --gold: #d9962f;
  --ok: #178a5f;
  --ok-bg: #e3f5ec;
  --bad: #c9402f;
  --bad-bg: #fbe9e6;
  --pend: #b7791f;
  --pend-bg: #fdf3e1;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(13, 59, 86, .06), 0 8px 24px rgba(13, 59, 86, .07);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  background: var(--sand);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--sea-2); }

/* ---------- سربرگ ---------- */
.top {
  background: linear-gradient(160deg, var(--sea) 0%, var(--sea-2) 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.top::after {
  content: "";
  position: absolute; inset: auto 0 -1px 0; height: 28px;
  background: var(--sand);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 28' preserveAspectRatio='none'%3E%3Cpath d='M0 28V14C150 0 300 0 450 12S750 26 900 14 1100 2 1200 10V28Z'/%3E%3C/svg%3E") center/100% 100%;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 28' preserveAspectRatio='none'%3E%3Cpath d='M0 28V14C150 0 300 0 450 12S750 26 900 14 1100 2 1200 10V28Z'/%3E%3C/svg%3E") center/100% 100%;
}
.top-inner { max-width: 880px; margin: 0 auto; padding: 22px 16px 46px; display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  background: rgba(255,255,255,.12); display: grid; place-items: center;
}
.logo svg { width: 28px; height: 28px; }
.top h1 { margin: 0; font-size: 1.25rem; font-weight: 800; }
.top .sub { margin: 0; opacity: .8; font-size: .9rem; }
.top .spacer { flex: 1; }

main { max-width: 880px; margin: -18px auto 0; padding: 0 16px 60px; position: relative; z-index: 1; }

/* ---------- کارت ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 14px; }
.hidden { display: none !important; }

/* ---------- دکمه ---------- */
.btn {
  border: 0; border-radius: 14px; padding: 11px 18px; cursor: pointer;
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
  min-height: 46px; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--sea); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-bad { background: var(--bad); color: #fff; }
.btn-soft { background: var(--sea-3); color: var(--sea); }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost-light { background: rgba(255,255,255,.14); color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 12px; border-radius: 11px; font-size: .88rem; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: 6px; border-radius: 10px; color: var(--muted); }
.icon-btn:hover { background: var(--sand); color: var(--ink); }

/* ---------- فرم ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.input {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 13px;
  padding: 11px 14px; outline: none; transition: border-color .15s, box-shadow .15s; min-height: 46px;
}
.input:focus { border-color: var(--sea-2); box-shadow: 0 0 0 4px rgba(21, 94, 128, .12); }
.input.num { direction: ltr; text-align: right; font-feature-settings: "tnum"; }
.hint { font-size: .8rem; color: var(--sea-2); min-height: 1.3em; margin-top: 3px; }
.seg { display: inline-flex; background: var(--sand); border-radius: 13px; padding: 4px; gap: 4px; }
.seg button {
  border: 0; background: transparent; padding: 8px 18px; border-radius: 10px; cursor: pointer; font-weight: 700; color: var(--muted);
}
.seg button.on { background: #fff; color: var(--sea); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- محاسبه ---------- */
.calc { background: var(--sand); border-radius: 16px; padding: 6px 14px; }
.calc-row { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 0; border-bottom: 1px dashed var(--line); gap: 12px; }
.calc-row:last-child { border-bottom: 0; }
.calc-row .k { color: var(--muted); font-size: .92rem; }
.calc-row .k small { opacity: .8; }
.calc-row .v { font-weight: 700; color: var(--sea); font-feature-settings: "tnum"; white-space: nowrap; }
.total-bar {
  margin-top: 10px; border-radius: 16px; padding: 14px 16px; color: #fff;
  background: linear-gradient(135deg, var(--sea), var(--sea-2));
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.total-bar .v { font-size: 1.35rem; font-weight: 800; }

/* ---------- آمار ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--sand); border-radius: 14px; padding: 10px 12px; }
.stat .k { font-size: .78rem; color: var(--muted); }
.stat .v { font-weight: 800; font-size: 1rem; }
.stat.ok .v { color: var(--ok); }
.stat.pend .v { color: var(--pend); }
.stat.sea .v { color: var(--sea); }
@media (max-width: 520px) { .stat .v { font-size: .9rem; } }

.progress { height: 10px; background: var(--sand-2); border-radius: 99px; overflow: hidden; display: flex; }
.progress i { display: block; height: 100%; }
.progress .p-ok { background: var(--ok); }
.progress .p-pend { background: var(--gold); opacity: .6; }

/* ---------- برچسب ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 99px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.chip.pending { background: var(--pend-bg); color: var(--pend); }
.chip.confirmed { background: var(--ok-bg); color: var(--ok); }
.chip.rejected { background: var(--bad-bg); color: var(--bad); }
.chip.time { background: var(--sea-3); color: var(--sea); }
.chip.dead { background: #eee; color: #777; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- لیست مشتری ---------- */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; background: #fff; box-shadow: var(--shadow);
  margin-bottom: 10px; cursor: pointer; transition: transform .1s; text-decoration: none; color: inherit;
}
.list-item:hover { transform: translateY(-1px); }
.avatar {
  width: 46px; height: 46px; border-radius: 14px; flex: none; display: grid; place-items: center;
  background: var(--sea-3); color: var(--sea); font-weight: 800; font-size: 1.1rem;
}
.badge-n { background: var(--gold); color: #fff; border-radius: 99px; padding: 0 8px; font-size: .75rem; font-weight: 800; }

/* ---------- فیش‌ها ---------- */
.receipts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.receipt {
  background: #fff; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  border: 2px solid transparent; transition: border-color .2s;
}
.receipt.confirmed { border-color: rgba(23,138,95,.35); }
.receipt.rejected { border-color: rgba(201,64,47,.35); }
.receipt .ph { position: relative; aspect-ratio: 4 / 3; background: var(--sand-2); cursor: zoom-in; overflow: hidden; }
.receipt .ph img { width: 100%; height: 100%; object-fit: cover; }
.receipt .ph .none { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .9rem; }
.receipt .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.receipt .amt { font-size: 1.2rem; font-weight: 800; color: var(--sea); }
.stamp {
  position: absolute; top: 12px; left: 12px; transform: rotate(-8deg);
  border: 3px solid currentColor; border-radius: 12px; padding: 2px 12px; font-weight: 800; background: rgba(255,255,255,.88);
  font-size: .95rem;
}
.stamp.confirmed { color: var(--ok); }
.stamp.rejected { color: var(--bad); }
.decide { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; padding-top: 6px; }
.decide .btn { min-height: 52px; font-size: 1rem; }

/* ---------- آپلود ---------- */
.drop {
  border: 2px dashed var(--line); border-radius: 18px; padding: 22px; text-align: center; cursor: pointer; color: var(--muted);
  transition: border-color .15s, background .15s; display: block;
}
.drop:hover, .drop.over { border-color: var(--sea-2); background: var(--sea-3); color: var(--sea); }
.up-row { display: flex; gap: 12px; align-items: center; padding: 10px; background: var(--sand); border-radius: 14px; margin-top: 10px; flex-wrap: wrap; }
.up-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.up-row .grow .input { margin-bottom: 6px; }

/* ---------- لینک مشتری ---------- */
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--sand); border-radius: 14px; padding: 8px 8px 8px 12px; }
.linkbox code { direction: ltr; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; color: var(--sea); }

/* ---------- پنجره‌ها ---------- */
.sheet-wrap {
  position: fixed; inset: 0; background: rgba(13, 32, 45, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.sheet-wrap.in { opacity: 1; }
.sheet-wrap.out { opacity: 0; }
.sheet {
  background: #fff; width: 100%; max-width: 520px; border-radius: 24px 24px 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(30px); transition: transform .22s ease; max-height: 92vh; overflow: auto;
}
.sheet-wrap.in .sheet { transform: none; }
@media (min-width: 640px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 24px; } }
.sheet h3 { margin: 0 0 6px; font-size: 1.15rem; }
.sheet p { margin: 0 0 14px; color: var(--muted); }
.sheet-actions { display: grid; gap: 8px; margin-top: 14px; }

.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 60; display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.viewer-close { position: absolute; top: 14px; left: 14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 1.2rem; cursor: pointer; }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; text-align: center; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(8px); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 2.6rem; }

.back { display: inline-flex; align-items: center; gap: 6px; color: #fff; opacity: .85; text-decoration: none; font-size: .9rem; }
.back:hover { opacity: 1; }

.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.dark { border-color: var(--line); border-top-color: var(--sea); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 60px; }

.fade-in { animation: fadeIn .3s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

[hidden] { display: none !important; }
.ocr-st { margin-top: 4px; }
.ocr-st.ok { color: var(--ok); }
.ocr-st.warn { color: #a86b00; }
.up-row.ocr-done { opacity: .6; transition: opacity .4s; }
/* جدول شیت سرویس */
.sheet-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; }
.sheet-tbl { border-collapse: collapse; font-size: .85rem; min-width: 100%; }
.sheet-tbl th { background: var(--sand); color: var(--muted); font-weight: 600; padding: 7px 5px; white-space: nowrap; text-align: right; }
.sheet-tbl td { border-top: 1px solid var(--line); padding: 1px 3px; white-space: nowrap; }
.sheet-tbl .cell { width: 100%; min-width: 48px; border: 1px solid transparent; background: transparent; padding: 7px 4px; border-radius: 6px; font: inherit; color: inherit; }
.sheet-tbl .cell:hover { border-color: var(--line); }
.sheet-tbl .cell:focus { border-color: var(--sea); background: #fff; outline: none; }
.sheet-tbl .out { background: rgba(14, 91, 122, .06); color: var(--sea); font-weight: 600; text-align: left; font-feature-settings: "tnum"; padding: 7px 6px; }
.sheet-tbl tfoot td { font-weight: 800; border-top: 2px solid var(--line); padding: 8px 6px; }
.sheet-tbl .icon-btn { width: 28px; height: 28px; font-size: .8rem; opacity: .5; }
.sheet-tbl tr:hover .icon-btn { opacity: 1; }
.bad, .calc-row .v.bad { color: var(--bad); }
  details.calcbox { margin-top: 12px; }
  details.calcbox summary { cursor: pointer; color: var(--sea-2); font-weight: 700; font-size: .92rem; list-style: none; padding: 6px 0; }
  details.calcbox summary::-webkit-details-marker { display: none; }
  details.calcbox summary::before { content: "▾ "; }
  details.calcbox:not([open]) summary::before { content: "◂ "; }
/* انتخاب تاریخ شمسی */
.jdate, label.field > span.jdate { display: flex; gap: 6px; margin: 0; }
.jdate select { flex: 1; min-width: 0; padding-left: 6px; padding-right: 6px; }
.jdate select[data-jp=m] { flex: 1.6; }
.inbox-item .ocr-st { margin-top: 6px; }
