[hidden] { display: none !important; }
:root {
  --bg: #f4f6f8; --card: #fff; --text: #1d2730; --muted: #66727d; --line: #e2e7ec;
  --primary: #1f5f8b; --primary-soft: #e3eef6; --ok: #2e8b57; --warn: #e08a00; --bad: #c8382e;
  --ok-soft: #e4f3ea; --warn-soft: #fdf1dc; --bad-soft: #fbe4e2; --radius: 12px;
  --bar: #1f5f8b; --on-primary: #fff;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12171c; --card: #1c232a; --text: #e8edf1; --muted: #9aa6b0; --line: #2c353e;
    --primary: #5aa7da; --primary-soft: #1d3446; --ok: #4cbb7f; --warn: #f0a32a; --bad: #ef6a5f;
    --ok-soft: #1b3326; --warn-soft: #3a2d14; --bad-soft: #3c1f1d;
    --bar: #1b3a52; --on-primary: #0b1a26; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans Hebrew", sans-serif;
  font-size: 16px; line-height: 1.45; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.wrap { max-width: 680px; margin: 0 auto; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.right { text-align: left; }

/* header */
.topbar { background: var(--bar); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 5; }
.topbar .inner { max-width: 680px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.topbar h1 { margin: 0; font-size: 18px; flex: 1; }
.monthnav { display: flex; align-items: center; gap: 4px; }
.monthnav button { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 8px; width: 36px; height: 34px; font-size: 18px; }
.monthnav span { min-width: 104px; text-align: center; font-weight: 600; }

/* bottom nav */
.nav { position: fixed; bottom: 0; right: 0; left: 0; background: var(--card); border-top: 1px solid var(--line);
  display: flex; z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; text-align: center; padding: 8px 2px 9px; text-decoration: none; color: var(--muted); font-size: 12px; }
.nav a .ic { display: block; font-size: 20px; line-height: 1.2; }
.nav a.on { color: var(--primary); font-weight: 700; }
.fab { position: fixed; left: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); font-size: 32px; line-height: 58px; text-align: center; text-decoration: none;
  box-shadow: 0 3px 10px rgba(0,0,0,.25); z-index: 9; }

/* summary */
.summary { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; text-align: center; }
.summary .lbl { font-size: 12px; color: var(--muted); }
.summary .val { font-size: 18px; font-weight: 700; }
.big { font-size: 28px; font-weight: 800; }

/* categories */
.cat { display: block; text-decoration: none; color: inherit; }
.cat .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cat .name { font-weight: 700; }
.cat .left { font-weight: 800; font-size: 18px; }
.cat .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.bar { height: 9px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 6px; transition: width .3s; }
.st-warn .bar > i { background: var(--warn); }
.st-bad .bar > i { background: var(--bad); }
.st-warn .left { color: var(--warn); }
.st-bad .left { color: var(--bad); }
.st-ok .left { color: var(--ok); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); margin-inline-start: 4px; vertical-align: middle; }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

/* forms */
label.f { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 16px; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.amount-input { font-size: 34px !important; font-weight: 800; text-align: center; direction: ltr; padding: 10px !important; }
.btn { display: inline-block; border: 0; border-radius: 10px; padding: 12px 16px; background: var(--primary); color: var(--on-primary); font-weight: 700;
  text-decoration: none; text-align: center; cursor: pointer; }
.btn.block { display: block; width: 100%; margin-top: 16px; font-size: 18px; padding: 14px; }
.btn.sec { background: var(--primary-soft); color: var(--primary); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 7px 11px; font-size: 14px; border-radius: 8px; }
.btn:disabled { opacity: .5; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 8px 13px; font-size: 15px; cursor: pointer; }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }
.chip.sug { border-color: var(--primary); border-style: dashed; }
.seg { display: flex; background: var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 9px 4px; font-size: 15px; }
.seg button.on { background: var(--card); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.check input { width: 22px; height: 22px; }
.err { color: var(--bad); margin-top: 8px; }
.receipt-thumb { max-width: 100%; max-height: 220px; border-radius: 8px; display: block; margin-top: 8px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }

/* lists */
.list .item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.list a.item { text-decoration: none; color: inherit; }
.item .desc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12px; color: var(--muted); }
.item .amt { font-weight: 700; white-space: nowrap; }
.amt.inc { color: var(--ok); }
.dayhead { font-size: 13px; color: var(--muted); font-weight: 700; margin: 12px 0 0; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .full { grid-column: 1 / -1; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* debts */
.ent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.ent { background: var(--card); border-radius: var(--radius); padding: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.ent .lbl { font-size: 13px; color: var(--muted); }
.ent .val { font-size: 22px; font-weight: 800; }
.ent .meta { font-size: 12px; margin-top: 2px; }

/* tables */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: right; }
table.t th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.t td.n, table.t th.n { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tr.tot td { font-weight: 800; border-top: 2px solid var(--text); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.hbars .hb { display: grid; grid-template-columns: 58px 1fr 74px; gap: 8px; align-items: center; font-size: 13px; margin: 5px 0; }
.hbars .track { height: 14px; background: var(--line); border-radius: 4px; overflow: hidden; }
.hbars .track i { display: block; height: 100%; background: var(--primary); width: 0; }
.hbars .hb.cur .track i { background: var(--warn); }

/* import */
.imp-row { border-bottom: 1px solid var(--line); padding: 10px 0; }
.imp-row.skip { opacity: .5; }
.imp-row .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.imp-row select { padding: 7px 8px; font-size: 14px; }
.sticky-bottom { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); background: var(--bg); padding: 8px 0; }

/* login */
.login { max-width: 360px; margin: 10vh auto 0; padding: 0 16px; }
.login .logo { text-align: center; font-size: 46px; }
.login h1 { text-align: center; }

.toast { position: fixed; bottom: calc(90px + env(safe-area-inset-bottom)); right: 50%; transform: translateX(50%);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; display: flex; gap: 14px; align-items: center;
  max-width: 92vw; box-shadow: 0 3px 12px rgba(0,0,0,.3); }
.toast button { background: none; border: 0; color: #8fd0ff; font-weight: 700; }
.settings-cat { display: grid; grid-template-columns: 1fr 96px; gap: 6px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.settings-cat .tools { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 14px; }
.settings-cat input[type=text], .settings-cat input[type=number] { padding: 8px 10px; }

/* --- גרסה 2: חשבונות, ייבוא חודשי, אייקונים --- */
.ico { display: inline-block; vertical-align: middle; flex: none; }
.monthnav button { display: inline-flex; align-items: center; justify-content: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.amt.xfer { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.amount-input.inc { color: var(--ok); }
select.need { border-color: var(--warn); background: var(--warn-soft); }
.linkbtn { background: none; border: 0; color: var(--primary); padding: 8px 0 0; font-size: 14px; text-decoration: underline; cursor: pointer; }
.warnbox { background: var(--warn-soft); }
.filecard select { margin-top: 8px; }
.mapform { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 4px; }
.imp-row .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 6px; }
.imp-row .grid3 select { padding: 7px 6px; font-size: 13px; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.statgrid div { background: var(--bg); border-radius: 8px; padding: 8px 4px; }
.statgrid b { display: block; font-size: 20px; }
.statgrid span { font-size: 11px; color: var(--muted); line-height: 1.2; display: block; }
.statgrid .st-warn b { color: var(--warn); }
.acct-row { display: grid; grid-template-columns: 1fr 84px; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.acct-row input, .acct-row select { padding: 8px 10px; font-size: 15px; }
.acct-row label { grid-column: 1 / -1; }
.debtlink { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.debtlink b { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.planned-note { color: var(--warn); }
.grid2f { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
input[type=month] { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 16px; }
.acct-row select[data-k=purpose], .acct-row select[data-k=linked] { grid-column: span 1; }
h2.row a { font-weight: 400; }

.bar.marked { position: relative; }
.bar.marked::after { content: ""; position: absolute; top: -3px; bottom: -3px; right: 50%; width: 2px; background: var(--text); opacity: .45; }
.warnText { color: var(--warn); font-weight: 600; }
.p2pnote { margin-top: 6px; padding: 8px 10px !important; font-size: 14px !important; border-color: var(--warn) !important; }
