/* Hesabdar web app: iOS look. Tokens first, then layout, then components. Logical properties keep RTL and LTR right. */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --label: #000000;
  --label2: rgba(60, 60, 67, 0.6);
  --label3: rgba(60, 60, 67, 0.3);
  --fill: rgba(120, 120, 128, 0.12);
  --fill2: rgba(120, 120, 128, 0.2);
  --sep: rgba(60, 60, 67, 0.18);
  --tint: #007aff;
  --deposit: #2a78d6;
  --withdrawal: #e34948;
  --transfer: #898781;
  --good: #0ca30c;
  --warn: #fab219;
  --crit: #d03b3b;
  --glass: rgba(250, 250, 252, 0.72);
  --glass-border: rgba(255, 255, 255, 0.6);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  --sheet-bg: #f2f2f7;
  --card-in-sheet: #ffffff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --label: #ffffff;
    --label2: rgba(235, 235, 245, 0.6);
    --label3: rgba(235, 235, 245, 0.3);
    --fill: rgba(120, 120, 128, 0.24);
    --fill2: rgba(120, 120, 128, 0.36);
    --sep: rgba(84, 84, 88, 0.6);
    --tint: #0a84ff;
    --deposit: #3987e5;
    --withdrawal: #e66767;
    --glass: rgba(40, 40, 44, 0.7);
    --glass-border: rgba(255, 255, 255, 0.12);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    --sheet-bg: #1c1c1e;
    --card-in-sheet: #2c2c2e;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--label);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
body { position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
body, button, .nosel { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, .selectable { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.i { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.125em; flex: none; }
svg.i.fill { fill: currentColor; stroke: none; }
.flip.back { transform: scaleX(-1); }
[dir="rtl"] .flip { transform: scaleX(-1); }
[dir="rtl"] .flip.back { transform: none; }

/* ---------- Screens ---------- */
#app { position: absolute; inset: 0; }
.tabs-root { position: absolute; inset: 0; }
.screen {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 66px) 16px calc(var(--safe-bottom) + 112px); background: var(--bg);
  overscroll-behavior-y: contain;
}
.screen[hidden] { display: none; }
.screen { scrollbar-width: none; }
.screen::-webkit-scrollbar, .sheet-body::-webkit-scrollbar { display: none; }
.screen-title { margin: 0 0 14px; font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: 0.2px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.topbar {
  position: fixed; z-index: 20; inset-inline: 0; top: 0; height: calc(var(--safe-top) + 50px); padding: calc(var(--safe-top) + 4px) 16px 0;
  display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar .inline-title {
  position: absolute; inset-inline: 0; top: calc(var(--safe-top) + 12px); text-align: center; font-weight: 600; font-size: 17px; opacity: 0; transition: opacity .15s; pointer-events: none;
}
.topbar.scrolled { background: linear-gradient(var(--bg) 55%, transparent); }
.topbar.scrolled .inline-title { opacity: 1; }
.glass-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; color: var(--label);
  background: var(--glass); border: 0.5px solid var(--glass-border); box-shadow: 0 2px 10px rgba(0,0,0,.1);
  -webkit-backdrop-filter: blur(20px) saturate(1.8); backdrop-filter: blur(20px) saturate(1.8);
}
.glass-btn.text { width: auto; padding: 0 16px; border-radius: 22px; font-size: 17px; }
.glass-btn:active { transform: scale(.94); }
.ptr { position: fixed; z-index: 15; inset-inline: 0; top: calc(var(--safe-top) + 50px); text-align: center; color: var(--label2); font-size: 13px; pointer-events: none; opacity: 0; transition: opacity .15s; }

/* ---------- Tab bar (floating, glass) ---------- */
.tabbar {
  position: fixed; z-index: 30; inset-inline: 16px; bottom: calc(var(--safe-bottom) + 10px); height: 64px; max-width: 520px; margin-inline: auto;
  display: flex; padding: 5px; border-radius: 32px; background: var(--glass); border: 0.5px solid var(--glass-border); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 27px; font-size: 10.5px; font-weight: 500; color: var(--label); transition: background .15s; }
.tab svg.i { font-size: 23px; }
.tab.active { color: var(--tint); background: var(--fill); }

/* ---------- Cards and text ---------- */
.card { background: var(--card); border-radius: 18px; padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.sec { color: var(--label2); }
.sub { font-size: 15px; color: var(--label2); }
.foot { font-size: 12px; color: var(--label2); }
.caption2 { font-size: 11px; color: var(--label2); }
.headline { font-size: 17px; font-weight: 600; }
.title2 { font-size: 22px; font-weight: 600; }
.title3 { font-size: 20px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; unicode-bidi: plaintext; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
hr, .divider { border: 0; height: 0.5px; background: var(--sep); margin: 0; }
.pad { padding: 16px; }
a { color: var(--tint); text-decoration: none; }
.link { color: var(--tint); font-size: 15px; }

.hero-num { font-size: 48px; font-weight: 600; line-height: 1.1; white-space: nowrap; }
.big-num { font-size: 34px; font-weight: 600; line-height: 1.15; }
.val { font-size: 22px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.unit { font-size: 12px; color: var(--label2); }
.base { display: flex; align-items: baseline; gap: 6px; }
.dep { color: var(--deposit); }
.wd { color: var(--withdrawal); }
.stat .lab { display: flex; align-items: center; gap: 4px; font-size: 15px; color: var(--label2); }
.stat .lab svg { font-size: 12px; stroke-width: 3; }

/* ---------- Buttons ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 20px; border-radius: 25px; font-weight: 600; font-size: 17px; width: 100%; }
.btn.prominent { background: var(--tint); color: #fff; }
.btn.bordered { background: var(--fill); color: var(--tint); }
.btn.small { min-height: 36px; width: auto; padding: 0 14px; font-size: 15px; }
.btn.destructive { color: var(--crit); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.btn:active { opacity: .7; }

/* ---------- Budget meter, chips, segmented ---------- */
.meter-bar { height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--meter) 20%, transparent); overflow: hidden; }
.meter-bar > i { display: block; height: 100%; border-radius: 4px; background: var(--meter); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px; margin: 0 -16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 20px; background: var(--card); font-size: 15px; white-space: nowrap; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }
.chip.on { background: var(--tint); color: #fff; font-weight: 600; }
.seg { display: flex; padding: 2px; border-radius: 9px; background: var(--fill); }
.seg button { flex: 1; text-align: center; padding: 6px 4px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.15); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg button.on { background: #636366; } }

/* ---------- Transaction rows ---------- */
.tx { display: flex; align-items: center; gap: 12px; padding: 8px 0; width: 100%; }
.tx .ic { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 15px; }
.tx .ic svg { stroke-width: 3; }
.tx .t1 { font-size: 17px; }
.tx .t2 { font-size: 12px; color: var(--label2); }
.tx .amt { font-size: 15px; font-weight: 600; white-space: nowrap; }
.tx-sep { height: 0.5px; background: var(--sep); margin-inline-start: 50px; }

/* ---------- Grouped lists (Form) ---------- */
.group-h { padding: 0 16px 6px; font-size: 13px; color: var(--label2); text-transform: uppercase; letter-spacing: .2px; }
.group-f { padding: 6px 16px 0; font-size: 13px; color: var(--label2); }
.group { background: var(--card); border-radius: 18px; overflow: hidden; }
.group + .group-f, .gwrap { margin-bottom: 0; }
.gwrap { margin-bottom: 24px; }
.li { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 16px; width: 100%; position: relative; }
.li + .li::before { content: ""; position: absolute; inset-inline: 16px 0; top: 0; height: 0.5px; background: var(--sep); }
.li .v { margin-inline-start: auto; color: var(--label2); text-align: end; }
.li.tap:active { background: var(--fill); }
.li .chev { color: var(--label3); font-size: 13px; stroke-width: 3; margin-inline-start: 4px; }
.li input[type=text], .li input[type=search], .li input:not([type]), .li select { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 17px; padding: 0; text-align: start; }
.li input.right { text-align: end; }
.li select { text-align-last: end; appearance: none; -webkit-appearance: none; color: var(--label2); }
.li.blue { color: var(--tint); }
.li.red { color: var(--crit); }
.amount-input { font-size: 28px !important; font-weight: 600; }
.switch { position: relative; width: 51px; height: 31px; border-radius: 16px; background: var(--fill2); flex: none; transition: background .2s; margin-inline-start: auto; }
.switch::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.3); transition: transform .2s; }
.switch.on { background: #34c759; }
.switch.on::after { transform: translateX(20px); }
[dir="rtl"] .switch.on::after { transform: translateX(-20px); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; padding: 12px 16px; }
.cat-chip { padding: 9px 4px; border-radius: 20px; background: var(--fill); text-align: center; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-chip.on { background: var(--tint); color: #fff; }
.date-grid { display: grid; grid-template-columns: 1.2fr 1.6fr 1fr 1fr; gap: 6px; flex: 1; }
.date-grid select { background: var(--fill); border-radius: 8px; padding: 8px 6px; text-align: center; text-align-last: center; color: var(--label); font-size: 15px; }

/* ---------- Sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.35); opacity: 0; transition: opacity .25s; }
.scrim.on { opacity: 1; }
.sheet {
  position: fixed; z-index: 51; inset-inline: 0; bottom: 0; top: calc(var(--safe-top) + 8px); background: var(--sheet-bg); border-radius: 38px 38px 0 0;
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; overflow: hidden; max-width: 700px; margin-inline: auto;
}
.sheet.on { transform: translateY(0); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; min-height: 64px; position: relative; flex: none; }
.sheet-head .ttl { position: absolute; inset-inline: 80px; text-align: center; font-weight: 600; font-size: 17px; pointer-events: none; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px calc(var(--safe-bottom) + 28px); overscroll-behavior: contain; }
.sheet-body .big-title { font-size: 34px; font-weight: 700; margin: 4px 0 14px; }
.sheet.pad-bottom .sheet-body { padding-bottom: calc(var(--safe-bottom) + 90px); }

/* ---------- Alert ---------- */
.alert-scrim { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.32); display: grid; place-items: center; padding: 24px; opacity: 0; transition: opacity .15s; }
.alert-scrim.on { opacity: 1; }
.alert { width: min(100%, 320px); background: var(--glass); -webkit-backdrop-filter: blur(30px) saturate(1.8); backdrop-filter: blur(30px) saturate(1.8); border: .5px solid var(--glass-border); border-radius: 28px; padding: 22px 18px 16px; text-align: center; box-shadow: var(--shadow); }
@media (prefers-color-scheme: light) { .alert { background: rgba(245,245,248,.92); } }
.alert h3 { margin: 0 0 6px; font-size: 17px; }
.alert p { margin: 0 0 16px; font-size: 13px; color: var(--label2); white-space: pre-line; }
.alert .acts { display: flex; gap: 8px; }
.alert .acts button { flex: 1; padding: 13px 8px; border-radius: 22px; background: var(--fill); font-size: 17px; font-weight: 500; text-align: center; }
.alert .acts button.destructive { color: var(--crit); font-weight: 600; }
.alert .acts button.primary { color: var(--tint); font-weight: 600; }
.alert input { width: 100%; margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; border: 0; background: var(--fill); font-size: 17px; text-align: start; }

/* ---------- Menus ---------- */
.menu-scrim { position: fixed; inset: 0; z-index: 70; }
.menu { position: fixed; z-index: 71; min-width: 240px; background: var(--glass); -webkit-backdrop-filter: blur(30px) saturate(1.8); backdrop-filter: blur(30px) saturate(1.8); border: .5px solid var(--glass-border); border-radius: 22px; box-shadow: var(--shadow); padding: 6px; }
@media (prefers-color-scheme: light) { .menu { background: rgba(248,248,250,.92); } }
.menu button { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%; padding: 12px 14px; border-radius: 14px; font-size: 17px; }
.menu button:active { background: var(--fill); }

/* ---------- Toast, banner ---------- */
.toast { position: fixed; z-index: 90; inset-inline: 16px; top: calc(var(--safe-top) + 8px); margin-inline: auto; max-width: 420px; padding: 12px 16px; border-radius: 22px; background: var(--glass); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); border: .5px solid var(--glass-border); box-shadow: var(--shadow); font-size: 15px; transform: translateY(-140%); transition: transform .3s; }
.toast.on { transform: translateY(0); }
@media (prefers-color-scheme: light) { .toast { background: rgba(248,248,250,.94); } }
.banner { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.banner svg { color: var(--warn); font-size: 18px; margin-top: 1px; }

/* ---------- Lock ---------- */
.lock { position: fixed; z-index: 100; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.lock svg { font-size: 44px; color: var(--label2); }

/* ---------- Charts ---------- */
.chart { position: relative; height: 190px; direction: ltr; margin-top: 4px; }
.chart .grid { position: absolute; inset: 0 0 20px 0; }
.chart .gl { position: absolute; inset-inline: 0; border-top: .5px solid var(--sep); }
.chart .gl span { position: absolute; top: -8px; left: 0; font-size: 10px; color: var(--label2); background: var(--card); padding-right: 4px; }
.chart .bars { position: absolute; inset: 0 0 20px 38px; display: flex; align-items: flex-end; gap: 2px; }
.chart .bar { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; cursor: pointer; }
.chart .bar i { display: block; width: 72%; min-height: 0; border-radius: 3px 3px 0 0; background: var(--withdrawal); opacity: .38; transition: opacity .1s; }
.chart .bar.on i { opacity: 1; }
.chart .xl { position: absolute; inset-inline: 38px 0; bottom: 0; height: 18px; display: flex; }
.chart .xl span { flex: 1; text-align: center; font-size: 10px; color: var(--label2); }
.cat-bar { height: 6px; border-radius: 3px; background: var(--withdrawal); }
.cat-bar.none { background: var(--transfer); }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 40px 24px; color: var(--label2); }
.empty svg { font-size: 44px; margin-bottom: 8px; stroke-width: 1.5; }
.empty .t { font-size: 20px; font-weight: 600; color: var(--label); margin-bottom: 6px; }
.month-switch { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.month-switch button { width: 44px; height: 44px; display: grid; place-items: center; font-size: 18px; }
.month-switch button:disabled { opacity: .3; }
/* Visual guide: a screenshot (690x1500) sized to fit the screen, with a pulsing ring and an arrow on the spot to tap.
   Ring and arrow are placed in % of the picture, so they stay on target at any size. Never mirrored: the shots are English. */
.guide-page { display: flex; flex-direction: column; gap: 12px; }
.guide-head { display: flex; flex-direction: column; gap: 3px; text-align: center; padding: 0 8px; }
.guide-mono { text-align: center; font-size: 17px; font-weight: 600; white-space: pre-wrap; align-self: center; padding: 8px 18px; }
.guide-shot { position: relative; direction: ltr; align-self: center; width: min(100%, max(210px, calc((100dvh - var(--safe-top) - var(--safe-bottom) - 400px) * .46)));
  aspect-ratio: 690 / 1500; border-radius: 22px; overflow: hidden; border: 1px solid var(--sep); background: var(--fill); flex: none; }
.guide-shot { cursor: zoom-in; transition: width .25s; }
.guide-shot.big { width: 100%; cursor: zoom-out; }
.guide-shot img { display: block; width: 100%; height: 100%; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.gs-ring { position: absolute; width: 13%; aspect-ratio: 1; border: 3px solid var(--withdrawal); border-radius: 50%; transform: translate(-50%, -50%);
  animation: gs-pulse .9s ease-in-out infinite alternate; pointer-events: none; }
.gs-arrow { position: absolute; width: 13%; transform: translate(-50%, -50%); filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .3)); pointer-events: none; }
.gs-arrow svg { display: block; width: 100%; height: auto; fill: var(--withdrawal); stroke: #fff; stroke-width: 1.6; stroke-linejoin: round; paint-order: stroke; }
.gs-arrow.up svg { transform: rotate(180deg); }
@keyframes gs-pulse { to { transform: translate(-50%, -50%) scale(1.25); opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .gs-ring { animation: none; } }
.pill-note { background: var(--fill); border-radius: 14px; padding: 10px 12px; font-size: 13px; }
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: 13px; direction: ltr; unicode-bidi: plaintext; word-break: break-all; }
.copybox { background: var(--fill); border-radius: 12px; padding: 10px 12px; }
.progress { height: 4px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--tint); transition: width .25s; }
.dots { display: flex; justify-content: center; gap: 6px; }
.install-hint { position: fixed; z-index: 40; inset-inline: 16px; bottom: calc(var(--safe-bottom) + 86px); }
@media (min-width: 700px) {
  .screen { padding-inline: calc(50% - 340px); }
  .topbar { padding-inline: calc(50% - 340px); }
}

/* ---------- Swipe actions ---------- */
.swipe { position: relative; overflow: hidden; }
.swipe-face { position: relative; background: var(--card); will-change: transform; }
.swipe-bar { position: absolute; top: 0; bottom: 0; display: flex; }
.swipe-bar.start { inset-inline-start: 0; }
.swipe-bar.end { inset-inline-end: 0; }
.swipe-act { width: 84px; color: #fff; display: grid; place-items: center; text-align: center; padding: 0 4px; line-height: 1.2; }
.swipe-act svg { font-size: 20px; }
.li > .seg { flex: 1; }
.li > .seg button { padding: 7px 4px; }
.sheet .group, .sheet .card { background: var(--card-in-sheet); }
.sheet .cat-chip, .sheet .date-grid select, .sheet .seg { background: var(--fill); }
.date-grid { grid-template-columns: .8fr 1.5fr 1.1fr 1.5fr !important; }
.date-grid input[type=time] { font-size: 14px !important; padding: 7px 2px !important; }
