:root {
  --bg: #012624; --bg-card: #011d1c; --bg-field: #003734; --bg-surface: #012f2c;
  --gold: #f3d300; --gold-dim: rgba(243,211,0,.10); --gold-ring: rgba(243,211,0,.28);
  --teal: #00827c; --teal-light: #00c8c2; --teal-dim: rgba(0,130,124,.14);
  --accent: #b34700;
  --text: #ffffff; --text-sub: #bbc7c6; --text-dim: #8a9493;
  --border: rgba(203,255,252,.08); --border-hi: rgba(203,255,252,.16);
  --r-lg: 16px; --r-sm: 8px;
  --shadow: 0 0 0 1px rgba(203,255,252,.06), 0 12px 40px rgba(0,0,0,.55);
  --font-h1: 'Heebo', 'Assistant', Arial, sans-serif;
  --font-h2: 'Rubik', 'Assistant', Arial, sans-serif;
  --font-body: 'Assistant', 'Heebo', Arial, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #edfffe; --bg-card: #ffffff; --bg-field: #f0fffe; --bg-surface: #e5fffe;
    --gold: #8a7600; --gold-dim: rgba(196,168,0,.12); --gold-ring: rgba(196,168,0,.35);
    --teal: #006b66; --teal-light: #007f7a; --teal-dim: rgba(0,107,102,.10);
    --accent: #8f3800;
    --text: #012624; --text-sub: #3a6665; --text-dim: #5f7f7e;
    --border: rgba(0,55,52,.10); --border-hi: rgba(0,55,52,.20);
    --shadow: 0 4px 24px rgba(0,0,0,.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text-sub);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { color: var(--text); margin: 0; }
h1 { font-family: var(--font-h1); font-weight: 900; }
h2 { font-family: var(--font-h2); font-weight: 900; font-size: 1.15rem; }
h3 { font-family: var(--font-body); font-weight: 800; font-size: 1rem; }
a { color: var(--teal-light); }
.dim { color: var(--text-dim); font-size: .85rem; }
.err { color: #ff8a3d; }
[hidden] { display: none !important; }

/* כפתורים ושדות */
.btn {
  font: 700 .95rem var(--font-body); border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--border-hi); background: var(--bg-field); color: var(--text);
  padding: .5rem .9rem; display: inline-flex; align-items: center; gap: .35rem;
  text-decoration: none; min-height: 40px; white-space: nowrap;
}
.btn:hover { border-color: var(--gold-ring); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
.btn-gold { background: #f3d300; color: #012624; border-color: #f3d300; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 34px; padding: .3rem .7rem; font-size: .85rem; }
.btn-lg { min-height: 52px; padding: .8rem 1.6rem; font-size: 1.05rem; }
.btn-icon { width: 40px; justify-content: center; padding: 0; font-size: 1.1rem; }
input, select, textarea {
  font: 400 1rem var(--font-body); color: var(--text); background: var(--bg-field);
  border: 1px solid var(--border-hi); border-radius: var(--r-sm); padding: .5rem .7rem;
  min-height: 40px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--text-dim); margin-bottom: .2rem; font-weight: 600; }
.field { margin-bottom: .75rem; }

/* כניסה */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  background: var(--bg-card); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 2.5rem 2rem; text-align: center; max-width: 380px; width: 100%;
}
.login-card h1 { font-size: 2rem; margin-bottom: .5rem; }
.login-card .sub { margin: 0 0 1.5rem; }

/* מסגרת */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem; padding: .6rem 16px;
  padding-top: max(.6rem, env(safe-area-inset-top));
}
.brand { font-size: 1.3rem; }
.tabs { display: flex; gap: .25rem; flex: 1; }
.tabs a {
  color: var(--text-sub); text-decoration: none; font-weight: 700;
  padding: .45rem .8rem; border-radius: var(--r-sm);
}
.tabs a.on { background: var(--gold-dim); color: var(--gold); }
.top-side { display: flex; align-items: center; gap: .6rem; }
.view { padding: 16px; max-width: 1200px; margin: 0 auto; padding-bottom: 96px; }

.card {
  background: var(--bg-card); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 1rem 1.1rem; min-width: 0;
}
.card > h2 { margin-bottom: .75rem; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* מונים */
.stat { cursor: pointer; text-align: start; border: 1px solid transparent; font: inherit; color: inherit; width: 100%; }
.stat:hover { border-color: var(--gold-ring); }
.stat .n { font: 900 2.2rem var(--font-h1); color: var(--text); line-height: 1.1; }
.stat .l { font-weight: 700; }
.stat.hl .n { color: var(--gold); }

/* גרף סטטוסים */
.bars { display: grid; gap: .45rem; }
.bar {
  display: grid; grid-template-columns: 9.5rem 1fr 2.5rem; align-items: center; gap: .6rem;
  background: none; border: 0; padding: .2rem 0; color: inherit; font: inherit; cursor: pointer; text-align: start;
}
.bar:hover .bar-fill { filter: brightness(1.15); }
.bar-track { background: var(--bg-field); border-radius: 99px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; min-width: 3px; }
.bar-n { font-weight: 800; color: var(--text); text-align: end; }
.bar-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .55rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .6rem; align-items: center; }
.list li:last-child { border-bottom: 0; }
.list .when { color: var(--gold); font-weight: 700; min-width: 7.5rem; font-size: .9rem; }
.empty { color: var(--text-dim); padding: .5rem 0; }

/* סרגל כלים ברשימה */
.toolbar { display: grid; grid-template-columns: 1fr 13rem 13rem auto; gap: .6rem; margin-bottom: .8rem; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .6rem; scrollbar-width: thin; }
.chip {
  border: 1px solid var(--border-hi); background: var(--bg-card); color: var(--text-sub);
  border-radius: 99px; padding: .3rem .8rem; font: 700 .85rem var(--font-body); cursor: pointer; white-space: nowrap;
  display: inline-flex; gap: .35rem; align-items: center; min-height: 34px;
}
.chip.on { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }
.chip .c { opacity: .75; font-weight: 600; }
.dot { width: .6rem; height: .6rem; border-radius: 50%; display: inline-block; flex: none; }

/* שורות לידים */
.leads { display: grid; gap: .5rem; }
.lead {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.6fr) 12rem auto; gap: .8rem; align-items: center;
  background: var(--bg-card); border-radius: var(--r-lg); padding: .7rem 1rem; border: 1px solid var(--border);
}
.lead:hover { border-color: var(--border-hi); }
.lead-name { color: var(--text); font-weight: 800; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-sub { font-size: .85rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-src { font-size: .85rem; overflow: hidden; }
.lead-src div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-act { display: flex; gap: .35rem; }
.status-sel { font-weight: 700; border-inline-start: 5px solid var(--sc, var(--border-hi)); }
.tag {
  display: inline-block; font-size: .75rem; font-weight: 700; padding: .05rem .5rem; border-radius: 99px;
  background: var(--teal-dim); color: var(--teal-light); margin-inline-end: .25rem;
}
.tag.gold { background: var(--gold-dim); color: var(--gold); }
.tag.warn { background: rgba(179,71,0,.18); color: #ff8a3d; }
.next { font-size: .8rem; color: var(--gold); font-weight: 700; }
.next.late { color: #ff8a3d; }

/* כרטיס ליד */
.lead-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.lead-head h1 { font-size: 1.7rem; }
.lead-title { flex: 1 1 16rem; min-width: 0; }
.kv { display: grid; grid-template-columns: 8rem 1fr; gap: .35rem .8rem; font-size: .92rem; }
.kv dt { color: var(--text-dim); font-weight: 600; }
.kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.subtabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: .8rem; }
.subtabs button {
  background: none; border: 0; color: var(--text-sub); font: 700 .95rem var(--font-body); padding: .5rem .8rem;
  cursor: pointer; border-bottom: 2px solid transparent; min-height: 40px;
}
.subtabs button.on { color: var(--gold); border-bottom-color: var(--gold); }
.act { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.act:last-child { border-bottom: 0; }
.act-meta { font-size: .8rem; color: var(--text-dim); }
.act-body { color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.task { display: flex; gap: .6rem; align-items: flex-start; }
.task input[type=checkbox] { width: 22px; height: 22px; min-height: 0; margin-top: .15rem; accent-color: var(--gold); }
.task.done .act-body { text-decoration: line-through; color: var(--text-dim); }

/* פגישות */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: start; color: var(--text-dim); font-weight: 700; padding: .5rem; border-bottom: 1px solid var(--border-hi); }
.table td { padding: .55rem .5rem; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.table select { min-height: 34px; padding: .2rem .4rem; width: auto; }

/* חלון */
dialog {
  border: 0; border-radius: var(--r-lg); background: var(--bg-card); color: var(--text-sub);
  box-shadow: var(--shadow); padding: 1.3rem; width: min(480px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin-bottom: 1rem; }
.form2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .7rem; }
.form2 .full { grid-column: 1 / -1; }

.toast {
  position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); inset-inline-start: 50%; transform: translateX(50%);
  background: #f3d300; color: #012624; font-weight: 800; padding: .6rem 1.1rem; border-radius: 99px;
  box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px);
}
.toast.bad { background: #b34700; color: #fff; }

/* נייד */
@media (max-width: 860px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g2 { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .search { grid-column: 1 / -1; }
  .lead { grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
  .lead-src { grid-column: 1 / -1; order: 3; }
  .lead-status { grid-column: 1 / -1; order: 4; }
  .lead-act { order: 2; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: .4rem; }
  .brand { font-size: 1.1rem; }
  .tabs {
    order: 3; flex-basis: 100%; position: fixed; bottom: 0; inset-inline: 0; z-index: 20;
    background: var(--bg-card); border-top: 1px solid var(--border-hi); justify-content: space-around;
    padding: .4rem .5rem max(.4rem, env(safe-area-inset-bottom));
  }
  .tabs a { flex: 1; text-align: center; }
  .top-side { margin-inline-start: auto; }
  .stat .n { font-size: 1.8rem; }
  .bar { grid-template-columns: 7rem 1fr 2rem; }
  .kv { grid-template-columns: 6.5rem 1fr; }
  .lead-head h1 { font-size: 1.45rem; }
  .form2 { grid-template-columns: 1fr; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { background: var(--bg-card); border-radius: var(--r-lg); padding: .6rem .8rem; margin-bottom: .5rem; }
  .table td { border: 0; padding: .15rem 0; }
  .table td[data-l]::before { content: attr(data-l) ': '; color: var(--text-dim); font-weight: 600; }
}
