/* تم «خرجمون» = همان پالت و فونت elid.gold: زمرد تیره، طلایی، مرواریدی. فقط تیره، مثل خود سایت. */
@font-face { font-family: Vazirmatn; font-weight: 100 900; font-display: swap; src: url(/vazirmatn-arabic-wght-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Vazirmatn; font-weight: 100 900; font-display: swap; src: url(/vazirmatn-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }

:root {
  color-scheme: dark;
  --bg: #0e2a23;          /* emerald-night */
  --surface: #10302a;     /* emerald-deep */
  --raised: #143a32;
  --gold: #c9a45c;
  --gold-soft: #c9a45c40; /* hairline-gold */
  --fg: #f4f1ea;          /* pearl */
  --muted: #a7b3ac;
  --ink: #0b0b0c;
  --neg: #f0a196;
  --pos: #9fd8b4;
  --radius: 6px;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  font: 16px/1.7 Vazirmatn, system-ui, -apple-system, Tahoma, sans-serif;
  color: var(--fg);
  background: radial-gradient(circle at 50% 0%, #c9a45c1f, transparent 60%) no-repeat, var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* --- سربرگ --- */
header {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  /* مات و کامل، نه شیشه‌ای: زیر نوار وضعیت آیفون محتوای ورق‌خورده تار دیده می‌شد */
  padding: calc(env(safe-area-inset-top) + 18px) 18px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--gold-soft);
}
header strong { color: var(--gold); font-weight: 600; font-size: 19px; letter-spacing: .5px; }
header > span { display: flex; align-items: center; gap: 6px; }
header .icon { all: unset; position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--muted); cursor: pointer; }
header .icon:active { background: #f4f1ea14; }
header .icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#status { color: var(--pos); }
#status.pending { color: var(--neg); }
#status.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* تعداد موارد منتظر اینترنت، گوشه‌ی آیکون همگام‌سازی */
#status-count { position: absolute; top: 2px; inset-inline-end: 0; min-width: 16px; padding: 0 4px; border-radius: 999px; background: var(--neg); color: var(--ink); font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
#status-count:empty { display: none; }
#status:focus-visible, #logout:focus-visible, #pw-open:focus-visible, .del:focus-visible, button.link:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* --- چیدمان --- */
main, #login { max-width: 520px; margin: 0 auto; padding: 18px 16px calc(env(safe-area-inset-bottom) + 90px); }
/* minmax(0,1fr): ردیف افقیِ قرص‌ها نباید ستون را از عرض صفحه پهن‌تر کند */
form, section, .tags { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
h1 { font-size: 26px; font-weight: 600; color: var(--gold); text-align: center; }
h2 { font-size: 16px; font-weight: 600; margin-top: 12px; color: var(--gold); }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.row { display: flex; justify-content: space-between; align-items: center; }
button.link { all: unset; font-size: 13px; color: var(--gold); cursor: pointer; padding: 2px 0; }
.hint { font-size: 13px; color: var(--muted); }
.error { color: var(--neg); font-size: 14px; } .error:empty { display: none; }

/* --- صفحه‌ی ورود --- */
#login { padding-top: 14vh; gap: 16px; }
#login::before {
  content: ""; justify-self: center; width: 96px; height: 96px; border-radius: 22px;
  background: url(/icon.png) center / cover; box-shadow: 0 0 0 1px var(--gold-soft), 0 12px 40px #00000059;
}

/* --- فیلدها و دکمه‌ها --- */
/* 16px: آیفون روی فیلد کوچک‌تر زوم می‌کند */
input:not([type=radio]), select, #date-btn {
  font: inherit; font-size: 16px; color: var(--fg); text-align: start;
  background: #f4f1ea0a; border: 1px solid var(--gold-soft); border-radius: var(--radius);
  padding: 10px 12px; width: 100%; min-height: 46px;
}
input::placeholder { color: #a7b3ac99; }
input:focus, select:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px #c9a45c26; }
select { appearance: none; -webkit-appearance: none; padding-inline-end: 34px; /* فلش سمت چپ = انتهای خط در RTL */
  background: #f4f1ea0a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23c9a45c' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat left 12px center; }
select option { background: var(--surface); color: var(--fg); }
#date-btn { cursor: pointer; }
form > button {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--gold);
  border: 1px solid var(--gold); border-radius: 999px; min-height: 50px; cursor: pointer; margin-top: 4px;
}
form > button:active { filter: brightness(.92); }

/* نوع تراکنش: یک نوار تکه‌تکه (segmented) در یک ردیف */
.kinds { display: flex; gap: 2px; border: 1px solid var(--gold-soft); border-radius: 999px; padding: 3px; background: #0b231d; }
.kinds label { flex: 1; display: block; text-align: center; padding: 7px 0; border-radius: 999px; color: var(--muted); font-size: 14px; white-space: nowrap; cursor: pointer; }
/* label باید positioned باشد تا رادیوی پنهان از ردیف ورق‌خور بیرون نزند و صفحه را پهن نکند */
.kinds label, .chips label { position: relative; }
.kinds input, .chips input { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.kinds label:has(:checked) { background: var(--gold); color: var(--ink); font-weight: 600; }
.kinds label:has(:focus-visible), .chips label:has(:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }

/* --- فرم ثبت --- */
#tx-form { gap: 16px; }
/* فیلد اصلی: عدد درشت وسط، بدون کادر؛ واحد در خود برچسب است («مبلغ به تومان») */
.field.hero { justify-items: center; text-align: center; padding: 6px 0 2px; }
.field.hero > span:first-child { font-size: 13px; }
.field.hero input { font-size: 38px; font-weight: 700; text-align: center; border: 0; border-bottom: 1px solid var(--gold-soft); border-radius: 0; background: none; box-shadow: none; padding: 4px 0; min-height: 0; color: var(--gold); }
.field.hero input:focus { border-bottom-color: var(--gold); box-shadow: none; }
.field.hero input::placeholder { color: #c9a45c55; }
#rate-hint { text-align: center; } #rate-hint:empty { display: none; }

.card { display: grid; gap: 12px; background: linear-gradient(160deg, var(--raised), var(--surface)); border: 1px solid var(--gold-soft); border-radius: 12px; padding: 12px; }
.card select, .card input, .card #date-btn { background: #0e2a2399; }
#account-balance { font-size: 12px; color: var(--muted); } #account-balance:empty { display: none; }

/* دسته و علت: قرص‌ها در یک ردیف که افقی ورق می‌خورد */
.tags { display: grid; gap: 6px; }
.tags .row > span { font-size: 14px; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.chips label { flex: none; display: block; padding: 6px 14px; border: 1px solid var(--gold-soft); border-radius: 999px; color: var(--fg); font-size: 14px; white-space: nowrap; cursor: pointer; }
.chips label:has(:checked) { background: #c9a45c26; border-color: var(--gold); color: var(--gold); font-weight: 600; }

.details #date-btn { color: var(--gold); text-align: center; }

/* --- فهرست‌ها --- */
ul { list-style: none; padding: 0; }
li { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #c9a45c26; }
li > :first-child { flex: 1; min-width: 0; }
li strong { font-weight: 500; }
li small { display: block; color: var(--muted); font-size: 12px; }
li b { white-space: nowrap; font-size: 14px; font-weight: 600; }
.empty { color: var(--muted); justify-content: center; border: 0; }
.del { all: unset; width: 36px; height: 36px; flex: none; text-align: center; line-height: 36px; font-size: 18px; color: var(--muted); cursor: pointer; border-radius: 50%; }
.del:active { background: #f4f1ea14; }
.neg { color: var(--neg); } .pos { color: var(--pos); }
.reason { font-size: 11px; font-weight: 400; color: var(--gold); border: 1px solid var(--gold-soft); border-radius: 999px; padding: 0 8px; margin-inline-start: 6px; vertical-align: 1px; }

/* کارت‌ها: گزارش ماه و جمع موجودی */
#report, #total {
  background: linear-gradient(160deg, var(--raised), var(--surface));
  border: 1px solid var(--gold-soft); border-radius: 10px; padding: 12px 16px;
}
/* --- گزارش --- */
.month-nav { display: flex; justify-content: space-between; align-items: center; }
.month-nav strong { color: var(--gold); font-weight: 600; font-size: 18px; }
.month-nav button { display: grid; place-items: center; color: var(--gold); background: none; border: 0; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }
.month-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.month-nav button:disabled { opacity: .25; cursor: default; }
#rep-overview, #rep-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
#report { text-align: center; padding: 18px 16px 14px; }
#report .big-label, #total .big-label { font-size: 13px; color: var(--muted); }
#report .big, #txd .big, #total .big, #acc .big { font-size: 30px; font-weight: 700; color: var(--gold); line-height: 1.4; }
#report .coin-exp { font-size: 14px; color: var(--fg); }
#report .cmp { font-size: 13px; margin-top: 2px; }
#report .stats { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--gold-soft); }
#report .stats small { font-size: 13px; color: var(--muted); }
#report .stats b { font-weight: 600; white-space: nowrap; }

/* ردیف‌های تفکیک: نوار سهم پشت متن (--w) */
#breakdown li, .txl li { padding: 0; border: 0; }
#breakdown button { all: unset; box-sizing: border-box; position: relative; overflow: hidden; display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 12px 14px; margin-bottom: 6px; border: 1px solid var(--gold-soft); border-radius: 10px; cursor: pointer; }
#breakdown button::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--w); background: #c9a45c24; }
#breakdown button > * { position: relative; }
#breakdown span { flex: 1; min-width: 0; }
#breakdown b { font-weight: 600; font-size: 14px; white-space: nowrap; }
#breakdown small { color: var(--gold); font-size: 12px; min-width: 32px; text-align: end; }
#breakdown button:focus-visible, .txl button:focus-visible, .tile:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#crypto-line { text-align: center; } #crypto-line:empty { display: none; }
.ghost { font: inherit; color: var(--gold); background: none; border: 1px solid var(--gold-soft); border-radius: 999px; min-height: 46px; cursor: pointer; }

/* لایه‌ی ۲: فهرست تراکنش‌ها به تفکیک روز */
.rep-head {
  position: sticky; top: var(--hh, 0); z-index: 1; display: flex; align-items: center; gap: 12px;
  margin-inline: -16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--gold-soft);
}
.rep-head strong { color: var(--gold); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rep-back { display: flex; align-items: center; gap: 4px; flex: none; font: inherit; font-size: 14px; color: var(--ink); background: var(--gold); border: 0; border-radius: 999px; padding: 6px 12px 6px 14px; cursor: pointer; }
#rep-back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.txl .day { font-size: 12px; color: var(--gold); padding: 14px 0 4px; }
.txl button { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 0; border-bottom: 1px solid #c9a45c1f; cursor: pointer; }
.txl button > span { flex: 1; min-width: 0; }
.txl strong { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txl small { display: block; color: var(--muted); font-size: 12px; }

/* پنجره‌ی جزئیات تراکنش */
#txd h2 { text-align: center; color: var(--fg); }
#txd .big { text-align: center; margin-bottom: 10px; }
#txd-body p:not(.big) { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid #c9a45c1f; font-size: 14px; }
#txd-body p span:first-child { color: var(--muted); white-space: nowrap; }
#txd-body p span:last-child { text-align: end; }
.danger { font: inherit; width: 100%; min-height: 46px; margin-top: 16px; color: var(--neg); background: none; border: 1px solid #f0a19666; border-radius: 999px; cursor: pointer; }
#txd-close { font: inherit; color: var(--muted); background: none; border: 0; width: 100%; min-height: 44px; margin-top: 6px; cursor: pointer; }

/* --- حساب‌ها: کارت دارایی + کاشی‌ها --- */
#total { text-align: center; padding: 18px 16px 14px; }
#total .coins { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
#total .coins span { font-size: 13px; padding: 2px 10px; border: 1px solid var(--gold-soft); border-radius: 999px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tiles h2 { grid-column: 1 / -1; font-size: 13px; font-weight: 500; color: var(--muted); margin: 6px 0 -2px; }
.tile {
  all: unset; box-sizing: border-box; display: grid; align-content: start; gap: 4px; min-height: 112px; padding: 14px;
  background: linear-gradient(160deg, var(--raised), var(--surface)); border: 1px solid var(--gold-soft); border-radius: 14px; cursor: pointer;
}
.tile:active { filter: brightness(1.15); }
.tile .ico { width: 30px; height: 30px; margin-bottom: 6px; }
.tile .name { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile b { font-size: 16px; font-weight: 700; color: var(--fg); overflow-wrap: anywhere; }
.tile b.neg { color: var(--neg); }
.tile.add { place-content: center; justify-items: center; text-align: center; border-style: dashed; background: none; font-size: 28px; line-height: 1; color: var(--gold); }
.tile.add .name { color: var(--gold); }
.ico { fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* پنجره‌ی حساب */
#acc h2 { text-align: center; }
#acc-view { text-align: center; margin-bottom: 8px; }
#acc-view .big.neg { color: var(--neg); }
#acc-view h3 { font-size: 12px; font-weight: 500; color: var(--gold); text-align: start; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--gold-soft); }
#acc-tx { text-align: start; max-height: 32vh; overflow-y: auto; }
#acc { max-height: 90vh; overflow-y: auto; }
/* انتخاب آیکون: شش دکمه‌ی گرد */
.icons { display: flex; gap: 6px; justify-content: center; border: 0; padding: 0; }
.icons legend { font-size: 14px; color: var(--muted); margin-bottom: 6px; padding: 0; }
.icons label { position: relative; display: grid; place-items: center; flex: 1; min-width: 0; height: 42px; border: 1px solid var(--gold-soft); border-radius: 12px; cursor: pointer; }
.icons input { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.icons .ico { width: 24px; height: 24px; stroke: var(--muted); }
.icons label:has(:checked) { border-color: var(--gold); background: #c9a45c26; }
.icons label:has(:checked) .ico { stroke: var(--gold); }
.icons.banks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 4px; }
.icons.banks label { height: auto; padding: 6px 2px 4px; gap: 3px; }
.icons.banks small { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.icons.banks label:has(:checked) small { color: var(--gold); }
.ico.badge { display: grid; place-items: center; width: auto; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px; background: var(--b); color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; justify-self: start; }
.icons .ico.badge { width: auto; height: 26px; font-size: 11px; padding: 0 6px; opacity: .55; justify-self: center; }
.icons label:has(:checked) .ico.badge { opacity: 1; }
.ico.logo { object-fit: contain; }
.icons .ico.logo { width: 30px; height: 30px; opacity: .55; }
.icons label:has(:checked) .ico.logo { opacity: 1; }
.icons label:has(:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }

/* --- نوار پایین --- */
nav {
  position: fixed; inset: auto 0 0; z-index: 2; display: flex;
  background: #0b231de6; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--gold-soft); padding-bottom: env(safe-area-inset-bottom);
}
nav button { flex: 1; font: inherit; font-size: 14px; color: var(--muted); background: none; border: 0; min-height: 56px; cursor: pointer; position: relative; }
nav button[aria-current] { color: var(--gold); font-weight: 600; }
nav button[aria-current]::after { content: ""; position: absolute; top: -1px; inset-inline: 30%; height: 2px; background: var(--gold); border-radius: 2px; }

/* --- پنجره‌ها --- */
/* margin: auto — ریست سراسری بالا وسط‌چین پیش‌فرض dialog را صفر می‌کند */
dialog {
  margin: auto; width: min(360px, calc(100vw - 32px)); padding: 18px;
  border: 1px solid var(--gold-soft); border-radius: 14px;
  background: linear-gradient(170deg, var(--raised), var(--surface)); color: var(--fg);
  box-shadow: 0 24px 60px #00000080;
}
dialog::backdrop { background: #04100dbf; }
dialog h2 { margin-top: 0; }
#cat-list { max-height: 40vh; overflow-y: auto; margin-bottom: 12px; }
#pw-cancel, #cats-close, .close { font: inherit; color: var(--muted); background: none; border: 0; width: 100%; min-height: 44px; margin-top: 6px; cursor: pointer; }

/* تقویم */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-head strong { color: var(--gold); font-weight: 600; }
.cal-head button, #cal-grid button, #cal-today { font: inherit; color: var(--fg); background: none; border: 0; border-radius: 50%; min-height: 40px; cursor: pointer; }
.cal-head button { width: 44px; font-size: 22px; color: var(--gold); }
#cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
#cal-grid .wd { font-size: 12px; color: var(--muted); padding: 4px 0; }
#cal-grid .wd:last-of-type { color: var(--neg); }
#cal-grid button { aspect-ratio: 1; min-height: 0; }
#cal-grid .today { box-shadow: inset 0 0 0 1px var(--gold); }
#cal-grid [aria-pressed] { background: var(--gold); color: var(--ink); font-weight: 700; }
#cal-today { width: 100%; margin-top: 10px; color: var(--gold); border-radius: 999px; border: 1px solid var(--gold-soft); }

/* --- تنظیمات --- */
.avatar { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--gold); color: var(--ink); font-weight: 700; font-size: 18px; }
.card.me { display: flex; align-items: center; gap: 12px; }
.me strong, .user strong { display: block; font-weight: 600; }
.me small, .user small { display: block; font-size: 13px; color: var(--muted); direction: ltr; text-align: end; }
/* فهرست گزینه‌ها: هر ردیف یک دکمه با آیکون */
.menu { display: grid; border: 1px solid var(--gold-soft); border-radius: 12px; overflow: hidden; }
.menu button { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer; background: #f4f1ea05; }
.menu button + button { border-top: 1px solid var(--gold-soft); }
.menu button::after { content: "‹"; margin-inline-start: auto; color: var(--muted); font-size: 20px; line-height: 1; }
.menu button:active { background: #f4f1ea14; }
.menu button:focus-visible, .user:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.menu .ico { width: 22px; height: 22px; flex: none; }
.card.sync { justify-items: stretch; text-align: center; }
.card.sync p { font-size: 14px; color: var(--muted); white-space: pre-line; }
#users-section { display: grid; gap: 10px; }
#users-section h2 { margin-top: 6px; }
.users { display: grid; gap: 8px; }
.user { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--gold-soft); border-radius: 12px; background: linear-gradient(160deg, var(--raised), var(--surface)); cursor: pointer; }
.user > span:last-child { flex: 1; min-width: 0; }
.user i { font-style: normal; font-size: 11px; font-weight: 500; color: var(--gold); border: 1px solid var(--gold-soft); border-radius: 999px; padding: 0 8px; margin-inline-start: 4px; vertical-align: 2px; }
.user.add { border-style: dashed; background: none; }
.user.add .avatar { background: none; border: 1px dashed var(--gold); color: var(--gold); font-size: 22px; }
.user.add strong { color: var(--gold); }
#tab-settings > .danger { margin-top: 4px; }

/* ثبت‌کننده: دایره‌ی رنگی با حرف اول نام (رنگ از personColor در app.js) */
.who { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--c); color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1; }
.txl .who { flex: none; }
#breakdown .who { flex: none; align-self: center; width: 26px; height: 26px; font-size: 13px; }
