/* ===== CRM פיננסי משפחתי ===== */
:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-light: #ccfbf1;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e6e5e1;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #8a8985;
  --income: #1baf7a;
  --expense: #eb6834;
  --series-1: #2a78d6;
  --good: #1baf7a;
  --warn: #eda100;
  --bad: #e34948;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; margin: 0; }
html { color-scheme: light; }
body {
  font-family: 'Heebo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  font-size: 15px;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 40px 36px; width: 100%; max-width: 380px; text-align: center; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .sub { color: var(--text-3); font-size: 13px; margin-bottom: 24px; }
.login-card input { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; background: var(--bg); }
.login-card input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.login-error { color: var(--bad); font-size: 13px; min-height: 20px; margin-bottom: 6px; }

/* ---- Shell ---- */
.shell { display: none; }
.shell.active { display: block; }
header.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 20px; display: flex; align-items: center; gap: 18px;
  position: sticky; top: 0; z-index: 50; height: 58px;
}
.logo { font-weight: 700; font-size: 17px; color: var(--brand-dark); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
nav.tabs button {
  background: none; border: none; padding: 18px 13px; font-size: 14px; color: var(--text-2);
  border-bottom: 2.5px solid transparent; white-space: nowrap;
}
nav.tabs button.active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 600; }
.topbar .user { color: var(--text-3); font-size: 13px; white-space: nowrap; }
.topbar .user b { color: var(--text); }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }
.page { display: none; }
.page.active { display: block; }
h2.page-title { font-size: 20px; margin-bottom: 4px; }
.page-sub { color: var(--text-3); font-size: 13px; margin-bottom: 20px; }

/* ---- Cards & grids ---- */
.grid { display: grid; gap: 14px; margin-bottom: 20px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card h3 { font-size: 14px; color: var(--text-2); font-weight: 600; margin-bottom: 12px; }

/* stat tile */
.stat .label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.stat .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat .value.neg { color: var(--bad); }
.stat .value.pos { color: var(--good); }

/* ---- Tables ---- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: right; color: var(--text-3); font-weight: 500; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #f0efec; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .neg { color: var(--bad); }
.tbl .pos { color: var(--good); }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2.5px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge.active { background: #e6f7f0; color: #0c7a52; }
.badge.inactive { background: #f1f0ee; color: var(--text-3); }
.badge.warn { background: #fdf3dc; color: #9a6b00; }
.badge.danger { background: #fdeaea; color: #b02a29; }
.badge.info { background: #e8f1fc; color: #1d5fb5; }
.badge.brand { background: var(--brand-light); color: var(--brand-dark); }

/* ---- Charts ---- */
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; flex-wrap: wrap; }
.chart-legend .key { display: flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 11px; height: 11px; border-radius: 3px; }
#tooltip {
  position: fixed; pointer-events: none; z-index: 200; display: none;
  background: #21201e; color: #fff; border-radius: 8px; padding: 8px 12px;
  font-size: 12.5px; line-height: 1.5; box-shadow: 0 4px 14px rgba(0,0,0,.25); max-width: 260px;
}

/* category bars */
.cat-row { display: grid; grid-template-columns: 170px 1fr 90px; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; }
.cat-row .bar-track { background: #f0efec; border-radius: 4px; height: 14px; overflow: hidden; }
.cat-row .bar { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.cat-row .amount { text-align: left; font-variant-numeric: tabular-nums; color: var(--text-2); }
.cat-row .cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Buttons & forms ---- */
.btn {
  background: var(--brand); color: #fff; border: none; border-radius: 9px;
  padding: 9px 18px; font-size: 14px; font-weight: 500;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 7px; }
.btn.ghost { background: none; border: none; color: var(--text-3); padding: 4px 8px; }
.btn.ghost:hover { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }

/* ---- Tasks ---- */
.task-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0efec; }
.task-item:last-child { border-bottom: none; }
.task-item input[type=checkbox] { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--brand); }
.task-item .t-title { font-weight: 500; }
.task-item.done .t-title { text-decoration: line-through; color: var(--text-3); font-weight: 400; }
.task-item .t-meta { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.task-item .t-desc { font-size: 13px; color: var(--text-2); margin-top: 3px; white-space: pre-wrap; }

/* ---- Misc ---- */
.empty { text-align: center; color: var(--text-3); padding: 40px 10px; font-size: 14px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill-row button { background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 6px 14px; font-size: 13px; color: var(--text-2); }
.pill-row button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.note { background: #fdf3dc; border-radius: 10px; padding: 10px 14px; font-size: 13px; color: #7a5500; margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.muted { color: var(--text-3); font-size: 12.5px; }
dialog { border: none; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.2); padding: 26px; width: min(440px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin-bottom: 16px; }
@media (max-width: 720px) {
  .cat-row { grid-template-columns: 110px 1fr 80px; }
  nav.tabs button { padding: 18px 9px; font-size: 13px; }
  main { padding: 16px 12px 70px; }
}
