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

:root {
  --bg: #f4f5f1;
  --card: #ffffff;
  --ink: #16201c;
  --muted: #6b7570;
  --line: #e3e6df;
  --accent: #14735a;
  --accent-soft: #e2f1eb;
  --gold: #a87a12;
  --gold-soft: #f6eed8;
  --red: #b4372f;
  --red-soft: #f8e6e3;
  --green: #14735a;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1714;
    --card: #18221e;
    --ink: #eef2ee;
    --muted: #93a09a;
    --line: #26332d;
    --accent: #3fbf96;
    --accent-soft: #173229;
    --gold: #e3b54a;
    --gold-soft: #2f2a19;
    --red: #ef7b70;
    --red-soft: #3a1f1c;
    --green: #3fbf96;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.6 Vazirmatn, system-ui, sans-serif;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- ورود ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-box img { border-radius: 20px; }
.login-box h1 { font-size: 22px; margin: 12px 0 24px; }
.login-box input { width: 100%; text-align: center; margin-bottom: 12px; }
.err { color: var(--red); min-height: 1.6em; margin: 8px 0 0; font-size: 14px; }

/* ---------- سربرگ و زبانه‌ها ---------- */
#app { padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 24px); }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--bg);
}
.top h1 { font-size: 20px; font-weight: 700; margin: 0; }
.top-actions { display: flex; gap: 4px; }
.icon-btn { width: 40px; height: 40px; border: 0; background: transparent; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: var(--line); }
.icon-btn.on { color: var(--accent); }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 6;
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 12px; }
.tabs button.on { color: var(--accent); font-weight: 500; }

.fab {
  position: fixed; z-index: 7; left: 16px; bottom: calc(var(--tabs-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px; border-radius: 18px; border: 0;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(20, 115, 90, .35);
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.2; }
@media (prefers-color-scheme: dark) { .fab { color: #0f1714; } }

main { padding: 0 16px; max-width: 640px; margin: 0 auto; }

/* ---------- کارت‌ها ---------- */
.card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.hero { padding: 20px; margin-bottom: 14px; }
.hero .label { color: var(--muted); font-size: 13px; }
.hero .big { font-size: 30px; font-weight: 700; line-height: 1.3; margin-top: 4px; letter-spacing: -.3px; }
.hero .unit { font-size: 14px; font-weight: 400; color: var(--muted); margin-right: 4px; }
.hero .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.mix { display: flex; height: 8px; border-radius: 99px; overflow: hidden; margin-top: 16px; background: var(--line); }
.mix span { display: block; height: 100%; }
.mix-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.mix-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-left: 5px; vertical-align: middle; }

.rows { overflow: hidden; margin-bottom: 14px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 16px; border: 0; background: none; text-align: right;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
button.row:active { background: var(--bg); }
.row .dot { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 15px; }
.row .dot svg { width: 20px; height: 20px; }
.row .main { flex: 1; min-width: 0; display: block; }
.row .t, .row .s { display: block; }
.row .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .v { text-align: left; flex: none; }
.row .v b { font-weight: 700; display: block; }
.row .v small { display: block; font-size: 12px; color: var(--muted); }

.c-acc { background: var(--accent-soft); color: var(--accent); }
.c-gold { background: var(--gold-soft); color: var(--gold); }
.c-red { background: var(--red-soft); color: var(--red); }
.pos { color: var(--green) !important; }
.neg { color: var(--red) !important; }

.section-h { display: flex; justify-content: space-between; align-items: baseline; margin: 20px 4px 8px; }
.section-h h2 { font-size: 15px; margin: 0; font-weight: 700; }
.section-h span { font-size: 13px; color: var(--muted); }

.prices { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: none; }
.prices::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 10px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: 12.5px; }
.chip b { display: block; font-size: 14px; font-weight: 700; }
.chip span { color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--line); border-radius: 14px; margin-bottom: 14px; }
.seg button { border: 0; background: none; padding: 8px; border-radius: 10px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.note-line { font-size: 12px; color: var(--muted); text-align: center; margin: 4px 0 16px; }

/* ---------- برگه‌ی پایین و فرم ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); animation: fade .2s; }
.sheet {
  position: absolute; inset: auto 0 0 0; max-height: 92dvh; overflow-y: auto;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + var(--safe-b));
  animation: up .25s cubic-bezier(.2, .8, .2, 1);
  max-width: 640px; margin: 0 auto;
}
.sheet-handle { width: 40px; height: 4px; border-radius: 9px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field .hint { display: block; font-size: 12px; color: var(--accent); margin-top: 4px; min-height: 1.4em; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); outline: none;
  font-size: 16px; /* جلوگیری از زوم خودکار */
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
.money { font-weight: 700; font-size: 18px; direction: ltr; text-align: right; }
.date3 { display: grid; grid-template-columns: 1fr 1.6fr 1.2fr; gap: 8px; }
.date3 select { padding-inline: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 14px; }
.check input { width: auto; }

.btns { display: flex; gap: 10px; margin-top: 6px; }
.btn { flex: 1; padding: 13px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); font-weight: 700; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0f1714; } }
.btn.danger { color: var(--red); flex: 0 0 auto; padding-inline: 18px; }
.btn:disabled { opacity: .6; }

.menu .row { font-size: 15px; }

.toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + var(--safe-b) + 84px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-size: 14px;
  animation: fade .2s;
}

.masked .amt { filter: blur(7px); }
