:root {
  /* הצבעים של התוכנה של משי (מהגדרות המסכים באקסס) */
  --bg: #fefbf8;          /* רקע המסך הראשי */
  --panel: #fce6d4;       /* אפרסק - כפתורים ראשיים */
  --card: #ffffff;
  --tile: #fce6d4;
  --text: #2b1c10;
  --muted: #7d6450;
  --border: #ecd3bd;
  --primary: #7a4e2b;     /* חום - מסגרות וטקסט */
  --primary-dark: #5c3a1f;
  --head: #7a4e2b;
  --orange: #f59d56;      /* מסגרות כתומות */
  --orange-light: #f7b580;
  --peach-dark: #f9cdaa;
  --group: #eceae6;       /* רקע קבוצות בדוחות וביצוע */
  --green: #cddcaf;
  --danger: #b42318;
  --success: #1e7b45;
  --warning: #9a6700;
  --radius: 6px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Assistant', 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === כותרת עליונה === */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: var(--primary); color: #fff; padding: 10px 20px;
  position: sticky; top: 0; z-index: 900;   /* נשאר למעלה גם בגלילה (מתחת לחלונות קופצים ולוח השנה) */
}
.topbar a { color: #fff; }
.brand { font-weight: 700; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a { padding: 6px 12px; border-radius: 6px; }
.mainnav a:hover, .mainnav a.active { background: rgba(255,255,255,.18); text-decoration: none; }
.userbox { margin-inline-start: auto; display: flex; gap: 12px; align-items: center; font-size: 14px; }
.userbox .inst { background: rgba(255,255,255,.18); padding: 4px 10px; border-radius: 6px; }
.userbox .role { opacity: .75; }

.container { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
h1 { font-size: 26px; margin: 0 0 16px; }
h2 { font-size: 19px; margin: 0 0 12px; }

/* === כרטיסים וטבלאות === */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--muted); font-size: 14px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: right; }
th { color: var(--muted); font-weight: 600; font-size: 14px; background: #fdf3ea; }
tr:hover td { background: #fef6ee; }
.num { text-align: left; direction: ltr; white-space: nowrap; }
.muted { color: var(--muted); }
.table-wrap { overflow-x: auto; }

/* === טפסים === */
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
input[type=text], input[type=password], input[type=email], input[type=search], input[type=date], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(122,74,31,.25); border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 20px; }
.field { margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.hint { color: var(--muted); font-size: 13px; margin-top: 3px; }

.btn {
  display: inline-block; padding: 9px 18px; border: 0; border-radius: 8px; cursor: pointer;
  font: inherit; font-weight: 600; background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-light { background: #f6e6d6; color: var(--text); }
.btn-light:hover { background: #eed5bd; }
.btn-danger { background: var(--danger); }
.btn-block { display: block; width: 100%; text-align: center; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 13px; background: #f6e6d6; }
.badge-ok { background: #dff3e7; color: var(--success); }
.badge-off { background: #f3e1df; color: var(--danger); }
.badge-warn { background: #fbf0d9; color: var(--warning); }
.badge-tag { background: #f6e3b4; color: #7a5410; }
/* חיוג מהטלפון שליד המחשב - רק כשמוגדר טלפון במחשב */
.dial { display: none; border: 0; background: none; cursor: pointer; padding: 0 4px; font-size: 15px; line-height: 1; vertical-align: middle; }
body.can-dial .dial { display: inline-block; }
.dial:hover, .dial:focus-visible { transform: scale(1.2); }
@media print { .dial, body.can-dial .dial { display: none !important; } }
#dial_toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px); background: #2f2116; color: #fff; padding: 10px 18px; border-radius: 8px;
              font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 1000; }
#dial_toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* הוספת לקוח מהירה מתוך טופס */
.results a.cp-new { border-top: 1px solid var(--border); color: var(--primary); }
.cp-modal { position: fixed; inset: 0; background: rgba(40,25,10,.45); z-index: 2000; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; overflow-y: auto; }
.cp-box { background: #fff; border-radius: 10px; padding: 18px 20px; width: min(640px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.cp-box h2 { margin: 0 0 12px; }
.cp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 12px; }
.cp-grid .field { margin: 0; }
.cp-msg { color: var(--danger); margin-top: 8px; min-height: 1.2em; }
.cp-dups { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.cp-dups:empty { display: none; }
/* תגיות ללקוחות */
.label-chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--lc, #6b7a8f); color: var(--lc, #6b7a8f); background: #fff;
              border-radius: 999px; padding: 1px 10px; font-size: 13px; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.label-chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 15px; line-height: 1; }
.label-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.label-bar form { display: inline-flex; gap: 4px; margin: 0; }
.label-bar select { width: auto; padding: 2px 6px; font-size: 13px; }

/* === חיפוש ורשימות === */
.searchbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.searchbar input[type=search] { flex: 1; min-width: 220px; font-size: 17px; }
.searchbar select, .searchbar input[type=date] { width: auto; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager span { padding: 5px 11px; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.pager span.cur { background: var(--primary); color: #fff; border-color: var(--primary); }
tr.clickable { cursor: pointer; }
.debt { color: var(--danger); font-weight: 600; }

/* === כרטיס לקוח === */
.contact-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.contact-head h1 { margin: 0; }
.contact-head .sub { color: var(--muted); margin-top: 4px; }
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 24px; }
.details div span { display: block; color: var(--muted); font-size: 13px; }
.badge.badge-frozen { background: #e3eefb; color: #1d4f8a; text-decoration: none; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 16px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); text-decoration: none; }
.tabs a .count { font-weight: 400; font-size: 13px; }
tfoot td { font-weight: 700; background: #fdf3ea; }

/* === בחירת לקוח בטופס === */
.picker { position: relative; max-width: 560px; }
.picked { display: flex; gap: 12px; align-items: baseline; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fef6ee; }
/* כרטיס לקוח אחרי בחירה */
.picked:has(.picked-card) { align-items: flex-start; justify-content: space-between; box-shadow: 3px 3px 0 #ecd3bd; }
.picked.contact-box { margin-bottom: 18px; padding: 14px 16px; }
.picked-card { flex: 1; text-align: center; line-height: 1.6; }
.picked-card .cc-name { font-size: 18px; font-weight: 700; }
.picked-card .cc-line { font-size: 14px; color: #5a4a3a; }
.picked-card .cc-extra { margin-top: 2px; }
.picked-card .cc-debt { color: var(--danger); font-weight: 600; }
.picked-card .cc-nodebt { color: var(--success); }
.results { position: absolute; z-index: 10; inset-inline: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.08); max-height: 320px; overflow-y: auto; }
.results:empty { display: none; }
.results a { display: block; padding: 8px 12px; color: var(--text); border-bottom: 1px solid var(--border); }
.results a:hover { background: #fdeedd; text-decoration: none; }
[hidden] { display: none !important; }

/* === טבלת הזנת עליות === */
table.aliyot td { padding: 5px 6px; vertical-align: top; }
table.aliyot input, table.aliyot select { padding: 7px 9px; }
table.aliyot td.picker { position: relative; }
table.aliyot .results { top: 100%; min-width: 320px; }
input.a-contact.ok { border-color: var(--success); background: #f1faf4; }

/* === סינון טבלאות === */
.table-filter { display: flex; gap: 12px; align-items: center; margin: 0 0 8px; }
.table-filter input { max-width: 320px; padding: 7px 11px; }
.table-filter .muted { font-size: 14px; }
tr[hidden] { display: none; }

/* === מסך ראשי (כמו באקסס) === */
.home { display: grid; grid-template-columns: 270px 1fr; gap: 18px; align-items: start; }
.home-main { background: var(--panel); border: 1px solid #ecd3bd; border-radius: 6px; padding: 16px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.home-col { display: grid; grid-template-rows: auto auto; gap: 14px; align-content: start; }
.group { background: #fff; border: 1px solid #ecd3bd; border-radius: 4px; padding: 0 0 12px; min-height: 180px; }
.group h2 { margin: 0 0 10px; padding: 6px 8px; text-align: center; color: var(--head); font-size: 20px; font-weight: 700; background: #fce6d4; }
.tile { display: block; margin: 7px 10px; padding: 9px 6px; text-align: center; background: var(--tile); color: var(--primary);
        font-weight: 600; border-radius: 4px; box-shadow: 0 1px 0 #d9c7b1; transition: background .15s; }
.tile:hover { background: #f9d9bf; text-decoration: none; }
.tile.soon { color: #b5a592; cursor: default; }
.tile.soon:hover { background: var(--tile); }
.tile small { display: block; font-weight: 400; font-size: 12px; }
.home-side { display: grid; gap: 18px; }
.side-box { background: var(--panel); border: 1px solid #ecd3bd; border-radius: 6px; padding: 14px; }
.side-inner { background: #fffaf4; border: 1px solid #ecd3bd; padding: 12px; text-align: center; }
.side-inner .bsd { font-size: 13px; color: var(--muted); }
.side-inner .appname { font-size: 34px; font-weight: 700; color: var(--primary); margin: 4px 0 0; line-height: 1.1; }
.side-inner .appname img { vertical-align: middle; margin-inline-end: 6px; }
.side-inner .ver { font-size: 12px; color: var(--head); margin-bottom: 10px; }
.side-inner table th, .side-inner table td { padding: 5px 6px; border: 0; text-align: center; background: none; }
.side-inner table th { background: #f3e3cc; color: var(--muted); font-weight: 400; }
.side-inner table td { font-weight: 700; font-size: 16px; }
.side-btns { display: flex; gap: 8px; margin-top: 12px; }
.side-btns a { flex: 1; text-align: center; padding: 8px 4px; background: #fce6d4; border: 1px solid #d9a27a; color: var(--primary); font-weight: 600; border-radius: 3px; box-shadow: 1px 1px 0 #c08a60; }
.side-btns a:hover { background: #f9d9bf; text-decoration: none; }
.date-box { text-align: center; }
.date-box div { background: #fff; border: 1px solid #ecd3bd; padding: 6px; margin-bottom: 6px; font-weight: 700; font-size: 17px; }
.exit-btn { display: block; width: 120px; margin: 18px auto 4px; padding: 10px; text-align: center; background: #fce6d4; border: 1px solid #d9a27a; color: var(--primary); font-weight: 700; box-shadow: 2px 2px 0 #c08a60; }
.exit-btn:hover { background: #f9d9bf; text-decoration: none; }
.side-stats { font-size: 14px; }
.side-stats div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed #e3d2bb; }
.side-stats div:last-child { border: 0; }
@media (max-width: 1000px) {
  .home { grid-template-columns: 1fr; }
  .home-main { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) { .home-main { grid-template-columns: 1fr; } }
input:disabled, select:disabled { background: #f1f3f5; color: var(--muted); }

/* === הודעות === */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: #e9f7ef; border-color: #b9e2c8; color: var(--success); }
.alert-error   { background: #fdecea; border-color: #f4c2bd; color: var(--danger); }
.alert-info    { background: #fbf1e3; border-color: #e8cfae; color: var(--primary-dark); }

/* === מסך כניסה === */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; }
.login-box h1 { text-align: center; color: var(--primary); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 18px 0; font-size: 14px; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.btn-google { background: #fff; color: var(--text); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-google:hover { background: #fef6ee; }

.inst-list { display: grid; gap: 10px; }
.inst-list button { text-align: right; padding: 14px 16px; font-size: 17px; }

@media (max-width: 700px) {
  .topbar { gap: 10px; }
  .userbox { margin-inline-start: 0; width: 100%; }
}

/* === חיוב קבוצתי === */
tr.row-warn td { background: #fdf0ec; }
tr.row-dup td { background: #fdf7e3; }
.g-del { color: var(--danger); font-size: 17px; text-decoration: none; }
details summary { margin: 6px 0; }
tr.row-entry td { background: #fffbf3; }
tr.row-entry .g-q { border-style: dashed; }
.results a.active { background: #f1dcc0; outline: 1px solid #d9b98f; }

/* === סיכום חוב בקליטת תשלום === */
.debt-box { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; background: #fff6e8; border: 1px solid #ecd3ad; border-radius: 8px; padding: 12px 16px; margin: 0 0 16px; max-width: 760px; }
.debt-lines { flex: 1; min-width: 260px; }
.debt-title { font-weight: 700; color: var(--head); margin-bottom: 4px; }
.debt-line { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; }
.debt-line strong { color: var(--danger); font-size: 17px; }
.debt-total { border-top: 1px dashed #e0c49b; margin-top: 4px; padding-top: 6px; }
.debt-total strong { font-size: 19px; }
#pay_all { font-size: 17px; padding: 11px 24px; }

/* === דוח ללקוח (גיליון להדפסה) === */
.sheet { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 32px 40px; max-width: 900px; margin: 0 auto 30px; color: #111; }
.sheet-top { display: flex; justify-content: space-between; font-size: 14px; }
.sheet-inst { text-align: center; font-size: 26px; font-weight: 700; margin: 4px 0 20px; color: var(--primary); }
.sheet-to { margin-bottom: 18px; line-height: 1.6; }
.sheet-to strong { font-size: 18px; }
.sheet-title { text-align: center; font-size: 20px; margin: 10px 0 16px; border-bottom: 2px solid #333; padding-bottom: 6px; }
.sheet-period { display: block; font-size: 14px; font-weight: 400; color: #555; }
.sheet h3 { font-size: 16px; margin: 18px 0 6px; }
.sheet-table { border: 1px solid #999; font-size: 14px; }
.sheet-table th, .sheet-table td { border: 1px solid #bbb; padding: 5px 8px; color: #111; }
.sheet-table th { background: #f0f0f0; color: #111; }
.sheet-table tr:hover td { background: none; }
.sheet-table tfoot td { background: #f5f5f5; }
.sheet-empty { color: #555; }
.sheet-summary { margin: 24px 0 0 auto; max-width: 440px; border: 2px solid #333; padding: 10px 14px; }
.sheet-summary .sum-title { font-weight: 700; margin-bottom: 6px; }
.sheet-summary .sum-line { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; }
.sheet-summary .sum-total { border-top: 1px solid #333; margin-top: 4px; padding-top: 6px; font-size: 17px; }

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .topbar, .no-print, .alert { display: none !important; }
  .container { max-width: none; margin: 0; padding: 0; }
  .sheet { border: 0; padding: 0; max-width: none; margin: 0; }
  .sheet-inst { color: #000; }
  .sheet-table tr { page-break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}
.sheet-table.recon { max-width: 640px; }
.sheet-table.recon td:first-child { width: 55%; }
.sheet-table .recon-total td { font-weight: 700; background: #f5f5f5; border-top: 2px solid #555; }
.sheet-note { font-size: 12px; color: #555; margin: 4px 0 0; }

/* === טלפון === */
.nav-toggle { display: none; }
@media screen and (max-width: 800px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand { font-size: 18px; }
  .nav-toggle { display: block; margin-inline-start: auto; background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 8px;
                font-size: 22px; line-height: 1; padding: 7px 12px; cursor: pointer; }
  .mainnav, .userbox { display: none; width: 100%; }
  .topbar.open .mainnav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .topbar.open .mainnav a { padding: 10px 12px; background: rgba(255,255,255,.08); }
  .topbar.open .userbox { display: flex; flex-wrap: wrap; margin: 4px 0 2px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.2); }

  .container { margin: 12px auto; padding: 0 10px; }
  h1 { font-size: 21px; margin-bottom: 12px; }
  .card { padding: 12px; margin-bottom: 14px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .details { grid-template-columns: 1fr 1fr; gap: 8px 14px; }
  .stat { padding: 10px; }
  .stat .value { font-size: 20px; }

  /* טבלאות: כל שורה ככרטיס, כל תא עם שם העמודה - בלי גלילה לצד */
  main table:not(.keep-table) { display: block; }
  main table:not(.keep-table) thead { display: none; }
  main table:not(.keep-table) tbody, main table:not(.keep-table) tfoot { display: block; }
  main table:not(.keep-table) tr { display: block; margin: 8px; padding: 6px 12px; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
  main table:not(.keep-table) tfoot tr { background: #fdf3ea; }
  main table:not(.keep-table) tr[hidden] { display: none !important; }
  main table:not(.keep-table) td { display: block; padding: 6px 0; border: 0; border-bottom: 1px dashed #efe3d3; text-align: left;
                                   white-space: normal; background: none !important; overflow: hidden; }
  main table:not(.keep-table) td:last-child { border-bottom: 0; }
  main table:not(.keep-table) td::before { content: attr(data-label); float: right; margin-left: 12px; color: var(--muted); font-size: 13px; font-weight: 600; text-align: right; }
  main table:not(.keep-table) td[data-label=""] { text-align: right; }
  main table:not(.keep-table) td[data-label=""]::before { display: none; }
  main table:not(.keep-table) td:empty, main table:not(.keep-table) td.blank { display: none; }
  main table:not(.keep-table) td.has-field { text-align: right; }
  main table:not(.keep-table) td.has-field::before { float: none; display: block; margin: 0 0 3px; }
  main table:not(.keep-table) td.has-field input:not([type=checkbox]):not([type=radio]), main table:not(.keep-table) td.has-field select { width: 100% !important; }
  main table:not(.keep-table) td.num { direction: rtl; }
  main table:not(.keep-table) tr.row-warn { background: #fdf0ec; }
  main table:not(.keep-table) tr.row-dup { background: #fdf7e3; }
  main table:not(.keep-table) tr.row-entry { background: #fffbf3; border-style: dashed; }
  .card.table-wrap, .table-wrap { padding: 0; overflow: visible; }

  /* טפסים: שדות ברוחב מלא, כפתורים גדולים למגע */
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .searchbar { gap: 8px; }
  .searchbar input[type=search] { min-width: 0; width: 100%; flex-basis: 100%; }
  .searchbar > select, .searchbar > .field { flex: 1 1 45%; }
  .searchbar .field select, .searchbar .field input { width: 100%; }
  input[type=text], input[type=password], input[type=email], input[type=search], input[type=date], input[type=number], select, textarea { font-size: 16px; }
  .btn { padding: 11px 18px; }
  .actions .btn { flex: 1 1 auto; text-align: center; }
  .picker { max-width: none; }
  .results { max-height: 50vh; }
  .results a { padding: 12px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs a { white-space: nowrap; padding: 9px 12px; }
  .contact-head .actions { width: 100%; }
  .table-filter input { max-width: none; }

  /* מסך ראשי: האריחים קודם, הפאנל אחריהם */
  .home-main { padding: 10px; gap: 10px; }
  .home-side { order: 2; }
  .group { min-height: 0; }
  .tile { padding: 12px 6px; }
  .side-inner .appname { font-size: 26px; }

  .debt-box { padding: 10px; }
  .debt-lines { min-width: 0; }
  .sheet { padding: 16px 12px; }
  .sheet-summary { max-width: none; }
}
@media screen and (max-width: 420px) {
  .topbar.open .mainnav { grid-template-columns: 1fr; }
}

/* טלפון: שם המוסד תמיד גלוי בכותרת */
.inst-mobile { display: none; }
@media screen and (max-width: 800px) {
  .inst-mobile { display: block; margin-inline-start: auto; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
                 background: rgba(255,255,255,.18); padding: 5px 10px; border-radius: 6px; font-size: 14px; font-weight: 600; }
  .inst-mobile + .nav-toggle { margin-inline-start: 0; }
}

/* שורת זכויות בתחתית כל דף */
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 16px 24px; }
@media print { .site-footer { display: none; } }


/* =====================================================================
   מסכים בפריסת Access (includes/access_layout.php)
   ===================================================================== */
.ax-fit { margin: 0 auto; position: relative; width: max-content; max-width: 100%; overflow-x: auto; }
.ax-screen { color: #000; }
.ax-screen input, .ax-screen select, .ax-screen textarea { color: #000; }
.container:has(.ax-fit) { max-width: none; }
.ax-screen { position: relative; transform-origin: top left; direction: ltr; font-family: Arial, sans-serif; }
.ax { direction: rtl; position: absolute; box-sizing: border-box; overflow: hidden; display: flex; align-items: center; justify-content: center;
      text-align: center; line-height: 1.15; padding: 1px 3px; }
.ax-rectangle { padding: 0; }
.ax-label { white-space: pre-line; align-items: flex-start; }   /* באקסס טקסט של תווית צמוד למעלה */
.ax-label:not([style*="text-align:center"]) { justify-content: flex-start; }
.ax-image { padding: 0; }
.ax-image img { max-width: 100%; max-height: 100%; }
.ax-commandbutton { cursor: pointer; text-decoration: none; font: inherit; }
.ax-commandbutton span { display: block; }
.ax-commandbutton img { max-width: 100%; max-height: 100%; display: block; }
.ax-commandbutton:hover { filter: brightness(.94); text-decoration: none; }
.ax-commandbutton:active { filter: brightness(.86); }
.ax-commandbutton:focus-visible { outline: 3px solid #1a73e8; outline-offset: 1px; }
/* כפתור שעוד לא פעיל: מסגרת אדומה מקווקוות (יורדת כשהכפתור מחובר) */
.ax-soon { cursor: help; outline: 2px dashed #d40000 !important; outline-offset: 2px; }
.ax-soon.ax-snip { clip-path: none; }
/* פינה חתוכה (צורה 2 באקסס) - הפינה העליונה הימנית */
.ax-snip { clip-path: polygon(0 0, 83% 0, 100% 17%, 100% 100%, 0 100%); }
.ax-snip::before { content: ""; position: absolute; top: 0; left: 83%; width: 24.2%; border-top: 2.7px solid var(--primary);
                   transform-origin: top left; transform: rotate(45deg); pointer-events: none; }
.ax-textbox, .ax-combobox { background: #fff; padding: 0; }
.ax-textbox input, .ax-combobox select { width: 100%; direction: ltr; height: 100%; border: 0; background: transparent; font: inherit; color: inherit;
                                         text-align: center; padding: 0 1px; }
.ax-textbox input:focus, .ax-combobox select:focus { outline: 2px solid var(--orange); }
.ax-home-bar { display: flex; justify-content: space-between; align-items: center; max-width: 1110px; margin: 0 auto 6px; font-size: 14px; color: var(--muted); }

/* =====================================================================
   צפיה בפרטים - רשימה בפריסת תת-הטופס "כללי"
   ===================================================================== */
.ax-subform { align-items: stretch; justify-content: flex-start; padding: 0; background: #fff; border: 1px solid #b9b9b9; }
.dl { direction: ltr; display: flex; flex-direction: column; height: 100%; font-family: Arial, sans-serif; font-size: 10pt; color: #000; }
.dl-head { position: relative; flex: none; }
.dl-head-cell { position: absolute; top: 0; direction: rtl; text-align: center; overflow: hidden; white-space: nowrap; font-size: 10pt; font-weight: 700; border-left: 1px solid #e6c7ad; }
.dl-body { flex: 1; overflow-y: auto; overflow-x: hidden; }
.dl-row { position: relative; border-bottom: 1px solid #eee; }
.dl-row:hover { background: #fff3e6 !important; }
.dl-cell { position: absolute; top: 0; direction: rtl; box-sizing: border-box; border: 0; background: transparent; font: inherit; padding: 0 2px; margin: 0;
           white-space: nowrap; overflow: hidden; }
input.dl-cell, select.dl-cell { border: 1px solid transparent; }
input.dl-cell:focus, select.dl-cell:focus { border-color: var(--orange); background: #fff; outline: none; }
input.dl-cell[readonly] { color: #000; }
input.dl-cell[dir=ltr] { text-align: left; }
input.dl-cell { padding: 0 1px; }
.ax-label { overflow: visible; white-space: nowrap; }
select.dl-cell { -webkit-appearance: none; appearance: none; cursor: pointer; }
select.dl-cell:disabled, input.dl-cell:disabled { color: inherit; opacity: 1; cursor: default; }
.dl-btn { background: #f9cdaa; border: 1px solid #f59d56; cursor: pointer; font-size: 8.5pt; }
.dl-saved { background: #e3f6e3 !important; transition: background 1.5s; }
.dl-error { background: #fde2e1 !important; }
.dl-foot { flex: none; direction: rtl; padding: 6px 10px; border-top: 1px solid #ddd; font-size: 10pt; }
.ax-textbox input[type=text], .ax-combobox select { font-size: 10pt; color: #000; }
.ax-checkbox { background: transparent !important; border: 0 !important; }
.ax-label a { color: inherit; text-decoration: underline dotted; }
.ax-label.ax-click { cursor: pointer; }

/* =====================================================================
   רשימות עריכה (includes/access_grid.php) - תתי-טפסים רציפים
   ===================================================================== */
.ax-subform > div { width: 100%; height: 100%; }
.ag { direction: ltr; font: 10pt Arial, sans-serif; color: #000; background: #fff; border: 1px solid #c9b6a4; max-width: 100%; }
.ag-head { position: relative; border-bottom: 1px solid #d7b99f; }
.ag-hc { position: absolute; direction: rtl; text-align: center; white-space: nowrap; overflow: hidden; font-size: 10pt; font-weight: 700; }
.ag-body { overflow-y: auto; overflow-x: hidden; }
.ag-row { position: relative; border-bottom: 1px solid rgba(0,0,0,.06); }
.ag-new { box-shadow: inset 0 1px 0 #d7b99f; }
.ag-new::before { content: "*"; position: absolute; right: -10px; top: 0; color: #999; }
.ag-selectable .ag-row[data-id] { cursor: pointer; }
.ag-sel { outline: 2px solid var(--orange); outline-offset: -2px; z-index: 1; }
.agc { position: absolute; top: 0; height: 100%; direction: rtl; box-sizing: border-box; border: 1px solid transparent; background: transparent;
       font: inherit; padding: 0 2px; margin: 0; white-space: nowrap; overflow: hidden; }
input.agc:focus, select.agc:focus { border-color: var(--orange); background: #fff; outline: none; }
select.agc { -webkit-appearance: none; appearance: none; cursor: pointer; }
select.agc:disabled { color: inherit; opacity: 1; }
input.agc[readonly] { color: #222; }
input.agc[dir=ltr], input.ag-date { direction: ltr; text-align: center; }
.ag-chk { display: flex; align-items: center; justify-content: center; }
.ag-del { background: #f3d4d1; border: 1px solid #d99; color: var(--danger); cursor: pointer; font-weight: 700; }
.ag-ok { background: #e3f6e3 !important; }
.ag-err { background: #fde2e1 !important; }
.ag-saved { animation: agflash 1.5s; }
@keyframes agflash { from { background: #e3f6e3; } }
.ax textarea { width: 100%; height: 100%; border: 0; resize: none; font: 10pt Arial, sans-serif; background: transparent; }
.ax-listbox select, .ax select[size] { border: 0; font: 10pt Arial, sans-serif; }
/* תאריכים ומספרים - שלא ייחתכו בכתב הגדול */
input.ag-date, input.dl-cell[dir=ltr] { padding: 0; letter-spacing: -.4px; font-size: 9.5pt; }

/* לוח שנה לשדות תאריך (assets/datepick.js) */
.dp-pop { position: absolute; z-index: 1000; background: #fff; border: 1px solid #c9a98c; border-radius: 8px; box-shadow: 0 6px 20px #0003; padding: 8px; width: 238px; direction: rtl; font-family: Assistant, Arial, sans-serif; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dp-head b { font-size: 15px; color: #7a4e2b; }
.dp-head button, .dp-foot button { border: 1px solid #e0b48f; background: #fdf3ea; border-radius: 4px; cursor: pointer; padding: 2px 10px; font: inherit; }
.dp-head button { font-size: 18px; line-height: 1; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-dn { font-size: 12px; font-weight: 700; color: #7a4e2b; padding: 2px 0; }
.dp-d { border: 1px solid transparent; background: #fff; border-radius: 4px; padding: 4px 0; cursor: pointer; font: 14px Arial, sans-serif; }
.dp-d:hover { background: #fce6d4; border-color: #f59d56; }
.dp-we { color: #999; }
.dp-today { border-color: #7a4e2b; font-weight: 700; }
.dp-sel { background: #f59d56 !important; color: #fff; font-weight: 700; }
.dp-foot { display: flex; justify-content: space-between; margin-top: 6px; }

/* מסך שנכנס כולו לחלון (render_access_layout עם fit/stretch): בלי שורת הזכויות ובלי שוליים מיותרים - בלי גלילה של הדף */
body:has(.ax-fit[data-fit]) .site-footer { display: none; }
.container:has(.ax-fit[data-fit]) { margin-top: 8px; margin-bottom: 0; }
.container:has(.ax-fit[data-fit]) .ax-fit { overflow: hidden; }
/* עד שההתאמה לחלון רצה (axlayout.js) - בלי פס גלילה, כדי שלא יופיע לרגע ויעלם */
html:has(.ax-fit[data-fit]:not(.ax-fitted)) { overflow: hidden; }
/* צפיה בפרטים: תאי הרשימה עם קווי רשת ישרים כמו באקסס */
.dl .dl-cell { border-radius: 0; box-shadow: none; }
/* כפתור "הערה לפיתוח" בסרגל העליון */
.topbar .dn-btn { background: rgba(255,255,255,.18); padding: 3px 10px; border-radius: 14px; font-size: 14px; margin-inline-end: 6px; }
.topbar .dn-btn:hover { background: rgba(255,255,255,.3); text-decoration: none; }
