/* פורום קופות הקהילות — עיצוב. ניגודיות טקסט ≥ 4.5:1 (ת"י 5568 / WCAG AA). */
:root {
  --navy: #1C224E; --navy-2: #2a3270; --gold: #998E66;
  --bg: #f6f7fb; --line: #d5d9e4; --text: #1b1f2a; --muted: #4f5566;
  --debt: #a4161a; --credit: #1b5e20; --warn-bg: #fff4d6; --warn: #6b4e00;
  --focus: #0b63ce;
}
* { box-sizing: border-box; }
/* "hidden" תמיד מנצח עיצוב (אחרת פריטי מנהל/יציאה עלולים להופיע) */
[hidden] { display: none !important; }
/* כותרת שמקבלת פוקוס אחרי מעבר מסך (לקוראי מסך) — בלי מסגרת */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }
html { font-size: 16px; }
body { margin: 0; font-family: Arial, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text);
       min-height: 100vh; display: flex; flex-direction: column; line-height: 1.5; }
main { flex: 1; width: 100%; max-width: 1150px; margin: 0 auto; padding: 20px 16px 40px; min-width: 0; }
main:focus { outline: none; }

/* פריסה: סרגל ניווט בצד ימין (ראשון בשורה = ימין ב-RTL) + תוכן */
.layout { flex: 1; display: flex; align-items: stretch; }
.sidebar { width: 230px; flex-shrink: 0; background: #fff; border-inline-end: 1px solid var(--line); padding: 16px 10px; }
.sidebar ul { list-style: none; margin: 0 0 14px; padding: 0; }
.sidebar a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600; }
.sidebar a:hover { background: #eef0f7; }
.sidebar a[aria-current="page"] { background: var(--navy); color: #fff; }
.nav-group { margin: 6px 12px 6px; font-size: 13px; color: var(--muted); font-weight: 700; }
.menu-toggle { display: none; background: transparent; border-color: #fff; }
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; border-inline-end: 0; border-bottom: 1px solid var(--line); display: none; }
  .sidebar.open { display: block; }
  .menu-toggle { display: inline-block; }
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; inset-inline-start: 8px; top: -60px; background: #fff; color: var(--navy);
             padding: 8px 14px; border-radius: 6px; z-index: 10; font-weight: 700; }
.skip-link:focus { top: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.site-header { background: var(--navy); color: #fff; padding: 12px 20px; display: flex; flex-wrap: wrap;
               align-items: center; justify-content: space-between; gap: 10px; border-bottom: 3px solid var(--gold); }
.site-title { margin: 0; font-size: 18px; font-weight: 700; }
.site-header ul { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; }
.site-header a { color: #fff; text-decoration: none; padding: 8px 14px; border-radius: 8px; display: inline-block; }
.site-header a:hover { background: var(--navy-2); }

.user-box { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user-box button.secondary { background: transparent; color: #fff; border-color: #fff; }
.user-box button.secondary:hover { background: var(--navy-2); }
.login { max-width: 520px; margin: 30px auto; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0; grid-column: 1 / -1; }
legend { font-weight: 700; color: var(--navy); padding: 0 6px; }
fieldset .check { display: block; margin: 4px 0; }

h1 { font-size: 24px; margin: 6px 0 16px; color: var(--navy); }
h2 { font-size: 19px; margin: 0 0 12px; color: var(--navy); }
h3 { font-size: 16px; margin: 0 0 10px; color: var(--navy); }
a { color: var(--focus); }
.muted { color: var(--muted); }
.back { display: inline-block; margin-bottom: 4px; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tile .label { color: var(--muted); font-size: 14px; display: block; }
.tile .value { font-size: 22px; font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
caption { text-align: right; font-weight: 700; padding-bottom: 6px; color: var(--navy); }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 15px; vertical-align: top; }
th { color: var(--muted); font-weight: 700; background: #fafbfd; }
td.num, th.num { text-align: left; direction: ltr; unicode-bidi: plaintext; white-space: nowrap; }
tr.panel-row > td { background: #f3f5fb; }
tr.is-cancelled td { color: var(--muted); text-decoration: line-through; }
tr.is-cancelled td.keep { text-decoration: none; }

.badge { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 13px; background: #eef0f7; color: var(--navy); white-space: nowrap; }
.badge.debt { background: #fde8e8; color: var(--debt); }
.badge.credit { background: #e3f3e4; color: var(--credit); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.amount.debt { color: var(--debt); font-weight: 700; }
.amount.credit { color: var(--credit); font-weight: 700; }

button, .button { font: inherit; background: var(--navy); color: #fff; border: 2px solid var(--navy); border-radius: 8px;
                  padding: 8px 16px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover { background: var(--navy-2); }
button.secondary, .button.secondary { background: #fff; color: var(--navy); }
button.secondary:hover { background: #eef0f7; }
button.danger { background: #fff; color: var(--debt); border-color: var(--debt); }
button.small, .button.small { padding: 4px 10px; font-size: 14px; }
button:disabled { opacity: .6; cursor: wait; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.form { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 10px 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.field .req { color: var(--muted); font-weight: 400; }
.field .hint { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }
.field.check label { display: inline; font-weight: 400; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #8a90a0; border-radius: 8px; background: #fff; color: var(--text); }
input[type="checkbox"], input[type="radio"] { width: auto; margin-inline-end: 6px; }
.form-error { color: var(--debt); font-weight: 700; margin: 8px 0 0; }
.form-error:empty { display: none; }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 14px; margin: 10px 0; }

.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.details dt { font-weight: 700; color: var(--muted); }
.details dd { margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { min-width: 200px; }
details > summary { cursor: pointer; font-weight: 700; color: var(--navy); padding: 6px 0; }
.list-plain { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }

/* גרף עמודות — סדרה אחת, צבע אחד; קצה עליון מעוגל 4px, רווח 2px בין עמודות */
.chart { margin: 0; }
.chart figcaption { font-weight: 700; color: var(--navy); margin-bottom: 10px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 200px; border-bottom: 1px solid #b9bfcc; padding-top: 24px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: 100%; position: relative; }
.bar { background: var(--navy); border-radius: 4px 4px 0 0; min-height: 0; position: relative; cursor: default; }
.bar:hover, .bar:focus-visible { background: var(--navy-2); }
.bar:hover::after, .bar:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); inset-inline-start: 50%; transform: translateX(50%);
  background: #1b1f2a; color: #fff; font-size: 13px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; }
.bar-label { position: absolute; top: 100%; inset-inline: 0; text-align: center; font-size: 12px; color: var(--muted); padding-top: 4px; }
/* מקום לשמות החודשים מתחת לעמודות — שלא יעלו על מה שבא אחרי הגרף */
.chart .bars { margin-bottom: 28px; }
.chart details { margin-top: 6px; }
/* זוג עמודות לחודש: צפוי מול נגבה (צבעים נבדקו — מובחנים גם לעיוורון צבעים) */
:root { --series-expected: #3F5BD8; --series-collected: #B8860B; }
.bars.paired { gap: 10px; }
.pair { display: flex; align-items: flex-end; gap: 2px; height: 100%; }
.pbar { flex: 1; border-radius: 4px 4px 0 0; position: relative; }
.pbar.expected { background: var(--series-expected); }
.pbar.collected { background: var(--series-collected); }
.pbar:hover, .pbar:focus-visible { filter: brightness(.85); }
.pbar:hover::after, .pbar:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); inset-inline-start: 50%; transform: translateX(50%);
  background: #1b1f2a; color: #fff; font-size: 13px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 14px; color: var(--text); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.expected { background: var(--series-expected); }
.swatch.collected { background: var(--series-collected); }
.total-row td { font-weight: 700; border-top: 2px solid var(--line); }

/* עמודות אופקיות — חוב לפי מוצר */
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hbars li { display: grid; grid-template-columns: 140px 1fr auto; gap: 10px; align-items: center; }
.hbar-track { background: #eef0f7; border-radius: 4px; height: 14px; }
.hbar { display: block; height: 100%; background: var(--navy); border-radius: 4px; }
.hbar-value { font-size: 14px; white-space: nowrap; }

/* בניית טפסים — עורך הסעיפים והשדות */
.mono-ltr { direction: ltr; unicode-bidi: isolate; font-family: Consolas, "Courier New", monospace; font-size: 14px; }
.button.secondary-link { background: #fff; color: var(--navy); }
.form-builder { display: grid; gap: 0; }
.section-box { display: grid; gap: 8px; margin-bottom: 12px; padding: 12px; }
.section-box > button, .sections > button { justify-self: start; }
/* תיבת סימון/בחירה צמודה לתווית שלה */
.check { display: flex; align-items: center; gap: 6px; }
.field .check label, .check label { display: inline; margin: 0; font-weight: 700; }
.section-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.section-head input { flex: 1; min-width: 180px; font-weight: 700; }
.field-rows { display: grid; gap: 6px; }
.field-row { display: grid; grid-template-columns: 32px minmax(160px, 2fr) minmax(100px, 1fr) minmax(150px, 1.4fr) auto auto auto; gap: 6px; align-items: center; }
.field-row-head { font-size: 13px; color: var(--muted); font-weight: 700; }
.row-num { color: var(--muted); font-size: 13px; text-align: center; }
.req-toggle { white-space: nowrap; font-size: 14px; }
.row-btns { display: flex; gap: 4px; }
.field-row input[name^="opt-"] { grid-column: 2 / 5; }
.field-row .perfam { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 14px; }
.field-row .perfam label { font-weight: 400; }
@media (max-width: 900px) {
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row-head { display: none; }
  .row-num { text-align: start; }
  .field-row input[name^="opt-"] { grid-column: 1 / -1; }
}

ul.notes { margin: 0; padding-inline-start: 18px; font-size: 14px; }

/* הדפסה / PDF: רק התוכן */
@media print {
  .site-header, .sidebar, .siro-footer, .no-print, .skip-link, form, details > summary { display: none !important; }
  body { background: #fff; }
  .card { border: 0; padding: 0; break-inside: avoid; }
  main { max-width: none; padding: 0; }
}

@media (max-width: 640px) {
  .hbars li { grid-template-columns: 1fr; }
  th, td { font-size: 14px; padding: 7px 6px; }
  h1 { font-size: 21px; }
}

/* מחולל הטפסים (docs/02 כלל 27): מסך המחולל ומסך הביקורת */
.mt { margin-top: 16px; }
.fields.one { grid-template-columns: 1fr; margin-top: 12px; }
textarea.big-text { min-height: 320px; line-height: 1.6; }
.logo-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.logo-opt { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 600; background: #fff; }
.logo-opt:has(input:checked) { border-color: var(--navy); background: #eef0f7; }
.logo-thumb { display: inline-flex; align-items: center; justify-content: center; background: #1C224E; border-radius: 8px; padding: 6px; height: 48px; min-width: 64px; }
.logo-thumb img { max-height: 36px; max-width: 120px; background: #fff; border-radius: 4px; padding: 2px; }
.logo-preview { background: #1C224E; border-radius: 10px; padding: 14px; display: inline-block; }
.logo-preview img { max-height: 80px; max-width: 320px; display: block; }
.theme-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.theme-opt { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 600; }
.theme-opt:has(input:checked) { border-color: var(--navy); background: #eef0f7; }
.swatches { display: inline-flex; gap: 2px; }
.sw { width: 16px; height: 16px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.steps-editor { display: grid; gap: 14px; }
.steps-editor > button { justify-self: start; }
.step-box { display: grid; gap: 10px; padding: 12px 14px; background: #fafbfd; }
.step-box .actions { align-items: center; }
.step-box .actions select { width: auto; }
.spacer { flex: 1; }
.blk-list { display: grid; gap: 6px; }
.blk { background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.blk.is-open { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }
.blk-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
.blk-sum { flex: 1; min-width: 160px; }
.blk-body { padding: 4px 12px 12px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.blk-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.blk-body h4 { margin: 6px 0 0; font-size: 14px; color: var(--navy); }
.blk-body > button, .blk-body button.small { justify-self: start; }
.sub-rows { display: grid; gap: 8px; }
.sub-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; align-items: end; padding: 8px; border: 1px dashed var(--line); border-radius: 8px; }
.sub-row > button { justify-self: start; }
.perfam { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 14px; }
.perfam .field.check label { font-weight: 400; }
.check-list { border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.check-list h3 { margin: 0 0 6px; }
.check-list ul { margin: 0 0 6px; padding-inline-start: 18px; }
.check-list.problems { background: #fde8e8; color: var(--debt); }
.check-list.problems h3 { color: var(--debt); }
.check-list.warnings { background: var(--warn-bg); color: var(--warn); }
.check-list.warnings h3 { color: var(--warn); }
.warn-list li { color: var(--warn); }
pre.src-text { white-space: pre-wrap; font-family: inherit; background: #fafbfd; border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 420px; overflow: auto; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); z-index: 3; }

/* ייבוא מהגיליון */
.small { font-size: 13px; }
.muted.small { margin-top: 2px; }
td button.small { margin: 2px 0 2px 4px; }

/* טבלה עם עמודות לבחירה ורוחב שניתן לגרור */
.coltable-tools { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.col-panel { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; background: #fafbfd; }
.col-list { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 6px 0; }
.col-list .check { font-weight: 400; }
table.fixed { table-layout: fixed; }
table.fixed td, table.fixed th { overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere; }
.coltable th { position: relative; padding-inline-end: 14px; }
.col-resize { position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: 10px; cursor: col-resize; touch-action: none; }
.col-resize::after { content: ""; position: absolute; top: 20%; bottom: 20%; inset-inline-end: 4px; width: 2px; background: var(--line); border-radius: 2px; }
.col-resize:hover::after, .col-resize:focus-visible::after { background: var(--navy); }

/* גרפים צבעוניים בדאשבורד */
.viz { margin: 0 0 8px; display: grid; gap: 10px; min-width: 0; }
.viz figcaption { font-weight: 700; color: var(--navy); }
.viz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 22px; margin-top: 14px; }
.viz-scroll { overflow-x: auto; }
.bars-svg { width: 100%; min-width: 520px; height: auto; display: block; }
.bars-svg .grid { stroke: #e6e8ee; stroke-width: 1; }
.bars-svg .axis { stroke: #b9bfcc; stroke-width: 1; }
.bars-svg .tick { font-size: 11px; fill: var(--muted); }
.viz .seg { transition: opacity .15s; cursor: default; outline: none; }
.viz svg:hover .seg { opacity: .55; }
.viz svg .seg:hover, .viz svg .seg:focus { opacity: 1; }
.viz .hit { cursor: default; outline: none; }
.donut-body { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.donut-total { font-size: 17px; font-weight: 700; fill: var(--text); }
.donut-sub { font-size: 11px; fill: var(--muted); }
.viz-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; flex: 1; min-width: 180px; }
.viz-legend li { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; font-size: 14px; }
.viz-legend.inline { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.viz-legend.inline li { display: inline-flex; gap: 6px; }
.viz-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.viz-legend .lg-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.rank li { display: grid; grid-template-columns: minmax(110px, 40%) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { background: #f1f2f6; border-radius: 4px; height: 14px; }
.rank-bar { display: block; height: 100%; border-radius: 4px; outline: none; }
.rank-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta { font-size: 13px; color: var(--muted); font-weight: 400; }
.delta .arrow.good { color: #0b8a3e; }
.delta .arrow.bad { color: #c62f2f; }
.delta .arrow.up { color: #0b8a3e; }
.delta .arrow.flat { color: var(--muted); }
.viz-tip { position: fixed; z-index: 50; background: #1b1f2a; color: #fff; font-size: 13px; padding: 6px 10px; border-radius: 6px; pointer-events: none; max-width: 320px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
@media (max-width: 640px) { .rank li { grid-template-columns: 1fr auto; } .rank-track { grid-column: 1 / -1; grid-row: 2; } }

/* מיילים אוטומטיים — תצוגת מייל */
.mail-preview { border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; margin: 12px 0; }
.mail-frame { width: 100%; height: 640px; border: 1px solid #e5e7eb; border-radius: 6px; background: #F7F6F2; }

/* הוצאות + רווחיות מיזמים */
tr.total th, tr.total td { border-top: 2px solid var(--navy); font-weight: 700; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 8px 0; }
dl.kv dt { color: var(--muted, #555); }
dl.kv dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.button.small { padding: 4px 10px; font-size: 14px; }
