:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e8eaed;
  --border-strong: #d8dbe0;
  --text: #1d2029;
  --text-soft: #616b7a;
  --text-faint: #657082;
  --brand: #dc5f3b;          /* טרקוטה */
  --brand-dark: #c44e2d;
  --brand-soft: #fdeee8;
  --red: #c73840;
  --blue: #2f6feb;
  --green: #16a34a;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --shadow-lg: 0 12px 34px rgba(16,24,40,.16);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Heebo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* ───────── כפתורים ───────── */
.btn {
  font-size: 14px; font-weight: 600;
  border: 1px solid transparent; border-radius: 9px;
  padding: 9px 16px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--on-brand, #fff); box-shadow: 0 2px 6px rgba(220,95,59,.28); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--text-soft); border-color: var(--border-strong); }
.btn-ghost:hover { background: #eef0f3; color: var(--text); }
.btn-danger { background: transparent; color: var(--red); border-color: transparent; }
.btn-danger:hover { background: #fdecec; }
.btn-block { width: 100%; }

/* ───────── מסך התחברות ───────── */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #dc5f3b 0%, #e8895f 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface); width: 100%; max-width: 380px;
  padding: 36px 32px; border-radius: 18px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 14px;
}
.login-logo { font-size: 27px; font-weight: 900; color: var(--brand); text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 8px; }
.login-sub { text-align: center; color: var(--text-soft); margin-bottom: 8px; }
.logo-dot { width: 14px; height: 14px; border-radius: 5px; background: var(--brand); display: inline-block; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; color: var(--text-soft); }
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 9px; padding: 9px 11px;
  outline: none; transition: border-color .15s, box-shadow .15s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(220,95,59,.15); }
textarea { resize: vertical; }
.form-error { background: #fdecec; color: var(--red); border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 500; }

/* ───────── פריסה ───────── */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* סרגל צד */
.sidebar {
  width: 264px; min-width: 264px; height: 100vh;
  background: var(--surface); border-inline-start: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.side-logo { font-size: 21px; font-weight: 900; color: var(--brand);
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 14px; }
.side-search { position: relative; margin-bottom: 12px; }
.side-search input { padding-inline-start: 34px; background: var(--bg); border-color: transparent; }
.side-search input:focus { background: var(--surface); }
.search-ic { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .5; }

.side-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: start;
  background: transparent; border: none; border-radius: 9px; padding: 10px 12px;
  font-size: 14.5px; font-weight: 600; color: var(--text); cursor: pointer; margin-bottom: 2px;
}
.nav-item:hover { background: #f1f2f4; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav-ic { font-size: 15px; }

.side-section { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 6px; }
.side-section-title { font-size: 11.5px; font-weight: 700; color: var(--text-faint); letter-spacing: .04em; }
.side-add {
  width: 22px; height: 22px; border-radius: 6px; border: none; background: transparent;
  color: var(--text-faint); font-size: 17px; line-height: 1; cursor: pointer;
}
.side-add:hover { background: #f1f2f4; color: var(--brand); }

.side-projects { list-style: none; display: flex; flex-direction: column; }
.project-item {
  display: flex; align-items: center; gap: 10px; border-radius: 9px; padding: 9px 12px;
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 1px;
  background: transparent; border: none; width: 100%; text-align: start; font-family: inherit;
}
.project-item:hover { background: #f1f2f4; }
.project-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.project-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.project-item .p-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item .p-count { font-size: 12px; color: var(--text-faint); font-weight: 700; }

.side-user {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 4px;
  border-top: 1px solid var(--border); margin-top: 8px;
}
.side-user-info { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.side-user-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-role { font-size: 11.5px; color: var(--text-faint); }
.side-logout { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-soft); font-size: 16px; cursor: pointer; }
.side-logout:hover { background: #fdecec; color: var(--red); border-color: #f3caca; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}

/* ───────── אזור ראשי ───────── */
.main { flex: 1; overflow-y: auto; padding: 30px 36px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 6px; flex-wrap: wrap; }
.page-title { font-size: 27px; font-weight: 800; }
.page-sub { color: var(--text-faint); font-size: 14px; font-weight: 600; margin-bottom: 20px; }
.greeting { font-size: 27px; font-weight: 800; }
.greeting span { color: var(--brand); }

/* כפתורי סינון (גלולות) */
.filter-row { display: flex; align-items: center; gap: 12px; margin: 20px 0 22px; flex-wrap: wrap; }
.filter-row .pills { margin: 0; flex: 1; }
.assignee-filter { width: auto; min-width: 160px; padding: 7px 12px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; flex-shrink: 0; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 22px; }
.pill {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-soft);
  border-radius: 20px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: all .12s;
}
.pill:hover { border-color: var(--text-faint); }
.pill.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand, #fff); }
.pill .pill-dot { width: 8px; height: 8px; border-radius: 50%; }
.pill .pill-count { background: rgba(0,0,0,.08); border-radius: 10px; padding: 0 7px; font-size: 11.5px; }
.pill.active .pill-count { background: rgba(0,0,0,.18); }

/* הוספה מהירה */
.quick-add {
  display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 11px; padding: 8px 12px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.quick-add .qa-plus { color: var(--brand); font-size: 20px; font-weight: 700; }
.quick-add input[type=text] { border: none; padding: 6px 2px; box-shadow: none; }
.quick-add input[type=text]:focus { box-shadow: none; }
.quick-add input[type=date] { width: auto; border-color: var(--border); color: var(--text-soft); }

/* ───────── טבלת משימות ───────── */
.task-table { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.table-head {
  display: grid; grid-template-columns: 34px minmax(150px, 1.3fr) 128px 128px 112px 120px 40px; gap: 10px; align-items: center;
  padding: 11px 16px; font-size: 12px; font-weight: 700; color: var(--text-faint);
  border-bottom: 1px solid var(--border); background: #fafbfc;
}

.group { border-bottom: 1px solid var(--border); }
.group:last-child { border-bottom: none; }
.group-head {
  display: flex; align-items: center; gap: 8px; padding: 11px 16px; cursor: pointer; user-select: none;
  font-weight: 700; font-size: 13.5px;
}
.group-head:hover { background: #fafbfc; }
.group-caret { font-size: 10px; color: var(--text-faint); transition: transform .15s; width: 12px; }
.group.collapsed .group-caret { transform: rotate(-90deg); }
.group-count { background: #eef0f3; color: var(--text-soft); border-radius: 20px; padding: 0 9px; font-size: 12px; font-weight: 700; }
.group.g-overdue .group-title { color: var(--red); }
.group.g-upcoming .group-title { color: var(--blue); }
.group.collapsed .group-body { display: none; }

.task-row {
  display: grid; grid-template-columns: 34px minmax(150px, 1.3fr) 128px 128px 112px 120px 40px; gap: 10px; align-items: center;
  padding: 10px 16px; border-top: 1px solid var(--border); position: relative;
}
.task-row:hover { background: #fafbfc; }
.group-body .task-row:first-child { border-top: 1px dashed var(--border); }

/* עיגול השלמה */
.check {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong);
  background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; transition: all .12s; flex-shrink: 0;
}
.check:hover { border-color: var(--green); }
.check.done { background: var(--green); border-color: var(--green); }

.t-title { font-weight: 600; cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.t-title:hover { color: var(--brand); }
.task-row.done .t-title { text-decoration: line-through; color: var(--text-faint); }
.t-desc-ic { font-size: 11px; opacity: .5; margin-inline-start: 4px; }
.t-recur-ic { font-size: 11px; margin-inline-start: 4px; opacity: .85; }
.t-flag { font-size: 13px; font-weight: 700; }
.recurrence-hint { font-size: 12.5px; color: var(--text-soft); background: #f6f7f9; border-radius: 8px; padding: 9px 12px; line-height: 1.55; }

.t-project { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border-radius: 20px; padding: 3px 10px; background: #f1f2f4; width: fit-content; }
.t-project.empty { color: var(--text-faint); background: transparent; }
.t-project .project-dot { width: 8px; height: 8px; }

.t-status { display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; cursor: pointer; text-align: center;
  border-radius: 6px; padding: 3px 8px; width: 100%; max-width: 104px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.group-title .status-dot { width: 10px; height: 10px; }
.group-title { display: inline-flex; align-items: center; gap: 8px; }

.t-due { font-size: 13px; color: var(--text-soft); font-weight: 600; cursor: pointer; border-radius: 7px; padding: 3px 8px; width: fit-content; }
.t-due:hover { background: #eef0f3; }
.t-due.overdue { color: var(--red); }
.t-due.today { color: var(--brand-dark); font-weight: 700; }
.t-due.empty { color: var(--text-faint); }

.t-assignee { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-soft); font-weight: 600;
  cursor: pointer; border-radius: 8px; padding: 3px 6px; width: fit-content; }
.t-assignee:hover { background: #eef0f3; }
.mini-avatar { width: 24px; height: 24px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.t-assignee.empty .mini-avatar { background: #d5d9df; color: #7a828e; }

.t-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
.task-row:hover .t-actions { opacity: 1; }
.row-btn { width: 28px; height: 28px; border-radius: 7px; border: none; background: transparent; cursor: pointer;
  color: var(--text-faint); font-size: 14px; }
.row-btn:hover { background: #eef0f3; color: var(--text); }
.row-btn.del:hover { background: #fdecec; color: var(--red); }

.inline-input { padding: 4px 8px; font-size: 13px; }

.empty-state { text-align: center; color: var(--text-faint); padding: 60px 20px; }
.empty-state .es-emoji { font-size: 40px; display: block; margin-bottom: 10px; }

/* ───────── הגדרות ───────── */
.settings-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
.settings-grid .card.span-2 { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-head h2 { font-size: 16px; font-weight: 700; }
.card-body { padding: 16px 20px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; row-gap: 8px; }
.user-row:last-child { border-bottom: none; }
.user-meta { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-width: 130px; }
.user-meta .u-name { font-weight: 700; }
.user-meta .u-email { font-size: 12.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-tag { font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: 20px; letter-spacing: .03em; flex-shrink: 0; }
.role-admin { background: var(--brand-soft); color: var(--brand-dark); }
.role-member { background: #eef0f3; color: var(--text-soft); }
.user-row-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-inline-start: auto; }
.icon-btn { background: transparent; border: 1px solid var(--border-strong); border-radius: 7px; padding: 5px 9px;
  cursor: pointer; font-size: 12.5px; color: var(--text-soft); }
.icon-btn:hover { background: #eef0f3; color: var(--text); }
.icon-btn.danger:hover { background: #fdecec; color: var(--red); border-color: #f3caca; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.add-user-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.add-user-form .form-row { display: flex; gap: 10px; }
.color-row { display: flex; align-items: center; gap: 10px; }
.favicon-row { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.favicon-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.favicon-preview { width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--border); background: #fff; object-fit: contain; padding: 3px; }
.favicon-pick { cursor: pointer; }
.color-hex { font-size: 12.5px; color: var(--text-soft); font-family: monospace; text-transform: uppercase; }
.status-editor { margin-top: 6px; }
.se-title { font-size: 12px; font-weight: 700; color: var(--text-faint); margin-bottom: 10px; }
.se-hint { font-size: 12px; color: var(--text-faint); margin-bottom: 12px; line-height: 1.5; }
.se-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-weight: 600; }
.se-row input[type=color] { width: 34px; height: 32px; flex-shrink: 0; padding: 2px; }
.se-label { flex: 1; padding: 6px 9px; font-weight: 600; }
.se-type { width: auto; padding: 6px 8px; }
.add-status-form { display: flex; gap: 8px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.add-status-form input[type=color] { width: 40px; height: 38px; flex-shrink: 0; }
.add-status-form input[type=text] { flex: 1; }
.add-status-form select { width: auto; }

/* בחירת פרויקטים ללקוח */
.client-projects { padding: 4px 0; }
.cp-title { font-size: 12.5px; font-weight: 700; color: var(--text-soft); margin-bottom: 8px; }
.check-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; user-select: none; }
.check-pill:hover { border-color: var(--brand); }
.check-pill input { width: auto; margin: 0; accent-color: var(--brand); }
.check-pill .project-dot { width: 9px; height: 9px; }
.role-client { background: #e0f2fe; color: #0369a1; }
.role-supplier { background: #fef3c7; color: #92400e; }

/* ───────── חלוניות ───────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,24,31,.5); display: flex; align-items: center;
  justify-content: center; padding: 20px; z-index: 100; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 500px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-sm { max-width: 420px; }

/* ── חלונית צד (drawer) הנפתחת משמאל ── */
.drawer-overlay { justify-content: flex-start; align-items: stretch; padding: 0; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  height: 100vh; max-height: 100vh; width: 460px; max-width: 92vw;
  border-radius: 0; box-shadow: var(--shadow-lg); animation: drawer-in .22s ease;
}
@keyframes drawer-in { from { transform: translateX(-100%); opacity: .6; } to { transform: translateX(0); opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-close { background: transparent; border: none; font-size: 17px; cursor: pointer; color: var(--text-soft);
  width: 30px; height: 30px; border-radius: 6px; }
.modal-close:hover { background: #eef0f3; color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.spacer { flex: 1; }
.autosave-hint { font-size: 12.5px; color: var(--text-faint); font-weight: 600; transition: color .2s; }
.autosave-hint.saved { color: var(--green); }
.form-row { display: flex; gap: 12px; }
.form-row > label { flex: 1; }
input[type=color] { padding: 3px; height: 40px; width: 48px; cursor: pointer; }

/* ───────── טוסט ───────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1d2029; color: #fff;
  padding: 11px 20px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 200; animation: toast-in .2s ease; }
.toast.err { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ───────── רספונסיבי ───────── */
@media (max-width: 860px) {
  .settings-grid { grid-template-columns: 1fr; }
  .table-head, .task-row { grid-template-columns: 30px 1fr 104px 92px 36px; }
  .table-head .th-project, .task-row .t-project,
  .table-head .th-assignee, .task-row .t-assignee { display: none; }
}
@media (max-width: 680px) {
  .sidebar { position: fixed; z-index: 90; transform: translateX(100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 20px 16px 60px; }
  .mobile-menu-btn { display: inline-flex !important; }
}
.mobile-menu-btn { display: none; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 18px; cursor: pointer; }

/* ───────── נגישות: מיקוד מקלדת ───────── */
:focus-visible {
  outline: 2px solid var(--brand-dark);
  outline-offset: 2px;
  border-radius: 4px;
}
