/* ============ Jarvis Finance — design system ============ */
:root {
    --bg: #070a0f;
    /* Liquid-glass translucent surfaces */
    --surface: rgba(255, 255, 255, 0.055);
    --surface-2: rgba(255, 255, 255, 0.09);
    --elev: rgba(255, 255, 255, 0.14);
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --blur: blur(24px) saturate(180%);
    --sheen: inset 0 1px 0 rgba(255, 255, 255, 0.16);

    --text: #f0f4f9;
    --text-2: #b6c0cc;
    --muted: #7c8696;

    --accent: #5b9bff;
    --accent-2: #8b7bff;
    --grad: linear-gradient(135deg, #4f8cff 0%, #8b6cff 100%);

    --green: #45dd92;
    --red: #ff7a7a;
    --amber: #ffc24d;

    --r-sm: 14px;
    --r-md: 18px;
    --r-lg: 24px;
    --shadow: 0 10px 34px rgba(0, 0, 0, 0.40);

    --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
    font-family: -apple-system, system-ui, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    /* App shell: fixed header + scrollable content + fixed footer, no overlap. */
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Colorful blurred backdrop the glass refracts */
body::before {
    content: ""; position: fixed; inset: 0; z-index: -1;
    background:
        radial-gradient(42% 32% at 12% 8%, rgba(91, 155, 255, 0.34), transparent 70%),
        radial-gradient(46% 38% at 88% 12%, rgba(139, 123, 255, 0.30), transparent 70%),
        radial-gradient(52% 44% at 82% 92%, rgba(69, 221, 146, 0.18), transparent 72%),
        radial-gradient(48% 44% at 8% 96%, rgba(255, 122, 122, 0.16), transparent 72%);
}

/* ---------- Top bar ---------- */
.topbar {
    flex: none; z-index: 20;
    background: rgba(10, 14, 20, 0.45);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    padding: 14px 20px 12px;
    border-bottom: 1px solid var(--border);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.brand { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.icon-btn {
    width: 38px; height: 38px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--surface); color: var(--text-2);
    border: 1px solid var(--border-strong); cursor: pointer;
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--sheen);
    transition: transform .12s ease, background .15s ease, color .15s ease;
}
.icon-btn:active { transform: scale(0.92); background: var(--elev); color: var(--text); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Segmented control ---------- */
.segment {
    display: flex; gap: 2px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 13px; padding: 3px;
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--sheen);
}
.segment button {
    flex: 1; border: 0; background: transparent; color: var(--text-2);
    font-size: 14px; font-weight: 600; padding: 8px 4px; border-radius: 10px;
    cursor: pointer; transition: color .15s ease, background .15s ease;
}
.segment button.active { background: var(--elev); color: #fff; box-shadow: var(--sheen), 0 2px 8px rgba(0,0,0,.25); }

/* ---------- Content (the scroll area) ---------- */
#content {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 18px 16px 28px;
    display: flex; flex-direction: column; gap: 14px;
    animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 6px 2px 2px; }

/* ---------- Hero balance ---------- */
.hero {
    position: relative; overflow: hidden;
    border-radius: var(--r-lg); padding: 22px 20px;
    background: var(--grad); color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: var(--sheen), var(--shadow);
}
.hero::after {
    content: ""; position: absolute; right: -40px; top: -60px;
    width: 200px; height: 200px; border-radius: 50%;
    background: rgba(255,255,255,.14); filter: blur(8px);
}
.hero .label { font-size: 13px; opacity: .85; font-weight: 500; }
.hero .net { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; margin: 4px 0 16px; line-height: 1.05; }
.hero .legs { display: flex; gap: 10px; position: relative; z-index: 1; }
.leg { flex: 1; background: rgba(255,255,255,.16); border-radius: var(--r-sm); padding: 10px 12px; backdrop-filter: blur(4px); }
.leg .leg-l { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 5px; }
.leg .leg-v { font-size: 17px; font-weight: 700; margin-top: 2px; }
.hero .xfer-note { margin-top: 12px; font-size: 12.5px; opacity: .9; position: relative; z-index: 1; }

/* ---------- Cards / blocks ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 16px;
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--sheen), 0 8px 30px rgba(0, 0, 0, 0.22);
}
.card.tight { padding: 4px 16px; }

.row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.row + .row { border-top: 1px solid var(--border); }
.row .lead { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row .txt { min-width: 0; }
.row .title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.amount { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.exp { color: var(--red); }
.amount.inc { color: var(--green); }

/* category dot + icon chip */
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chip {
    width: 38px; height: 38px; border-radius: 12px; flex: none;
    display: grid; place-items: center; font-size: 17px;
    background: var(--surface-2); border: 1px solid var(--border);
    box-shadow: var(--sheen);
}
.tag { font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 3px 8px; border-radius: 7px; }

/* category progress */
.cat { padding: 11px 0; }
.cat + .cat { border-top: 1px solid var(--border); }
.cat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cat-name { display: flex; align-items: center; gap: 9px; font-size: 14.5px; font-weight: 600; min-width: 0; }
.cat-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track { height: 7px; border-radius: 4px; background: rgba(255,255,255,.06); overflow: hidden; margin-top: 8px; }
.track > i { display: block; height: 100%; border-radius: 4px; transition: width .5s cubic-bezier(.2,.7,.2,1); }

/* ---------- Bank-card tile ---------- */
.bankcard {
    border-radius: var(--r-md); padding: 18px; color: #fff;
    background: linear-gradient(135deg, rgba(91,155,255,.45), rgba(40,52,80,.55));
    border: 1px solid rgba(255,255,255,.20); position: relative; overflow: hidden;
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--sheen), 0 8px 30px rgba(0,0,0,.25);
}
.bankcard.alt { background: linear-gradient(135deg, rgba(139,123,255,.45), rgba(52,40,80,.55)); }
.bankcard .bc-top { display: flex; justify-content: space-between; align-items: center; }
.bankcard .bc-name { font-weight: 600; font-size: 15px; }
.bankcard .bc-num { font-variant-numeric: tabular-nums; letter-spacing: .12em; opacity: .8; font-size: 13px; margin-top: 14px; }
.bankcard .bc-bal { font-size: 22px; font-weight: 800; margin-top: 4px; letter-spacing: -0.02em; }
.bankcard .bc-legs { display: flex; gap: 16px; margin-top: 12px; font-size: 12.5px; }
.bankcard .bc-legs b { display: block; font-size: 14px; font-weight: 700; margin-top: 1px; }

/* ---------- Budgets ---------- */
.bud { padding: 14px 0; }
.bud + .bud { border-top: 1px solid var(--border); }
.bud-top { display: flex; justify-content: space-between; align-items: baseline; }
.bud-name { font-size: 15px; font-weight: 600; }
.bud-pct { font-size: 13px; font-weight: 700; }
.bud-sub { font-size: 12.5px; color: var(--muted); margin: 2px 0 8px; }

/* ---------- Buttons ---------- */
.btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; border: 0; border-radius: var(--r-sm);
    padding: 15px; font-size: 15.5px; font-weight: 700; cursor: pointer;
    transition: transform .12s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(79,140,255,.3); }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--sheen); }
.btn.danger-ghost { background: transparent; color: var(--red); border: 1px solid rgba(255,107,107,.4); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.field input, .field select {
    width: 100%; background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: 12px; padding: 13px 14px;
    font-size: 16px; outline: none;
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    transition: border-color .15s ease;
}
.field input:focus, .field select:focus { border-color: var(--accent); }

/* ---------- AI insight card ---------- */
.ai-card { border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 16px; background: var(--surface); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--sheen); white-space: pre-wrap; line-height: 1.6; font-size: 14.5px; color: var(--text-2); }
.ai-card b { color: var(--text); }

/* ---------- Skeleton ---------- */
.sk { background: linear-gradient(100deg, var(--surface) 30%, var(--elev) 50%, var(--surface) 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-md); }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-hero { height: 168px; border-radius: var(--r-lg); }
.sk-row { height: 56px; margin-top: 10px; }

/* ---------- States ---------- */
.empty, .error { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 14.5px; }
.error { color: var(--red); }
.spinner { width: 22px; height: 22px; border: 2.5px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }

/* ---------- Tappable rows & detail ---------- */
.row.tappable { cursor: pointer; transition: background .12s ease; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.row.tappable:active { background: var(--surface-2); }
.row.tappable::after { content: "›"; color: var(--muted); font-size: 20px; margin-left: 8px; }

.chip.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 30px; margin: 0 auto; }
.tx-head { text-align: center; padding: 18px 0 6px; }
.tx-amount { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin-top: 14px; }
.tx-merchant { font-size: 16px; font-weight: 600; margin-top: 6px; }
.tx-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip {
    border: 1px solid var(--border-strong); background: var(--surface);
    color: var(--text); border-radius: 999px; padding: 10px 14px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--sheen);
    transition: transform .1s ease, background .15s ease;
}
.cat-chip:active { transform: scale(0.95); background: var(--elev); }

/* ---------- Tab bar ---------- */
/* Floating liquid-glass tab bar (Telegram-style) */
.tabbar {
    flex: none; z-index: 30;
    margin: 6px 12px calc(10px + var(--safe-b));
    border-radius: 24px;
    display: flex; gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(30px) saturate(190%);
    -webkit-backdrop-filter: blur(30px) saturate(190%);
    border: 1px solid var(--border-strong);
    box-shadow: var(--sheen), 0 12px 36px rgba(0, 0, 0, 0.45);
    padding: 7px;
}
.tab {
    flex: 1; border: 0; background: transparent; color: var(--muted);
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 9px 0; font-size: 11px; font-weight: 600; cursor: pointer;
    border-radius: 17px;
    transition: color .18s ease, background .18s ease;
}
.tab svg { width: 23px; height: 23px; transition: transform .15s ease; }
.tab.is-active {
    color: var(--accent);
    background: rgba(91, 155, 255, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.tab.is-active svg { transform: translateY(-1px); }
.tab:active svg { transform: scale(0.9); }
