:root {
  --navy: #163C6E;
  --navy-dark: #0E2A50;
  --ground: #F4F6F9;
  --card: #FFFFFF;
  --line: #E1E5EB;
  --line-soft: #EEF0F3;
  --text: #1B2430;
  --muted: #4A5563;
  --quiet: #5B6573;
  --sel: #E3ECF9;
  --warn: #B4400C;
  --warn-bg: #FFF0E6;
  --bad: #C92A2A;
  --bad-bg: #FFE3E3;
  --good: #2B8A3E;
  --good-bg: #EBFBEE;
  --calc: #EEF3FA;
  --auto: #F6F7F9;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--text); font-family: Heebo, Arial, sans-serif; font-size: 14px; }
button, input, select { font-family: inherit; font-size: inherit; }
a { color: var(--navy); }
[hidden] { display: none !important; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 10px 24px; min-height: 56px; background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: baseline; gap: 8px; font-size: 18px; }
.brand span { font-size: 14px; opacity: .8; border-inline-start: 1px solid rgba(255,255,255,.4); padding-inline-start: 8px; }
#tabs { display: flex; gap: 4px; flex-wrap: wrap; }
#tabs a { color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 6px; opacity: .85; }
#tabs a:hover { background: rgba(255,255,255,.1); opacity: 1; }
#tabs a.on { background: #fff; color: var(--navy); opacity: 1; font-weight: 500; }
.who { margin-inline-start: auto; font-size: 13px; opacity: .9; display: flex; gap: 8px; align-items: center; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

.alerts { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 24px 0; }
.al { padding: 6px 12px; border-radius: 6px; text-decoration: none; font-size: 13px; }
.al.good { background: var(--good-bg); color: var(--good); }
.al.bad { background: var(--bad-bg); color: var(--bad); font-weight: 500; }
.al.warn { background: var(--warn-bg); color: var(--warn); }

main { padding: 16px 24px 48px; }
.center { max-width: 560px; margin: 48px auto; text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
h2.sub { font-size: 16px; color: var(--muted); margin: 24px 0 8px; }
.note { color: var(--quiet); font-size: 13px; }
.bad-text { color: var(--bad); }
.warn-text { color: var(--warn); }
.neg { color: var(--bad); }
.grow { flex: 1; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--navy); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-dark); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.x { background: none; border: 0; color: var(--quiet); cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.x:hover { background: var(--bad-bg); color: var(--bad); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.toolbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
input, select { border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; background: #fff; }
input:focus, select:focus { outline: 2px solid var(--navy); outline-offset: -1px; border-color: transparent; }

.tiles { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.tile.wide { min-width: 300px; flex: 1; }
.tile > span { color: var(--muted); font-size: 13px; }
.tile > b { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile small { color: var(--quiet); font-size: 12px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
.kv:last-child { border-bottom: 0; }

/* the cash-flow grid */
.gridwrap { overflow: auto; max-height: calc(100vh - 290px); background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
table.cf { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; font-size: 13px; }
.cf th, .cf td { border-bottom: 1px solid var(--line-soft); border-inline-start: 1px solid var(--line-soft); padding: 4px 6px; white-space: nowrap; text-align: center; min-width: 72px; height: 28px; }
.cf thead th { position: sticky; top: 0; background: #fff; z-index: 2; font-weight: 500; border-bottom: 1px solid var(--line); }
.cf thead th small { display: block; color: var(--quiet); font-weight: 400; font-size: 11px; }
.cf tbody th, .cf th.corner { position: sticky; right: 0; background: #fff; z-index: 1; text-align: right; font-weight: 500; min-width: 210px; border-inline-end: 1px solid var(--line); }
.cf th.corner { z-index: 3; }
.cf .today { background: #FFF9DB; }
.cf thead th.today { background: #FFEC99; }
.cf thead th.sat { color: var(--quiet); }
.cf td.ed { cursor: cell; }
.cf td.ed:hover { background: var(--sel); }
.cf td.sel { outline: 2px solid var(--navy); outline-offset: -2px; background: var(--sel); }
.cf td.calc { background: var(--calc); color: var(--muted); }
.cf tr.sec th { background: var(--navy); color: #fff; }
.cf tr.sec td { background: var(--line-soft); }
.cf tr.auto th, .cf tr.auto td { background: var(--auto); font-style: italic; color: var(--muted); }
.cf tr.info td { font-size: 12px; white-space: normal; min-width: 72px; vertical-align: top; }
.cf tr.sum th, .cf tr.sum td { font-weight: 700; background: #FAFBFC; }
.cf tr.bal th, .cf tr.bal td { font-weight: 700; background: #F1F5FB; border-bottom: 2px solid var(--navy); }
.cf tr.bal td.neg { background: var(--bad-bg); }
.cf td.go { cursor: pointer; }
.cf td.go:hover { text-decoration: underline; }
.cf .tot { background: #FAFBFC; font-weight: 500; }
.due { display: block; color: var(--warn); }
.due.paid { color: var(--good); }
.cellin { width: 100%; min-width: 60px; border: 0; padding: 0; text-align: center; background: #fff; outline: none; }

/* suppliers */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { display: flex; align-items: baseline; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); background: #fff; border-radius: 999px; text-decoration: none; color: var(--text); font-weight: 500; }
.chip small { color: var(--quiet); }
.chip em { font-style: normal; font-size: 12px; color: var(--warn); font-weight: 400; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip.on small, .chip.on em { color: #fff; opacity: .85; }
.grp { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.grp.paid { opacity: .8; }
.grp > header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 16px; background: #FAFBFC; border-bottom: 1px solid var(--line); }
.grp h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.hdate { font-weight: 700; font-size: 15px; width: 92px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line-soft); color: var(--muted); }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.grp .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 12px 16px; }
.grp h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.grp footer { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 8px 16px; border-top: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
table.mini { border-collapse: collapse; width: 100%; margin-bottom: 6px; font-size: 13px; }
.mini th { text-align: right; font-weight: 500; color: var(--quiet); font-size: 12px; padding: 2px 4px; border-bottom: 1px solid var(--line); }
.mini td { padding: 2px 4px; border-bottom: 1px solid var(--line-soft); }
.mini input:not([type=checkbox]) { border-color: transparent; background: transparent; padding: 3px 4px; width: 100%; min-width: 0; }
.mini input:hover { border-color: var(--line); }
.mini input.est { color: var(--warn); }
.mini .num, .list .num { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini td.c { text-align: center; }
.mini tr.warnrow td, .list tr.warnrow td { background: var(--warn-bg); }

/* lists */
table.list { border-collapse: collapse; width: 100%; font-size: 13px; }
.list th { text-align: right; font-weight: 500; color: var(--quiet); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.list td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); }
.list .num { text-align: right; direction: rtl; }
.list tr.go { cursor: pointer; }
.list tr.go:hover td { background: var(--sel); }
.list tr.subtot td { font-weight: 500; background: #FAFBFC; }
.rates .rrow, .rrow { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.rrow label { display: flex; gap: 6px; align-items: center; }
.okbox, .warnbox { border-radius: 8px; padding: 10px 14px; margin-top: 12px; }
.okbox { background: var(--good-bg); }
.warnbox { background: var(--warn-bg); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.toast.bad { background: var(--bad); }
dialog.dlg { border: 0; border-radius: 12px; padding: 0; width: min(440px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog.dlg form { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
dialog.dlg h3 { margin: 0; }
dialog.dlg label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
dialog.dlg input, dialog.dlg select { padding: 7px 8px; font-size: 14px; color: var(--text); }
.dlg-actions { display: flex; gap: 8px; margin-top: 6px; }

@media (max-width: 900px) {
  main { padding: 12px 16px 40px; }
  .topbar { padding: 8px 16px; }
  .alerts { padding: 8px 16px 0; }
  .grp .cols { grid-template-columns: 1fr; }
  .mini { display: block; overflow-x: auto; }
  .cf tbody th, .cf th.corner { min-width: 130px; }
}

/* Tal 05.11: every heading filled and bold */
.cf thead th { background: #BCD0EA; color: var(--navy-dark); font-weight: 700; }
.cf thead th small { color: var(--navy); font-weight: 500; }
.cf thead th.today { background: #FFE066; }
.cf thead th.sat { color: var(--navy); }
.cf tbody th, .cf th.corner { background: #D3E0F1; color: var(--navy-dark); font-weight: 700; }
.cf th.corner { background: #A9C2E3; }
.cf tr.auto th { background: #D3E0F1; font-style: italic; }
.cf tr.sum th, .cf tr.bal th { background: #A9C2E3; }
.mini th, .list th { background: #BCD0EA; color: var(--navy-dark); font-weight: 700; }
.list th { padding: 8px; }
.grp h4 { color: var(--navy-dark); font-weight: 700; background: #D3E0F1; padding: 4px 8px; border-radius: 4px; }
.card h2, h2.sub { background: #D3E0F1; color: var(--navy-dark); font-weight: 700; padding: 6px 10px; border-radius: 6px; }
.tile > span { color: var(--navy-dark); font-weight: 700; }
.grp > header { background: #D3E0F1; }
.grp h3 { color: var(--navy-dark); font-weight: 700; }
.grp footer { background: #EEF3FA; font-weight: 500; }

/* Tal 05.11: the cumulative bank balance is always visible at the bottom of the grid, and stronger */
.cf tr.bal th, .cf tr.bal td { position: sticky; bottom: 0; z-index: 2; background: var(--navy); color: #fff; font-size: 15px; font-weight: 700; height: 36px; border-top: 2px solid var(--navy-dark); border-bottom: 0; }
.cf tr.bal th { z-index: 4; background: var(--navy-dark); }
.cf tr.bal td.today { background: #0B2140; color: #FFE066; }
.cf tr.bal td.neg { background: var(--bad); color: #fff; }
.cf th, .cf td { height: 26px; padding: 3px 6px; }

/* Tal 05.11: everything fits the window without scrolling up/down */
.cftb { margin-bottom: 8px; gap: 6px 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; color: var(--navy-dark); font-weight: 500; font-size: 13px; white-space: nowrap; }
.stat b { font-size: 15px; margin-inline-start: 4px; }
.stat small { color: var(--quiet); }
.sep { width: 1px; height: 26px; background: var(--line); }
.cftb .btn { padding: 5px 12px; }
.cf tr.sec th, .cf tr.sec td { height: 18px; padding: 0 6px; font-size: 12px; }
.cf tr.info td { white-space: nowrap; font-size: 11px; line-height: 1.2; }
.cf tr.info .due { display: block; }
.cf.d1 th, .cf.d1 td { height: 22px; padding: 1px 5px; font-size: 12.5px; }
.cf.d1 thead th { height: 30px; }
.cf.d1 tr.bal th, .cf.d1 tr.bal td { height: 30px; font-size: 14px; }
.cf.d2 th, .cf.d2 td { height: 19px; padding: 0 4px; font-size: 12px; }
.cf.d2 thead th { height: 28px; }
.cf.d2 thead th small { display: inline; margin-inline-end: 3px; }
.cf.d2 tr.sec th, .cf.d2 tr.sec td { height: 14px; font-size: 11px; }
.cf.d2 tr.bal th, .cf.d2 tr.bal td { height: 26px; font-size: 13.5px; }
.cf.d3 th, .cf.d3 td { height: 17px; padding: 0 4px; font-size: 11.5px; line-height: 1.1; }
.cf.d3 thead th { height: 22px; }
.cf.d3 thead th small { display: inline; margin-inline-end: 3px; }
.cf.d3 tr.sec th, .cf.d3 tr.sec td { height: 10px; font-size: 0; }
.cf.d3 tr.info td { font-size: 10px; }
.cf.d3 tr.bal th, .cf.d3 tr.bal td { height: 24px; font-size: 13px; }

/* Tal 05.11: clear split between expenses and income — coloured section bars across the whole row */
.cf tr.sec th, .cf tr.sec td { height: 22px; font-size: 13px; font-weight: 700; color: #fff; }
.cf tr.sec.out th, .cf tr.sec.out td { background: #A32020; }
.cf tr.sec.in th, .cf tr.sec.in td { background: #237032; }
.cf tr.sec.tot th, .cf tr.sec.tot td { background: var(--navy); }
.cf tr.out > th { background: #F6DADA; color: #6E1414; }
.cf tr.in > th { background: #D6EFDB; color: #17491F; }
.cf tr.auto.out > th { background: #F6DADA; }
.cf tr.sum.out > th, .cf tr.sum.out > td { background: #EFC3C3; color: #6E1414; }
.cf tr.sum.in > th, .cf tr.sum.in > td { background: #BFE5C7; color: #17491F; }
.cf tr.in > td.ed { background: #F5FBF6; }
.cf tr.in > td.ed.today, .cf tr.out > td.today { background: #FFF6CC; }
.cf.d1 tr.sec th, .cf.d1 tr.sec td { height: 18px; font-size: 12px; }
.cf.d2 tr.sec th, .cf.d2 tr.sec td { height: 16px; font-size: 11.5px; }
.cf.d3 tr.sec th, .cf.d3 tr.sec td { height: 14px; font-size: 11px; }
.cf tr.sec.out > th, .cf tr.sec.out > td { background: #A32020; color: #fff; }
.cf tr.sec.in > th, .cf tr.sec.in > td { background: #237032; color: #fff; }

/* Tal 05.11: each supplier in its country's colour */
.flag { display: inline-block; width: 22px; height: 15px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.18); flex: none; align-self: center; }
.flag.big { width: 36px; height: 24px; }
.supbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; margin-bottom: 10px; border-radius: 10px; background: var(--c); color: var(--fg); }
.supbar b { font-size: 20px; }
.supbar span { opacity: .9; }
.chip { border: 2px solid var(--c); background: var(--tint); align-items: center; }
.chip.on { background: var(--c); color: var(--fg); border-color: var(--c); }
.chip.on small, .chip.on em { color: var(--fg); }
.grp { border: 1px solid var(--c); border-inline-start: 6px solid var(--c); }
.grp > header { background: var(--tint); border-bottom: 1px solid var(--c); }
.grp h4 { background: var(--tint); }
.grp .mini th { background: var(--tint); filter: saturate(1.4) brightness(.95); }
.grp footer { background: var(--tint); }
/* Tal 05.11: "יתרה לרכישה" stands out */
.tobuy { padding: 3px 12px; border-radius: 6px; font-weight: 700; }
.tobuy b { font-size: 15px; }
.tobuy.need { background: var(--bad); color: #fff; }
.tobuy.ok { background: var(--good); color: #fff; }
.tobuy small { font-weight: 400; opacity: .9; }
/* Tal 05.11: the supplier name bar stays on screen while scrolling */
.supbar { position: sticky; top: var(--tb, 56px); z-index: 15; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
