/* Mission Manager — עיצוב רספונסיבי RTL, נייד תחילה */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1c2333;
  --muted: #6b7488;
  --line: #e6e9f2;
  --brand: #3b5bdb;
  --brand-dark: #2f49b3;
  --brand-soft: #e7ecff;
  --danger: #d6336c;
  --danger-soft: #ffe3ec;
  --open: #f59f00;
  --progress: #3b82f6;
  --waiting: #a855f7;
  --closed: #22a06b;
  --closed-soft: #d3f4e5;
  --shadow: 0 2px 10px rgba(28, 35, 51, .06);
  --radius: 14px;
  --nav-h: 62px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", "Heebo", Arial, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  font-size: 15px;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 15px;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 10px; padding: 10px 12px; color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
h1, h2, h3 { margin: 0; }

/* ---------- מעטפת ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.topbar .logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.topbar h1 { font-size: 17px; flex: 1; }
.topbar .who { font-size: 12px; color: var(--muted); text-align: left; line-height: 1.3; }
.role-badge {
  display: inline-block; background: var(--brand-soft); color: var(--brand);
  padding: 1px 8px; border-radius: 20px; font-weight: 600; font-size: 11px;
}

.layout { flex: 1; display: flex; }
.content { flex: 1; padding: 16px; padding-bottom: calc(var(--nav-h) + 24px); max-width: 1100px; margin: 0 auto; width: 100%; }

/* ---------- ניווט תחתון (נייד) / צד (מחשב) ---------- */
.nav {
  position: fixed; bottom: 0; right: 0; left: 0; z-index: 30;
  background: var(--panel); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.nav button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; padding: 6px 2px;
}
.nav button .ic { font-size: 21px; line-height: 1; }
.nav button.active { color: var(--brand); font-weight: 700; }

@media (min-width: 900px) {
  .nav {
    position: static; flex-direction: column; justify-content: flex-start;
    width: 210px; border-top: 0; border-left: 1px solid var(--line); height: auto;
    padding: 14px 10px; gap: 4px; flex-shrink: 0;
  }
  .nav button {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px;
    font-size: 14px; padding: 12px 14px; border-radius: 10px; width: 100%;
  }
  .nav button.active { background: var(--brand-soft); }
  .nav button .ic { font-size: 18px; }
  .content { padding: 26px 32px; padding-bottom: 40px; }
}

/* ---------- כפתורים ---------- */
.btn {
  border: 0; background: var(--brand); color: #fff;
  padding: 11px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn:active { background: var(--brand-dark); }
.btn.ghost { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.success { background: var(--closed); }
.btn.sm { padding: 7px 13px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- כרטיסים ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.panel h3 { font-size: 15px; margin-bottom: 10px; }
.card-row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  padding: 3px 9px; border-radius: 20px; font-weight: 600; white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- מסך כניסה ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, var(--brand-soft), var(--bg) 60%);
}
.auth-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px 24px; width: 100%; max-width: 400px; box-shadow: 0 16px 50px rgba(28,35,51,.12);
}
.auth-card .logo-big {
  width: 54px; height: 54px; border-radius: 14px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 21px; margin: 0 auto 14px;
}
.auth-card h2 { text-align: center; font-size: 19px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin: 4px 0 10px; }

/* ---------- משימות ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select { width: auto; flex: 1; min-width: 130px; max-width: 240px; }
.task-card { padding: 14px 16px; }
.task-card .title { font-weight: 700; font-size: 15px; }
.task-card .meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 6px; }
.task-actions { display: flex; gap: 8px; margin-top: 12px; }
.task-actions .btn { flex: 1; }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--closed);
  background: var(--closed-soft); border-radius: 8px; padding: 6px 12px; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px;
}
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--closed); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.fab {
  position: fixed; bottom: calc(var(--nav-h) + 18px); left: 18px; z-index: 25;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--brand); color: #fff; font-size: 26px;
  box-shadow: 0 6px 20px rgba(59,91,219,.4);
}
@media (min-width: 900px) { .fab { bottom: 28px; left: 28px; } }

/* ---------- רשימות ---------- */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.list-item:last-child { border-bottom: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 16px; flex-shrink: 0;
}

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.data th { color: var(--muted); font-size: 12px; font-weight: 600; background: #f7f9fd; }
.table-scroll { overflow-x: auto; }

/* ---------- מודאל ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(20, 26, 40, .5);
  display: grid; place-items: end center; z-index: 50;
}
.modal {
  background: var(--panel); border-radius: 18px 18px 0 0; padding: 20px;
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
@media (min-width: 700px) {
  .modal-bg { place-items: center; padding: 24px; }
  .modal { border-radius: 18px; }
}
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal-foot { display: flex; gap: 10px; margin-top: 18px; }
.modal-foot .btn { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- דיווח בודד ---------- */
.report-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.report-item .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }

/* ---------- טוסט ---------- */
#toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); right: 50%; transform: translateX(50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast-msg {
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 24px;
  font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 90vw;
  animation: toast-in .25s ease;
}
.toast-msg.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- זיהוי כתב יד ---------- */
.ink-canvas {
  width: 100%; display: block; touch-action: none;
  background: linear-gradient(#f7f9fd 1px, transparent 1px) 0 0/100% 34px, #fff;
  border: 1px solid var(--line); border-radius: 12px; cursor: crosshair;
}
.hw-letters { display: flex; flex-wrap: wrap; gap: 4px; direction: rtl; }
.hw-chip {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; font-weight: 700; font-size: 15px;
}
.hw-target { font-size: 62px; text-align: center; font-weight: 700; color: var(--brand); line-height: 1.2; }
.thumb-strip { display: flex; flex-wrap: wrap; gap: 8px; direction: rtl; }
.thumb-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.thumb-cell canvas { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.thumb-cell input { width: 44px; text-align: center; padding: 6px 4px; font-size: 16px; font-weight: 700; }
.word-sep { width: 16px; align-self: stretch; border-left: 2px dashed var(--line); margin: 0 3px; }
.hw-stages { display: flex; gap: 8px; flex-wrap: wrap; }
.stage-chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 20px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.stage-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.stage-chip.done { color: var(--closed); border-color: var(--closed); }
.stage-chip.on.done { color: #fff; }

/* ---------- דשבורד: ריבועים ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; transition: transform .08s;
}
.tile:active { transform: scale(.98); }
.tile .n { font-size: 26px; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tile .bar { height: 4px; border-radius: 4px; margin-top: 10px; }

/* ---------- לוח קנבן ---------- */
.kanban { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: start; }
@media (min-width: 900px) { .kanban { grid-template-columns: repeat(4, 1fr); } }
.kcol { background: #eef1f8; border-radius: var(--radius); padding: 10px; }
.kcol h3 {
  margin: 2px 6px 10px; font-size: 14px; display: flex; align-items: center; gap: 8px;
}
.kcol h3 .cnt { background: #fff; color: var(--muted); font-size: 12px; border-radius: 20px; padding: 1px 9px; }
.kcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 13px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer;
}
.kcard:active { transform: scale(.99); }
.kcard .kc-cust { color: var(--brand); font-size: 12px; font-weight: 600; }
.kcard .kc-title { font-weight: 600; font-size: 14px; margin: 3px 0 5px; }

.done-strike { text-decoration: line-through; opacity: .65; }
.hw-thumb {
  width: 54px; height: 54px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; cursor: zoom-in; flex-shrink: 0;
}
.desc-snippet { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-btn {
  border: 0; background: transparent; padding: 10px 14px; font-size: 13px; color: var(--muted);
}
.seg-btn.active { background: var(--brand); color: #fff; font-weight: 600; }

.empty { color: var(--muted); text-align: center; padding: 34px 10px; font-size: 14px; }
.banner {
  background: #fff8e6; border: 1px solid #ffe08a; color: #7a5b00;
  padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px;
}
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.section-title h2 { font-size: 18px; }
