/* Coco Budget — light dashboard look: soft grey page, white cards, colored icon squares. Mobile-first. */
:root {
  --bg: #eef0f5;
  --surface: #ffffff;
  --surface-2: #f4f5f9;
  --side: #f8f9fc;
  --text: #1c2033;
  --muted: #8b90a3;
  --line: #e7e9f0;
  --accent: #1a7cff;
  --accent-soft: #e8f1ff;
  --accent-ink: #ffffff;
  --pos: #1fb37a;
  --neg: #f2545b;
  --warn: #f08a24;
  --info: #1a7cff;
  --save: #1a7cff;
  --ghost: #e9ecf3;      /* pale bars behind */
  --ring: #ff8a5b;       /* "Spent" ring */
  /* Icon-square colors per kind of money */
  --k-bills: #7b5cff;
  --k-pet: #ff8a5b;
  --k-parents: #ffb020;
  --k-loans: #f2545b;
  --k-misc: #1fb37a;
  --k-card: #1a7cff;
  --k-income: #1fb37a;
  --k-spent: #f2545b;
  --k-saving: #1a7cff;
  --k-office: #8b5cf6;
  --k-wallet: #ff8a5b;
  --k-settle: #14b8a6;
  --k-bank: #1a7cff;
  --k-ewallet: #7b5cff;
  --k-cash: #1fb37a;
  /* Chart series (Insights) and category colors */
  --c1: #1fb37a; --c2: #1a7cff; --c3: #7b5cff; --c4: #ff8a5b; --c5: #ffb020; --c6: #8b90a3;
  --g-bills: #7b5cff; --g-pet: #ff8a5b; --g-parents: #ffb020; --g-loans: #f2545b; --g-misc: #1fb37a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 32, 51, .04), 0 8px 24px rgba(28, 32, 51, .05);
  --tabbar-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --surface: #171a2b;
    --surface-2: #1f2337;
    --side: #141729;
    --text: #eceef6;
    --muted: #8b90a8;
    --line: #262a40;
    --accent: #4d9bff;
    --accent-soft: #1b2a47;
    --accent-ink: #ffffff;
    --pos: #3ccf92;
    --neg: #ff6b72;
    --warn: #ffa24c;
    --info: #4d9bff;
    --save: #4d9bff;
    --ghost: #262b42;
    --k-card: #4d9bff; --k-saving: #4d9bff; --k-income: #3ccf92; --k-misc: #3ccf92; --k-spent: #ff6b72; --k-loans: #ff6b72;
    --c1: #3ccf92; --c2: #4d9bff;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Jost", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; font-weight: 500; }
h1 { font-size: 1.45rem; margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; margin: 0 0 .7rem; font-weight: 600; }
h3 { font-size: .8rem; margin: 1rem 0 .5rem; color: var(--muted); font-weight: 500; }
p { margin: .4rem 0; }
code { background: var(--surface-2); padding: .1em .45em; border-radius: 6px; }
small { font-size: .78rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.center { text-align: center; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.save { color: var(--save); }

/* Colored icon squares */
.ico {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px;
  background: var(--ico, var(--k-misc)); color: #fff;
}
.ico svg { width: 21px; height: 21px; }
.ico.lg { width: 48px; height: 48px; border-radius: 12px; }
.ico.lg svg { width: 25px; height: 25px; }
.ico.sm { width: 24px; height: 24px; border-radius: 7px; margin-right: .5rem; }
.ico.sm svg { width: 14px; height: 14px; }
.ico.ghost { background: none; border: 1.5px dashed var(--line); color: var(--muted); }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #7b5cff, #1a7cff); color: #fff; font-weight: 600; font-size: .85rem;
}

/* ── Layout ── */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  display: flex; align-items: center; gap: 2rem;
  padding: .85rem max(20px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 600; font-size: 1.2rem; color: var(--text); white-space: nowrap; }
.brand img { width: 36px; height: 36px; margin-block: -6px; }
.nav { display: flex; gap: 1.6rem; flex: 1; }
.nav a { padding: .3rem 0; color: var(--muted); font-weight: 400; }
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); font-weight: 600; }
.top-right { display: flex; align-items: center; gap: .9rem; }
.view { max-width: 1240px; margin: 0 auto; padding: .5rem 20px 3rem; }

.tabbar { display: none; }
.gear { display: none; }
@media (max-width: 760px) {
  .nav, .add-top, .top-right .avatar { display: none; }
  .topbar { justify-content: center; padding-block: .7rem; }
  .view { padding-inline: 16px; }
  .gear {
    display: grid; place-items: center; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px; border-radius: 10px; background: var(--surface); color: var(--muted); box-shadow: var(--shadow);
  }
  .gear svg { width: 19px; height: 19px; }
  .gear.active { color: var(--accent); }
  .view { padding-bottom: calc(var(--tabbar-h) + 2rem + env(safe-area-inset-bottom, 0px)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding: 0 8px env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 -1px 0 var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .68rem; color: var(--muted); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--accent); font-weight: 600; }
  .fab {
    justify-self: center; width: 54px; height: 54px; margin-top: -24px; border-radius: 16px;
    border: 4px solid var(--bg); background: var(--accent); color: #fff;
    font: 400 1.9rem/1 inherit; cursor: pointer; box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 40%, transparent);
  }
}

.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin: .5rem 0 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1.1rem; box-shadow: var(--shadow); min-width: 0;
}
.card-head, .sec-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.card-head h2, .sec-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

/* ── Home ── */
.home { display: flex; flex-direction: column; }
.home-main { display: contents; }
/* Phone order: header, tip, overview, upcoming bills + calendar, then the rest. */
.h-head { order: 1; } .h-tip { order: 2; } .h-overview { order: 3; } .h-owes { order: 4; } .home-side { order: 5; }
.h-tiles { order: 6; } .h-people { order: 7; } .h-float { order: 8; } .h-recent { order: 9; }
@media (min-width: 1020px) {
  .home {
    display: grid; grid-template-columns: minmax(0, 1fr) 330px; align-items: start;
    background: var(--surface-2); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
  }
  .home-main { display: block; padding: 1.6rem 1.75rem .75rem; min-width: 0; }
  .home-side { background: var(--side); align-self: stretch; padding: 1.6rem 1.5rem; border-left: 1px solid var(--line); }
}

.h-head { display: flex; align-items: center; gap: .9rem; margin: .4rem 0 1.2rem; flex-wrap: wrap; }
.h-title { flex: 1; min-width: 0; }
.h-title h1 { color: var(--accent); }
.h-title small { color: var(--muted); }
.month-pick {
  display: inline-flex; align-items: center; gap: .2rem; background: var(--surface); border-radius: 8px;
  padding: .25rem; box-shadow: var(--shadow); font-size: .88rem; color: var(--muted);
}
.month-pick span { display: inline-flex; align-items: center; gap: .45rem; padding: 0 .4rem; white-space: nowrap; color: var(--text); }
.month-pick svg { width: 16px; height: 16px; color: var(--muted); }
.month-pick button { width: 30px; height: 30px; border: 0; border-radius: 6px; background: none; color: var(--text); font-size: 1.15rem; cursor: pointer; }
.month-pick button:hover { background: var(--surface-2); }
.month-pick button:disabled { opacity: .3; cursor: default; background: none; }
@media (max-width: 520px) { .month-pick { width: 100%; justify-content: space-between; } .h-title small { display: none; } }

.h-overview { display: grid; grid-template-columns: minmax(0, 1fr) 250px; padding: 0; overflow: hidden; }
.ov-left { padding: 1.3rem 1.4rem 1rem; min-width: 0; }
.ov-right { padding: 1.3rem 1.4rem; border-left: 1.5px dashed var(--line); display: flex; flex-direction: column; }
@media (max-width: 700px) {
  .h-overview { grid-template-columns: 1fr; }
  .ov-right { border-left: 0; border-top: 1.5px dashed var(--line); }
}
.ov-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.ov-stat { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.dot-ico {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; margin-bottom: .45rem;
  background: color-mix(in srgb, var(--ico) 14%, transparent); color: var(--ico);
}
.dot-ico svg { width: 16px; height: 16px; }
.ov-stat b { font-size: 1.25rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-stat small { font-size: .82rem; }
@media (max-width: 420px) { .ov-stat b { font-size: 1.02rem; } }

.bars { display: grid; grid-template-columns: auto repeat(7, 1fr); gap: .5rem; align-items: end; height: 180px; margin-top: 1.4rem; }
.baxis { display: flex; flex-direction: column; justify-content: space-between; height: calc(100% - 1.4rem); align-self: start; font-size: .68rem; color: var(--muted); padding-right: .2rem; }
.bcol { display: flex; flex-direction: column; align-items: center; gap: .4rem; height: 100%; min-width: 0; }
.bstack { position: relative; flex: 1; width: 100%; max-width: 46px; }
.bstack i { position: absolute; bottom: 0; border-radius: 4px 4px 2px 2px; }
.bstack .ghost { left: 0; width: 70%; background: var(--ghost); }
.bstack .fill { right: 4%; width: 42%; background: var(--k-card); }
.bcol span { font-size: .72rem; color: var(--muted); }
.bcol.on span { color: var(--text); font-weight: 600; }
.legend { display: flex; gap: 1rem; margin-top: .6rem; font-size: .75rem; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: .35rem; vertical-align: -.02em; }

.ov-right h2 { margin-bottom: .4rem; }
.donut { position: relative; width: 170px; margin: .2rem auto .6rem; }
.donut svg { display: block; width: 100%; }
.donut circle { fill: none; stroke-width: 15; }
.donut .track { stroke: var(--ghost); }
.donut .spent { stroke: var(--ring); stroke-linecap: round; }
.donut .saved { stroke: var(--k-saving); stroke-linecap: round; }
.donut-c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-c b { font-size: 1.15rem; font-weight: 600; }
.donut-c span { font-size: .8rem; color: var(--ring); }
.donut-foot { display: flex; justify-content: space-between; gap: .75rem; margin-top: auto; }
.donut-foot div { display: flex; flex-direction: column; }
.donut-foot div:last-child { text-align: right; }
.donut-foot b { font-weight: 600; font-size: 1.02rem; }
.donut-foot small { color: var(--muted); }

.h-tiles { margin: .4rem 0 1.2rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .9rem; }
@media (max-width: 420px) { .tiles { grid-template-columns: 1fr 1fr; gap: .7rem; } }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.tile .ico { margin-bottom: .7rem; }
.tile span { font-size: .8rem; color: var(--muted); }
.tile b { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile small { color: var(--muted); font-size: .72rem; }

.people { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.person-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.person-head b { font-weight: 600; }
.person-row { display: flex; justify-content: space-between; gap: .5rem; font-size: .87rem; padding: .18rem 0; }
.person-row span { color: var(--muted); }
.person-row b { font-weight: 500; }
@media (max-width: 420px) { .people { gap: .7rem; } .people .card { padding: .9rem; } .person-row { flex-direction: column; gap: 0; } }

.tip { padding: .7rem .95rem; border-radius: 10px; margin-bottom: 1rem; font-size: .88rem; background: var(--surface); box-shadow: var(--shadow); border-left: 4px solid var(--info); }
.tip.good { border-left-color: var(--pos); }
.tip.warn { border-left-color: var(--warn); }
.tip.bad { border-left-color: var(--neg); }

/* Sidebar: upcoming bills + calendar */
.home-side { min-width: 0; }
.side-sec { margin-bottom: 1.6rem; }
@media (max-width: 1019px) { .side-sec { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1.1rem; } }
.side-sec h2 { color: var(--muted); font-weight: 500; font-size: 1.05rem; }
.up-total { font-weight: 600; }
.up-row { display: flex; align-items: center; gap: .4rem; }
.up-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: .8rem; padding: .55rem .25rem;
  border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 10px;
}
.up-main:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.up-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.up-info b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-info small { color: var(--muted); font-size: .76rem; }
.up-amt { font-weight: 600; white-space: nowrap; font-size: .92rem; }
.st { font-style: normal; }
.st.bad { color: var(--neg); font-weight: 600; }
.st.warn { color: var(--warn); font-weight: 600; }
.add-new {
  display: flex; align-items: center; gap: .8rem; width: 100%; padding: .55rem .25rem; margin-top: .2rem;
  border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; border-radius: 10px; text-align: left;
}
.add-new:hover { color: var(--accent); }
.add-new:hover .ico { border-color: var(--accent); color: var(--accent); }

.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.cal-week span { font-size: .7rem; color: var(--muted); padding-bottom: .5rem; }
.cd {
  position: relative; display: grid; place-items: center; height: 36px; margin: 1px; border: 0; border-radius: 9px;
  background: none; color: var(--text); font: inherit; font-size: .84rem;
}
.cd.out { color: color-mix(in srgb, var(--muted) 55%, transparent); }
button.cd:disabled { cursor: default; }
.cd.has { cursor: pointer; font-weight: 600; }
.cd.has:hover { background: var(--surface-2); }
.cd.today { background: var(--accent); color: #fff; font-weight: 600; }
.cd.picked { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cd .dots { position: absolute; bottom: 3px; left: 0; right: 0; display: flex; justify-content: center; gap: 2px; }
.cd .dots i { width: 5px; height: 5px; border-radius: 50%; }
.cd.today .dots i { box-shadow: 0 0 0 1px #fff; }
.cal-list { margin-top: .6rem; }
.cal-list h3 { margin-top: .4rem; }
.cal-hint { margin-top: .6rem; }

/* Who owes who */
.owe-big { display: flex; align-items: center; gap: .9rem; }
.owe-big div { display: flex; flex-direction: column; }
.owe-big small { color: var(--muted); font-size: .85rem; }
.owe-big b { font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.owe-big.in b { color: var(--pos); }
.owe-big.out b { color: var(--neg); }
.owe-list { display: flex; flex-direction: column; }
.owe-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; padding: .45rem .25rem;
  border: 0; border-bottom: 1px solid var(--line); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.owe-row:last-child { border-bottom: 0; }
.owe-row:hover { background: var(--surface-2); }
.owe-row span { display: flex; flex-direction: column; min-width: 0; }
.owe-row b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owe-row small { color: var(--muted); font-size: .74rem; }
.owe-row em { font-style: normal; font-weight: 600; white-space: nowrap; }
.owe-more { width: 100%; margin-top: .3rem; color: var(--accent); }
.not-paid { display: flex; flex-direction: column; gap: .1rem; padding: .6rem .8rem; border-radius: 10px; background: var(--surface-2); }
.not-paid b { color: var(--warn); font-weight: 600; }
.not-paid small { color: var(--muted); }

/* Accounts (sidebar) */
.acct-row { display: flex; align-items: center; gap: .8rem; padding: .5rem .25rem; color: inherit; font-weight: 400; border-radius: 10px; }
.acct-row:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }

/* Account picker in the entry form */
.wallet-hint, .owe-hint { color: var(--muted); font-size: .8rem; }
.wallet-hint b, .owe-hint b { color: var(--text); }
.wallet-hint b.neg { color: var(--neg); }
.parts { display: flex; flex-direction: column; gap: .5rem; padding: .75rem; border-radius: 10px; background: var(--surface-2); }
.part-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: .5rem; align-items: center; }
.part-row .calc-input input { font-size: 1rem; }
.parts-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.parts-foot small { font-weight: 600; }

/* Floating Cash */
.floating-card { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; color: inherit; font-weight: 400; }
.floating-card:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent), var(--shadow); }
.fl-main { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.fl-main > small:first-child { color: var(--muted); }
.floating-total { font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.floating-total small { display: block; font-size: .78rem; font-weight: 400; color: var(--muted); }
.floating-split { display: flex; gap: 1.25rem; flex-wrap: wrap; font-weight: 600; }
.floating-split span { display: flex; flex-direction: column; }
.floating-split i { font-style: normal; font-weight: 400; font-size: .76rem; color: var(--muted); }
.office-box { background: var(--surface-2); border-radius: 10px; padding: .8rem; display: flex; flex-direction: column; gap: .8rem; }
.office-row { display: flex; align-items: center; gap: .3rem; border-bottom: 1px solid var(--line); }
.office-row:last-child { border-bottom: 0; }
.office-row.sel { background: var(--accent-soft); border-radius: 10px; }
.pick { width: 34px; display: grid; place-items: center; flex: none; }
.pick input { width: 18px; height: 18px; }
.office-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: .75rem; padding: .65rem .4rem; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.office-main .tx-main { display: flex; flex-direction: column; }
.bulk-bar {
  position: sticky; bottom: 16px; z-index: 15; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .7rem .9rem; margin-bottom: 1rem; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.bulk-bar .btn:not(.primary) { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }
@media (max-width: 760px) { .bulk-bar { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)); } }

/* Hero (Floating Cash page summary) */
.hero { display: grid; gap: 1rem; }
@media (min-width: 761px) { .hero { grid-template-columns: 1fr 1.4fr; align-items: center; } }
.hero-main span { color: var(--muted); font-size: .85rem; }
.hero-main b { display: block; font-size: 2rem; font-weight: 600; line-height: 1.2; color: var(--k-office); }
.hero-main b.neg { color: var(--neg); }
.hero-main small { color: var(--muted); }
.hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.hero-grid div { background: var(--surface-2); border-radius: 10px; padding: .6rem .75rem; min-width: 0; }
.hero-grid span { display: block; font-size: .74rem; color: var(--muted); }
.hero-grid b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Upcoming-bill bits shared with other screens */
.due-meta { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; min-width: 0; margin-top: .1rem; }
.due-note { font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.due-right { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; flex: none; }
.due-right b { font-weight: 600; }
.tag { font-size: .68rem; font-weight: 500; padding: .05rem .45rem; border-radius: 5px; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.home-side .tag { background: var(--surface); }
@media (max-width: 1019px) { .home-side .tag { background: var(--surface-2); } }
.tag.shared { background: color-mix(in srgb, var(--k-bills) 13%, transparent); color: var(--k-bills); }
.tag.person { background: color-mix(in srgb, var(--k-card) 12%, transparent); color: var(--k-card); }
.card-hint { display: block; margin-top: .35rem; font-size: .8rem; color: var(--muted); }
.card-hint b { color: var(--text); }
.card-hint .neg { color: var(--neg); }
.loan-next { display: flex; flex-direction: column; gap: .35rem; padding: .75rem; border-radius: 10px; background: var(--surface-2); }
.chip.done { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 40%, var(--line)); }
.chip.waiting { color: var(--warn); cursor: default; }

.line { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line b { font-weight: 600; white-space: nowrap; }
.line.item { width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; padding-inline: .2rem; }
.line.item:hover { background: var(--surface-2); }
.line.item.off { opacity: .45; }
.warn-line { color: var(--warn); font-weight: 600; }

/* ── Stats (Insights) ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: .8rem; }
.stat b { display: block; font-size: 1.35rem; font-weight: 600; }
.stat small { color: var(--muted); }

/* ── Buttons & forms ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 500; font-size: .9rem;
  padding: .55rem 1.05rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 25%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--neg); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn.small { padding: .3rem .7rem; font-size: .8rem; border-radius: 7px; }
.btn.block { width: 100%; padding: .75rem; }
.btn.big { padding: .75rem 1.6rem; font-size: 1rem; }

.fields { display: flex; flex-direction: column; gap: .85rem; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > span { font-size: .8rem; font-weight: 500; color: var(--muted); }
.field small { color: var(--muted); }
.field small.field-note { color: var(--accent); font-weight: 600; }
.field small.field-note:empty { display: none; }
.field.check { flex-direction: row; align-items: center; gap: .5rem; }
.row-2 { display: flex; gap: .75rem; }
.row-2 .grow { flex: 1; }
@media (max-width: 420px) { .row-2 { flex-direction: column; } }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 8px; padding: .6rem .75rem; width: 100%; min-width: 0;
}
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

/* Chips & tabs */
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-bottom: .8rem; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  font: inherit; font-size: .86rem; white-space: nowrap;
  padding: .4rem .8rem; border-radius: 8px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.3;
}
.chip small { color: var(--muted); font-size: .72rem; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 500; }
.chip.on small { color: var(--accent); }
.chip.add { border-style: dashed; color: var(--muted); background: none; }
.chips.small .chip { font-size: .78rem; padding: .22rem .6rem; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.seg.small { display: inline-grid; background: var(--surface); box-shadow: var(--shadow); }
.seg-btn { font: inherit; font-weight: 500; font-size: .86rem; border: 0; background: none; color: var(--muted); padding: .48rem .6rem; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(28, 32, 51, .1); }
.seg.small .seg-btn.on { background: var(--accent-soft); color: var(--accent); box-shadow: none; }

/* Entry sheet */
.entry-sheet { display: flex; flex-direction: column; gap: 1rem; }
.entry-sheet section { display: flex; flex-direction: column; gap: 1rem; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 0; background: var(--surface-2); color: var(--text); font: 500 1rem/1 inherit; cursor: pointer; }
.calc-input { position: relative; }
.calc-input .peso { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); font-weight: 500; color: var(--muted); }
.calc-input input { padding-left: 2rem; font-size: 1.2rem; font-weight: 500; }
.field.calc:first-child .calc-input input { font-size: 1.6rem; padding-block: .65rem; }
.calc-preview { color: var(--accent) !important; font-weight: 600; min-height: 1em; }
.keypad { display: grid; grid-template-columns: repeat(7, 1fr); gap: .35rem; margin-top: -.6rem; }
.key { font: inherit; font-weight: 600; font-size: 1.05rem; padding: .5rem 0; border-radius: 8px; border: 0; background: var(--surface-2); color: var(--text); cursor: pointer; }
.key[data-key="="] { background: var(--accent); color: #fff; }
.total-line { display: flex; justify-content: space-between; padding: .7rem .9rem; background: var(--accent-soft); border-radius: 10px; font-weight: 600; color: var(--accent); }
.split-box { background: var(--surface-2); border-radius: 10px; padding: .8rem; display: flex; flex-direction: column; gap: .6rem; }
.split-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.split-inputs label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; font-weight: 500; }
.split-inputs small { color: var(--muted); }
.pct-input { position: relative; }
.pct-input input { padding-right: 1.8rem; font-weight: 500; }
.pct-input i { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: .8rem; }
.filter { display: flex; flex-direction: column; gap: .15rem; flex: 0 1 160px; min-width: 120px; }
.filter.grow { flex: 1 1 200px; }
.filter span { font-size: .72rem; color: var(--muted); }
.filter input, .filter select { padding: .45rem .6rem; }

/* ── Lists ── */
.card.list { padding: .4rem .7rem; }
.day-head { font-size: .74rem; font-weight: 500; color: var(--muted); padding: .8rem .5rem .25rem; }
.tx-row {
  display: flex; align-items: center; gap: .8rem; width: 100%;
  padding: .55rem .5rem; border: 0; background: none; color: inherit; font: inherit; text-align: left;
  border-radius: 10px; cursor: pointer;
}
.tx-row:hover { background: var(--surface-2); }
.tx-main { flex: 1; min-width: 0; }
.tx-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-sub { font-size: .77rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-weight: 600; white-space: nowrap; }
.tx-amt.income { color: var(--pos); }
.tx-amt.saving { color: var(--save); }
.tx-amt.card_payment { color: var(--muted); }
.tx-amt.office { color: var(--muted); text-decoration: line-through dotted; }
.summary-line { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: .86rem; margin: 0 0 .6rem .25rem; color: var(--muted); }

.pill { display: inline-block; font-size: .72rem; font-weight: 500; padding: .12rem .55rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.good { background: color-mix(in srgb, var(--pos) 13%, transparent); color: var(--pos); }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--neg) 12%, transparent); color: var(--neg); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

/* ── Bars ── */
.bar { position: relative; height: 8px; border-radius: 999px; background: var(--ghost); margin: .35rem 0; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.bar.warn i { background: var(--warn); }
.hbars { display: flex; flex-direction: column; gap: .55rem; }
.hbar { display: grid; grid-template-columns: minmax(90px, 1.1fr) 2fr auto; align-items: center; gap: .6rem; font-size: .86rem; }
.hbar .bar { margin: 0; }
.hbar b { font-weight: 600; white-space: nowrap; }
.hbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Charts & tables ── */
.chart-box { position: relative; height: 250px; }
.chart-box.short { height: 170px; margin-bottom: .5rem; }
.table-wrap { overflow-x: auto; margin-top: .75rem; }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th { text-align: left; font-size: .74rem; color: var(--muted); font-weight: 500; padding: .45rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .5rem; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }

/* ── Manage ── */
.invite { display: flex; align-items: center; gap: .75rem; margin: .5rem 0; }
.invite code { font-size: 1.35rem; letter-spacing: .15em; padding: .4rem .8rem; font-weight: 600; }
.cat-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .5rem 1.5rem; }
.cat-group h3 { margin-top: .5rem; display: flex; align-items: center; }

/* ── Gate (sign in / onboarding) ── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 2rem 16px; }
.gate-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px; padding: 1.75rem; box-shadow: var(--shadow); }
.gate-brand { display: flex; flex-direction: column; align-items: center; gap: .3rem; font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; }
.gate-brand img { width: 72px; height: 72px; }
.gate h2 { text-align: center; }
.gate .steps { padding-left: 1.2rem; display: grid; gap: .5rem; }
.onboard { background: var(--surface-2); border-radius: 12px; padding: 1rem; }
.onboard h3 { margin: 0; color: var(--text); font-size: 1rem; font-weight: 600; }
.or { text-align: center; color: var(--muted); margin: .75rem 0; font-size: .85rem; }

/* ── Modal & toast ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 18, 32, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 500px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--surface); border-radius: 16px; padding: 1.3rem; box-shadow: 0 16px 48px rgba(0, 0, 0, .22);
}
.modal h2 { font-size: 1.25rem; }
.modal-actions { display: flex; gap: .5rem; margin-top: .5rem; align-items: center; }
.spacer { flex: 1; }
@media (max-width: 560px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 94vh; padding-bottom: calc(1.3rem + env(safe-area-inset-bottom, 0px)); animation: up .2s ease-out; }
  .modal-actions .btn.primary { flex: 1; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--text); color: var(--bg); padding: .65rem 1.1rem; border-radius: 10px; font-weight: 500;
  max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
@media (max-width: 760px) { .toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); } }
.toast.error { background: var(--neg); color: #fff; }
