:root {
  --field: #2f4a2a;
  --field-2: #3f6337;
  --leaf: #5f8a4e;
  --wheat: #e2b84f;
  --wheat-soft: #f6e7bd;
  --soil: #7a5a3a;
  --bg: #f5f2e9;
  --card: #ffffff;
  --ink: #1f2a1c;
  --muted: #6c7468;
  --line: #e4e0d3;
  --danger: #b5432f;
  --ok: #3f7d3a;
  --warn: #c8871c;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 42, 28, .06), 0 4px 14px rgba(31, 42, 28, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
}
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* ---------- מבנה ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--field);
  color: #fff;
  padding: calc(var(--safe-t) + 12px) 16px 12px;
  display: flex; align-items: center; gap: 12px;
}
.topbar h1 { font-size: 19px; font-weight: 600; margin: 0; flex: 1; }
.topbar .back { font-size: 22px; }
.icon-btn {
  background: transparent; border: 0; width: 40px; height: 40px; border-radius: 12px;
  display: inline-grid; place-items: center; color: inherit; font-size: 18px;
}
.icon-btn:active { background: rgba(255, 255, 255, .15); }
.icon-btn svg { width: 22px; height: 22px; }
.spin svg { animation: spin 1s linear infinite; }

main { padding: 16px 16px calc(96px + var(--safe-b)); max-width: 720px; margin: 0 auto; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: var(--safe-b);
}
.nav button {
  background: none; border: 0; padding: 9px 0 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px; color: var(--muted);
}
.nav button svg { width: 24px; height: 24px; }
.nav button.active { color: var(--field); font-weight: 600; }
.nav button.active svg { stroke-width: 2.3; }

/* ---------- רכיבים ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
.section-title { font-size: 15px; font-weight: 600; color: var(--muted); margin: 22px 4px 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty svg { width: 44px; height: 44px; opacity: .45; display: block; margin: 0 auto 8px; }

.btn {
  border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 600; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--field); color: #fff;
}
.btn svg { width: 20px; height: 20px; }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.wheat { background: var(--wheat); color: var(--ink); }
.btn.ghost { background: #ecebe2; color: var(--ink); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid #e8c3bb; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 11px; }
.btn[disabled] { opacity: .5; }

.fab {
  position: fixed; left: 18px; bottom: calc(78px + var(--safe-b)); z-index: 19;
  border-radius: 999px; padding: 14px 20px; box-shadow: 0 6px 18px rgba(47, 74, 42, .35);
}

/* ---------- בית ---------- */
.hero {
  background: linear-gradient(160deg, var(--field) 0%, var(--field-2) 100%);
  color: #fff; border-radius: 20px; padding: 18px; margin-bottom: 14px; position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; inset: auto -40px -60px auto; width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(226, 184, 79, .35), transparent 70%);
}
.hero .date { opacity: .8; font-size: 14px; }
.hero h2 { margin: 2px 0 14px; font-size: 22px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; position: relative; z-index: 1; }
.hero-stat { background: rgba(255, 255, 255, .12); border-radius: 12px; padding: 10px; }
.hero-stat > b { display: block; font-size: 19px; }
.hero-stat > span { font-size: 12px; opacity: .85; }

.tiles { display: grid; grid-template-columns: 1fr; gap: 10px; }
.tile {
  background: #fff; border: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: flex; align-items: center; gap: 14px; text-align: right;
}
.tile .ico {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; flex: none;
}
.tile .ico svg { width: 28px; height: 28px; }
.tile.fuel .ico { background: #fbefd0; color: #9a6a10; }
.tile.trac .ico { background: #e3eedb; color: var(--field); }
.tile.jobs .ico { background: #efe5da; color: var(--soil); }
.tile b { font-size: 17px; display: block; }
.pill .num, .tl .num { display: inline; }
.tile small { color: var(--muted); font-size: 13px; }
.tile .chev { color: #b9b6a8; font-size: 22px; }

.install-banner { background: var(--wheat-soft); border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; font-size: 14px; }

/* ---------- סטטיסטיקה ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 12px 10px; }
.stat > b { display: block; font-size: 18px; }
.stat > span { font-size: 12px; color: var(--muted); }

.chart { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding-top: 18px; }
.chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.chart .bar i {
  display: block; width: 100%; max-width: 26px; background: var(--leaf); border-radius: 6px 6px 3px 3px;
  min-height: 2px; position: relative;
}
.chart .bar.cur i { background: var(--wheat); }
.chart .bar em { font-style: normal; font-size: 10px; color: var(--muted); }
.chart .bar u { text-decoration: none; font-size: 9px; color: var(--ink); direction: ltr; }
.year-switch { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.year-switch b { font-size: 16px; }

/* ---------- רשימות ---------- */
.list { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line);
  background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: right;
}
.item:last-child { border-bottom: 0; }
.item:active { background: #faf8f1; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .v { font-weight: 600; text-align: left; white-space: nowrap; }
.item .v small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.month-head { background: #f1eee4; padding: 7px 14px; font-size: 13px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }

/* ---------- טרקטורים ---------- */
.tgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tcard {
  background: #fff; border: 0; padding: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; text-align: right; display: flex; flex-direction: column;
}
.tphoto { aspect-ratio: 4 / 3; background: #e6eadf center / cover no-repeat; display: grid; place-items: center; color: #9aa592; }
.tphoto svg { width: 46px; height: 46px; }
.tcard .tb { padding: 10px 12px 12px; }
.tcard .tn { font-weight: 600; font-size: 16px; margin-bottom: 2px; }
.tcard .tl { font-size: 12px; color: var(--muted); }
.pill {
  display: inline-block; margin-top: 8px; padding: 4px 9px; border-radius: 99px; font-size: 13px; font-weight: 600;
  background: #e3eedb; color: var(--field);
}
.pill.none { background: #f1eee4; color: var(--muted); font-weight: 500; }

.tdetail-photo { margin: -16px -16px 14px; aspect-ratio: 16 / 10; background: #e6eadf center / cover no-repeat; display: grid; place-items: center; color: #9aa592; }
.tdetail-photo svg { width: 64px; height: 64px; }
.next-box { background: var(--wheat-soft); border-radius: 14px; padding: 14px; display: flex; justify-content: space-between; align-items: center; }
.next-box b { font-size: 26px; }
.next-box > svg { width: 34px; height: 34px; color: #9a6a10; flex: none; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.kv div { background: #f6f4ec; border-radius: 12px; padding: 10px; }
.kv > div > span { display: block; font-size: 12px; color: var(--muted); }
.kv b { font-size: 16px; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* ---------- קבלנות ---------- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.sumbar { display: flex; justify-content: space-between; align-items: center; background: var(--field); color: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.sumbar b { font-size: 20px; }
.sumbar > div > span { font-size: 13px; opacity: .85; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: #fbefd0; color: #8a5d0c; margin-inline-start: 6px; font-weight: 500; }

/* ---------- טפסים ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: #3b4637; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  padding: 12px 13px; font-size: 16px; outline: none; appearance: none; -webkit-appearance: none;
}
select.input {
  background-image: linear-gradient(45deg, transparent 50%, #889 50%), linear-gradient(135deg, #889 50%, transparent 50%);
  background-position: 18px 50%, 13px 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-left: 30px;
}
.input:focus { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(95, 138, 78, .15); }
.input.ltr { direction: ltr; text-align: right; }
textarea.input { min-height: 70px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.calc {
  background: #f6f4ec; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.calc b { font-size: 20px; }
.diff { font-size: 13px; font-weight: 600; margin-top: 6px; }
.diff.minus { color: var(--danger); }
.diff.plus { color: var(--ok); }
.photo-pick {
  border: 1.5px dashed #c9c5b5; border-radius: 14px; aspect-ratio: 16 / 9; display: grid; place-items: center;
  background: #faf8f1 center / cover no-repeat; color: var(--muted); text-align: center; font-size: 14px; position: relative; overflow: hidden;
}
.photo-pick svg { width: 32px; height: 32px; display: block; margin: 0 auto 4px; }
.photo-pick.has > div { background: rgba(0, 0, 0, .45); color: #fff; padding: 6px 10px; border-radius: 10px; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; }
.form-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }

/* ---------- כניסה ---------- */
.login {
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px;
  background: linear-gradient(170deg, var(--field) 0%, #22361f 100%); color: #fff;
}
.login .logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 14px; display: block; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.login h1 { text-align: center; margin: 0; font-size: 26px; }
.login p { text-align: center; opacity: .8; margin: 6px 0 26px; }
.login .box { background: #fff; color: var(--ink); border-radius: 20px; padding: 20px; max-width: 380px; width: 100%; margin: 0 auto; }
.pin-input { text-align: center; letter-spacing: 10px; font-size: 26px; direction: ltr; }
.pin-input::placeholder { letter-spacing: normal; font-size: 16px; direction: rtl; }

/* ---------- גיליון תחתון ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20, 28, 18, .45); opacity: 0; transition: opacity .2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; background: var(--bg);
  border-radius: 22px 22px 0 0; transform: translateY(100%); transition: transform .25s ease;
  display: flex; flex-direction: column; max-width: 720px; margin: 0 auto;
}
.sheet.open { pointer-events: auto; }
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: translateY(0); }
.sheet-grip { width: 40px; height: 5px; border-radius: 9px; background: #d4d0c2; margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; padding: 6px 12px 4px 16px; }
.sheet-head h2 { flex: 1; font-size: 19px; margin: 0; }
.sheet-body { overflow-y: auto; padding: 8px 16px calc(20px + var(--safe-b)); }

/* ---------- חיווי ---------- */
.busy { position: fixed; inset: 0; z-index: 80; background: rgba(245, 242, 233, .55); display: none; place-items: center; }
.busy.on { display: grid; }
.spinner { width: 42px; height: 42px; border: 4px solid #d8dccf; border-top-color: var(--field); border-radius: 50%; animation: spin .8s linear infinite; }
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 74px); transform: translate(-50%, -12px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 15px; z-index: 90;
  opacity: 0; transition: all .2s; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }
.offline { background: #fbefd0; color: #7a5208; font-size: 13px; text-align: center; padding: 6px; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 560px) {
  .tgrid { grid-template-columns: repeat(3, 1fr); }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile { flex-direction: column; text-align: center; }
  .tile .chev { display: none; }
}
