/* מועדון — שפת העיצוב של Mission Control / HUB */

:root {
  color-scheme: dark;
  --page:    #131315;
  --panel:   #1a1a1d;
  --panel-2: #212125;
  --border:  #2b2b30;
  --ink-1:   #e9e9eb;
  --ink-2:   #9c9ca4;
  --muted:   #66666e;
  --accent:  #4da3ff;
  --k-benefit: #3987e5;
  --k-credit:  #eb6834;
  --k-gift:    #1baf7a;
  --k-content: #a06cd5;
  --k-welcome: #2ec5c0;
  --st-good: #34c759; --st-warn: #fab219; --st-crit: #e5484d;
}

* { box-sizing: border-box; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px),
    var(--page);
  background-size: 40px 40px, 40px 40px, auto;
  color: var(--ink-1); padding: 0 0 48px; min-height: 100vh; font-size: 14px;
}

/* ---- כותרת עליונה + טאבים ---- */
header { background: var(--page); border-bottom: 1px solid var(--border); padding: 16px 28px 0; position: sticky; top: 0; z-index: 20; }
.hrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 16px; font-weight: 650; }
h1 small { color: var(--muted); font-weight: 400; font-size: 12px; margin-inline-start: 8px; }
.spacer { flex: 1; }

.tabs { display: flex; gap: 22px; margin-top: 16px; }
.tab { font: inherit; font-size: 14px; padding: 10px 2px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--ink-2); cursor: pointer; }
.tab:hover { color: var(--ink-1); }
.tab[aria-selected="true"] { color: var(--ink-1); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1240px; margin: 0 auto; padding: 22px 28px; }
section[hidden] { display: none; }

.avatar {
  width: 32px; height: 32px; border-radius: 999px; padding: 0;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--ink-1);
  font: inherit; font-size: 13px; font-weight: 650; cursor: pointer;
  display: grid; place-items: center; line-height: 1;
}
.avatar:hover { background: var(--border); }
.avatar[aria-expanded="true"] { border-color: var(--accent); }
.profile { position: relative; }
.pmenu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 40;
  min-width: 200px; padding: 6px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--panel); box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.pmenu[hidden] { display: none; }
.pinfo { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.pname { font-weight: 650; font-size: 13px; }
.pemail { color: var(--muted); font-size: 12px; word-break: break-all; }
.pitem {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font: inherit; font-size: 13px; text-align: start; padding: 8px 10px;
  border: none; border-radius: 6px; background: none; color: var(--ink-1); cursor: pointer;
}
.pitem:hover { background: var(--panel-2); }

/* ---- כפתורים ---- */
select, button.btn {
  font: inherit; font-size: 13px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--ink-1); cursor: pointer;
}
button.btn:hover { background: var(--panel-2); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #0d1117; font-weight: 600; }
button.btn.small { padding: 3px 10px; font-size: 12px; border-radius: 6px; }
button.btn.tiny  { padding: 1px 7px; font-size: 11px; }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
button.btn.crit { color: var(--st-crit); }
.btn.google { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; text-decoration: none; background: var(--panel-2); }
.btn.google:hover { background: var(--border); }

/* ---- כרטיסים ---- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.statgrid { display: grid; gap: 10px; margin-bottom: 18px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.statcard { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.statcard .v { font-size: 24px; font-weight: 650; line-height: 1.1; }
.statcard .l { font-size: 12.5px; color: var(--ink-2); margin-top: 5px; }
.statcard .n { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.statcard.warn .v { color: var(--st-warn); }

/* ---- טפסים ---- */
.frow { margin-bottom: 10px; font-size: 13px; }
.frow label { display: block; color: var(--ink-2); margin-bottom: 4px; font-size: 12px; }
.frow input, .frow select, .frow textarea {
  width: 100%; font: inherit; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--page); color: var(--ink-1);
}
.frow textarea { min-height: 80px; resize: vertical; }
.fhint { font-size: 11.5px; color: var(--muted); line-height: 1.65; margin-top: 6px; }
.frow2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- דיאלוגים, טוסט ---- */
dialog {
  margin: auto;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--panel); color: var(--ink-1);
  padding: 24px; width: min(480px, 92vw);
  max-height: 88vh; overflow-y: auto;
}
dialog.wide { width: min(680px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { font-size: 15px; margin-bottom: 14px; }
.dactions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

#toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(50%); background: #0c0c0e; color: var(--ink-1); border: 1px solid var(--border); padding: 10px 20px; border-radius: 10px; font-size: 13px; display: none; z-index: 100; }
#toast.err { border-color: var(--st-crit); color: #ffb4b6; }

.spinner {
  width: 15px; height: 15px; flex: none; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .7s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { color: var(--muted); font-size: 12.5px; padding: 18px 16px; }

/* ---- תגיות סוג ---- */
.kchip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap; }
.kchip .sw { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.pchip { font-size: 11px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap; }
.pchip[data-tone="good"] { color: var(--st-good); border-color: color-mix(in srgb, var(--st-good) 45%, transparent); }
.pchip[data-tone="warn"] { color: var(--st-warn); border-color: color-mix(in srgb, var(--st-warn) 45%, transparent); }
.pchip[data-tone="crit"] { color: var(--st-crit); border-color: color-mix(in srgb, var(--st-crit) 45%, transparent); }

/* ---- הלוח השבועי ---- */
.weekbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.weekbar .title { font-size: 15px; font-weight: 650; }
.weekbar .navs { display: flex; gap: 10px; margin-inline-start: 190px; }
.weekgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.daycol { min-width: 0; }
.dayhead { font-size: 12px; color: var(--ink-2); padding: 4px 2px 8px; text-align: center; }
.dayhead b { display: block; font-size: 13px; color: var(--ink-1); font-weight: 650; }
.daycol.today .dayhead b { color: var(--accent); }
.daycards { display: flex; flex-direction: column; gap: 8px; min-height: 132px; border-radius: 11px; }
.daycards.dragover { outline: 1px dashed var(--accent); outline-offset: 3px; }
.dhead { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.dhead h3 { flex: 1; margin: 0; }
.xbtn {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 16px;
  line-height: 1; padding: 4px 6px; border-radius: 8px; cursor: pointer;
}
.xbtn:hover { color: var(--ink-1); background: var(--panel); }
.linkbtn {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  cursor: pointer; text-decoration: underline;
}
/* משבצות ריקות: מקום נחיתה לגרירה בלבד — מופיעות רק כשגוררים כרטיס */
.slotcard { display: none; }
#board.dragging .slotcard {
  height: 132px; border-radius: 11px; border: 1px dashed var(--border); background: transparent;
  color: var(--muted); font: inherit; font-size: 11.5px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#board.dragging .slotcard:hover { border-color: var(--accent); color: var(--ink-2); }
#board.dragging .slotcard.dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.acard.dragover { border-color: var(--accent); border-style: dashed; }
.acard {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 12px; cursor: pointer; height: 132px;
  display: flex; flex-direction: column; gap: 6px; text-align: start; font: inherit; color: var(--ink-1);
}
/* מסגרת בצבע הסוג — במקום תגית סוג */
.acard[data-kind="benefit"] { border-color: color-mix(in srgb, var(--k-benefit) 55%, transparent); }
.acard[data-kind="credit"]  { border-color: color-mix(in srgb, var(--k-credit) 55%, transparent); }
.acard[data-kind="gift"]    { border-color: color-mix(in srgb, var(--k-gift) 55%, transparent); }
.acard[data-kind="content"] { border-color: color-mix(in srgb, var(--k-content) 55%, transparent); }
.acard[data-kind="welcome"] { border-color: color-mix(in srgb, var(--k-welcome) 55%, transparent); }
.acard .sub {
  font-size: 11px; color: var(--muted); line-height: 1.55; white-space: pre-line;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.acard .sub.warn { color: var(--st-warn); }
.acard .meta { margin-top: auto; }
.acard:hover { border-color: var(--accent); }
.acard .time { font-size: 11px; color: var(--muted); }
.acard .name { font-size: 12.5px; font-weight: 600; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.acard .name.none { color: var(--st-warn); font-weight: 500; }
.acard .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.acard.sent { opacity: .6; }
.acard.sent:hover { border-color: var(--st-good); }

/* ---- בנק ההטבות ---- */
.bankbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.bankbar input[type=search] {
  font: inherit; font-size: 13px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--page); color: var(--ink-1); width: 220px;
}
.catchips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.catchip {
  font: inherit; font-size: 12px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel); color: var(--ink-2); cursor: pointer;
}
.catchip:hover { border-color: var(--accent); color: var(--ink-1); }
.catchip.on { border-color: var(--accent); color: var(--accent); background: var(--panel-2); }

.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.bcard {
  position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; cursor: pointer; text-align: start; font: inherit; color: var(--ink-1); padding: 0;
  display: flex; flex-direction: column;
}
.bcard:hover { border-color: var(--accent); }
.bcard img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: var(--panel-2); }
.bcard .bbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.bcard .btitle { font-size: 13px; font-weight: 600; line-height: 1.4; }
.bcard .bprice { font-size: 12px; color: var(--ink-2); white-space: pre-line; }
.corner-tag {
  position: absolute; inset-block-start: 8px; inset-inline-end: 8px;
  color: #fff; font-size: 9.5px; font-weight: 700;
  letter-spacing: .02em; padding: 2px 7px; border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.corner-tag.blue { background: var(--accent); }
.corner-tag.green { background: var(--st-good); }
.corner-tag.auto { background: var(--k-gift); }

.bdetail { display: flex; flex-direction: column; gap: 10px; }
.bdetail img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; }
.bdetail .desc { font-size: 13px; line-height: 1.7; color: var(--ink-2); white-space: pre-line; }
.finebox { background: var(--page); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 12px; color: var(--ink-2); line-height: 1.7; white-space: pre-line; max-height: 160px; overflow-y: auto; }

/* ---- חלון תוכן בכרטיס שיבוץ ---- */
.msgbox {
  width: 100%; font: inherit; font-size: 13px; line-height: 1.7;
  background: var(--page); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; color: var(--ink-1); min-height: 140px; resize: vertical;
}

/* ---- טבלת נתונים ---- */
table.stattable { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.stattable th, .stattable td { padding: 9px 14px; border-bottom: 1px solid var(--border); text-align: start; }
.stattable thead th { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.stattable tbody tr:last-child td { border-bottom: none; }
.minibar {
  display: inline-block; width: 54px; height: 6px; border-radius: 3px;
  background: var(--panel-2); overflow: hidden; vertical-align: middle; margin-inline-end: 7px;
}
.minibar i { display: block; height: 100%; border-radius: 3px; }

/* ---- הגדרות ---- */
.setgroup { max-width: 820px; margin-bottom: 24px; }
.setgroup > h2 { font-size: 14.5px; font-weight: 650; margin-bottom: 4px; }
.setgroup > p.sub { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.slotrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.slotrow:last-child { border-bottom: none; }
.slotrow .info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.slotrow .day { font-weight: 650; min-width: 64px; }
.slotrow .lbl { color: var(--ink-2); }
.slotrow .acts { display: flex; gap: 6px; flex: none; }
.exrow { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.exrow:last-child { border-bottom: none; }
.exrow .body { color: var(--ink-2); white-space: pre-line; line-height: 1.65; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.exrow .acts { margin-top: 6px; }
.prow { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; gap: 12px; }
.prow:last-child { border-bottom: none; }
.prow label { color: var(--ink-2); }
.prow input[type=text], .prow input[type=url] { width: 300px; font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--page); color: var(--ink-1); }
.prow input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---- מסך התחברות ---- */
.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.loginbox { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px 26px; }
.loginbox h1 { font-size: 17px; margin-bottom: 4px; }
.loginbox p.sub { color: var(--muted); font-size: 12.5px; margin-bottom: 20px; }
.loginerr { color: var(--st-crit); font-size: 12.5px; margin-top: 10px; min-height: 17px; }

/* טבלה רחבה גוללת בתוך הפאנל — הדף עצמו לא זז לרוחב */
.panel:has(> .stattable) { overflow-x: auto; }
.stattable td, .stattable th { white-space: nowrap; }
.stattable td:nth-child(3) { white-space: normal; min-width: 140px; }
.slotrow .info > * { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 1000px) {
  .weekgrid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .weekbar .navs { margin-inline-start: 0; }
}

/* ---- מובייל ---- */
@media (max-width: 600px) {
  body { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
  header { padding: 10px 14px 0; }
  .hrow { gap: 8px; flex-wrap: nowrap; }
  h1 { font-size: 15px; white-space: nowrap; }
  h1 small { display: none; }
  #btnRefresh { padding: 6px 10px; font-size: 12.5px; white-space: nowrap; }
  /* טאבים בשורה אחת, גלילה אופקית אם צריך */
  .tabs { gap: 14px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; font-size: 13px; padding: 9px 2px; }
  main { padding: 14px 14px 24px; }

  /* iOS מגדיל את הדף כשמתמקדים בשדה קטן מ-16px */
  .frow input, .frow select, .frow textarea, .prow input[type=text], .prow input[type=url],
  .bankbar input[type=search], textarea.msgbox, dialog select { font-size: 16px; }
  .frow2 { grid-template-columns: 1fr; }
  /* יעדי מגע */
  button.btn.small, button.btn.tiny { min-height: 32px; padding-inline: 10px; font-size: 12px; }
  .catchip { padding: 7px 12px; }

  /* הלוח: יום מתחת ליום, כרטיס ברוחב מלא */
  .weekbar { gap: 8px; margin-bottom: 14px; }
  .weekbar .title { flex-basis: 100%; }
  .weekbar .navs { width: 100%; gap: 6px; }
  .weekbar .navs .btn { flex: 1; }
  .weekbar .spacer { display: none; }
  .weekbar > .btn { flex: 1 1 auto; }
  .weekgrid { grid-template-columns: 1fr; gap: 14px; }
  .dayhead { display: flex; align-items: baseline; gap: 8px; text-align: start; padding: 0 2px 6px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
  .dayhead b { display: inline; font-size: 14px; }
  .daycards { min-height: 0; }
  .acard { height: auto; min-height: 0; padding: 10px 12px; }
  #board.dragging .slotcard { height: 56px; }
  .acard .name { -webkit-line-clamp: 2; }
  .acard .sub { -webkit-line-clamp: 1; }

  /* בנק */
  .bankbar input[type=search] { width: 100%; }
  .bgrid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .bcard .btitle { font-size: 12.5px; }
  .statgrid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
  .statcard { padding: 12px 14px; }
  .statcard .v { font-size: 22px; }

  /* הגדרות */
  .prow { flex-wrap: wrap; }
  .prow label { flex: 1 1 200px; }
  .prow input[type=text], .prow input[type=url] { width: 100%; }
  .slotrow { padding: 10px 12px; }

  /* דיאלוגים: כמעט מסך מלא, כפתורים ברוחב */
  dialog, dialog.wide { width: calc(100vw - 16px); max-width: none; max-height: calc(100dvh - 16px); padding: 16px; border-radius: 12px; }
  .dactions { gap: 8px; }
  .dactions .spacer { display: none; }
  .dactions .btn { flex: 1 1 45%; min-height: 40px; }
  .msgbox { min-height: 160px; }

  #toast { max-width: calc(100vw - 24px); bottom: calc(16px + env(safe-area-inset-bottom)); text-align: center; }
}

/* פוסט שהועתק — יורד לאפור וחותמת "שומש" גדולה יושבת עליו, כדי שלא
   יועתק פעמיים. ההעתקה היא סימן השליחה, אז זה תמיד עדכני. */
.acard.sent { filter: grayscale(1); opacity: .5; }
.acard.sent:hover { opacity: .75; }
.acard.sent .stamp {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-9deg);
  font-size: 20px; font-weight: 800; letter-spacing: 2px; white-space: nowrap;
  max-width: 84%; box-sizing: border-box;
  color: var(--ink-1); opacity: .9;
  border: 3px solid var(--ink-1); border-radius: 9px; padding: 1px 10px 3px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  pointer-events: none;
}
