/* H.E.N.I. Finance — iPhone-first, Apple-like. Light and dark follow the phone. */
:root {
  --bg: #f2f2f7; --card: #ffffff; --card2: #f7f7fa; --text: #000; --text2: #3c3c4399; --text3: #3c3c434d; --sep: #3c3c432e;
  --blue: #007aff; --green: #34c759; --red: #ff3b30; --orange: #ff9500; --yellow: #ffcc00; --purple: #af52de; --teal: #30b0c7; --pink: #ff2d55; --indigo: #5856d6;
  --fill: #78788033; --fill2: #7878801f; --shadow: 0 1px 2px #0000000d, 0 8px 24px #0000000a;
  --bar: #f9f9f9d9; --r: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --card2: #2c2c2e; --text: #fff; --text2: #ebebf599; --text3: #ebebf54d; --sep: #54545899;
    --blue: #0a84ff; --green: #30d158; --red: #ff453a; --orange: #ff9f0a; --yellow: #ffd60a; --purple: #bf5af2; --teal: #40c8e0; --pink: #ff375f; --indigo: #5e5ce6;
    --fill: #7878805c; --fill2: #7878803d; --shadow: none; --bar: #161618d9; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif; letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
main { padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 96px); max-width: 640px; margin: 0 auto; }
.hidden { display: none !important; }

/* headers */
.top { display: flex; align-items: flex-end; justify-content: space-between; margin: 8px 0 14px; }
.top h1 { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: 0.01em; margin: 0; }
.top .sub { color: var(--text2); font-size: 15px; font-weight: 500; margin-bottom: 2px; }
.iconbtn { width: 36px; height: 36px; border-radius: 18px; background: var(--fill2); display: grid; place-items: center; color: var(--blue); }
.iconbtn svg { width: 20px; height: 20px; }
h2.sec { font-size: 22px; font-weight: 700; margin: 26px 2px 10px; display: flex; justify-content: space-between; align-items: baseline; }
h2.sec a, .link { color: var(--blue); font-size: 17px; font-weight: 400; text-decoration: none; }

/* cards */
.card { background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.stat .k { font-size: 13px; color: var(--text2); font-weight: 500; }
.stat .v { font-size: 20px; font-weight: 600; margin-top: 2px; }
.muted { color: var(--text2); }
.small { font-size: 13px; }
.caption { font-size: 12px; color: var(--text2); }

/* hero */
.hero { display: flex; align-items: center; gap: 18px; }
.hero .ring { flex: 0 0 132px; height: 132px; position: relative; }
.hero .ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hero .ring .c { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.hero .ring .c b { display: block; font-size: 24px; font-weight: 700; }
.hero .ring .c span { font-size: 12px; color: var(--text2); }
.hero .side { flex: 1; min-width: 0; }
.hero .big { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.hero .line { display: flex; justify-content: space-between; font-size: 15px; padding: 5px 0; border-bottom: 0.5px solid var(--sep); }
.hero .line:last-child { border: 0; }
.ring-bg { stroke: var(--fill2); }

/* segmented control */
.seg { display: flex; background: var(--fill2); border-radius: 9px; padding: 2px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 6px 0; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--text); transition: background .2s; }
.seg button.on { background: var(--card); box-shadow: 0 3px 8px #0000001f, 0 3px 1px #0000000a; }
@media (prefers-color-scheme: dark) { .seg button.on { background: #636366; } }

/* charts */
.chart { width: 100%; display: block; }
.chart text { fill: var(--text2); font-size: 10px; }
.chart .avg { stroke: var(--text3); stroke-dasharray: 3 3; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.chart-head b { font-size: 22px; font-weight: 700; }
.donut-wrap { display: flex; gap: 16px; align-items: center; }
.donut-wrap svg { flex: 0 0 120px; height: 120px; transform: rotate(-90deg); }
.legend { flex: 1; min-width: 0; display: grid; gap: 6px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* insights */
.chips-scroll { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 2px 16px 4px; scrollbar-width: none; }
.chips-scroll::-webkit-scrollbar { display: none; }
.insight { flex: 0 0 74%; scroll-snap-align: start; background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; text-align: left; }
.insight .e { font-size: 26px; }
.insight b { display: block; font-size: 15px; }
.insight span { font-size: 13px; color: var(--text2); }
.insight.bad { box-shadow: inset 0 0 0 1.5px var(--red); }
.insight.warn { box-shadow: inset 0 0 0 1.5px var(--orange); }
.insight.good { box-shadow: inset 0 0 0 1.5px var(--green); }

/* lists (inset grouped) */
.list { background: var(--card); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 52px; position: relative; width: 100%; text-align: left; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 62px; border-top: 0.5px solid var(--sep); }
.list.plain .row + .row::before { left: 16px; }
.row .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; flex: none; }
.row .mid { flex: 1; min-width: 0; }
.row .mid b { display: block; font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .mid span { display: block; font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-weight: 600; font-size: 16px; text-align: right; white-space: nowrap; }
.row .amt small { display: block; font-weight: 400; font-size: 12px; color: var(--text2); }
.amt.out { color: var(--text); }
.amt.in { color: var(--green); }
.amt.move { color: var(--text2); }
.chev { color: var(--text3); font-size: 20px; }
.day-head { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; margin: 20px 4px 6px; display: flex; justify-content: space-between; }
.empty { text-align: center; color: var(--text2); padding: 40px 20px; }
.empty .e { font-size: 44px; margin-bottom: 8px; }

/* pills / buttons */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 999px; background: var(--fill2); font-size: 14px; font-weight: 500; white-space: nowrap; }
.pill.on { background: var(--blue); color: #fff; }
.pill.ai { background: color-mix(in srgb, var(--purple) 16%, transparent); color: var(--purple); }
.pill.warn { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.pills { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px; }
.pills::-webkit-scrollbar { display: none; }
.btn { display: block; width: 100%; padding: 14px; border-radius: 14px; background: var(--blue); color: #fff; font-weight: 600; font-size: 17px; text-align: center; }
.btn.light { background: var(--fill2); color: var(--blue); }
.btn.green { background: var(--green); }
.btn.red { background: none; color: var(--red); }
.btn:disabled { opacity: .5; }
.btns { display: grid; gap: 10px; margin-top: 16px; }
.mini { padding: 6px 12px; border-radius: 999px; background: var(--blue); color: #fff; font-size: 14px; font-weight: 600; }
.mini.light { background: var(--fill2); color: var(--blue); }

/* progress */
.prog { height: 8px; border-radius: 4px; background: var(--fill2); overflow: hidden; margin-top: 8px; }
.prog i { display: block; height: 100%; border-radius: 4px; background: var(--green); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.prog i.warn { background: var(--orange); }
.prog i.bad { background: var(--red); }

/* tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; align-items: flex-start;
  padding: 7px 4px calc(env(safe-area-inset-bottom) + 4px); background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep); }
.tabs button { flex: 1; display: grid; justify-items: center; gap: 2px; font-size: 10px; font-weight: 500; color: #999; padding-top: 2px; }
.tabs button svg { width: 26px; height: 26px; }
.tabs button.on { color: var(--blue); }
.tabs .plus { flex: 0 0 64px; }
.tabs .plus span { width: 48px; height: 48px; border-radius: 24px; background: var(--blue); color: #fff; display: grid; place-items: center; margin-top: -14px;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--blue) 40%, transparent); }
.tabs .plus svg { width: 26px; height: 26px; }

/* sheets */
.scrim { position: fixed; inset: 0; z-index: 40; background: #0006; opacity: 0; transition: opacity .25s; }
.scrim.in { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 14px 14px 0 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px); transform: translateY(100%); transition: transform .32s cubic-bezier(.2, .9, .25, 1); max-width: 640px; margin: 0 auto; }
.sheet.in { transform: none; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--fill); margin: 0 auto 8px; }
.sheet .bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; min-height: 36px; }
.sheet .bar h3 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.sheet .bar button { color: var(--blue); font-size: 17px; min-width: 64px; text-align: left; }
.sheet .bar button.r { text-align: right; font-weight: 600; }
.action-list .row { font-size: 17px; }

/* forms */
.form { background: var(--card); border-radius: 12px; overflow: hidden; margin-bottom: 18px; }
.form label { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 46px; position: relative; }
.form label + label::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
.form label > span { flex: 0 0 auto; min-width: 92px; }
.form input, .form select, .form textarea { flex: 1; min-width: 0; border: 0; background: none; outline: none; text-align: right; padding: 12px 0; font-size: 17px; color: var(--text); }
.form textarea { text-align: left; resize: none; }
.form select { direction: rtl; appearance: none; -webkit-appearance: none; color: var(--text2); }
.form .toggle { justify-content: space-between; }
.form-note { font-size: 13px; color: var(--text2); margin: -12px 16px 18px; }
.amount-in { text-align: center; margin: 10px 0 18px; }
.amount-in input { width: 100%; border: 0; background: none; outline: none; text-align: center; font-size: 52px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.amount-in .cur { color: var(--text2); font-size: 15px; }
.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.cats button { display: grid; justify-items: center; gap: 4px; padding: 10px 2px; border-radius: 12px; background: var(--card); font-size: 11px; line-height: 1.15; color: var(--text2); }
.cats button .e { font-size: 24px; }
.cats button.on { background: var(--blue); color: #fff; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 16px; background: var(--fill); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px #00000026; transition: transform .2s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(20px); }
.receipt-img { width: 100%; border-radius: 12px; margin-bottom: 14px; max-height: 280px; object-fit: cover; }

/* lock */
.lock { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 20px) 24px calc(env(safe-area-inset-bottom) + 20px); }
.lock .logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 18px; }
.lock h1 { font-size: 22px; font-weight: 600; margin: 0 0 6px; text-align: center; }
.lock p { color: var(--text2); text-align: center; margin: 0 0 22px; font-size: 15px; max-width: 320px; }
.dots { display: flex; gap: 18px; margin-bottom: 40px; }
.dots i { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--text); transition: background .1s; }
.dots i.on { background: var(--text); }
.dots.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.pad { display: grid; grid-template-columns: repeat(3, 78px); gap: 16px 26px; }
.pad button { width: 78px; height: 78px; border-radius: 50%; background: var(--fill2); font-size: 34px; font-weight: 400; display: grid; place-items: center; line-height: 1; }
.pad button small { display: block; font-size: 10px; letter-spacing: 2px; font-weight: 600; margin-top: -4px; }
.pad button:active { background: var(--fill); }
.pad button.blank { background: none; }
.pad button.txt { background: none; font-size: 16px; }
.lock .alt { margin-top: 26px; color: var(--blue); font-size: 15px; }
.lock .field { width: 100%; max-width: 340px; }
.lock .field input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 0; background: var(--card); font-size: 17px; margin-bottom: 12px; outline: none; }
.lock .err { color: var(--red); font-size: 14px; min-height: 18px; margin: -26px 0 20px; text-align: center; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; padding-bottom: 80px; }
.bubble { max-width: 82%; padding: 9px 14px; border-radius: 19px; font-size: 16px; line-height: 1.35; white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 6px; }
.bubble.ai { align-self: flex-start; background: var(--card); border-bottom-left-radius: 6px; box-shadow: var(--shadow); }
.bubble.typing { color: var(--text2); }
.verdict { align-self: flex-start; display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 14px; font-size: 14px; font-weight: 600; }
.verdict.yes { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.verdict.stretch, .verdict.wait { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.verdict.no { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.composer { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 62px); z-index: 15; padding: 8px 12px; background: var(--bar);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); display: flex; gap: 8px; max-width: 640px; margin: 0 auto; }
.composer input { flex: 1; border: 0.5px solid var(--sep); border-radius: 20px; padding: 9px 14px; background: var(--card); outline: none; font-size: 16px; }
.composer button { width: 36px; height: 36px; border-radius: 18px; background: var(--blue); color: #fff; display: grid; place-items: center; }
.composer button svg { width: 18px; height: 18px; }
.prompts { display: grid; gap: 8px; margin-top: 12px; }
.prompts button { text-align: left; background: var(--card); padding: 12px 14px; border-radius: 14px; font-size: 15px; box-shadow: var(--shadow); }
.ai-hero { text-align: center; padding: 26px 0 10px; }
.ai-hero .orb { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px; background: conic-gradient(from 180deg, var(--blue), var(--purple), var(--pink), var(--orange), var(--blue));
  filter: saturate(1.2); animation: spin 8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-hero h1 { font-size: 22px; margin: 0; }

/* toast */
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 10px); transform: translateX(-50%); z-index: 80; background: var(--card); color: var(--text);
  padding: 10px 18px; border-radius: 22px; box-shadow: 0 8px 30px #00000033; font-size: 15px; font-weight: 500; max-width: 90vw; animation: drop .3s; }
@keyframes drop { from { transform: translate(-50%, -30px); opacity: 0; } }

/* motion */
.fade { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
