:root {
    --bg: #0f1420;
    --bg-elev: #161d2e;
    --bg-elev-2: #1d2540;
    --bg-elev-3: #242d4d;
    --border: #2a3350;
    --text: #e8ecf7;
    --text-muted: #a3abc4;
    --accent: #f5b942;
    --accent-dark: #d99a1f;
    --accent-text: #1a1406;
    --success: #3ecf8e;
    --danger: #ef5566;
    --warn: #f5b942;
    --info: #4fa3f7;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 8px 24px rgba(0,0,0,0.35);
    --sidebar-w: 260px;
    --accent-fg: #f5b942;      /* זהב כטקסט — במצב יום כהה יותר כדי שיהיה קריא */
    --backdrop: rgba(0,0,0,0.55);
    color-scheme: dark;
}

/* ===================== מצב יום (בהיר) ===================== */
:root[data-theme="light"] {
    --bg: #f3f5fa;
    --bg-elev: #ffffff;
    --bg-elev-2: #eef1f7;
    --bg-elev-3: #e2e7f0;
    --border: #d5dbe7;
    --text: #1a2133;
    --text-muted: #5b6478;
    --accent: #f5b942;
    --accent-dark: #e3a52a;
    --accent-text: #1a1406;
    --accent-fg: #9a6400;
    --success: #0f8a57;
    --danger: #c9283c;
    --warn: #9a6400;
    --info: #1d6fc4;
    --shadow: 0 6px 20px rgba(26,33,51,0.12);
    --backdrop: rgba(26,33,51,0.35);
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Heebo", "Arial Hebrew", Arial, sans-serif;
    min-height: 100vh;
}

/* נגישות: מכבד prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* פוקוס גלוי לניווט מקלדת — לא מסתמכים רק על outline ברירת המחדל */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===================== חשוב: תיקון תצוגת hidden ===================== *
 * באג אמיתי שנתפס בצילום מסך: כל class עם display משלו (display:flex/none)
 * מתחרה בספציפיות שווה מול [hidden] של הדפדפן — כלל ה-CSS *האחרון בקוד*
 * מנצח בתיקו, לא [hidden] אוטומטית. זה גרם למסך ההתחברות והאפליקציה להיות
 * גלויים בו-זמנית אחרי התחברות, ולכפתור סגירת המגירה להופיע גם בדסקטופ.
 * הפתרון החזק: כלל גורף אחד עם !important — hidden מנצח תמיד, בלי תלות
 * בסדר הכללים האחרים או בזה שמישהו ישכח :not([hidden]) בהמשך.            */
[hidden] { display: none !important; }

/* ===================== Login ===================== */
.login-screen {
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 20%, var(--bg-elev-2) 0%, var(--bg) 60%);
    padding: 20px;
    animation: fadein .2s ease;
}
.login-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: 0.5px; }
.login-sub { color: var(--text-muted); margin: 0 0 28px; font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 6px; text-align: right; }
.login-card label { font-size: 13px; color: var(--text-muted); margin-top: 10px; }
.login-card input {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 13px 14px;
    font-size: 16px;
    outline: none;
    transition: border-color .15s;
}
.login-card input:focus { border-color: var(--accent); }
.login-error {
    margin-top: 14px;
    color: var(--danger);
    font-size: 13.5px;
    background: rgba(239,85,102,0.12);
    border: 1px solid rgba(239,85,102,0.35);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

/* ===================== App shell: sidebar + content ===================== */
/* display:flex בלי flex-direction מפורש: ברירת המחדל (row) כבר מכבדת
 * dir="rtl" מה-html ומציבה את הילד הראשון ב-DOM (הסיידבר) בימין. row-reverse
 * היה הופך את זה בטעות ומעביר את הסיידבר לשמאל — בדיוק ההפך ממה שהתבקש. */
.app {
    min-height: 100vh;
    display: flex;
    animation: fadein .2s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.app-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* מונע גלישה אופקית מתוכן רחב */
}

/* ----- Sidebar ----- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-elev);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; padding: 0 4px; }
.brand-icon { font-size: 24px; }
.brand-name { flex: 1; }
/* .drawer-close מוצג רק במדיה-קוורי המובייל למטה — נסתר כברירת מחדל דרך
 * display, לא דרך hidden (הנראות שלו היא עניין רספונסיבי, לא state של JS). */
.drawer-close { display: none; }

.sidebar-account { display: flex; flex-direction: column; gap: 8px; }
.account-select {
    width: 100%;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    font-size: 14px;
}

.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side-nav-divider { height: 1px; background: var(--border); margin: 8px 4px; }
.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 13px 14px;
    font-size: 15px;
    text-align: right;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 100%;
    min-height: 46px;
    transition: background .12s, color .12s;
}
.nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-btn:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-btn.active { background: rgba(245,185,66,0.13); color: var(--accent-fg); font-weight: 700; }
.nav-btn.nav-admin.active, .nav-btn.nav-admin:hover { color: var(--accent-fg); }

.sidebar-logout { margin-top: auto; }

/* ----- Mobile top bar + drawer ----- */
.mobile-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.mobile-topbar-title { flex: 1; font-weight: 700; font-size: 16px; }
.btn-icon {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: var(--backdrop);
    z-index: 29;
}

@media (max-width: 880px) {
    .mobile-topbar { display: flex; }
    .sidebar {
        /* inline-start = ימין ב-RTL — מצמיד את המגירה לימין, אותו צד שבו
         * היא יושבת קבועה בדסקטופ. translateX(100%) פיזי (לא לוגי) מזיז
         * אותה ימינה מחוץ למסך במצב סגור, ללא קשר לכיווניות. */
        position: fixed;
        top: 0;
        inset-inline-start: 0;
        height: 100vh;
        z-index: 30;
        box-shadow: var(--shadow);
        transform: translateX(100%);
        transition: transform .22s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .drawer-close { display: flex; }
}

/* ===================== Content ===================== */
.content { padding: 24px 28px; max-width: 1000px; width: 100%; margin: 0 auto; flex: 1; }
@media (max-width: 880px) { .content { padding: 18px 16px; } }
.page-title { font-size: 20px; margin: 0 0 18px; }
.tab-panel { display: none; animation: fadein .15s ease; }
.tab-panel.active { display: block; }

/* ===================== Cards & grid ===================== */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 20px;
}
.card h3 { margin: 0 0 8px; font-size: 17px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.card-header h3 { margin: 0; }
.muted { color: var(--text-muted); font-size: 13.5px; margin: 4px 0 14px; line-height: 1.6; }
.field-label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

.grid { display: grid; gap: 16px; margin-bottom: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .grid-4 { grid-template-columns: 1fr; } }

.stat-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}
.stat-label { color: var(--text-muted); font-size: 12.5px; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; }

.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 4px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* ===================== Buttons ===================== */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .08s, opacity .15s, background .15s;
    font-family: inherit;
    min-height: 44px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-secondary { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-elev-3); }
.btn-danger { background: rgba(239,85,102,0.15); color: var(--danger); border: 1px solid rgba(239,85,102,0.4); }
.btn-danger:hover:not(:disabled) { background: rgba(239,85,102,0.25); }
.btn-warn { background: rgba(245,185,66,0.15); color: var(--warn); border: 1px solid rgba(245,185,66,0.4); }
.btn-warn:hover:not(:disabled) { background: rgba(245,185,66,0.25); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.btn-ghost:hover { color: var(--text); background: var(--bg-elev-2); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 12px; font-size: 13px; min-height: 38px; }
.btn-lg { padding: 15px 28px; font-size: 16px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; align-items: center; }

/* ===================== Badges ===================== */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-muted { background: rgba(163,171,196,0.15); color: var(--text-muted); }
.badge-success { background: rgba(62,207,142,0.16); color: var(--success); }
.badge-danger { background: rgba(239,85,102,0.16); color: var(--danger); }
.badge-info { background: rgba(79,163,247,0.16); color: var(--info); }
.badge-warn { background: rgba(245,185,66,0.16); color: var(--warn); }

/* ===================== Broadcast live ===================== */
.broadcast-live { border-color: var(--accent); }
.progress-bar-outer {
    background: var(--bg-elev-2);
    border-radius: 999px;
    height: 14px;
    overflow: hidden;
    margin: 14px 0 8px;
}
.progress-bar-inner {
    background: linear-gradient(90deg, var(--accent-dark), var(--accent));
    height: 100%;
    transition: width .4s ease;
}
.broadcast-meta { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-muted); margin-bottom: 12px; }
.ride-preview {
    background: var(--bg-elev-2);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 13.5px;
    color: var(--text-muted);
    white-space: pre-wrap;
    max-height: 100px;
    overflow-y: auto;
    margin-bottom: 4px;
}

/* ===================== Connect WhatsApp ===================== */
.connect-panel { border-color: var(--info); }
.connect-code {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 4px;
    text-align: center;
    background: var(--bg-elev-2);
    border: 1px dashed var(--info);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin: 14px 0;
    color: var(--accent-fg);
    direction: ltr;
}

/* ===================== Inputs ===================== */
textarea, input[type="text"] {
    width: 100%;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 13px 14px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
}
textarea:focus, input[type="text"]:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.send-result { margin-top: 12px; font-size: 14px; min-height: 1em; }
.send-result.success { color: var(--success); }
.send-result.error { color: var(--danger); }

/* ===================== Groups ===================== */
#groupSearch, #cleanSearch { margin-bottom: 12px; }
/* בלי max-height/overflow-y כאן בכוונה: זו הרשימה היחידה עם שורות שמשנות
   גובה דינמית במקום (תפריט שינוי-מיקום נפתח בתוך השורה עצמה) — בתוך container
   עם גלילה מקוננת קבועת-גובה, שינוי גובה כזה לפעמים לא מצייר מחדש נכון
   בדפדפני מובייל (במיוחד Android/Chrome), ונראה כאילו התוכן "חופף" לשורות
   שכנות. גלילת הדף הרגילה (בלי container מקונן) לא סובלת מהבאג הזה. */
.groups-list { display: flex; flex-direction: column; gap: 6px; }
.group-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-elev-2);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .12s, border-color .12s;
    user-select: none;
    min-height: 46px;
}
.group-row:hover { border-color: var(--border); }
.group-row.in-queue { background: rgba(245,185,66,0.09); border-color: rgba(245,185,66,0.35); }
.group-row .pos { width: 26px; text-align: center; font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.group-row.in-queue .pos { color: var(--accent-fg); font-weight: 700; }
.group-row .name { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-row .check { font-size: 16px; flex-shrink: 0; }
/* מצב תפריט/עריכת-מיקום: עמודה מפורשת (לא הסתמכות על flex-wrap בתוך שורה
   מעורבת) — פס עליון עם המיקום+שם, ומתחתיו תמיד שורה נפרדת לכפתורים/שדה
   הקלט. חשוב במיוחד ברוחב מובייל: בלי זה הכפתורים "נדחסו" לאותה שורה עם
   שם קבוצה ארוך והתחלקו לתצוגה שבורה/חופפת. */
.group-row.menu-open { cursor: default; flex-direction: column; align-items: stretch; gap: 0; }
.group-row-main { display: flex; align-items: center; gap: 12px; width: 100%; }
.group-menu { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; margin-top: 10px; align-items: center; }
.pos-input {
    width: 70px; background: var(--bg-elev-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); padding: 6px 10px;
    font-size: 14px; font-family: inherit; outline: none; text-align: center;
}
.pos-input:focus { border-color: var(--accent); }
.diagnose-result { margin-top: 12px; font-size: 13.5px; white-space: pre-wrap; color: var(--text-muted); }

/* ===================== Speed ===================== */
.speed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.speed-opt {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all .12s;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.speed-opt:hover { border-color: var(--accent); }
.speed-opt.selected { background: rgba(245,185,66,0.15); border-color: var(--accent-fg); color: var(--accent-fg); }

/* ===================== Alerts / lists ===================== */
.alerts-list { display: flex; flex-direction: column; gap: 10px; max-height: 560px; overflow-y: auto; }
.alert-item {
    background: var(--bg-elev-2);
    border-radius: var(--radius-sm);
    border-inline-start: 3px solid var(--accent);
    padding: 12px 14px;
    font-size: 13.5px;
}
.alert-item .driver-name { font-weight: 700; margin-bottom: 4px; }
.alert-item .ride-text { color: var(--text-muted); margin-bottom: 4px; }
.alert-item .msg-body { color: var(--text); }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px 20px; font-size: 14px; }

/* ===================== Credentials box (new web user created) ===================== */
.credentials-box {
    background: rgba(62,207,142,0.1);
    border: 1px solid rgba(62,207,142,0.4);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 12px;
    font-size: 14px;
}
.credentials-box .cred-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.credentials-box .cred-label { color: var(--text-muted); flex-shrink: 0; }
.credentials-box .cred-value {
    font-weight: 700; font-family: monospace; font-size: 14px; direction: ltr; text-align: left;
    flex: 1; overflow-x: auto; white-space: nowrap;
}
.credentials-box .cred-copy { flex-shrink: 0; padding: 6px 10px; font-size: 15px; }
.credentials-box .cred-hint { color: var(--text-muted); font-size: 12.5px; margin-top: 10px; line-height: 1.6; }

/* ===================== Admin user rows ===================== */
.user-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-elev-2);
    border-radius: var(--radius-sm);
    border-inline-start: 3px solid var(--info);
    padding: 12px 14px;
}
.user-row.is-owner { border-inline-start-color: var(--accent); }
.user-row .user-info { flex: 1; min-width: 0; }
.user-row .user-name { font-weight: 700; font-size: 14px; }
.user-row .user-meta { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ===================== Toast ===================== */
#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 100;
    max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { border-color: var(--success); }
#toast.error { border-color: var(--danger); }

/* ===================== Broadcast cards + driver tags ===================== */
.bc-list { display: flex; flex-direction: column; gap: 12px; }
.bc-card {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.bc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.bc-date { font-weight: 700; font-size: 14px; margin-inline-end: 4px; }
.bc-ride-short { color: var(--text-muted); font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.bc-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.bc-meta { font-size: 13px; color: var(--text-muted); }
.bc-details { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.bc-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.bc-stat-grid > div {
    background: var(--bg-elev);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex; flex-direction: column; gap: 2px;
}
.bc-stat-label { font-size: 12px; color: var(--text-muted); }
.bc-stat-val { font-size: 14px; font-weight: 700; }
.bc-ride { white-space: pre-wrap; }
.bc-tags-section { margin-top: 14px; }
.bc-tags-title { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.tags-empty { color: var(--text-muted); font-size: 13.5px; padding: 12px 4px; }

.tags-list { display: flex; flex-direction: column; gap: 10px; }
.tag-item {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-inline-start: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 13.5px;
    overflow-wrap: anywhere;
}
.broadcast-live .tag-item { background: var(--bg-elev-2); }
.tag-item.replied { border-inline-start-color: var(--success); }
.tag-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tag-driver { font-weight: 700; font-size: 14.5px; }
.tag-time { color: var(--text-muted); font-size: 12.5px; flex-shrink: 0; }
.tag-kind { color: var(--accent-fg); font-size: 12.5px; margin: 2px 0 6px; }
.tag-line { color: var(--text-muted); margin-bottom: 4px; }
.tag-ride { white-space: pre-wrap; }
.tag-msg { color: var(--text); margin: 4px 0 2px; white-space: pre-wrap; }
.tag-replied { color: var(--success); font-size: 12.5px; margin-top: 6px; }
.tag-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.tag-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.tag-nolink { color: var(--text-muted); font-size: 12.5px; }
.k-form { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.k-form-row { display: flex; gap: 8px; align-items: center; }
.k-form-row .k-phone { flex: 1; min-width: 0; direction: ltr; text-align: right; }

@media (max-width: 560px) {
    .bc-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .bc-bottom .bc-toggle { width: 100%; }
    .tag-actions .btn { flex: 1 1 auto; justify-content: center; }
    .k-form-row { flex-wrap: wrap; }
    .k-form-row .k-phone { flex-basis: 100%; }
    .k-form-row .btn { flex: 1; }
}


/* ===================== מתג מצב יום/לילה (בסגנון אייפון) ===================== */
.theme-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--bg-elev-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 12px; cursor: pointer;
    font-size: 14px; user-select: none; min-height: 44px;
}
.theme-switch { position: relative; width: 51px; height: 31px; flex-shrink: 0; }
.theme-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.theme-track {
    position: absolute; inset: 0; border-radius: 31px;
    background: var(--bg-elev-3); border: 1px solid var(--border);
    transition: background .25s ease, border-color .25s ease;
}
.theme-thumb {
    position: absolute; top: 2px; right: 2px; width: 27px; height: 27px; border-radius: 50%;
    background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: transform .25s cubic-bezier(.3,.7,.4,1);
}
.theme-switch input:checked + .theme-track { background: #34c759; border-color: #34c759; }
/* RTL: הכפתור מתחיל בימין ונע שמאלה כשמופעל */
.theme-switch input:checked + .theme-track .theme-thumb { transform: translateX(-20px); }
.theme-switch input:focus-visible + .theme-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* קוד החיבור לחיץ — לחיצה עליו מעתיקה אותו (כמו כפתור "העתק קוד") */
.connect-code { cursor: pointer; user-select: all; }
.connect-code:empty { display: none; }
.connect-code-actions { justify-content: center; margin-top: 0; }

/* ===================== התראות תיוגים (למעלה) ===================== */
.tag-alerts {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(420px, calc(100vw - 24px));
    pointer-events: none;
}
.tag-alert {
    display: flex;
    align-items: stretch;
    gap: 4px;
    background: var(--bg-elev);
    border: 1px solid var(--accent);
    border-inline-start: 4px solid var(--accent);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    overflow: hidden;
    pointer-events: auto;
    animation: tagAlertIn .18s ease;
}
@keyframes tagAlertIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.tag-alert-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-start;
    text-align: start;
    background: none;
    border: none;
    color: var(--text);
    font-family: inherit;
    padding: 12px 14px;
    cursor: pointer;
    min-height: 44px;
}
.tag-alert-main:hover { background: var(--bg-elev-2); }
.tag-alert-title { font-weight: 700; font-size: 14.5px; }
.tag-alert-sub { color: var(--text-muted); font-size: 12.5px; }
.tag-alert-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 15px; cursor: pointer; padding: 0 12px; min-width: 44px;
}
.tag-alert-close:hover { color: var(--text); background: var(--bg-elev-2); }

/* מונה תיוגים שלא נצפו — על לשונית "שלח נסיעה" */
.nav-badge {
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 11px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 12.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
}

/* הבהוב קצר על התיוג שאליו קפצנו מההתראה */
.tag-item.tag-flash { animation: tagFlash 2.4s ease; }
@keyframes tagFlash {
    0%, 100% { background: var(--bg-elev); }
    10%, 60% { background: rgba(245,185,66,0.22); border-inline-start-color: var(--accent); }
}

/* תיוג שנסגר ב"מי קיבל" */
.tag-closed { color: var(--info); font-size: 12.5px; margin-top: 4px; }
.tag-item.closed { border-inline-start-color: var(--info); }
