:root{
  --ink:#12263a; --ink-2:#4a5b6c; --line:#dde3e9; --bg:#f2f5f8; --panel:#fff;
  --brand:#0f6e73; --brand-d:#0b5156; --brand-l:#e1f1f1;
  --amber:#b7791f; --amber-l:#fbf0d9; --red:#b3372f; --red-l:#fbe5e3; --green:#2b7a4b; --green-l:#e2f3e8;
  --r:10px;
  --tab-bar-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
*{box-sizing:border-box}
html,body{margin:0;overflow-x:hidden}
body{font-family:'Heebo',system-ui,sans-serif;background:var(--bg);color:var(--ink);font-size:16px;line-height:1.5}
[hidden]{display:none!important}
button,input,select,textarea{font:inherit;color:inherit}
:focus-visible{outline:3px solid var(--brand);outline-offset:2px}

.brand{display:flex;align-items:center;gap:.6rem;font-weight:800;font-size:1.25rem}
.logo{display:grid;place-items:center;width:2.1rem;height:2.1rem;border-radius:9px;background:var(--brand);color:#fff;font-weight:800}

/* auth */
.auth{min-height:100vh;display:grid;place-items:center;padding:1rem;
  background:linear-gradient(160deg,#12263a 0 46%,var(--bg) 46%)}
.auth-card{width:min(420px,100%);background:var(--panel);border-radius:16px;padding:2rem;box-shadow:0 20px 50px rgba(18,38,58,.25)}
.auth-card h1{font-size:1.5rem;margin:1.2rem 0 1rem}

.field{display:block;font-weight:500;font-size:.92rem;margin-bottom:.9rem;color:var(--ink-2)}
.field input,.field select,.field textarea,#search{
  display:block;width:100%;margin-top:.3rem;padding:.6rem .75rem;border:1px solid var(--line);
  border-radius:8px;background:#fff;color:var(--ink)}
.field textarea{min-height:84px;resize:vertical}
.error{color:var(--red);min-height:1.3em;margin:.2rem 0 .6rem;font-size:.9rem}

.btn{border:1px solid var(--line);background:#fff;padding:.55rem 1rem;border-radius:8px;cursor:pointer;font-weight:500}
.btn:hover{border-color:var(--ink-2)}
.btn.primary{background:var(--brand);border-color:var(--brand);color:#fff}
.btn.primary:hover{background:var(--brand-d)}
.btn.danger{color:var(--red)}
.btn.sm{padding:.25rem .6rem;font-size:.85rem}
.btn.block{width:100%}
.link{background:none;border:0;color:var(--brand);cursor:pointer;padding:.4rem 0;font-weight:500}

/* shell */
.app{display:grid;grid-template-columns:240px 1fr;min-height:100vh;min-height:100dvh}
.side{background:var(--ink);color:#d7e0e8;padding:1.2rem;display:flex;flex-direction:column;gap:1.4rem;position:sticky;top:0;height:100vh;height:100dvh}
.side .brand{color:#fff}
#nav{display:flex;flex-direction:column;gap:.2rem;flex:1}
#nav a{display:flex;justify-content:space-between;align-items:center;padding:.6rem .8rem;border-radius:8px;color:inherit;text-decoration:none;font-weight:500}
#nav a:hover{background:rgba(255,255,255,.08)}
#nav a.on{background:var(--brand);color:#fff}
#nav .count{font-size:.8rem;background:rgba(255,255,255,.16);border-radius:99px;padding:0 .55rem}
.side-foot{border-top:1px solid rgba(255,255,255,.14);padding-top:.8rem}
.side-foot .link{color:#8fd4d6;padding:0}
.user{font-weight:500;color:#fff;overflow:hidden;text-overflow:ellipsis}

.main{padding:1.6rem 2rem 3rem;min-width:0}
.top{display:flex;justify-content:space-between;align-items:center;gap:1rem;flex-wrap:wrap;margin-bottom:1.4rem}
.top h2{margin:0;font-size:1.6rem}
.top-actions{display:flex;gap:.6rem;align-items:center}
#search{margin:0;width:220px}

/* dashboard */
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:1rem;margin-bottom:1.4rem}
.kpi{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);padding:1rem 1.2rem}
.kpi b{display:block;font-size:1.9rem;font-weight:800;line-height:1.2}
.kpi span{color:var(--ink-2);font-size:.92rem}
.kpi.warn b{color:var(--red)}
.kpi.main-kpi{background:var(--brand);color:#fff;border-color:var(--brand)}
.kpi.main-kpi span{color:#cfe9ea}

.panels{display:grid;grid-template-columns:1.2fr 1fr;gap:1rem}
.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);padding:1.1rem 1.2rem}
.panel h3{margin:0 0 .8rem;font-size:1.05rem}
.bars{display:flex;align-items:flex-end;gap:.6rem;height:170px;padding-top:.5rem}
.bar{flex:1;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;gap:.3rem;height:100%;font-size:.78rem;color:var(--ink-2)}
.bar i{display:block;width:100%;background:var(--brand);border-radius:5px 5px 0 0;min-height:2px}
.list{list-style:none;margin:0;padding:0}
.list li{display:flex;justify-content:space-between;gap:.8rem;padding:.55rem 0;border-bottom:1px solid var(--line)}
.list li:last-child{border:0}
.muted{color:var(--ink-2)}

/* tables */
.table-wrap{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);overflow-x:auto}
table{border-collapse:collapse;width:100%;min-width:640px}
th,td{text-align:right;padding:.7rem 1rem;border-bottom:1px solid var(--line);white-space:nowrap}
th{font-size:.85rem;color:var(--ink-2);font-weight:500;background:#f8fafb}
tr:last-child td{border-bottom:0}
td.actions{display:flex;gap:.4rem;justify-content:flex-end}
td.wrap{white-space:normal;min-width:180px}
.thumb{width:44px;height:34px;object-fit:cover;border-radius:5px;vertical-align:middle}
.badge{display:inline-block;padding:.1rem .6rem;border-radius:99px;font-size:.82rem;font-weight:500;background:#e9edf1;color:var(--ink-2)}
.badge.ok{background:var(--green-l);color:var(--green)}
.badge.warn{background:var(--amber-l);color:var(--amber)}
.badge.bad{background:var(--red-l);color:var(--red)}
.badge.info{background:var(--brand-l);color:var(--brand-d)}
.empty{padding:2.5rem 1rem;text-align:center;color:var(--ink-2)}

/* export */
.export{max-width:520px}
.export .btn{margin-top:.4rem}

/* modal */
dialog{border:0;border-radius:14px;padding:1.5rem;width:min(560px,94vw);box-shadow:0 20px 60px rgba(0,0,0,.3)}
dialog::backdrop{background:rgba(18,38,58,.55)}
dialog h3{margin:0 0 1rem}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:0 1rem}
.grid2 .full{grid-column:1/-1}
.modal-actions{display:flex;gap:.6rem;justify-content:flex-start;margin-top:.6rem}
.img-prev{max-width:100%;max-height:140px;border-radius:8px;margin-top:.4rem}

.toast{position:fixed;bottom:1.2rem;left:50%;transform:translate(-50%,120px);background:var(--ink);color:#fff;padding:.7rem 1.2rem;border-radius:8px;transition:transform .25s;z-index:99}
.toast.show{transform:translate(-50%,0)}

/* רכיבי מובייל - מוסתרים כברירת מחדל בדסקטופ */
.mobile-tab-bar,
.mobile-fab,
.sheet-backdrop,
.bottom-sheet,
.pwa-install-banner,
.ios-hint-banner,
.cards-mobile,
.client-sticky-bar {
  display: none !important;
}
.table-desktop {
  display: block;
}

/* =====================================================
   טלפון (עד 600 פיקסלים) - Mobile First
   ===================================================== */
@media (max-width: 600px) {
  .app {
    display: block !important;
    padding-bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 16px) !important;
    min-height: 100dvh !important;
  }
  .side {
    display: none !important;
  }
  .main {
    padding: 1rem 1rem calc(var(--tab-bar-h) + var(--safe-bottom) + 1rem) !important;
    min-width: 0;
  }
  .top {
    flex-direction: column;
    align-items: stretch;
    gap: .7rem;
    margin-bottom: 1rem;
  }
  .top h2 {
    font-size: 1.4rem;
  }
  .top-actions {
    display: flex;
    gap: .5rem;
    width: 100%;
  }
  #search {
    flex: 1;
    width: 100%;
    margin: 0;
    font-size: 16px;
  }
  #addBtn {
    display: none !important; /* פעולת ההוספה מנוהלת באמצעות ה-FAB הצף */
  }
  #ticketPdfStudioBtn {
    font-size: .85rem;
    padding: .45rem .65rem;
  }

  /* סרגל ניווט תחתון קבוע */
  .mobile-tab-bar {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--tab-bar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--ink);
    color: #9cb0c2;
    border-top: 1px solid rgba(255, 255, 255, .1);
    z-index: 80;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .18);
  }

  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: inherit;
    text-decoration: none;
    background: none;
    border: none;
    padding: 4px 2px;
    font-size: .74rem;
    font-weight: 500;
    position: relative;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    transition: color .15s;
  }

  .tab-item:hover, .tab-item:focus-visible {
    color: #fff;
  }

  .tab-item[aria-current="page"],
  .tab-item.on {
    color: #fff;
    font-weight: 700;
  }

  .tab-item[aria-current="page"] .tab-icon,
  .tab-item.on .tab-icon {
    transform: scale(1.12);
  }

  .tab-item[aria-current="page"]::after,
  .tab-item.on::after {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--brand);
    border-radius: 0 0 3px 3px;
  }

  .tab-icon {
    font-size: 1.25rem;
    line-height: 1.2;
    transition: transform .15s;
  }

  .tab-label {
    font-size: .72rem;
    white-space: nowrap;
    margin-top: 2px;
  }

  .tab-badge {
    position: absolute;
    top: 3px;
    inset-inline-end: calc(50% - 18px);
    background: var(--brand);
    color: #fff;
    font-size: .65rem;
    font-weight: 800;
    min-width: 17px;
    height: 17px;
    border-radius: 99px;
    display: inline-grid;
    place-items: center;
    padding: 0 3px;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
  }

  .tab-badge.dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    padding: 0;
    top: 5px;
    inset-inline-end: calc(50% - 12px);
    background: var(--amber);
  }

  /* כפתור הוספה צף (+) */
  .mobile-fab {
    display: grid !important;
    place-items: center;
    position: fixed;
    bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 14px);
    inset-inline-end: 16px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    border: none;
    box-shadow: 0 6px 20px rgba(15, 110, 115, .5);
    font-size: 2rem;
    font-weight: 300;
    line-height: 1;
    z-index: 75;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    transition: transform .15s, background .15s;
  }
  .mobile-fab:active {
    transform: scale(.92);
  }
  .mobile-fab[hidden] {
    display: none !important;
  }

  /* מסך עולה תחתון (Bottom Sheet) */
  .sheet-backdrop {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(18, 38, 58, .6);
    backdrop-filter: blur(2px);
    z-index: 90;
    transition: opacity .2s;
  }
  .sheet-backdrop[hidden] {
    display: none !important;
  }

  .bottom-sheet {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--panel);
    border-radius: 20px 20px 0 0;
    padding: .8rem 1.2rem calc(var(--safe-bottom) + 1.2rem);
    z-index: 95;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, .25);
    max-height: 85dvh;
    overflow-y: auto;
    transform: translateY(0);
    transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .bottom-sheet[hidden] {
    display: none !important;
  }

  .sheet-handle {
    width: 42px;
    height: 4px;
    background: var(--line);
    border-radius: 99px;
    margin: 0 auto .6rem;
  }

  .sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: .6rem;
  }

  .sheet-links {
    display: flex;
    flex-direction: column;
    gap: .3rem;
  }

  .sheet-link {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .75rem .8rem;
    border-radius: 10px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
    background: none;
    border: none;
    width: 100%;
    min-height: 46px;
    text-align: start;
    cursor: pointer;
    font-size: .98rem;
  }
  .sheet-link:hover, .sheet-link:focus-visible {
    background: var(--bg);
  }
  .sheet-link.danger {
    color: var(--red);
  }
  .sheet-link .count {
    margin-inline-start: auto;
    font-size: .8rem;
    background: var(--line);
    padding: 0 .55rem;
    border-radius: 99px;
  }

  /* תצוגת כרטיסים בניידים */
  .table-desktop {
    display: none !important;
  }
  .cards-mobile {
    display: flex !important;
    flex-direction: column;
    gap: .8rem;
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .card-item {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: .95rem 1rem;
    box-shadow: 0 2px 8px rgba(18, 38, 58, .05);
    position: relative;
    transition: border-color .15s, box-shadow .15s;
  }
  .card-item:focus-within, .card-item:hover {
    border-color: var(--brand);
  }

  .card-click-area {
    cursor: pointer;
    outline: none;
  }

  .card-header-line {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .6rem;
    margin-bottom: .35rem;
  }

  .card-title-text {
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
  }

  .card-secondary-line {
    font-size: .88rem;
    color: var(--ink-2);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem .6rem;
    margin-top: .25rem;
  }

  .card-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--line);
    margin-top: .75rem;
    padding-top: .5rem;
  }

  .card-actions-links {
    display: flex;
    gap: .4rem;
    align-items: center;
  }

  .card-menu-wrap {
    position: relative;
  }

  .card-menu-btn {
    padding: .3rem .65rem;
    font-size: 1.2rem;
    line-height: 1;
    min-height: 44px;
    min-width: 44px;
  }

  .card-dropdown {
    position: absolute;
    bottom: calc(100% + 4px);
    inset-inline-end: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
    min-width: 180px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    padding: .35rem;
  }
  .card-dropdown[hidden] {
    display: none !important;
  }

  .card-dropdown-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem .85rem;
    border: none;
    background: none;
    color: var(--ink);
    text-decoration: none;
    font-size: .92rem;
    font-weight: 500;
    border-radius: 7px;
    width: 100%;
    text-align: start;
    cursor: pointer;
    min-height: 44px;
  }
  .card-dropdown-item:hover, .card-dropdown-item:focus-visible {
    background: var(--bg);
  }
  .card-dropdown-item.danger {
    color: var(--red);
  }

  /* טפסים ומודאלים במסך מלא בנייד */
  #modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    border: none !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex;
    flex-direction: column;
  }
  #modal[open] {
    display: flex !important;
  }

  #modalForm {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
  }

  #modalTitle {
    padding: 1rem 1.2rem;
    margin: 0;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
  }

  #modalFields {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
    display: flex !important;
    flex-direction: column !important;
    gap: .9rem;
    -webkit-overflow-scrolling: touch;
  }

  .modal-actions {
    position: sticky;
    bottom: 0;
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding: .8rem 1.2rem calc(.8rem + var(--safe-bottom));
    display: flex;
    gap: .8rem;
    z-index: 10;
  }

  .modal-actions .btn {
    flex: 1;
    min-height: 46px;
    font-size: 1rem;
  }

  /* מניעת זום של iOS: פונט 16px לפחות */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* סדר לוח הבקרה בנייד: תשלומים באיחור תחילה -> KPI בשני טורים -> תרשים -> קרובים */
  .dashboard-container {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
  }
  .dash-order-late {
    order: 1;
  }
  .dash-order-kpis {
    order: 2;
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: .75rem !important;
    margin-bottom: 0 !important;
  }
  .dash-order-kpis .kpi {
    padding: .85rem .95rem;
  }
  .dash-order-kpis .kpi b {
    font-size: 1.55rem;
  }
  .dash-order-chart {
    order: 3;
  }
  .dash-order-upcoming {
    order: 4;
  }
  .dash-order-tickets {
    order: 5;
  }
  .dash-order-start {
    order: 6;
  }

  /* הודעת Toast מעל הטאב-בר */
  .toast {
    bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 14px) !important;
    max-width: 90vw;
    text-align: center;
  }

  /* לשוניות שליטה (Segmented Tabs) */
  .segmented-control {
    display: flex;
    background: var(--line);
    padding: 3px;
    border-radius: 9px;
    gap: 3px;
    margin-bottom: 1.2rem;
  }
  .seg-btn {
    flex: 1;
    border: none;
    background: none;
    padding: .55rem .4rem;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ink-2);
    border-radius: 7px;
    cursor: pointer;
    min-height: 44px;
    transition: background .15s, color .15s;
  }
  .seg-btn.on {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
  }

  /* סרגל חיוג ווואטסאפ צף בדף לקוח */
  .client-sticky-bar {
    position: fixed;
    bottom: calc(var(--tab-bar-h) + var(--safe-bottom));
    left: 0;
    right: 0;
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding: .6rem 1rem;
    display: flex !important;
    gap: .6rem;
    z-index: 70;
    box-shadow: 0 -4px 14px rgba(0,0,0,.08);
  }
  .client-sticky-bar .btn {
    flex: 1;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* באנרים מובייל (אנדרואיד / iOS) */
  .pwa-install-banner, .ios-hint-banner {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    background: var(--brand-l);
    border: 1px solid var(--brand);
    border-radius: 10px;
    padding: .65rem .9rem;
    margin-bottom: 1rem;
    font-size: .88rem;
  }
  .ios-hint-banner {
    background: var(--amber-l);
    border-color: var(--amber);
  }
}

/* =====================================================
   טאבלט (601 פיקסלים עד 960 פיקסלים) - מסילת אייקונים צרה
   ===================================================== */
@media (min-width: 601px) and (max-width: 960px) {
  .app {
    grid-template-columns: 74px 1fr !important;
  }
  .side {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    padding: 0.9rem 0.35rem;
    align-items: center;
    width: 74px;
    gap: 1rem;
  }
  .side .brand span:not(.logo) {
    display: none;
  }
  .side .brand {
    justify-content: center;
  }
  #nav {
    gap: 0.4rem;
    width: 100%;
  }
  #nav a {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 0.2rem;
    font-size: 0.72rem;
    gap: 0.25rem;
    text-align: center;
    border-radius: 8px;
    width: 100%;
  }
  #nav .count {
    font-size: 0.68rem;
    padding: 0 0.4rem;
  }
  .user {
    display: none;
  }
  .side-foot {
    border-top: 1px solid rgba(255,255,255,.14);
    padding-top: 0.6rem;
    width: 100%;
    text-align: center;
  }
  .side-foot #logout {
    font-size: 0.8rem;
  }
  .main {
    padding: 1.2rem 1.4rem 2.5rem;
    min-width: 0;
  }
  .cards-mobile {
    display: none !important;
  }
  .table-desktop {
    display: block !important;
  }
}

/* =====================================================
   דסקטופ (מעל 960 פיקסלים) - ללא שינוי!
   ===================================================== */
@media (min-width: 961px) {
  .cards-mobile {
    display: none !important;
  }
  .table-desktop {
    display: block !important;
  }
}

/* קופסת העלאת תמונות - מצלמה + גלריה */
.image-upload-box {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.image-upload-buttons {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  min-height: 44px;
}
.sr-file-input {
  display: none !important;
}

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

/* =====================================================
   תוספות עיצוב למסכים שנוספו (נכס, לקוח, ניהול, חוק)
   ===================================================== */

/* באנרים בראש האפליקציה (אימות מייל / תקופת ניסיון): שורה מלאה בגריד */
#verify-banner,
#trial-banner {
  grid-column: 1 / -1
}

/* תיבת סימון בטופס ההרשמה */
.field input[type=checkbox] {
  display: inline-block;
  width: auto;
  margin: .2rem 0 0;
  padding: 0;
  flex: none;
  accent-color: var(--brand)
}

.field a {
  color: var(--brand)
}

/* קישורים שנראים ככפתורים */
a.btn {
  display: inline-block;
  text-decoration: none;
  color: var(--ink)
}

a.btn.primary {
  color: #fff
}

.btn:disabled {
  opacity: .6;
  cursor: not-allowed
}

/* עמודת פעולות: נשארת תא טבלה רגיל, כך שהקווים לא נשברים */
td.actions {
  display: table-cell;
  text-align: left;
  white-space: nowrap
}

td.actions>* {
  margin-inline-start: .4rem;
  vertical-align: middle
}

/* כותרות בתוך פאנלים */
.panel h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem
}

.panel h2 {
  font-size: 1.15rem;
  margin: 0 0 .8rem
}

/* שלושה כרטיסי סיכום (עלות / שולם / יתרה) */
.panels-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem
}

.panels-3 .kpi {
  background: var(--bg)
}

/* גלריית תמונות בדף נכס */
.prop-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .7rem
}

.prop-img-wrap {
  position: relative;
  aspect-ratio: 4/3;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #e9edf1
}

.prop-img-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover
}

.prop-img-del {
  position: absolute;
  top: .35rem;
  inset-inline-start: .35rem;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(18, 38, 58, .82);
  color: #fff;
  cursor: pointer;
  line-height: 1
}

.prop-img-del:hover {
  background: var(--red)
}

.prop-img-add {
  display: grid;
  place-items: center;
  aspect-ratio: 4/3;
  border: 2px dashed #b8c6d1;
  border-radius: 10px;
  color: var(--brand);
  font-size: 2rem;
  cursor: pointer
}

.prop-img-add:hover {
  border-color: var(--brand);
  background: var(--brand-l)
}

/* דפי חוק: נגישות, פרטיות, תנאים */
.legal-page {
  max-width: 800px;
  line-height: 1.8
}

.legal-page h2 {
  font-size: 1.15rem;
  margin: 1.6rem 0 .4rem
}

.legal-page ul {
  padding-inline-start: 1.3rem
}

#standalone-legal {
  line-height: 1.7
}

/* =====================================================
   תצוגה והדפסה של מכתב פנייה ותרומה (PDF)
   ===================================================== */
#pdfDialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(860px, 96vw);
  max-height: 92vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
  background: var(--bg);
  overflow: hidden;
}

#pdfDialog::backdrop {
  background: rgba(18, 38, 58, .65);
}

.pdf-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .8rem 1.2rem;
  background: var(--ink);
  color: #fff;
  gap: .8rem;
  flex-wrap: wrap;
}

.pdf-dialog-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.pdf-dialog-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.pdf-scroll-area {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(92vh - 65px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* דף A4 מדורג ומעוצב */
.pdf-sheet {
  background: #fff;
  width: 100%;
  max-width: 720px;
  min-height: 960px;
  padding: 3rem 3.5rem;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .08);
  border: 1px solid var(--line);
  color: #1a2a3a;
  font-family: 'Heebo', system-ui, sans-serif;
  line-height: 1.7;
  position: relative;
  box-sizing: border-box;
}

.pdf-brand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 1.2rem;
  margin-bottom: 1.8rem;
}

.pdf-brand-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pdf-logo-img {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
}

.pdf-brand-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
  font-family: 'Frank Ruhl Libre', serif;
}

.pdf-brand-sub {
  font-size: .88rem;
  color: var(--ink-2);
  margin-top: .15rem;
}

.pdf-meta-left {
  text-align: left;
  font-size: .88rem;
  color: var(--ink-2);
}

.pdf-recipient-card {
  background: var(--bg);
  border-radius: 8px;
  padding: .9rem 1.2rem;
  margin-bottom: 1.6rem;
  border-inline-start: 4px solid var(--brand);
}

.pdf-recipient-card b {
  font-size: 1.05rem;
  color: var(--ink);
}

.pdf-subject-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--ink);
  margin: 1.2rem 0;
  text-decoration: underline;
  text-underline-offset: 6px;
}

.pdf-body-text {
  font-size: 1.05rem;
  white-space: pre-wrap;
  margin-bottom: 2rem;
  color: #243545;
}

/* תיבת תמיכה / יעד תרומה */
.pdf-callout-box {
  background: var(--brand-l);
  border: 1px solid var(--brand);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  margin: 1.5rem 0;
}

.pdf-callout-box h4 {
  margin: 0 0 .5rem;
  color: var(--brand-d);
  font-size: 1.1rem;
}

/* פרטי חשבון להעברת תרומה */
.pdf-bank-box {
  background: #fbfbfb;
  border: 1px dashed #b8c6d1;
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  margin: 1.5rem 0;
  font-size: .95rem;
}

.pdf-bank-box h4 {
  margin: 0 0 .5rem;
  color: var(--ink);
  font-size: 1.05rem;
}

.pdf-bank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .5rem 1rem;
}

.pdf-sign-row {
  margin-top: 3rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.pdf-sign-box {
  text-align: center;
  min-width: 180px;
}

.pdf-sign-line {
  border-top: 1px solid var(--line);
  margin-top: 2.5rem;
  padding-top: .4rem;
  font-size: .88rem;
  color: var(--ink-2);
}

.pdf-footer-note {
  margin-top: 3.5rem;
  text-align: center;
  font-size: .78rem;
  color: #8fa0b0;
  border-top: 1px solid var(--line);
  padding-top: .8rem;
}

/* התאמה מלאה להדפסה (Print / Save as PDF) */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm 15mm;
  }
  
  html, body {
    background: #fff !important;
    color: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* הסתרת כל רכיבי המערכת פרט למסמך המודפס */
  #app,
  #auth,
  #landing,
  #toast,
  dialog:not(#pdfDialog),
  .pdf-dialog-header,
  .lp-nav,
  .lp-foot,
  .no-print {
    display: none !important;
  }

  #pdfDialog {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    height: auto !important;
    border: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  #pdfDialog::backdrop {
    display: none !important;
  }

  .pdf-scroll-area {
    padding: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .pdf-sheet {
    box-shadow: none !important;
    border: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    min-height: auto !important;
    background: #fff !important;
  }
}

/* =====================================================
   סטודיו לעריכת מכתבי PDF ופניות
   ===================================================== */
#pdfDialog.pdf-studio {
  width: min(1260px, 98vw);
  max-height: 94vh;
}

.pdf-layout-body {
  display: grid;
  grid-template-columns: 420px 1fr;
  height: calc(94vh - 58px);
  overflow: hidden;
}

.pdf-editor-panel {
  background: var(--panel);
  border-inline-end: 1px solid var(--line);
  padding: 1.2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.pdf-editor-panel .field {
  margin-bottom: .5rem;
  font-size: .88rem;
}

.pdf-editor-panel .field input,
.pdf-editor-panel .field select,
.pdf-editor-panel .field textarea {
  font-size: .9rem;
  padding: .45rem .65rem;
  margin-top: .2rem;
}

.pdf-editor-panel .field textarea {
  min-height: 110px;
}

@media (max-width: 960px) {
  .pdf-layout-body {
    grid-template-columns: 1fr;
    height: calc(92vh - 58px);
    overflow-y: auto;
  }
  .pdf-editor-panel {
    border-inline-end: none;
    border-bottom: 2px solid var(--line);
    max-height: none;
  }
}

@media print {
  .pdf-layout-body {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }
}