/* מראה בהשראת monday.com: טבלה עם קבוצות צבעוניות, תאי סטטוס מלאים, פס סיכום */
:root {
  --bg: #ffffff; --surface: #f6f7fb; --card: #ffffff; --ink: #323338; --muted: #676879; --line: #d0d4e4; --line-soft: #e6e9ef;
  --primary: #0073ea; --primary-hover: #0060b9; --primary-ink: #fff; --selected: #cce5ff;
  --todo: #c4c4c4; --doing: #fdab3d; --stuck: #df2f4a; --done: #00c875;
  --late: #df2f4a;
  --shadow: 0 4px 17px rgba(0, 0, 0, .1);
  --r: 8px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181b34; --surface: #1f2342; --card: #30324e; --ink: #d5d8df; --muted: #9699a6; --line: #4b4e69; --line-soft: #393b53;
    --selected: #133774; --todo: #797e93; --shadow: 0 4px 17px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.4 Rubik, Figtree, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  min-height: 100dvh; padding-bottom: calc(80px + var(--safe-b));
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ───── כותרת הלוח ───── */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-top: env(safe-area-inset-top, 0px); border-bottom: 1px solid var(--line-soft); }
.top > * { max-width: 960px; margin-inline: auto; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 4px; }
.board-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.board-icon { flex: none; width: 34px; height: 34px; border-radius: 8px; background: var(--primary); display: grid; grid-auto-flow: column; align-items: end; justify-content: center; gap: 3px; padding: 8px 0; }
.board-icon i { width: 5px; border-radius: 3px; background: #fff; }
.board-icon i:nth-child(1) { height: 60%; } .board-icon i:nth-child(2) { height: 100%; } .board-icon i:nth-child(3) { height: 40%; }
h1 { font-size: 21px; font-weight: 600; margin: 0; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.icon-btn { width: 40px; height: 40px; border-radius: 6px; font-size: 24px; line-height: 1; color: var(--muted); }
.icon-btn:active, .icon-btn:hover { background: var(--surface); }

.tabs { display: flex; gap: 4px; padding: 0 12px; }
.tabs button { padding: 10px 10px 9px; color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-pressed="true"] { color: var(--ink); font-weight: 500; border-bottom-color: var(--primary); }

.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line-soft); }
.btn-new { flex: none; background: var(--primary); color: var(--primary-ink); border-radius: 4px; padding: 7px 14px; font-weight: 500; font-size: 14px; min-height: 36px; }
.btn-new:active, .btn-new:hover { background: var(--primary-hover); }
.chips { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 6px 10px; border-radius: 4px; color: var(--ink); font-size: 14px; min-height: 36px; }
.chips button:hover { background: var(--surface); }
.chips button[aria-pressed="true"] { background: var(--selected); color: var(--primary); font-weight: 500; }
@media (prefers-color-scheme: dark) { .chips button[aria-pressed="true"] { color: #fff; } }

main { max-width: 960px; margin: 0 auto; padding: 8px 12px 0; }
.empty { text-align: center; color: var(--muted); padding: 56px 16px; }
.empty b { display: block; font-size: 40px; margin-bottom: 8px; }

/* ───── קבוצה = טבלה ───── */
.group { margin: 18px 0 26px; --gc: #579bfc; --title-w: 150px; --cols: 6px var(--title-w) 88px 84px 72px 108px 108px 84px; }
@media (min-width: 720px) { .group { --title-w: 300px; } }
.group-head { display: flex; align-items: center; gap: 6px; padding: 0 0 6px; }
.group-title { display: flex; align-items: center; gap: 8px; min-height: 36px; text-align: start; color: var(--gc); font-weight: 500; font-size: 18px; }
.group-title .chev { display: inline-grid; place-items: center; width: 20px; height: 20px; font-size: 12px; transition: transform .15s; }
.group.collapsed .chev { transform: rotate(90deg); }
.group-head .count { color: var(--muted); font-size: 13px; }
.group-head .add { margin-inline-start: auto; width: 32px; height: 32px; border-radius: 4px; font-size: 22px; line-height: 1; color: var(--muted); }
.group-head .add:hover, .group-head .add:active { background: var(--surface); }

.table { border-radius: var(--r); overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line-soft); overscroll-behavior-x: contain; }
.scroll-hint { margin: 0 0 6px; font-size: 13px; color: var(--primary); }
.group.collapsed .scroll-hint { display: none; }
.group.collapsed .table { display: none; }
.collapsed-bar { display: none; }
.group.collapsed .collapsed-bar { display: grid; grid-template-columns: 6px 1fr auto; align-items: center; gap: 10px; border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; min-height: 44px; padding-inline-end: 10px; }
.collapsed-bar .strip { align-self: stretch; background: var(--gc); }
.collapsed-bar .battery { width: 110px; }

.trow { display: grid; grid-template-columns: var(--cols); width: max-content; min-width: 100%; min-height: 44px; border-top: 1px solid var(--line-soft); background: var(--card); }
/* פס הצבע ושם המשימה נשארים במקום כשגוללים הצידה, כמו במאנדיי */
.trow > .strip { position: sticky; inset-inline-start: 0; z-index: 2; }
.trow > .c-title, .addrow > form { position: sticky; inset-inline-start: 6px; z-index: 2; background: var(--card); box-shadow: -1px 0 0 var(--line-soft); }
.trow > * { border-inline-start: 1px solid var(--line-soft); }
.trow > :first-child { border: 0; }
.trow.thead { min-height: 36px; border-top: 0; font-size: 13px; color: var(--muted); }
.thead > div { display: grid; place-items: center; }
.thead > .c-title { justify-items: start; padding-inline: 12px; }
.strip { background: var(--gc); }
.trow.sub .strip { background: color-mix(in srgb, var(--gc) 45%, transparent); }

.c-title { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 6px 10px; }
.trow.sub .c-title { padding-inline-start: 30px; }
.c-title .name { flex: 1; min-width: 0; text-align: start; padding: 4px 0; overflow-wrap: anywhere; font-size: 15px; }
.trow.s-done .c-title .name { color: var(--muted); }
.expander { flex: none; display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px; border-radius: 4px; color: var(--muted); font-size: 12px; min-height: 26px; }
.expander:hover { background: var(--surface); }
.expander .chev { font-size: 10px; }
.expander[aria-expanded="true"] { color: var(--primary); }
.icons { display: inline-flex; gap: 4px; color: var(--muted); font-size: 13px; flex: none; }

/* תא סטטוס מלא, כמו במאנדיי */
.c-status { display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 500; text-align: center; padding: 0 4px; background: var(--todo); position: relative; }
.c-status.s-doing { background: var(--doing); }
.c-status.s-stuck { background: var(--stuck); }
.c-status.s-done { background: var(--done); }
.c-status::after { content: ""; position: absolute; top: 0; inset-inline-end: 0; border: 6px solid transparent; border-top-color: rgba(0, 0, 0, .14); border-inline-end-color: rgba(0, 0, 0, .14); opacity: 0; transition: .12s; }
.c-status:hover::after { opacity: 1; }

.c-date { position: relative; display: grid; place-items: center; font-size: 13px; color: var(--ink); }
.c-date input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; padding: 0; cursor: pointer; }
.c-date .ph { color: var(--muted); opacity: .6; }
.c-date.late .lbl { color: var(--late); font-weight: 500; }
.c-date.late .lbl::before { content: "!"; display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: var(--late); color: #fff; font-size: 10px; font-weight: 700; margin-inline-end: 4px; }
.c-date.done .lbl { text-decoration: line-through; color: var(--muted); }

.trow.addrow { min-height: 40px; }
.thead > .c-title, .tfoot > .c-title { background: var(--card); }
.tfoot > .strip { background: transparent; }

.c-text { display: flex; }
.trow .c-text input[type=text] { min-height: 0; border-radius: 0; width: 100%; border: 0; background: none; text-align: center; font-size: 13px; padding: 0 6px; min-width: 0; color: var(--ink); }
.trow .c-text input::placeholder { color: var(--muted); opacity: .45; }
.trow .c-text input[type=text]:focus { outline: none; box-shadow: inset 0 0 0 1px var(--primary); background: var(--card); }
.addrow form { grid-column: 2; display: flex; border: 0; }
.addrow input { flex: 1; border: 0; background: none; padding: 0 12px; min-height: 40px; color: var(--ink); }
.addrow input::placeholder { color: var(--muted); }
.addrow input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--primary); }
.trow.sub.addrow form input { padding-inline-start: 30px; font-size: 14px; }

.trow.tfoot { min-height: 34px; background: transparent; border-top: 1px solid var(--line-soft); }
.tfoot > div { border: 0; }
.tfoot .c-status { background: none; padding: 7px 8px; }
.battery { display: flex; width: 100%; height: 20px; border-radius: 2px; overflow: hidden; background: var(--line-soft); }
.battery i { display: block; height: 100%; }

.new-group { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); font-size: 14px; margin: 4px 0 20px; }
.new-group:hover { background: var(--surface); }

/* ───── מדריך ───── */
#guide { width: min(92vw, 440px); max-height: 88dvh; overflow-y: auto; padding: 20px 20px 16px; border-radius: 12px; margin: auto; box-shadow: var(--shadow); }
#guide h2 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
#guide ol { margin: 12px 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 12px; }
#guide li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; font-size: 15px; }
#guide li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; }
#guide .ex { display: inline-block; color: #fff; border-radius: 3px; padding: 0 6px; font-size: 13px; }
#guide .primary { width: 100%; margin-top: 6px; }

/* ───── קנבן ───── */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding: 12px 2px 16px; scroll-snap-type: x mandatory; }
.kcol { flex: 0 0 min(80vw, 280px); scroll-snap-align: start; background: var(--surface); border-radius: var(--r); overflow: hidden; align-self: flex-start; }
.kcol-head { color: #fff; font-weight: 500; padding: 10px 12px; display: flex; justify-content: space-between; background: var(--todo); }
.kcol-head.s-doing { background: var(--doing); } .kcol-head.s-stuck { background: var(--stuck); } .kcol-head.s-done { background: var(--done); }
.kcards { display: grid; gap: 8px; padding: 8px; min-height: 60px; }
.kcard { background: var(--card); border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); padding: 10px 12px; display: grid; gap: 8px; cursor: pointer; }
.kcard .name { font-size: 15px; overflow-wrap: anywhere; }
.kcard .krow { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); }
.kcard .gtag { display: inline-flex; align-items: center; gap: 5px; }
.kcard .gtag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--gc); }
.kcard .kstatus { color: #fff; border-radius: 4px; padding: 3px 8px; font-size: 12px; background: var(--todo); }
.kcard .kstatus.s-doing { background: var(--doing); } .kcard .kstatus.s-stuck { background: var(--stuck); } .kcard .kstatus.s-done { background: var(--done); }
.kcard .late { color: var(--late); font-weight: 500; }

/* ───── שורת הוספה תחתונה ───── */
.addbar { position: fixed; inset-inline: 0; bottom: 0; display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px calc(10px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line-soft); z-index: 4; }
.addbar textarea { flex: 1; resize: none; max-height: 140px; padding: 11px 14px; border-radius: 4px; border: 1px solid var(--line); background: var(--card); min-height: 44px; }
.addbar textarea:focus { outline: none; border-color: var(--primary); }
.addbar button { flex: none; width: 44px; height: 44px; border-radius: 4px; background: var(--primary); color: var(--primary-ink); font-size: 26px; line-height: 1; }
@media (min-width: 980px) { .addbar { inset-inline: 50% auto; transform: translateX(50%); width: 960px; } }

/* ───── דיאלוגים ───── */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--card); }
dialog::backdrop { background: rgba(41, 47, 76, .5); }
#sheet { width: 100%; max-width: 720px; margin: auto auto 0; border-radius: 16px 16px 0 0; max-height: 92dvh; overflow-y: auto; padding: 8px 18px calc(22px + var(--safe-b)); }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet-top { display: flex; gap: 8px; align-items: flex-start; }
.sheet-top input { flex: 1; font-size: 20px; font-weight: 500; border: 1px solid transparent; border-radius: 4px; background: none; padding: 6px 8px; min-width: 0; }
.sheet-top input:hover { border-color: var(--line); }
.sheet-top input:focus { outline: none; border-color: var(--primary); }
.x { width: 40px; height: 40px; border-radius: 4px; font-size: 20px; color: var(--muted); }
.field { margin: 14px 0; }
.field > label, .label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button { padding: 10px 4px; border-radius: 4px; font-weight: 500; font-size: 14px; color: #fff; opacity: .45; }
.seg button[aria-pressed="true"] { opacity: 1; box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }
.seg button[data-s="todo"] { background: var(--todo); } .seg button[data-s="doing"] { background: var(--doing); }
.seg button[data-s="stuck"] { background: var(--stuck); } .seg button[data-s="done"] { background: var(--done); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type=date], input[type=time], input[type=text], input[type=password], select, textarea.notes {
  width: 100%; padding: 10px 12px; border-radius: 4px; border: 1px solid var(--line); background: var(--card); min-height: 42px; }
.c-date input { min-height: 0; }
textarea.notes { min-height: 84px; resize: vertical; }
.quick { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.quick button { padding: 6px 12px; border-radius: 4px; background: var(--surface); font-size: 13px; color: var(--primary); }
.sheet-subs { list-style: none; padding: 0; margin: 0 0 8px; border: 1px solid var(--line-soft); border-radius: 4px; overflow: hidden; }
.sheet-subs:empty { display: none; }
.sheet-subs li { display: grid; grid-template-columns: 1fr 86px 36px; align-items: stretch; min-height: 40px; border-top: 1px solid var(--line-soft); }
.sheet-subs li:first-child { border-top: 0; }
.sheet-subs .stitle { padding: 9px 10px; cursor: pointer; overflow-wrap: anywhere; }
.sheet-subs .c-status { border: 0; }
.sheet-subs .del { color: var(--muted); font-size: 16px; }
.subadd { display: flex; gap: 8px; }
.subadd input { flex: 1; }
.subadd button { padding: 0 16px; border-radius: 4px; background: var(--primary); color: var(--primary-ink); font-weight: 500; }
.danger { color: var(--stuck); font-weight: 500; padding: 12px; width: 100%; margin-top: 8px; border-radius: 4px; }
.danger:active { background: color-mix(in srgb, var(--stuck) 12%, transparent); }
.byline { text-align: center; font-size: 12px; color: var(--muted); margin-top: 10px; }

dialog.small { border-radius: 8px; padding: 16px; width: min(86vw, 320px); margin: auto; box-shadow: var(--shadow); }
dialog.small > button { display: block; width: 100%; padding: 12px; text-align: start; border-radius: 4px; }
dialog.small > button:hover, dialog.small > button:active { background: var(--surface); }
dialog.small .muted { color: var(--muted); }
.picker { display: none; }
.picker[open] { display: grid; gap: 6px; padding: 12px; width: min(70vw, 220px); }
.picker button.c-status { min-height: 40px; border-radius: 2px; font-size: 14px; }
.picker button.c-status[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }
#login-form { display: grid; gap: 12px; }
#login-form h2 { margin: 0; font-weight: 600; }
.muted-text { margin: 0; color: var(--muted); font-size: 14px; }
.err { margin: 0; color: var(--stuck); font-weight: 500; }
.primary { padding: 12px; border-radius: 4px; background: var(--primary); color: var(--primary-ink); font-weight: 500; }

#toast { position: fixed; inset-inline: 16px; bottom: calc(86px + var(--safe-b)); margin: auto; width: fit-content; max-width: 90vw; padding: 10px 16px;
  border-radius: 4px; background: #323338; color: #fff; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; z-index: 10; }
#toast.on { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
