/* ===== יהלומים של מיכל — עיצוב מותאם קודם כל לטלפון ===== */
:root {
  --brand-1: #7c4dff;
  --brand-2: #b06ab3;
  --brand-soft: #f2ecff;
  --bg: #f4f5fa;
  --card: #ffffff;
  --text: #1f2437;
  --muted: #6b7391;
  --line: #e6e8f0;
  --ok: #12b886;
  --ok-soft: #e5f8f1;
  --low: #f59f00;
  --low-soft: #fff6e5;
  --bad: #f03e3e;
  --bad-soft: #ffecec;
  --idle: #94a1b8;
  --idle-soft: #eef0f5;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 10px rgba(31, 36, 55, .06);
  --shadow-lg: 0 12px 32px rgba(31, 36, 55, .16);
  --nav-h: 68px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Rubik", "Heebo", "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

button, input, select, textarea { font-family: inherit; font-size: 1rem; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-1); text-decoration: none; }

/* ===== מסך התחברות ===== */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--brand-1), var(--brand-2));
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card); border-radius: 24px; padding: 28px 22px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { margin: 0 0 4px; font-size: 1.5rem; text-align: center; }
.login-card .sub { margin: 0 0 22px; text-align: center; color: var(--muted); font-size: .92rem; }
.demo-box {
  margin-top: 18px; padding: 12px 14px; background: var(--brand-soft);
  border-radius: var(--radius-sm); font-size: .82rem; color: #574b7a; line-height: 1.7;
}
.demo-box b { display: block; margin-bottom: 4px; }

/* ===== מבנה האפליקציה ===== */
.app { padding-bottom: calc(var(--nav-h) + 16px); }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(120deg, var(--brand-1), var(--brand-2));
  color: #fff; padding: 14px 16px 16px;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 4px 18px rgba(124, 77, 255, .25);
}
.topbar .row { display: flex; align-items: center; gap: 10px; }
.topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
.topbar .tag { font-size: .74rem; opacity: .88; }
.topbar .spacer { flex: 1; }
.topbar .who {
  background: rgba(255,255,255,.18); border: 0; color: #fff;
  border-radius: 999px; padding: 7px 13px; font-size: .8rem; display: flex; align-items: center; gap: 6px;
}
.back-btn {
  background: rgba(255,255,255,.2); border: 0; color: #fff;
  width: 34px; height: 34px; border-radius: 50%; font-size: 1.1rem; line-height: 1;
  display: grid; place-items: center;
}

main { padding: 16px 14px 8px; max-width: 1100px; margin: 0 auto; }

.page-title { display: flex; align-items: center; gap: 10px; margin: 4px 2px 14px; }
.page-title h2 { margin: 0; font-size: 1.18rem; font-weight: 600; }
.page-title .spacer { flex: 1; }

/* ===== ניווט תחתון ===== */
.tabbar {
  position: fixed; bottom: 0; right: 0; left: 0; z-index: 40;
  height: var(--nav-h);
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .68rem; padding: 6px 2px; position: relative;
}
.tabbar button .ic { font-size: 1.32rem; line-height: 1; }
.tabbar button.active { color: var(--brand-1); font-weight: 600; }
.tabbar .badge {
  position: absolute; top: 6px; inset-inline-start: calc(50% - 22px);
  background: var(--bad); color: #fff; border-radius: 999px;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: .66rem; display: grid; place-items: center;
}

/* ===== כרטיסים ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.card h3 { margin: 0 0 10px; font-size: 1rem; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); border-inline-start: 5px solid var(--brand-1);
}
.stat .lbl { font-size: .76rem; color: var(--muted); margin-bottom: 6px; }
.stat .val { font-size: 1.34rem; font-weight: 700; line-height: 1.2; }
.stat .sub { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.stat.ok  { border-color: var(--ok); }
.stat.low { border-color: var(--low); }
.stat.bad { border-color: var(--bad); }

/* ===== רשימות ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 13px 14px; display: flex; align-items: center; gap: 12px;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .name { font-weight: 600; font-size: 1rem; }
.list-item .meta { font-size: .78rem; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.avatar {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  background: var(--brand-soft); color: var(--brand-1);
  display: grid; place-items: center; font-weight: 700; font-size: 1rem;
}
.avatar.inactive { background: var(--idle-soft); color: var(--idle); }

.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.empty .ic { font-size: 2.4rem; display: block; margin-bottom: 8px; }

/* ===== תגיות סטטוס ===== */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap;
}
.pill.ok   { background: var(--ok-soft);   color: #0b7a5b; }
.pill.low  { background: var(--low-soft);  color: #a86a00; }
.pill.bad  { background: var(--bad-soft);  color: #c92a2a; }
.pill.idle { background: var(--idle-soft); color: #5b6478; }
.pill.brand{ background: var(--brand-soft); color: var(--brand-1); }

/* ===== כפתורים ===== */
.btn {
  border: 0; border-radius: 14px; padding: 12px 18px;
  font-weight: 600; font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--brand-1); color: #fff; transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.big { padding: 16px; font-size: 1.05rem; border-radius: 16px; }
.btn.ghost { background: var(--brand-soft); color: var(--brand-1); }
.btn.soft { background: var(--idle-soft); color: var(--text); }
.btn.danger { background: var(--bad-soft); color: #c92a2a; }
.btn.sm { padding: 8px 13px; font-size: .82rem; border-radius: 11px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn {
  border: 0; background: var(--idle-soft); color: var(--muted);
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 1rem; flex: none;
}

/* ===== טפסים ===== */
.field { margin-bottom: 13px; }
.field > label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 13px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); background: #fbfbfd; outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-1); background: #fff; }
.field textarea { min-height: 80px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkline { display: flex; align-items: center; gap: 9px; font-size: .9rem; }
.checkline input { width: 20px; height: 20px; accent-color: var(--brand-1); }

.searchbar { position: relative; margin-bottom: 12px; }
.searchbar input {
  width: 100%; padding: 13px 42px 13px 14px; border: 0; border-radius: 15px;
  background: var(--card); box-shadow: var(--shadow); outline: none;
}
.searchbar .ic { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 0; background: var(--card); color: var(--muted); box-shadow: var(--shadow);
  border-radius: 999px; padding: 8px 15px; font-size: .82rem; white-space: nowrap; font-weight: 500;
}
.chip.active { background: var(--brand-1); color: #fff; }

/* ===== טאבים ===== */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: var(--card); color: var(--muted); box-shadow: var(--shadow);
  padding: 9px 16px; border-radius: 12px; font-size: .86rem; white-space: nowrap; font-weight: 500;
}
.tabs button.active { background: var(--brand-1); color: #fff; font-weight: 600; }

/* ===== טבלאות ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 460px; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .76rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: left; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable:active { background: var(--brand-soft); }

/* ===== תשלומים מהירים ===== */
.payment-list { display: flex; flex-direction: column; gap: 10px; }
.payment-row { border: 1px solid var(--line); border-radius: 15px; padding: 12px; background: #fff; }
.payment-row.debt { border-color: #ffd4d4; background: #fffafa; }
.payment-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.payment-amounts { color: var(--muted); font-size: .78rem; line-height: 1.55; margin-top: 3px; }
.payment-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }

/* ===== ניהול שעות ===== */
.hours-summary { grid-template-columns: repeat(2, 1fr); }
.hours-list { display: flex; flex-direction: column; gap: 9px; }
.hours-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 15px; padding: 11px; }
.hours-row .grow { flex: 1; min-width: 0; }
.hours-row .name { font-weight: 600; }
.hours-row .meta { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.hours-total { color: var(--brand-1); white-space: nowrap; font-size: .9rem; }

@media (max-width: 560px) {
  .hours-row { flex-wrap: wrap; }
  .hours-row .grow { min-width: calc(100% - 58px); }
  .hours-total { margin-inline-start: 54px; }
}

/* ===== מבט ציוד כולל ===== */
.eq-overview table { min-width: max-content; }
.eq-overview th, .eq-overview td { text-align: center; min-width: 92px; }
.eq-overview .eq-child-col { position: sticky; right: 0; z-index: 2; min-width: 130px; text-align: right; background: #fff; box-shadow: -3px 0 6px rgba(31, 36, 55, .05); }
.eq-overview thead .eq-child-col { z-index: 3; background: #fff; }
.eq-child-link { border: 0; padding: 0; background: none; color: var(--text); font-weight: 700; text-align: right; }
.eq-cell span { margin-inline-end: 5px; }
.eq-cell.ok { background: var(--ok-soft); color: #0b7a5b; }
.eq-cell.missing { background: var(--bad-soft); color: #c92a2a; }

/* ===== בוררי מצב ציוד ===== */
.eq-item { padding: 13px 0; border-bottom: 1px solid var(--line); }
.eq-item:last-child { border-bottom: 0; }
.equipment-tip { margin-bottom: 8px; padding: 11px 12px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-2); font-size: .84rem; line-height: 1.55; }
.eq-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.eq-head .nm { font-weight: 600; flex: 1; }
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.seg button {
  border: 1.5px solid var(--line); background: #fff; color: var(--muted);
  padding: 11px 4px; border-radius: 13px; font-size: .82rem; font-weight: 600; transition: all .12s;
}
.seg button[data-v="ok"].on      { background: var(--ok-soft);  border-color: var(--ok);  color: #0b7a5b; }
.seg button[data-v="missing"].on { background: var(--bad-soft); border-color: var(--bad); color: #c92a2a; }
.qty-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.qty-row label { font-size: .78rem; color: var(--muted); }
.qty-row input { width: 90px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: #fbfbfd; }
.qty-row .note { flex: 1; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: #fbfbfd; min-width: 0; }

.sticky-save {
  position: sticky; bottom: calc(var(--nav-h) + 8px); z-index: 20;
  padding-top: 10px; background: linear-gradient(to top, var(--bg) 62%, transparent);
}

/* ===== התראות ===== */
.alert-item { display: flex; gap: 11px; align-items: flex-start; }
.alert-item .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; }
.alert-item.high .dot { background: var(--bad); }
.alert-item.medium .dot { background: var(--low); }
.alert-item .ttl { font-weight: 600; font-size: .93rem; line-height: 1.4; }
.alert-item .dsc { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.alert-item.done { opacity: .55; }

/* ===== ציר היסטוריה ===== */
.timeline { position: relative; padding-inline-start: 18px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 4px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before {
  content: ''; position: absolute; inset-inline-start: -18px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--brand-1); box-shadow: 0 0 0 3px var(--brand-soft);
}
.tl-item .when { font-size: .74rem; color: var(--muted); }
.tl-item .what { font-size: .9rem; margin-top: 2px; line-height: 1.5; }
.tl-item .chg { font-size: .78rem; margin-top: 3px; }
.tl-item .chg .from { color: var(--muted); text-decoration: line-through; }
.tl-item .chg .to { color: var(--text); font-weight: 600; }

/* ===== חלון קופץ ===== */
.modal-back {
  position: fixed; inset: 0; z-index: 100; background: rgba(20, 22, 34, .48);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.modal {
  background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: up .22s cubic-bezier(.2, .9, .3, 1);
}
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 1.1rem; flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(28px); opacity: .4; } }

/* ===== הודעות מערכת ===== */
#toasts { position: fixed; top: 14px; inset-inline: 14px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #23283d; color: #fff; padding: 11px 18px; border-radius: 14px;
  font-size: .88rem; box-shadow: var(--shadow-lg); animation: up .2s ease; max-width: 92vw;
}
.toast.ok { background: #0f9e78; }
.toast.err { background: #d64545; }

.loader { text-align: center; padding: 44px; color: var(--muted); }
.skeleton { height: 74px; border-radius: var(--radius); background: linear-gradient(90deg, #eceef4, #f6f7fb, #eceef4); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 10px; }
@keyframes sk { to { background-position: -200% 0; } }

.divider { height: 1px; background: var(--line); margin: 14px 0; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.total-banner {
  background: linear-gradient(120deg, var(--brand-1), var(--brand-2)); color: #fff;
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px; text-align: center;
}
.total-banner .lbl { font-size: .82rem; opacity: .9; }
.total-banner .val { font-size: 1.85rem; font-weight: 700; margin-top: 4px; }

.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  background: var(--card); border: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 15px 15px; font-size: .96rem; font-weight: 500;
}
.menu-list button .ic { font-size: 1.25rem; }
.menu-list button .arrow { margin-inline-start: auto; color: var(--muted); }

.bar { height: 8px; border-radius: 999px; background: var(--idle-soft); overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }

/* ===== מסך רחב ===== */
@media (min-width: 820px) {
  /* הניווט הופך לסרגל צד בצד ימין, והתוכן מוסט ממנו */
  .app { padding-bottom: 24px; padding-inline-start: 210px; }
  .tabbar {
    position: fixed; top: 0; bottom: 0; right: 0; left: auto;
    width: 210px; height: 100vh; flex-direction: column; padding: 18px 12px; gap: 4px;
    border-top: 0; border-inline-start: 1px solid var(--line); background: #fff;
  }
  .tabbar button {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    font-size: .92rem; padding: 13px 15px; border-radius: 13px;
  }
  .tabbar button.active { background: var(--brand-soft); }
  .tabbar .badge { position: static; margin-inline-start: auto; }
  .topbar { border-radius: 0 0 22px 0; padding: 18px 24px; }
  main { padding: 22px 24px; max-width: 1120px; margin: 0 auto; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .modal-back { align-items: center; }
  .modal { border-radius: 24px; }
  .sticky-save { bottom: 12px; }
  table { min-width: 0; }
}
