/* ===== צבעים (בהיר / כהה), לפי הלוגו: בורדו ושמנת ===== */
:root {
  color-scheme: light dark;
  --brand: #46040c;      /* הבורדו של הלוגו */
  --brand-ink: #eed5b9;  /* השמנת של הלוגו */
  --bg: #f8f2ea;
  --card: #fffdf9;
  --ink: #2a1215;
  --mute: #7a6266;
  --line: #eadfd2;
  --acc: #5a0b16;
  --acc-ink: #f6e6d0;
  --acc-soft: #f3e4e1;
  --warn: #c2550a;
  --chip: #f1e7da;
  --shadow: 0 1px 2px #46040c10;

  --s0: #e8eef8; --s0-ink: #2a4a7a;   /* ליד חדש */
  --s1: #f3ecdc; --s1-ink: #7a5a1c;   /* שיחת היכרות */
  --s2: #efe4f3; --s2-ink: #66307a;   /* הצעת מחיר */
  --s3: #e3efe9; --s3-ink: #2f6f5e;   /* נסגר */
  --s4: #d7ecd9; --s4-ink: #1f6a2b;   /* פעיל */
  --s5: #eeeeec; --s5-ink: #6b6b66;   /* אבוד */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #170a0c;
    --card: #241316;
    --ink: #f3e6d6;
    --mute: #b59f96;
    --line: #3a2226;
    --acc: #e9cfae;
    --acc-ink: #3a060d;
    --acc-soft: #3a1d20;
    --warn: #f08a5d;
    --chip: #301a1d;
    --shadow: none;
    --s0: #1f2a3b; --s0-ink: #9dbbe8;
    --s1: #352d1d; --s1-ink: #e0c27e;
    --s2: #33243a; --s2-ink: #d2a3e3;
    --s3: #22352e; --s3-ink: #8fd3bd;
    --s4: #1e3522; --s4-ink: #8fd69b;
    --s5: #2c2c29; --s5-ink: #a09f98;
  }
}

/* ===== בסיס ===== */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding-inline: 16px;
}

main.wrap { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

h1, h2, h3 { margin: 0; line-height: 1.25; }

/* ===== כותרת וכרטיסיות ===== */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand);
  color: var(--brand-ink);
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  padding-bottom: 10px;
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.brand-logo { width: 46px; height: 31px; object-fit: cover; border-radius: 6px; flex: none; }
.brand h1 { font: 500 21px/1.2 'Didot', 'Bodoni 72', 'Bodoni MT', Georgia, serif; letter-spacing: 0.01em; }
.brand-name {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.75;
  direction: ltr;
  margin-inline-start: auto;
}
.top .link { color: var(--brand-ink); font-size: 14px; }
.status { font-size: 13px; opacity: 0.8; }
.top .status.late { color: #ffb48a; opacity: 1; }

/* מה שמוצג רק אחרי כניסה */
body:not([data-mode='app']) .only-app { display: none; }
.login-logo { display: block; width: 168px; height: 168px; margin: 28px auto 0; border-radius: 22px; box-shadow: 0 6px 24px #46040c33; }
.login { max-width: 400px; margin: 24px auto 0; padding: 20px; }
.login h2 { font-size: 19px; margin-bottom: 14px; }
.login .btn { width: 100%; margin-top: 4px; }
.form-error { color: var(--warn); font-size: 14px; margin: 0 0 10px; }
.form-error:empty, .form-ok:empty { display: none; }
.form-ok { color: var(--acc); font-size: 14px; margin: 0 0 10px; }
.login .forgot { display: block; margin: 14px auto 0; font-size: 14px; }
.center { text-align: center; margin-top: 40px; }
.center p { margin: 8px 0 14px; color: var(--mute); }

.tabs { display: flex; gap: 6px; }
.tab {
  flex: 1;
  text-align: center;
  padding: 9px 4px;
  border-radius: 10px;
  border: 1px solid #eed5b940;
  background: #eed5b912;
  color: var(--brand-ink);
  text-decoration: none;
  font-size: 15px;
}
.tab.on { background: var(--brand-ink); border-color: var(--brand-ink); color: var(--brand); font-weight: 600; }

/* ===== הודעות ===== */
.notice {
  margin: 12px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--chip);
  color: var(--mute);
  font-size: 13px;
}
.notice.warn { color: var(--warn); }

.empty { color: var(--mute); margin: 8px 0 16px; }

.toast {
  position: fixed;
  inset-inline: 16px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  margin: 0 auto;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  text-align: center;
  z-index: 40;
  animation: fade-in 0.15s ease-out;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }

/* ===== אזורים ===== */
section { margin-top: 20px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 17px; margin: 20px 0 10px; }
section > .section-title { margin-top: 0; }
.count { font-size: 13px; font-weight: 500; color: var(--mute); background: var(--chip); padding: 1px 9px; border-radius: 99px; }

/* ===== כרטיסים ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.card-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta { color: var(--mute); font-size: 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.notes { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.late { color: var(--warn); }

.badge { font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 99px; background: var(--chip); }
.stage-0 { background: var(--s0); color: var(--s0-ink); }
.stage-1 { background: var(--s1); color: var(--s1-ink); }
.stage-2 { background: var(--s2); color: var(--s2-ink); }
.stage-3 { background: var(--s3); color: var(--s3-ink); }
.stage-4 { background: var(--s4); color: var(--s4-ink); }
.stage-5 { background: var(--s5); color: var(--s5-ink); }

.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pill {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--acc);
  text-decoration: none;
  font-size: 14px;
}

/* ===== משימות ===== */
.task { display: flex; align-items: center; gap: 12px; }
.task input[type='checkbox'] { width: 22px; height: 22px; flex: none; accent-color: var(--acc); margin: 0; }
.grow { flex: 1; min-width: 0; }
.task-title { font-weight: 500; }
.task.done .task-title { text-decoration: line-through; color: var(--mute); }
.auto { font-size: 12px; background: var(--acc-soft); color: var(--acc); padding: 0 8px; border-radius: 99px; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--acc);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--mute);
  font-size: 16px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--chip); color: var(--warn); }

.add-task { margin-top: 16px; }
.add-task .btn { width: 100%; margin-top: 4px; }

/* ===== לידים ===== */
.toolbar { display: flex; gap: 8px; margin-top: 16px; }
.toolbar input { flex: 1; }
.toolbar .btn { flex: none; }

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 0;
  margin-bottom: 4px;
  scrollbar-width: none;
}
.chip {
  flex: none;
  padding: 6px 12px;
  border-radius: 99px;
  border: 0;
  background: var(--chip);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.chip.on { background: var(--acc); color: var(--acc-ink); }

/* ===== סיכום ===== */
.stats { padding-block: 4px; }
.stat { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stat:last-child { border-bottom: 0; }
.stats .hint { margin: -6px 0 0; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.stats + .section-title, .card + .section-title { margin-top: 22px; }

/* ===== טפסים ===== */
input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* מונע הגדלה אוטומטית באייפון */
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 1px;
  border-color: transparent;
}

.field { display: block; margin-bottom: 10px; }
.field-label { display: block; font-size: 14px; color: var(--mute); margin-bottom: 4px; }
.hint { display: block; font-size: 13px; color: var(--mute); margin: 0 0 10px; }
.hint:empty { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.btn {
  padding: 11px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--acc);
  color: var(--acc-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.secondary { background: var(--chip); color: var(--ink); font-weight: 500; }
.btn.danger { background: none; color: var(--warn); margin-inline-start: auto; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.fab {
  position: fixed;
  inset-inline-start: max(16px, calc(50% - 364px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 58px;
  height: 58px;
  padding: 0;
  border-radius: 50%;
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
  box-shadow: 0 4px 14px #0000003a;
  z-index: 20;
}

/* ===== חלון שעולה מלמטה ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: #00000070;
}
.sheet {
  width: 100%;
  max-width: 760px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
}
.sheet h2 { font-size: 19px; margin-bottom: 12px; }
.sheet .pills { margin: 0 0 14px; }
.lead-tasks { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.lead-tasks h3 { font-size: 15px; margin-bottom: 6px; }
.lead-tasks ul { margin: 0; padding-inline-start: 20px; }
.lead-tasks li { margin-bottom: 4px; }

@media (min-width: 700px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 18px; max-width: 560px; }
}

.brand h1, .brand-name { white-space: nowrap; }
@media (max-width: 460px) {
  .brand-name { display: none; }
  .brand .status { margin-inline-start: auto; }
  .brand .status:empty + .brand-name + .link,
  .brand .status:empty ~ .link { margin-inline-start: auto; }
}

@media (max-width: 380px) {
  .grid-2 { grid-template-columns: 1fr; }
  .tab { font-size: 14px; }
}

/* ===== תפריט תחתון ===== */
.bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  flex: 1;
  max-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 7px;
  color: var(--mute);
  text-decoration: none;
  font-size: 12px;
}
.nav-item svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.on { color: var(--acc); font-weight: 600; }
.nav-item.on svg { stroke-width: 2.2; }
main.wrap { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
.toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }

/* ===== דף הבית ===== */
.hero { margin: 18px 0 14px; }
.hero-date { font-size: 13px; color: var(--mute); }
.hero h2 { font: 500 26px/1.2 'Didot', 'Bodoni 72', 'Bodoni MT', Georgia, serif; margin: 2px 0 4px; color: var(--acc); }
.hero p { margin: 0; color: var(--mute); }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.kpi-label { font-size: 13px; color: var(--mute); }
.kpi b { font-size: 21px; font-weight: 600; }
.kpi-sub { font-size: 12px; color: var(--mute); }

.alerts { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #f0c9a8;
  border-radius: 12px;
  background: #fff4ec;
  color: #8a3a06;
  font: inherit;
  font-size: 14px;
  text-align: start;
  cursor: pointer;
}
.alert > span {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--warn);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .alert { background: #3a1f12; border-color: #6b3a1c; color: #f6c7a4; }
}

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.quick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.quick-icon {
  width: 100%;
  max-width: 76px;
  aspect-ratio: 1.25;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 22px;
}

.rows { padding: 0; overflow: hidden; }
.row-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.row-btn:last-child { border-bottom: 0; }
.row-name { flex: 1; font-weight: 500; }
.more-link { display: inline-block; margin: 2px 0 6px; color: var(--acc); font-size: 14px; }

/* ===== לקוחות ותשלומים ===== */
.pill { font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pay-paid { background: var(--s4); color: var(--s4-ink); }
.pay-due { background: var(--chip); color: var(--mute); }
.pay-late { background: #fde6d6; color: #8a3a06; }
.toolbar .btn { white-space: nowrap; }

.sheet-section { font-size: 15px; margin: 18px 0 8px; color: var(--acc); }
.sheet form > .sheet-section:first-child { margin-top: 4px; }
.sheet-block { margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.pay-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; }
.pay-toggle {
  min-width: 96px;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--mute);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.pay-toggle.paid { background: var(--s4); border-color: transparent; color: var(--s4-ink); font-weight: 600; }
.plain-list { margin: 0 0 10px; padding-inline-start: 20px; }
.plain-list li { margin-bottom: 4px; }
.btn.block { display: block; width: 100%; margin-bottom: 12px; }
.btn.small { padding: 8px 14px; font-size: 14px; margin-bottom: 8px; }
.logout-row { justify-content: center; margin-top: 24px; }

/* ===== קמפיינים ===== */
.row-sub { display: block; font-size: 12.5px; font-weight: 400; color: var(--mute); margin-top: 2px; }
.results { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.result-row { display: grid; grid-template-columns: 1.3fr 1fr 0.8fr 0.9fr; gap: 6px; align-items: center; }
.result-row.head { font-size: 12px; color: var(--mute); }
.result-row input { padding: 8px; font-size: 16px; }
.result-month { font-size: 14px; }
.cpl { font-weight: 600; text-align: center; font-size: 14px; }
