/* ====================================================================
   ניהול מרכזייה טלפונית — עיצוב ראשי
   ==================================================================== */

:root {
    --brand: #00758c;
    --brand-dark: #005a6b;
    --brand-darker: #00434f;
    --brand-light: #e3f2f5;
    --brand-lighter: #f1f8fa;
    --accent: #a37011;
    --bg: #eef3f5;
    --card: #ffffff;
    --text: #1f2d33;
    --muted: #64777f;
    --border: #dbe4e8;
    --danger: #cc3344;
    --success: #1d8a4e;
    --warning: #b57e0f;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 3px rgba(16, 42, 51, .08), 0 4px 14px rgba(16, 42, 51, .06);
    --shadow-hover: 0 4px 10px rgba(16, 42, 51, .12), 0 10px 28px rgba(16, 42, 51, .10);
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Assistant', sans-serif;
    direction: rtl;
    min-height: 100vh;
}

/* ------------------------------------------------------------------ */
/* כותרת עליונה                                                        */
/* ------------------------------------------------------------------ */

.app-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 6px rgba(16, 42, 51, .06);
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* כותרת בשתי שורות מסודרות:
   שורה 1 — לוגו (ימין) | בחירת מערכת (מרכז, בולטת) | עזרה/התנתקות (שמאל)
   שורה 2 — חיפוש + מפת שלוחות + הדמיית שיחה + בדיקת תקינות + ניהול קריינות */
.app-header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 8px 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* grid למרכוז גיאומטרי אמיתי של המערכת (ללא תלות ברוחב הלוגו/החשבון) */
.hdr-row1 {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
}

.app-logo {
    grid-column: 1;
    justify-self: start;
}

/* בחירת המערכת — ממורכזת בשורה העליונה */
.app-header-center {
    grid-column: 2;
    justify-self: center;
    display: flex;
    align-items: center;
}

.hdr-account {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* כפתור הרענון יושב בתוך כדור המערכת — אייקון עגול בלי מסגרת */
.system-picker .btn-refresh {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: var(--brand-dark);
    box-shadow: none;
}

.system-picker .btn-refresh:hover {
    background: rgba(255, 255, 255, .8);
}

/* מערכת ריקה — שורת החיפוש והכלים אינה רלוונטית */
body.empty-system .hdr-row2 {
    display: none;
}

/* שורה 2 — חיפוש וכפתורי הניווט, ממורכזים */
.hdr-row2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.hdr-row2 .search-box {
    flex: 0 1 280px;
    min-width: 170px;
}

/* כפתור אייקון-בלבד (התנתקות) — עגול, באותו גובה כמו שאר הכפתורים */
.btn-header.btn-icon-only {
    width: 37px;
    height: 37px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

/* ------------------------------------------------------------------ */
/* מצב מוטמע (iframe באתר המארח) — תצוגה קומפקטית                        */
/* ------------------------------------------------------------------ */

/* רקע לבן נקי במצב מוטמע — משתלב באתר המארח */
html.embedded, html.embedded body {
    background: #fff;
}

/* הכותרת נשארת דביקה ואטומה (לבן מלא) — התוכן לא נראה מתחתיה בגלילה */
body.embedded .app-header {
    background: #fff;
}

body.embedded .app-logo {
    display: none;
}

body.embedded .app-header-inner {
    /* האתר המארח כבר נותן ריווח מעל ה-iframe — מתחילים מ-0.
       ב-iframe הרחב שתי השורות משוטחות לשורה אחת (display:contents) */
    padding: 0 16px 5px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

body.embedded .hdr-row1,
body.embedded .hdr-row2 {
    display: contents;
}

/* סדר בשורה האחת: מערכת → חיפוש → כפתורי ניווט → עזרה/התנתקות בקצה */
body.embedded .app-header-center {
    order: 1;
    margin-inline: 0;
}

/* גם ב-iframe החיפוש מוגבל ברוחב — אין צורך ביותר.
   margin אוטומטי כאן + בקצה החשבון ממרכזים את כל קבוצת הכפתורים,
   בעוד בחירת המערכת נשארת צמודה לימין */
body.embedded .hdr-row2 .search-box {
    order: 2;
    flex: 0 1 240px;
    margin-inline-start: auto;
}

body.embedded #simBtn { order: 3; }
body.embedded #mapBtn { order: 4; }
body.embedded #healthBtn { order: 5; }

/* סוף הקבוצה הממורכזת — margin אוטומטי שדוחף את העזרה לקצה השמאלי */
body.embedded #recordingsBtn {
    order: 6;
    margin-inline-end: auto;
}

body.embedded .hdr-account {
    order: 7;
}

body.embedded .btn-header {
    padding: 5px 12px;
    font-size: .82rem;
}

body.embedded .btn-header.btn-icon-only {
    width: 32px;
    height: 32px;
    padding: 0;
}

body.embedded .system-picker select {
    padding: 4px 12px;
    font-size: .85rem;
    min-width: 110px;
}

body.embedded .app-main {
    padding: 12px 16px;
}

body.embedded .content-cols {
    gap: 14px;
}

body.embedded .search-box input {
    padding: 7px 38px 7px 14px;
    font-size: .88rem;
}

body.embedded .breadcrumb-bar {
    margin-bottom: 10px;
}

body.embedded .current-card {
    padding: 12px 16px;
}

body.embedded .cc-icon {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    font-size: 1.15rem;
    border-radius: 11px;
}

body.embedded .cc-titles h2 {
    font-size: 1.05rem;
}

body.embedded .cc-desc {
    margin-top: 6px;
    font-size: .82rem;
}

body.embedded .cc-actions {
    margin-top: 10px;
}

body.embedded .btn-cc {
    padding: 5px 12px;
    font-size: .8rem;
}

body.embedded .children-wrap {
    padding: 10px 10px 12px;
    margin-bottom: 12px;
}

body.embedded .ext-list {
    gap: 8px;
}

body.embedded .ext-row {
    padding: 8px 12px;
    gap: 10px;
}

body.embedded .keypad {
    min-width: 38px;
    height: 38px;
    font-size: 1.05rem;
    border-radius: 9px;
}

body.embedded .ext-type-line {
    font-size: .92rem;
}

body.embedded .ext-name {
    font-size: .82rem;
}

body.embedded .btn-icon {
    width: 32px;
    height: 32px;
    font-size: .88rem;
}

body.embedded .add-row {
    padding: 10px;
    font-size: .9rem;
}

body.embedded .add-row .add-plus {
    width: 28px;
    height: 28px;
    font-size: .82rem;
}

body.embedded .sys-card {
    padding: 8px 12px;
}

body.embedded .edit-panel {
    top: calc(var(--app-header-h, 46px) + 8px);
    max-height: calc(100vh - var(--app-header-h, 46px) - 18px);
}

body.embedded #editPanel .edit-card {
    max-height: calc(100vh - var(--app-header-h, 46px) - 32px);
}

body.embedded .edit-card-header {
    padding: 10px 14px;
}

body.embedded .edit-card-body {
    padding: 12px 14px;
}

body.embedded .toast-stack {
    top: 48px;
}

/* כותרת במסך צר: לוגו, כפתורים ובחירת מערכת — שורות ממורכזות */
/* כותרת במסך צר: שורה 1 נערמת — לוגו, מערכת, חשבון — ממורכזים */
@media (max-width: 767px) {
    .app-header-inner {
        padding: 8px 12px 10px;
    }

    .hdr-row1 {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .app-logo,
    .app-header-center,
    .hdr-account {
        grid-column: 1;
        justify-self: center;
    }

    .app-logo {
        text-align: center;
    }

    .app-logo h1 {
        font-size: 1.1rem;
    }

    .btn-header {
        padding: 6px 12px;
        font-size: .82rem;
    }
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    grid-column: 1;
}

.app-logo-icon {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand), var(--brand-darker));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 3px 8px rgba(0, 117, 140, .35);
}

/* רוחב טקסט הלוגו מוגבל — כותרת המשנה גולשת לשתי שורות במקום להרחיב
   את הלוגו ולדחוף את שאר הכותרת לשורה נוספת */
.app-logo > div {
    max-width: 200px;
}

.app-logo h1 {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0;
    color: var(--brand-dark);
    line-height: 1.1;
}

.app-logo .app-subtitle {
    font-size: .76rem;
    color: var(--muted);
    margin: 2px 0 0;
    line-height: 1.25;
}

/* בוחר המערכת — מעוצב כ"כדור" בולט: זה הפקד הראשי בכותרת */
.system-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--brand-lighter);
    border: 2px solid var(--brand);
    border-radius: 999px;
    padding: 3px 6px 3px 14px;
    box-shadow: 0 2px 10px rgba(0, 117, 140, .18);
}

.system-picker label {
    font-size: .9rem;
    font-weight: 800;
    color: var(--brand-dark);
    margin: 0;
    white-space: nowrap;
}

/* ה-select ללא מסגרת משלו — הכדור החיצוני הוא המסגרת (בלי מסגרת כפולה) */
.system-picker select {
    border: none;
    background: #fff;
    border-radius: 999px;
    padding: 6px 16px;
    font-weight: 800;
    font-size: 1rem;
    color: var(--brand-dark);
    font-family: inherit;
    min-width: 140px;
    cursor: pointer;
}

.system-picker select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 117, 140, .15);
}

/* מערכת יחידה — תווית קבועה במקום בוחר (בלי מסגרת נוספת בתוך הכדור) */
.system-picker .system-single {
    background: #fff;
    border: none;
    border-radius: 999px;
    padding: 6px 16px;
    font-weight: 800;
    font-size: 1rem;
    color: var(--brand-dark);
}

body.embedded .system-picker .system-single {
    padding: 4px 12px;
    font-size: .85rem;
}

.btn-header {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--brand-dark);
    border-radius: 999px;
    padding: 7px 14px;
    font-weight: 600;
    font-size: .875rem;
    white-space: nowrap;
    transition: all .15s;
}

.btn-header:hover {
    background: var(--brand-light);
    border-color: var(--brand);
    color: var(--brand-dark);
}

.btn-header.btn-header-danger {
    color: var(--danger);
}

.btn-header.btn-header-danger:hover {
    background: #fdeef0;
    border-color: var(--danger);
}

.btn-header.btn-header-strong {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: 0 3px 8px rgba(0, 117, 140, .3);
}

.btn-header.btn-header-strong:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
}

/* כפתור "הדמיית שיחה" — הבולט שבכפתורים, עם נגיעת קסם בריחוף */
.btn-header.btn-header-cta {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--brand), var(--brand-darker));
    border-color: var(--brand-darker);
    font-weight: 800;
    box-shadow: 0 3px 12px rgba(0, 117, 140, .45);
}

.btn-header.btn-header-cta:hover {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-darker));
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 117, 140, .55);
}

/* פס ברק שחולף על הכפתור בריחוף */
.btn-header.btn-header-cta::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 45%;
    left: -60%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, .5), transparent);
    transform: skewX(-20deg);
    pointer-events: none;
}

.btn-header.btn-header-cta:hover::after {
    animation: ctaShine .65s ease;
}

@keyframes ctaShine {
    to {
        left: 130%;
    }
}

/* ב-RTL אפרכסת הטלפון פונה לכיוון הקריאה — היפוך אופקי */
.icon-flip,
.btn-header.btn-header-cta i {
    transform: scaleX(-1);
}

/* אייקון הטלפון "מצלצל" בריחוף (ההיפוך נשמר בתוך האנימציה) */
.btn-header.btn-header-cta:hover i {
    animation: ctaRing .45s ease-in-out infinite;
    transform-origin: 50% 40%;
}

@keyframes ctaRing {
    0%, 100% {
        transform: scaleX(-1) rotate(0deg);
    }
    25% {
        transform: scaleX(-1) rotate(-13deg);
    }
    75% {
        transform: scaleX(-1) rotate(11deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn-header.btn-header-cta:hover i,
    .btn-header.btn-header-cta:hover::after {
        animation: none;
    }
}

/* התאמת כפתורי Bootstrap לצבעי המותג (במקום הכחול של ברירת המחדל) */
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-darker);
    --bs-btn-active-border-color: var(--brand-darker);
    background-color: var(--brand);
    border-color: var(--brand);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--brand-dark) !important;
    border-color: var(--brand-dark) !important;
}

.btn-outline-primary {
    color: var(--brand-dark);
    border-color: var(--brand);
}

.btn-outline-primary:hover, .btn-outline-primary:active {
    background-color: var(--brand) !important;
    border-color: var(--brand) !important;
    color: #fff;
}

.btn-success {
    background-color: var(--success);
    border-color: var(--success);
}

/* כפתורי SweetAlert בצבעי המותג */
.swal-button--confirm:not(.swal-button--danger) {
    background-color: var(--brand);
}

.swal-button--confirm:not(.swal-button--danger):hover {
    background-color: var(--brand-dark) !important;
}

/* ------------------------------------------------------------------ */
/* פריסה ראשית                                                         */
/* ------------------------------------------------------------------ */

.app-main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px;
}

/* שתי העמודות (נווט + פאנל צד) מתחילות מאותו גובה — מתחת לפירורי הלחם */
.content-cols {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.nav-panel {
    flex: 1.25;
    min-width: 0;
}

.edit-panel {
    flex: 1;
    min-width: 0;
    position: sticky;
    /* נצמד מתחת לכותרת הדביקה — הגובה שלה נמדד ב-JS (‎--app-header-h)
       כדי שכותרת דו-שורתית לא תכסה את ראש הפאנל */
    top: calc(var(--app-header-h, 82px) + 12px);
    max-height: calc(100vh - var(--app-header-h, 82px) - 28px);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#editPanel {
    /* לא מתכווץ — כדי שסייר הקבצים לא יעלה על מסגרת העריכה */
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}

#editPanel:empty {
    display: none;
}

/* כשהעורך פתוח (הסייר מוסתר) — הכרטיס מוגבל לגובה המסך ונגלל פנימית */
#editPanel .edit-card {
    max-height: calc(100vh - 130px);
}

#filesPanel {
    flex: 1 1 auto;
    /* גובה מינימלי — שהסייר יישאר שמיש גם במסך נמוך */
    min-height: 260px;
    display: flex;
    flex-direction: column;
}

/* מסך נמוך במיוחד: מוותרים על ההצמדה ונותנים לעמוד לגלול */
@media (max-height: 560px) {
    .edit-panel {
        position: static;
        max-height: none;
    }

    #editPanel .edit-card {
        max-height: none;
    }

    #filesPanel .edit-card {
        max-height: 80vh;
        min-height: 300px;
    }
}

#editPanel .edit-card, #filesPanel .edit-card {
    min-height: 0;
    flex: 1 1 auto;
}

@media (max-width: 991px) {
    .content-cols {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-panel {
        width: 100%;
    }

    .edit-panel {
        position: static;
        max-height: none;
        width: 100%;
    }

    #editPanel .edit-card, #filesPanel .edit-card {
        max-height: 75vh;
    }
}

/* ------------------------------------------------------------------ */
/* סרגל ניווט — חיפוש ופירורי לחם                                       */
/* ------------------------------------------------------------------ */

.search-box {
    position: relative;
    flex: 1;
}

.search-box .fa-magnifying-glass, .search-box .fa-search {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 999px;
    /* גובה תואם לכפתורי הכותרת (7px) כדי שהחיפוש לא יבלוט גבוה מהם */
    padding: 7px 38px 7px 16px;
    background: #fff;
    font-family: inherit;
    box-shadow: var(--shadow);
}

.search-box input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(0, 117, 140, .15);
}

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    z-index: 1040;
    max-height: 320px;
    overflow: auto;
    display: none;
}

.search-results.open {
    display: block;
}

.search-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--brand-lighter);
}

.search-result:hover {
    background: var(--brand-lighter);
}

.search-result .sr-path {
    font-size: .78rem;
    color: var(--muted);
    direction: ltr;
    text-align: right;
}

.search-empty {
    padding: 12px 16px;
    color: var(--muted);
    text-align: center;
}

.breadcrumb-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
    font-size: .9rem;
}

.crumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--brand-dark);
    font-weight: 600;
    border-radius: 999px;
    padding: 4px 12px;
    cursor: pointer;
    transition: all .15s;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crumb:hover {
    background: var(--brand-light);
    border-color: var(--brand);
}

.crumb.current {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    cursor: default;
}

.crumb i {
    color: var(--accent);
    font-size: .82em;
}

.crumb.current i {
    color: rgba(255, 255, 255, .85);
}

.crumb-sep {
    color: var(--muted);
    font-size: .7rem;
}

/* ------------------------------------------------------------------ */
/* כרטיס השלוחה הנוכחית                                                 */
/* ------------------------------------------------------------------ */

.current-card {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: #fff;
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    /* פס זהות — אותו פס מופיע על הפאנל הצדדי: הם צמד ששייך לאותה שלוחה */
    border-top: 4px solid var(--accent);
}

/* כשיש תתי-שלוחות — הכרטיס "נפתח" אל המסגרת שעוטפת אותן */
.current-card.has-children {
    margin-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
}

.children-wrap {
    border: 2px solid var(--brand);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: rgba(255, 255, 255, .45);
    padding: 12px 12px 14px;
    margin-bottom: 16px;
}

.children-wrap .children-header {
    margin: 2px 6px 10px;
}

.current-card .cc-top {
    display: flex;
    align-items: center;
    gap: 14px;
}

.cc-icon {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .16);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
}

.cc-titles {
    min-width: 0;
    flex: 1;
}

.cc-titles h2 {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cc-titles .cc-type {
    font-size: .85rem;
    opacity: .85;
}

.cc-number {
    background: rgba(255, 255, 255, .18);
    padding: 4px 12px;
    font-weight: 800;
    border-radius: 9px;
    font-size: 1rem;
    white-space: nowrap;
}

.cc-desc {
    margin: 10px 2px 0;
    font-size: .88rem;
    opacity: .9;
}

.cc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.btn-cc {
    border: 1px solid rgba(255, 255, 255, .45);
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border-radius: 999px;
    padding: 6px 14px;
    font-weight: 600;
    font-size: .85rem;
    transition: background .15s;
}

.btn-cc:hover {
    background: rgba(255, 255, 255, .28);
    color: #fff;
}

.btn-cc.btn-cc-primary {
    background: #fff;
    color: var(--brand-dark);
    border-color: #fff;
}

.btn-cc.btn-cc-primary:hover {
    background: var(--brand-light);
}

/* ------------------------------------------------------------------ */
/* רשימת תתי-שלוחות                                                    */
/* ------------------------------------------------------------------ */

.children-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 4px 4px 10px;
}

.children-header h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--brand-dark);
    margin: 0;
}

.children-header .hint {
    font-size: .8rem;
    color: var(--muted);
}

/* בחירה מרובה */
.btn-multi-select {
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--brand-dark);
    font-weight: 700;
    font-size: .8rem;
    padding: 4px 12px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-multi-select:hover {
    background: var(--brand-lighter);
    border-color: var(--brand);
}

.select-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--brand-lighter);
    border: 1px solid var(--brand-light);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin: 0 4px 10px;
}

.select-bar .sel-all {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: .85rem;
    color: var(--brand-dark);
    margin: 0;
    cursor: pointer;
}

.select-bar .sel-count {
    font-size: .82rem;
    color: var(--muted);
}

.select-bar .sel-actions {
    display: flex;
    gap: 6px;
    margin-inline-start: auto;
}

.ext-row-selectable {
    cursor: pointer;
}

.ext-row-selectable .ext-select {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-inline-end: 2px;
    cursor: pointer;
}

.ext-row-selected {
    border-color: var(--brand);
    background: var(--brand-lighter);
    box-shadow: 0 0 0 2px rgba(0, 117, 140, .2);
}

.ext-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ext-row {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: box-shadow .15s, transform .15s, border-color .15s;
    position: relative;
}

.ext-row:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
    border-color: var(--brand);
}

.ext-row.selected {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(0, 117, 140, .25), var(--shadow);
}

.ext-row.flash {
    animation: flashRow 1.6s ease;
}

@keyframes flashRow {
    0%, 60% {
        background: #fff7dd;
        border-color: var(--accent);
    }
    100% {
        background: var(--card);
    }
}

.keypad {
    min-width: 46px;
    height: 46px;
    flex: 0 0 auto;
    padding: 0 8px;
    border-radius: 11px;
    background: linear-gradient(180deg, #ffffff, #e6edf0);
    border: 1px solid #c7d3d8;
    box-shadow: 0 2px 0 #b7c5cb, inset 0 1px 0 #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--brand-darker);
}

.keypad.keypad-sys {
    background: linear-gradient(180deg, #f8f9fa, #e9ecef);
    color: var(--muted);
    font-size: 1rem;
}

.ext-info {
    flex: 1;
    min-width: 0;
}

/* סוג השלוחה — השורה הראשית והבולטת */
.ext-type-line {
    font-weight: 800;
    font-size: 1rem;
    color: var(--brand-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ext-type-line i {
    color: var(--accent);
    margin-inline-end: 4px;
    font-size: .9em;
}

.ext-type-line.ext-type-sys {
    color: var(--muted);
}

.ext-type-line.ext-type-sys i {
    color: var(--muted);
}

/* תיאור השלוחה שהמשתמש הזין — משני */
.ext-name {
    font-weight: 500;
    font-size: .88rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ext-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
    flex-wrap: wrap;
    min-width: 0;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--brand-light);
    color: var(--brand-dark);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: .76rem;
    font-weight: 700;
    white-space: nowrap;
}

.chip i {
    font-size: .72rem;
}

.chip.chip-sys {
    background: #f1f3f5;
    color: var(--muted);
}

.chip.chip-count {
    background: var(--brand-light);
    color: var(--brand);
}

.chip.chip-warn {
    background: #fbeecb;
    color: var(--warning);
    cursor: help;
}

/* אזהרות "בריאות" על כרטיס השלוחה הנוכחית — מסגרת בגוון אזהרה, כדי שברור שזו התראה */
.cc-warnings {
    background: rgba(240, 180, 41, .16);
    border: 1px solid rgba(255, 215, 110, .5);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-top: 10px;
    font-size: .84rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cc-warnings i {
    color: #ffd76e;
    margin-inline-end: 4px;
}

.ext-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    transition: all .12s;
}

.btn-icon:hover {
    background: var(--brand-light);
    color: var(--brand-dark);
    border-color: var(--border);
}

.btn-icon.btn-icon-danger:hover {
    background: #fdeef0;
    color: var(--danger);
}

.btn-icon.btn-icon-restore {
    color: var(--success);
    background: #ebf7f0;
    border-color: #cde9da;
}

.btn-icon.btn-icon-restore:hover {
    background: var(--success);
    color: #fff;
}

.ext-chevron {
    color: #b7c5cb;
    font-size: .95rem;
    margin-inline-start: 2px;
}

.ext-row:hover .ext-chevron {
    color: var(--brand);
}

/* שורת הוספה */
.add-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2px dashed #b9cdd4;
    border-radius: var(--radius);
    padding: 14px;
    color: var(--brand-dark);
    font-weight: 700;
    cursor: pointer;
    background: rgba(255, 255, 255, .55);
    transition: all .15s;
}

.add-row:hover {
    border-color: var(--brand);
    background: var(--brand-lighter);
}

.add-row .add-plus {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    box-shadow: 0 3px 8px rgba(0, 117, 140, .35);
}

.empty-children {
    text-align: center;
    color: var(--muted);
    padding: 18px 10px 8px;
    font-size: .9rem;
}

/* מצב ריק ידידותי לתפריט חדש — הזמנה להתחיל */
.empty-children-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 26px 18px;
    border: 2px dashed var(--brand-light);
    border-radius: var(--radius);
    background: var(--brand-lighter);
}

.empty-children-cta .ec-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--brand-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--brand);
    margin-bottom: 2px;
}

.empty-children-cta h4 {
    margin: 0;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--brand-dark);
}

.empty-children-cta p {
    margin: 0;
    max-width: 420px;
    font-size: .88rem;
    color: var(--text);
    line-height: 1.5;
}

.empty-children-cta .btn {
    margin-top: 6px;
}

/* ------------------------------------------------------------------ */
/* סימולטור "נסו כמו מתקשר"                                             */
/* ------------------------------------------------------------------ */

.sim-phone {
    background: linear-gradient(180deg, #1d2b31, #0f191d);
    border-radius: 26px;
    padding: 16px 14px 12px;
    box-shadow: inset 0 0 0 3px #33474f, 0 10px 30px rgba(0, 30, 40, .35);
}

.sim-screen {
    background: #eef7f9;
    border-radius: 14px;
    min-height: 150px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

/* "שיחה אל 072..." — המספר שאליו חייג המתקשר */
.sim-dialed {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    font-weight: 800;
    color: var(--brand-dark);
    border-bottom: 1px dashed var(--border);
    padding-bottom: 6px;
    margin-bottom: 2px;
}

.sim-dialed i {
    color: var(--success);
    font-size: .85rem;
}

.sim-dialed-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    margin-inline-start: auto;
    animation: simCallDot 1.6s infinite;
}

@keyframes simCallDot {
    0%, 100% { opacity: 1; }
    50% { opacity: .25; }
}

.sim-path {
    font-size: .74rem;
    color: var(--muted);
    font-weight: 700;
}

.sim-title {
    font-size: 1.02rem;
    font-weight: 800;
    color: var(--brand-dark);
}

.sim-title i {
    color: var(--accent);
    margin-inline-end: 6px;
}

.sim-status {
    font-size: .82rem;
    color: var(--muted);
    min-height: 1.3em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sim-status.playing {
    color: var(--brand);
    font-weight: 700;
}

.sim-status.waiting {
    color: var(--success);
    font-weight: 700;
}

.sim-status.error, .sim-status.warn {
    color: var(--danger);
    font-weight: 700;
}

.sim-status.warn {
    color: var(--warning);
}

/* אקולייזר קטן בזמן השמעה */
.sim-eq {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
}

.sim-eq i {
    width: 3px;
    background: var(--brand);
    border-radius: 2px;
    animation: simEq .7s infinite ease-in-out;
}

.sim-eq i:nth-child(1) { height: 6px; animation-delay: 0s; }
.sim-eq i:nth-child(2) { height: 12px; animation-delay: .15s; }
.sim-eq i:nth-child(3) { height: 8px; animation-delay: .3s; }

@keyframes simEq {
    0%, 100% { transform: scaleY(.5); }
    50% { transform: scaleY(1.3); }
}

.sim-buffer {
    font-size: .95rem;
    font-weight: 800;
    color: var(--brand-dark);
    letter-spacing: 3px;
    direction: ltr;
    text-align: right;
    min-height: 1.2em;
}

.sim-action-card {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: .84rem;
    color: var(--text);
}

.sim-action-card > i {
    font-size: 1.2rem;
    color: var(--brand);
    margin-top: 2px;
}

.sim-action-card .sa-extra {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
    color: var(--brand-dark);
}

/* הקראה רובוטית בסימולטור — שורה קומפקטית עם הרחבת טקסט */
.sim-tts-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    background: none;
    border: none;
    padding: 2px 0;
    font-size: .8rem;
    font-weight: 700;
    color: var(--brand-dark);
    cursor: pointer;
}

.sim-tts-toggle .fa-robot {
    color: var(--brand);
}

.sim-tts-toggle .st-arrow {
    margin-inline-start: auto;
    font-size: .7rem;
    color: var(--muted);
    transition: transform .2s;
}

.sim-tts.open .st-arrow {
    transform: rotate(180deg);
}

.sim-tts-text {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: .8rem;
    color: var(--text);
    margin-top: 4px;
}

.sim-warn {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background: #fdf6e6;
    border: 1px solid #ecd9a8;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: .78rem;
    color: #7a5c10;
    margin-top: 6px;
}

.sim-warn i {
    color: var(--warning);
    margin-top: 2px;
}

.sim-ended {
    text-align: center;
    color: var(--danger);
    font-weight: 800;
    font-size: 1.05rem;
    padding: 12px 0;
}

.sim-ended i {
    display: block;
    font-size: 1.8rem;
    margin-bottom: 6px;
}

.sim-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    direction: ltr;
    margin-bottom: 12px;
}

.sim-key {
    background: linear-gradient(180deg, #3a4f58, #2a3c44);
    border: 1px solid #4b6570;
    border-radius: 12px;
    color: #fff;
    padding: 8px 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    transition: all .12s;
    min-height: 52px;
}

.sim-key:hover {
    background: linear-gradient(180deg, #48626d, #354a53);
}

.sim-key:active {
    transform: scale(.95);
}

.sim-key .sk-digit {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
}

.sim-key .sk-label {
    font-size: .58rem;
    color: #9fc3cf;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
    min-height: .9em;
}

.sim-key.has-target {
    border-color: var(--brand);
    box-shadow: 0 0 8px rgba(46, 163, 186, .45);
}

.sim-key.has-target .sk-digit {
    color: #7fe3f7;
}

.sim-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.sim-controls .btn {
    border-radius: 999px;
}

.sim-note {
    font-size: .7rem;
    color: #8fa6ae;
    text-align: center;
    line-height: 1.4;
}

/* מדריך קצר */
.help-intro {
    font-size: 1rem;
    background: var(--brand-lighter);
    border: 1px solid var(--brand-light);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 14px;
    color: var(--brand-dark);
}

.help-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.help-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: .92rem;
}

.help-item > i {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 10px;
    background: var(--brand-light);
    color: var(--brand-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.help-item strong {
    display: block;
    color: var(--brand-dark);
    margin-bottom: 2px;
}

/* אזהרה: תתי-שלוחות בשלוחה שאינה תפריט */
.orphan-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fdf6e6;
    border: 1px solid #ecd9a8;
    color: #7a5c10;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: .86rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.orphan-warning i {
    color: var(--warning);
    margin-top: 2px;
}

/* תפריט פעולות של שורה (3 נקודות) */
.ext-row-dropdown {
    min-width: 220px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    padding: 6px;
    font-family: 'Assistant', sans-serif;
}

.ext-row-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 7px;
    padding: 8px 12px;
    font-size: .9rem;
    font-weight: 600;
}

.ext-row-dropdown .dropdown-item i {
    width: 18px;
    text-align: center;
    color: var(--brand-dark);
    flex: 0 0 18px;
}

.ext-row-dropdown .dropdown-item.text-danger i {
    color: var(--danger);
}

.ext-row-dropdown .dropdown-item:hover {
    background: var(--brand-lighter);
}

.ext-row-dropdown .dropdown-divider {
    margin: 4px 0;
}

/* ------------------------------------------------------------------ */
/* תיקיות מערכת                                                        */
/* ------------------------------------------------------------------ */

.sys-section {
    margin-top: 26px;
}

.sys-section h3 {
    font-size: .92rem;
    font-weight: 800;
    color: var(--muted);
    margin: 0 4px 10px;
}

.sys-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.sys-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    cursor: pointer;
    transition: all .15s;
    box-shadow: var(--shadow);
}

.sys-card:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow-hover);
}

.sys-card i {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 9px;
    background: #f1f5f7;
    color: var(--brand-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sys-card .sys-name {
    font-weight: 700;
    font-size: .9rem;
}

.sys-card .sys-desc {
    font-size: .75rem;
    color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* פאנל עריכה                                                          */
/* ------------------------------------------------------------------ */

.edit-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.files-card .files-tabs {
    padding: 6px 12px 0;
}

.files-card .files-toolbar {
    padding: 8px 12px;
}

.files-card .edit-card-body {
    padding: 12px 14px;
}

.flash-card {
    animation: flashCard 1.4s ease;
}

@keyframes flashCard {
    0%, 45% {
        box-shadow: 0 0 0 3px var(--brand), var(--shadow-hover);
    }
    100% {
        box-shadow: var(--shadow);
    }
}

.edit-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--brand-lighter);
}

.edit-card-header .ech-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-card-header h3 {
    font-size: 1.02rem;
    font-weight: 800;
    margin: 0;
    color: var(--brand-dark);
}

.edit-card-header .ech-path {
    font-size: .8rem;
    color: var(--muted);
}

.edit-card-header .ech-path a {
    color: var(--brand);
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.edit-card-header .ech-path a:hover {
    text-decoration: underline;
}

.edit-card-header .btn-close {
    margin-inline-start: auto;
}

.edit-card-body {
    padding: 16px 18px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    flex: 1;
}

.edit-card-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: #fbfdfe;
    display: flex;
    gap: 10px;
    align-items: center;
}

/* פס הזהות גם על כרטיסי הפאנל הצדדי (סייר קבצים / עורך) */
#sidePanel .edit-card {
    border-top: 4px solid var(--accent);
}

/* טפסים */
.form-field {
    margin-bottom: 14px;
}

.form-field > label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: .88rem;
    color: var(--text);
    margin-bottom: 5px;
}

/* הגדרות השלוחה — פריסה אופקית חוסכת־מקום: תווית בחצי, שדה בחצי.
   שדות רחבים (textarea) נשארים ברוחב מלא עם תווית מעליהם. */
.ss-body .form-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 6px 12px;
    margin-bottom: 9px;
}

.ss-body .form-field > label {
    margin-bottom: 0;
}

.ss-body .form-field.form-field-wide {
    display: block;
}

.ss-body .form-field.form-field-wide > label {
    margin-bottom: 5px;
}

/* במסך צר מאוד — חוזרים לתווית מעל השדה */
@media (max-width: 420px) {
    .ss-body .form-field {
        display: block;
    }

    .ss-body .form-field > label {
        margin-bottom: 5px;
    }
}

.form-field .req {
    color: var(--danger);
}

.form-field .form-control, .form-field .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-family: inherit;
}

.form-field .form-control:focus, .form-field .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(0, 117, 140, .12);
}

/* בחירת סוג שלוחה — מציג אייקוני Font Awesome בתוך האפשרויות */
#extensionType, #extensionType option {
    font-family: 'Assistant', 'Font Awesome 6 Free', 'FontAwesome', sans-serif;
    font-weight: 600;
}

.field-help {
    color: #8fa6ae;
    cursor: help;
    font-size: .85rem;
}

.field-note {
    font-size: .78rem;
    color: var(--muted);
    margin-top: 4px;
}

.field-note-error {
    color: var(--danger);
    font-weight: 700;
}

/* כרטיסי בחירת סוג — התרחישים הנפוצים.
   מספר עמודות קבוע — שהגודל לא ישתנה כשמופיע פס גלילה */
.type-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

@media (max-width: 420px) {
    .type-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

.type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 6px;
    text-align: center;
    transition: all .15s;
    cursor: pointer;
}

.type-card i {
    font-size: 1.05rem;
    color: var(--brand);
}

.type-card .tc-label {
    font-weight: 800;
    font-size: .76rem;
    color: var(--brand-dark);
    line-height: 1.2;
}

.type-card .tc-desc {
    font-size: .64rem;
    color: var(--muted);
    line-height: 1.25;
}

.type-card.type-card-group i {
    color: var(--accent);
}

.type-card.type-card-back {
    background: #f6fafb;
}

.type-card.type-card-back i {
    color: var(--muted);
}

/* "או בחרו מהרשימה המלאה" — מודגש */
.full-list-note {
    font-weight: 800;
    font-size: .85rem;
    color: var(--brand-dark);
    margin: 2px 0 6px;
}

.full-list-note i {
    color: var(--accent);
    margin-inline-end: 4px;
}

/* שורות היסטוריית גרסאות */
.history-row {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: #fff;
}

.history-row .hr-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
}

.history-row .hr-head:hover {
    background: var(--brand-lighter);
    border-radius: var(--radius-sm);
}

.history-row .hr-toggle {
    background: none;
    border: none;
    color: var(--brand);
    padding: 2px 4px;
    cursor: pointer;
    flex: 0 0 auto;
}

.history-row .hr-arrow {
    transition: transform .18s;
}

.history-row.expanded .hr-arrow {
    transform: rotate(180deg);
}

.history-row .hr-icon {
    color: var(--brand);
    font-size: 1.1rem;
    flex: 0 0 auto;
}

.history-row .hr-info {
    flex: 1;
    min-width: 0;
}

.history-row .hr-restore {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* הרחבה קלה של מודאל היסטוריית הגרסאות — כדי ששורת המטא תיכנס */
#historyModal .modal-dialog {
    max-width: 620px;
}

.history-row .hr-content {
    border-top: 1px solid var(--border);
    padding: 10px 14px;
}

.history-row .hr-loading {
    color: var(--muted);
    font-size: .85rem;
    padding: 4px 0;
}

/* תצוגת תוכן הגרסה — שורות מפתח/ערך. LTR כי המפתחות הם קוד באנגלית */
.ini-preview {
    display: flex;
    flex-direction: column;
    gap: 2px;
    direction: ltr;
    text-align: left;
}

.ini-preview .ini-line {
    display: flex;
    gap: 10px;
    align-items: baseline;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: .84rem;
}

.ini-preview .ini-line:nth-child(odd) {
    background: #f6f9fa;
}

.ini-preview .ini-key {
    flex: 0 0 42%;
    color: var(--muted);
    font-weight: 600;
    word-break: break-word;
    font-family: monospace;
}

.ini-preview .ini-val {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}

/* ערך עברי בתוך טבלה LTR — מוצג נכון בזכות ה-bdi, מיושר לימין הקריא */
.ini-preview .ini-val bdi {
    unicode-bidi: isolate;
}

.ini-preview .ini-line-raw {
    font-family: monospace;
    color: var(--muted);
}

.history-row .hr-date {
    font-weight: 800;
    font-size: .92rem;
    color: var(--brand-dark);
}

.history-row .hr-meta {
    font-size: .74rem;
    color: var(--muted);
}

.type-card:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.type-card.selected {
    border-color: var(--brand);
    background: var(--brand-lighter);
    box-shadow: 0 0 0 2px rgba(0, 117, 140, .25);
}

.type-desc-box {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--brand-lighter);
    border: 1px solid var(--brand-light);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: .85rem;
    color: var(--brand-dark);
    margin-bottom: 14px;
}

.type-desc-box i {
    margin-top: 2px;
}

.settings-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    overflow: hidden;
}

.settings-section > .ss-title {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: #f6fafb;
    border: none;
    padding: 10px 14px;
    font-weight: 800;
    font-size: .88rem;
    color: var(--brand-dark);
    text-align: start;
}

.settings-section > .ss-title .ss-arrow {
    margin-inline-start: auto;
    transition: transform .2s;
    font-size: .75rem;
    color: var(--muted);
}

.settings-section.collapsed > .ss-title .ss-arrow {
    transform: rotate(90deg);
}

.settings-section > .ss-body {
    padding: 14px 14px 4px;
}

.settings-section.collapsed > .ss-body {
    display: none;
}

.number-display {
    display: flex;
    align-items: center;
    gap: 10px;
}

.number-display .keypad {
    min-width: 42px;
    height: 42px;
    font-size: 1.1rem;
}

.number-display .btn-change-number {
    font-size: .8rem;
    font-weight: 700;
    color: var(--brand);
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 12px;
}

.number-display .btn-change-number:hover {
    background: var(--brand-light);
    border-color: var(--brand);
}

/* בורר מספר שלוחה — מקלדת מקשים (תפריט חד־ספרתי), קומפקטית וממורכזת */
.number-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    max-width: 208px;
    margin: 4px auto 8px;
}

.nk-key {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-height: 40px;
    padding: 3px 2px;
    background: linear-gradient(180deg, #ffffff, #eef3f5);
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
    transition: all .13s;
}

.nk-key .nk-digit {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--brand-darker);
    line-height: 1;
}

.nk-key .nk-caption {
    font-size: .54rem;
    color: var(--muted);
    line-height: 1.05;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nk-key:hover:not(.taken) {
    border-color: var(--brand);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.nk-key.selected {
    border-color: var(--brand);
    background: var(--brand-lighter);
    box-shadow: 0 0 0 2px rgba(0, 117, 140, .3);
}

.nk-key.taken {
    cursor: not-allowed;
    opacity: .6;
    background: #f4f6f7;
}

.nk-key.taken .nk-digit {
    color: var(--muted);
}

/* המקש 0 ממורכז בשורה האחרונה */
.nk-key[data-digit="0"] {
    grid-column: 2;
}

.number-manual-toggle {
    margin: 2px 0 6px;
    text-align: center;
}

.link-btn {
    background: none;
    border: none;
    color: var(--brand);
    font-weight: 700;
    font-size: .82rem;
    cursor: pointer;
    padding: 2px 0;
}

.link-btn:hover {
    text-decoration: underline;
}

#numberKeypadNote {
    text-align: center;
}

body.embedded .number-keypad {
    max-width: 190px;
    gap: 4px;
}

body.embedded .nk-key {
    min-height: 36px;
}

/* קריינות תפריט (M1000) */
.m1000-widget {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    overflow: hidden;
}

.m1000-widget .m1000-title {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    padding: 9px 14px;
    font-weight: 800;
    font-size: .88rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.m1000-widget .m1000-body {
    padding: 14px;
}

/* ------------------------------------------------------------------ */
/* אזורי העלאה, הקלטה, התקדמות                                          */
/* ------------------------------------------------------------------ */

.upload-area {
    border: 2px dashed #b9cdd4;
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
    color: var(--muted);
    background: #fbfdfe;
    font-size: .88rem;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--brand);
    background: var(--brand-lighter);
    color: var(--brand-dark);
}

.upload-area strong {
    color: var(--brand-dark);
}

.record-button {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .9rem;
    transition: background .15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.record-button:hover {
    background: var(--brand-dark);
    color: #fff;
}

.record-button.recording {
    background: var(--danger);
    animation: recPulse 1.2s infinite;
}

@keyframes recPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(204, 51, 68, .4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(204, 51, 68, 0);
    }
}

.progress-wrap {
    position: relative;
    height: 22px;
    background: #eef2f4;
    border-radius: 999px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-wrap .bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--brand), #2ea3ba);
    transition: width .2s;
}

.progress-wrap .txt {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    font-weight: 700;
    color: var(--text);
}

.status-message {
    font-size: .82rem;
    color: var(--muted);
    text-align: center;
    margin-top: 6px;
    min-height: 1.2em;
}

.preview-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--brand-lighter);
    border: 1px solid var(--brand-light);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 10px;
}

/* ------------------------------------------------------------------ */
/* מודל ניהול קבצים                                                    */
/* ------------------------------------------------------------------ */

.modal-content {
    border-radius: var(--radius);
    border: none;
    font-family: 'Assistant', sans-serif;
}

.modal-header {
    background: var(--brand-lighter);
    border-bottom-color: var(--border);
}

.modal-title {
    font-weight: 800;
    color: var(--brand-dark);
}

.files-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 16px 0;
    border-bottom: 1px solid var(--border);
}

.files-tab {
    border: none;
    background: none;
    padding: 9px 16px;
    font-weight: 700;
    font-size: .9rem;
    color: var(--muted);
    border-bottom: 3px solid transparent;
    border-radius: 6px 6px 0 0;
}

.files-tab:hover {
    background: var(--brand-lighter);
    color: var(--brand-dark);
}

.files-tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

.files-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--brand-lighter);
    flex-wrap: wrap;
}

.files-toolbar .files-selall {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .85rem;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
}

.files-toolbar .files-selall input {
    cursor: pointer;
    margin: 0;
}

.files-toolbar .files-count {
    margin-inline-start: auto;
    font-size: .85rem;
    color: var(--muted);
    font-weight: 700;
}

.file-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: #fff;
    flex-wrap: wrap;
}

.file-row:hover {
    border-color: var(--brand);
}

/* קובץ מערכת (data.ini) — מכיל את הגדרות השלוחה */
.file-row-system {
    background: #fdf9ef;
    border-color: #e8d9b0;
}

.file-row-system:hover {
    border-color: var(--accent);
}

.file-sys-icon {
    color: var(--accent);
    font-size: .95rem;
    cursor: help;
}

/* קובץ מחוק בסל המחזור */
.file-row-deleted {
    background: #faf7f5;
    border-style: dashed;
}

.file-deleted-icon {
    color: var(--success);
    font-size: .9rem;
}

/* קובץ קריינות (M + 4 ספרות) */
.file-row-prompt {
    background: var(--brand-lighter);
    border-color: #bcdde5;
}

.file-row-prompt:hover {
    border-color: var(--brand);
}

.file-prompt-icon {
    color: var(--brand);
    font-size: .95rem;
    cursor: help;
}

/* פריסת שורת קובץ בפאנל הצד: שם ופעולות בשורה אחת, נגן בשורה מלאה */
.files-card .file-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 10px;
}

.files-card .file-row .file-info {
    flex: none;
    min-width: 0;
}

.files-card .file-row .file-name {
    max-width: 100%;
}

.files-card .file-row audio {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    height: 36px;
}

.files-card .file-row .file-check {
    grid-row: 1;
    grid-column: 1;
}

.files-card .file-row .file-info {
    grid-row: 1;
    grid-column: 2;
}

.files-card .file-row .file-actions {
    grid-row: 1;
    grid-column: 3;
    margin-inline-start: 0;
}

.files-card .btn-icon {
    width: 30px;
    height: 30px;
    font-size: .82rem;
}

.file-row .file-info {
    flex: 0 0 190px;
    min-width: 0;
    overflow: hidden;
}

.file-row .file-name {
    font-weight: 700;
    font-size: .88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    text-align: right;
}

.file-row .file-meta {
    font-size: .74rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-row audio {
    flex: 1 1 180px;
    min-width: 140px;
    height: 38px;
}

.file-row .file-actions {
    display: flex;
    gap: 2px;
    margin-inline-start: auto;
}

.files-loading {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}

.skeleton {
    background: linear-gradient(90deg, #edf1f3 25%, #f8fafb 50%, #edf1f3 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite linear;
    border-radius: var(--radius-sm);
    height: 54px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ------------------------------------------------------------------ */
/* טבלת קריינות                                                        */
/* ------------------------------------------------------------------ */

.rec-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .88rem;
}

.rec-table th {
    background: var(--brand-lighter);
    color: var(--brand-dark);
    font-weight: 800;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    text-align: right;
    position: sticky;
    top: 0;
}

.rec-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--brand-lighter);
    vertical-align: top;
}

.rec-table tbody tr:hover {
    background: #fbfdfe;
}

.rec-table audio {
    max-width: 230px;
    height: 36px;
}

.rec-cell {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    min-width: 180px;
}

.rec-cell .upload-area {
    padding: 6px 10px;
    font-size: .76rem;
    width: 100%;
}

.rec-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 12px;
    flex-wrap: wrap;
}

.rec-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 0;
}

.rec-toolbar .files-count {
    margin-inline-start: auto;
    font-size: .85rem;
    color: var(--muted);
    font-weight: 700;
}

/* ------------------------------------------------------------------ */
/* סרגל לוח-גזירים (clipboard)                                          */
/* ------------------------------------------------------------------ */

.clipboard-bar {
    position: fixed;
    bottom: 18px;
    inset-inline: 0;
    display: flex;
    justify-content: center;
    z-index: 1050;
    pointer-events: none;
}

.clipboard-bar .cb-inner {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--brand-darker);
    color: #fff;
    border-radius: 999px;
    padding: 9px 10px 9px 18px;
    box-shadow: 0 8px 30px rgba(0, 40, 48, .45);
    max-width: 92vw;
}

.clipboard-bar .cb-text {
    font-size: .88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clipboard-bar .btn {
    border-radius: 999px;
    font-weight: 700;
    font-size: .82rem;
    padding: 5px 14px;
    white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* הודעות toast                                                        */
/* ------------------------------------------------------------------ */

.toast-stack {
    position: fixed;
    top: 74px;
    inset-inline: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 2100;
    pointer-events: none;
}

.app-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-inline-start: 5px solid var(--success);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    padding: 10px 18px;
    font-weight: 700;
    font-size: .9rem;
    animation: toastIn .25s ease;
    max-width: min(480px, 92vw);
}

.app-toast.toast-error {
    border-inline-start-color: var(--danger);
}

.app-toast.toast-error i {
    color: var(--danger);
}

.app-toast.toast-warning {
    border-inline-start-color: var(--warning);
}

.app-toast.toast-warning i {
    color: var(--warning);
}

.app-toast i {
    color: var(--success);
}

.app-toast.hide {
    animation: toastOut .25s ease forwards;
}

/* כפתור פעולה בטוסט (למשל "ביטול" אחרי מחיקה) */
.toast-action {
    margin-inline-start: 6px;
    background: none;
    border: 1px solid var(--brand);
    border-radius: 999px;
    color: var(--brand);
    font-weight: 800;
    font-size: .82rem;
    padding: 3px 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
}

.toast-action:hover {
    background: var(--brand);
    color: #fff;
}

/* בדיקת תקינות — דוח */
.hc-ok {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 16px;
    padding: 18px 20px;
    background: #f0f9f2;
    border: 1px solid #bfe5c8;
    border-radius: var(--radius-sm);
    font-size: .92rem;
}

.hc-ok i {
    font-size: 2rem;
    color: var(--success);
}

.hc-ok strong {
    display: block;
    margin-bottom: 2px;
}

.hc-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
}

.hc-row:last-child {
    border-bottom: none;
}

.hc-row > i {
    color: var(--warning);
    margin-top: 3px;
}

.hc-row .hc-info {
    flex: 1;
    min-width: 0;
}

.hc-row .hc-title {
    font-weight: 800;
    font-size: .9rem;
    color: var(--brand-darker);
}

.hc-row .hc-issue {
    font-size: .82rem;
    color: var(--muted);
    margin-top: 2px;
}

.hc-row button {
    flex: 0 0 auto;
    align-self: center;
}

/* סיור היכרות — זרקור ובועה.
   מיקום fixed בקואורדינטות viewport — אותה מערכת צירים של getBoundingClientRect,
   כך שהיישור מדויק גם במצב מוטמע (iframe) וב-RTL עם scrollbar-gutter */
.tour-spot {
    position: fixed;
    z-index: 2000;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(10, 36, 43, .55);
    pointer-events: none;
    transition: all .3s ease;
}

.tour-bubble {
    position: fixed;
    z-index: 2001;
    width: min(300px, calc(100vw - 24px));
    background: #fff;
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 40px rgba(0, 40, 50, .35);
    padding: 14px 16px;
    transition: top .3s ease, left .3s ease;
}

.tour-bubble .tb-title {
    font-weight: 800;
    color: var(--brand-dark);
    margin-bottom: 4px;
}

.tour-bubble .tb-text {
    font-size: .86rem;
    color: var(--text);
    line-height: 1.45;
}

.tour-bubble .tb-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.tour-bubble .tb-dots {
    font-size: .78rem;
    color: var(--muted);
    margin-inline-end: auto;
}

.tour-bubble .tb-skip {
    background: none;
    border: none;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 6px;
}

.tour-bubble .tb-skip:hover {
    color: var(--text);
    text-decoration: underline;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateY(-12px);
    }
}

/* ------------------------------------------------------------------ */
/* מסך טעינה / חסימה                                                    */
/* ------------------------------------------------------------------ */

.app-loader {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 3000;
}

.app-loader .spinner {
    width: 54px;
    height: 54px;
    border: 5px solid var(--brand-light);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.app-loader .loader-text {
    color: var(--brand-dark);
    font-weight: 700;
}

/* מפת שלוחות */
.map-tree ul {
    list-style: none;
    padding-inline-start: 22px;
    margin: 0;
    border-inline-start: 1px dashed #c8d6dc;
}

.map-tree > ul {
    border: none;
    padding-inline-start: 0;
}

.map-tree li {
    margin: 3px 0;
}

.map-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .9rem;
    max-width: 100%;
}

.map-item:hover {
    background: var(--brand-light);
}

.map-item .map-num {
    background: var(--brand);
    color: #fff;
    border-radius: 6px;
    min-width: 24px;
    text-align: center;
    padding: 0 6px;
    font-weight: 800;
    font-size: .8rem;
}

.map-item .map-type {
    color: var(--brand-dark);
    font-size: .88rem;
    font-weight: 800;
    white-space: nowrap;
}

.map-item .map-type i {
    color: var(--accent);
    margin-inline-end: 3px;
    font-size: .82em;
}

.map-item .map-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: .85rem;
}

/* עמוד "אין שלוחות" / שגיאה — כרטיס בתוך הנווט (נפרד ממתג body.empty-system) */
.empty-state {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 24px;
    text-align: center;
}

.empty-state > i {
    font-size: 2.6rem;
    color: #b9cdd4;
    margin-bottom: 14px;
}

/* קישור עדין לפתיחת מערכת ריקה — פחות מזמין מהכפתור הראשי */
.empty-state .empty-blank-link {
    display: block;
    margin: 14px auto 0;
    font-size: .82rem;
    color: var(--muted);
    font-weight: 600;
}

.empty-state .empty-blank-link:hover {
    color: var(--brand);
    text-decoration: underline;
}

/* SweetAlert RTL fixes */
.swal-modal {
    font-family: 'Assistant', sans-serif;
    direction: rtl;
}

.swal-title, .swal-text {
    text-align: center;
}

.swal-footer {
    text-align: center;
}

/* התאמות קטנות למובייל */
@media (max-width: 575px) {
    .app-header-inner {
        padding: 8px 12px;
        gap: 8px;
    }

    .app-main {
        padding: 12px;
    }

    .ext-row {
        padding: 10px 12px;
        gap: 10px;
    }

    .ext-actions .btn-icon:not(.btn-row-menu) {
        display: none;
    }

    .file-row audio {
        min-width: 140px;
    }
}
