/* דשבורד פלאג אנד סטיי — mobile-first, RTL, בלי תלויות */
:root {
  --bg: #f3f4f6;
  --card: #fff;
  --text: #1c1f24;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #111;
  --urgent: #d33;
  --medium: #e8a33d;
  --low: #3a9d5d;
  --nav-h: 58px;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Hebrew", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.25rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: .25rem 0; }
pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; margin: 0; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ── ניווט ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--brand); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.topbar .logo { font-weight: 700; letter-spacing: .3px; }
.topbar .user { font-size: .85rem; opacity: .9; }
.topbar .user a { color: #ddd; margin-inline-start: 8px; }
.topnav { display: none; gap: 4px; }
.topnav a { color: #ddd; padding: 6px 10px; border-radius: 8px; font-size: .9rem; position: relative; }
.topnav a.active, .topnav a:hover { background: #333; color: #fff; text-decoration: none; }

.bottomnav {
  position: fixed; bottom: 0; right: 0; left: 0; height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
  display: flex; z-index: 30;
}
.bottomnav a, .bottomnav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .7rem; color: var(--muted); background: none; border: 0; position: relative; text-decoration: none;
}
.bottomnav .ico { font-size: 1.25rem; line-height: 1; }
.bottomnav .active { color: var(--brand); font-weight: 600; }
.pill {
  position: absolute; top: 4px; inset-inline-start: 50%; margin-inline-start: 6px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--urgent); color: #fff; font-size: .65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.pill:empty, .pill[data-zero="1"] { display: none; }
.topnav .pill { position: static; display: inline-flex; margin-inline-start: 4px; vertical-align: middle; }
.moremenu {
  display: none; position: fixed; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); inset-inline-end: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.15); z-index: 40; min-width: 160px; overflow: hidden;
}
.moremenu.open { display: block; }
.moremenu a { display: block; padding: 12px 16px; color: var(--text); border-bottom: 1px solid var(--line); }
.moremenu a:last-child { border-bottom: 0; }
.moremenu a.active { background: #f0f0f0; font-weight: 600; }

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

/* ── כרטיסים ── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
  border-inline-start: 4px solid var(--uc, var(--line));
}
.card.plain { border-inline-start-width: 1px; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600;
  color: #fff; background: var(--uc, #888); vertical-align: middle;
}
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: .72rem;
  background: #eef0f3; color: #444; vertical-align: middle;
}
.tag.ok { background: #e3f4e8; color: #1f6b3a; }
.tag.warn { background: #fdecc8; color: #7a4d00; }
.tag.bad { background: #fde2e2; color: #8b1a1a; }
.muted { color: var(--muted); font-size: .82rem; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row.between { justify-content: space-between; }
.empty { color: var(--muted); text-align: center; padding: 20px; background: #fafafa; border: 1px dashed var(--line); border-radius: var(--radius); }

.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; font-size: .85rem;
}
.btn:hover { background: #f5f5f5; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.done { border-color: var(--low); color: var(--low); font-weight: 600; }
.btn.done:hover { background: var(--low); color: #fff; }
.btn.danger { color: var(--urgent); border-color: var(--urgent); }
.btn.small { padding: 3px 8px; font-size: .78rem; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: .78rem; color: #444;
}
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.urg-btn[data-urg]:not([data-urg=""]) { border-color: var(--uc); color: var(--uc); }
.urg-btn[data-urg]:not([data-urg=""]).on { background: var(--uc); color: #fff; }
.chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }

details { margin-top: 8px; }
details > summary { cursor: pointer; color: var(--muted); font-size: .85rem; user-select: none; }
details .box { margin-top: 6px; background: #fafafa; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: .9rem; }
.ctx { list-style: none; padding: 0; margin: 0; }
.ctx li { padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: .85rem; }
.ctx li:last-child { border-bottom: 0; }
.ctx .who { color: var(--muted); font-size: .75rem; margin-inline-end: 6px; }

/* ── משימות ── */
.task-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.task-title { font-size: .98rem; font-weight: 600; margin: 2px 0 6px; }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.task.fade { opacity: .35; transition: opacity .3s; }
.board { display: grid; grid-template-columns: 1fr; gap: 12px; }
.col h2 { margin-top: .25rem; display: flex; align-items: center; gap: 8px; }
.col h2 .n { font-size: .8rem; background: var(--uc); color: #fff; border-radius: 999px; padding: 0 8px; }
.col.u-tabs { display: none; }
.coltabs { display: flex; gap: 6px; margin-bottom: 10px; }
.coltabs button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 4px; font-size: .85rem; font-weight: 600; }
.coltabs button.on { background: var(--uc); color: #fff; border-color: var(--uc); }
.board .col { display: none; }
.board .col.show { display: block; }

/* ── בוצעו אוטומטית היום (רצועה מתקפלת בסקירה) ── */
.tag.auto { background: #e8e6fb; color: #3b2f8f; }
.autodone { margin-bottom: 14px; padding: 8px 14px; border-inline-start: 4px solid #6b5bd6; }
.autodone > summary { font-weight: 600; color: var(--text); font-size: .9rem; }
.autodone > summary .muted { font-weight: 400; }
.autodone-list { margin-top: 6px; }
.autodone-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 7px 0; border-top: 1px dashed var(--line); }
.autodone-row.fade { opacity: .35; transition: opacity .3s; }
.autodone-main { min-width: 0; flex: 1; }
.autodone-title { font-weight: 600; font-size: .92rem; margin-inline-start: 4px; }
.autodone-evidence { margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.btn.reopen { color: #3b2f8f; border-color: #6b5bd6; white-space: nowrap; }
.btn.reopen:hover { background: #6b5bd6; color: #fff; }
@media (max-width: 480px) {
  .autodone-row { flex-direction: column; align-items: stretch; }
  .btn.reopen { width: 100%; }
}

/* ── KPI ── */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi .lbl { color: var(--muted); font-size: .75rem; }
.kpi .val { font-size: 1.35rem; font-weight: 700; margin-top: 2px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.kpi .val small { font-size: .8rem; font-weight: 600; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }

/* ── טבלאות ── */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { padding: 7px 9px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
td.wrap { white-space: normal; min-width: 160px; }
th { background: #f8f9fb; color: #444; font-weight: 600; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr.hide { display: none; }

/* ── טפסים ── */
form.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
form.grid .full { grid-column: 1 / -1; }
input[type=text], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
textarea { min-height: 70px; resize: vertical; }
label.lbl { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 2px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.filters select, .filters input { width: auto; padding: 5px 8px; font-size: .85rem; }

/* ── טאבים ── */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 10px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; white-space: nowrap; font-size: .88rem; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabpane { display: none; }
.tabpane.show { display: block; }

/* ── דוחות ── */
.reports { display: grid; grid-template-columns: 1fr; gap: 12px; }
.reports .list { max-height: 260px; overflow: auto; }
.reports .list a { display: block; padding: 6px 4px; border-bottom: 1px solid var(--line); color: var(--text); font-size: .88rem; }
.reports .list a.on { background: #f0f0f0; font-weight: 600; }
.reports .panel pre { font-size: .9rem; line-height: 1.55; }

/* ── טוסט ── */
#toast { position: fixed; bottom: calc(var(--nav-h) + 14px); left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
#toast .t { background: #222; color: #fff; padding: 9px 14px; border-radius: 10px; font-size: .88rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; transition: opacity .25s; max-width: 90vw; }
#toast .t.show { opacity: 1; }
#toast .t.err { background: var(--urgent); }
#toast .t.ok { background: var(--low); }

/* ── כניסה ── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { max-width: 380px; width: 100%; text-align: center; padding: 28px 22px; }
.login h1 { margin-bottom: 8px; }

/* ── דסקטופ ── */
@media (min-width: 900px) {
  body { padding-bottom: 20px; }
  .bottomnav, .moremenu { display: none !important; }
  .topnav { display: flex; }
  main { padding: 20px 24px; }
  .kpis { grid-template-columns: repeat(6, 1fr); }
  .coltabs { display: none; }
  .board { grid-template-columns: repeat(3, 1fr); align-items: start; }
  .board .col { display: block; }
  .reports { grid-template-columns: 300px 1fr; }
  .reports .list { max-height: 70vh; }
  #toast { bottom: 24px; }
  form.grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
}
@media (max-width: 480px) {
  main { padding: 12px 16px; }
  h1 { font-size: 1.15rem; }
  .task-actions { flex-direction: column; align-items: stretch; }
  .task-actions .btn.done { width: 100%; }
}
