:root {
    color-scheme: light;
    --bg: #f4f5f7;
    --card: #ffffff;
    --border: #e0e2e7;
    --text: #1f2430;
    --muted: #6b7280;
    --primary: #1d4ed8;
    --primary-dark: #1730a3;
    --primary-soft: #eef2ff;
    --danger: #dc2626;
    --success: #16a34a;
    --accent-blue: #2a78d6;
    --accent-aqua: #1baf7a; --accent-violet: #8b5cf6;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
    --shadow-md: 0 4px 10px rgba(16,24,40,.08), 0 2px 4px rgba(16,24,40,.06);
    --surface-alt: #f9fafb;
    --surface-hover: #eef2ff;
    --alert-success-bg: #ecfdf5; --alert-success-text: #065f46; --alert-success-border: #a7f3d0;
    --alert-error-bg: #fef2f2; --alert-error-text: #991b1b; --alert-error-border: #fecaca;
    --alert-info-bg: #eff6ff; --alert-info-text: #1e3a8a; --alert-info-border: #bfdbfe;
    --badge-view-bg: #e0e7ff; --badge-view-text: #3730a3;
    --badge-edit-bg: #dcfce7; --badge-edit-text: #166534;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0f1117;
        --card: #171a23;
        --border: #2a2e3a;
        --text: #e8e9ed;
        --muted: #9298ab;
        --primary: #4f8cf6;
        --primary-dark: #6ba0f8;
        --primary-soft: #1b2740;
        --danger: #f87171;
        --success: #34d399;
        --accent-blue: #5b9cf0;
        --accent-aqua: #2fd18f; --accent-violet: #a78bfa;
        --shadow: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.35);
        --shadow-md: 0 4px 14px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.3);
        --surface-alt: #1b1e28;
        --surface-hover: #1b2740;
        --alert-success-bg: #0f2e22; --alert-success-text: #6ee7b7; --alert-success-border: #1f5c44;
        --alert-error-bg: #351515; --alert-error-text: #fca5a5; --alert-error-border: #6b2626;
        --alert-info-bg: #10233f; --alert-info-text: #93c5fd; --alert-info-border: #1e4372;
        --badge-view-bg: #232a52; --badge-view-text: #a5b4fc;
        --badge-edit-bg: #123524; --badge-edit-text: #6ee7b7;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1117;
    --card: #171a23;
    --border: #2a2e3a;
    --text: #e8e9ed;
    --muted: #9298ab;
    --primary: #4f8cf6;
    --primary-dark: #6ba0f8;
    --primary-soft: #1b2740;
    --danger: #f87171;
    --success: #34d399;
    --accent-blue: #5b9cf0;
    --accent-aqua: #2fd18f; --accent-violet: #a78bfa;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.35);
    --shadow-md: 0 4px 14px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.3);
    --surface-alt: #1b1e28;
    --surface-hover: #1b2740;
    --alert-success-bg: #0f2e22; --alert-success-text: #6ee7b7; --alert-success-border: #1f5c44;
    --alert-error-bg: #351515; --alert-error-text: #fca5a5; --alert-error-border: #6b2626;
    --alert-info-bg: #10233f; --alert-info-text: #93c5fd; --alert-info-border: #1e4372;
    --badge-view-bg: #232a52; --badge-view-text: #a5b4fc;
    --badge-edit-bg: #123524; --badge-edit-text: #6ee7b7;
}
:root[data-theme="light"] {
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    text-align: right;
    transition: background-color .2s ease, color .2s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar .brand { font-weight: 700; font-size: 18px; display: inline-flex; align-items: center; gap: 8px; }
.brand-logo { height: 30px; width: 30px; object-fit: contain; border-radius: 6px; vertical-align: middle; }

.topbar-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-end { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.main-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 20px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background-color .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 14px; line-height: 1; }

.nav-dropdown { position: relative; }
.nav-caret { font-size: 9px; transition: transform .15s ease; }
.nav-dropdown.open .nav-caret { transform: rotate(180deg); }
.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 6px;
    min-width: 190px;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 50;
}
.nav-dropdown.open .nav-dropdown-menu { display: flex; }
.nav-dropdown-menu .nav-link { width: 100%; justify-content: flex-start; }

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    cursor: pointer;
    padding: 0;
}
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px; transition: transform .15s ease, opacity .15s ease; }
.nav-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}
.theme-toggle:hover { border-color: var(--primary); }
.theme-toggle-mobile { display: none; }
.theme-toggle-icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle-icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle-icon-light { display: inline; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle-icon-dark { display: none; }
    :root:not([data-theme="light"]) .theme-toggle-icon-light { display: inline; }
}

.topbar .user-info { font-size: 13px; color: var(--muted); white-space: nowrap; }
.mobile-user-info { display: none; }

.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.card h2, .card h1 { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 700px) {
    .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}

label { display: block; font-size: 13px; margin-bottom: 4px; color: var(--muted); }

input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=time], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
}

textarea { min-height: 70px; resize: vertical; }

.field { margin-bottom: 12px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--card); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--card); color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: 13px; }

.sort-link { color: var(--text); font-weight: 600; white-space: nowrap; }
.sort-link:hover { color: var(--primary); text-decoration: none; }
.sort-link.active { color: var(--primary); }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.success { background: var(--alert-success-bg); color: var(--alert-success-text); border: 1px solid var(--alert-success-border); }
.alert.error { background: var(--alert-error-bg); color: var(--alert-error-text); border: 1px solid var(--alert-error-border); }
.alert.info { background: var(--alert-info-bg); color: var(--alert-info-text); border: 1px solid var(--alert-info-border); }

.table-scroll { overflow-x: auto; margin: -4px -4px 0; padding: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th { background: var(--surface-alt); font-weight: 600; }
tbody tr:nth-child(even) td { background: var(--surface-alt); }
tr:hover td { background: var(--surface-hover); }
td.row-actions { white-space: nowrap; }

table.compact th, table.compact td { padding: 5px 8px; font-size: 13px; }
table.compact .inline-edit { min-width: 76px; font-size: 12px; padding: 3px 6px; }
table.compact .btn.small { padding: 2px 8px; min-height: 26px; font-size: 12px; }
table.compact .qv-toggle { padding: 2px 7px; min-height: 26px; min-width: 26px; font-size: 13px; font-weight: 700; }

.inline-edit {
    width: 100%;
    min-width: 110px;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    background: transparent;
    font-family: inherit;
    color: var(--text);
    transition: background-color .2s ease, border-color .2s ease;
}
.inline-edit:hover { border-color: var(--border); }
.inline-edit:focus { border-color: var(--primary); background: var(--card); outline: none; }
.inline-edit:disabled { opacity: .6; }
.inline-edit.inline-edit-ok { background: var(--alert-success-bg); border-color: var(--alert-success-border); }
.inline-edit.inline-edit-err { background: var(--alert-error-bg); border-color: var(--alert-error-border); }
td.row-actions .btn { margin-inline-end: 4px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.view { background: var(--badge-view-bg); color: var(--badge-view-text); }
.badge.edit { background: var(--badge-edit-bg); color: var(--badge-edit-text); }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }

.field-group { margin-bottom: 22px; }
.field-group h3 { font-size: 15px; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 12px; color: var(--primary-dark); }

.readonly-value { padding: 8px 0; color: var(--text); }

.search-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input, .search-bar select { flex: 1; min-width: 160px; }

.list-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.result-count { color: var(--muted); font-size: 13px; margin: 0; }

.pagination { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pagination-ellipsis { padding: 4px 6px; color: var(--muted); }
.btn.disabled { opacity: .4; pointer-events: none; cursor: default; }

.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat-tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-inline-start: 3px solid var(--accent, var(--primary));
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat-tile .icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    background: color-mix(in srgb, var(--accent, var(--primary)) 16%, transparent);
}
.stat-tile .label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.stat-tile .value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.15; }
.stat-tile .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat-tile.tone-blue { --accent: var(--accent-blue); }
.stat-tile.tone-green { --accent: var(--success); }
.stat-tile.tone-orange { --accent: #f59e0b; }
.stat-tile.tone-violet { --accent: #8b5cf6; }

.bar-chart { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; padding: 6px; margin: 0 -6px; border-radius: 8px; }
.bar-row-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, transform .1s ease;
}
.bar-row-link:hover { background: var(--surface-hover); text-decoration: none; }
.bar-row .bar-label {
    width: 140px;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bar-track {
    flex: 1;
    background: var(--bg);
    border-radius: 4px;
    height: 22px;
    overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 4px; min-width: 2px; width: 0; transition: width .8s cubic-bezier(.22,1,.36,1); }
.bar-value {
    width: 70px;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--muted);
    text-align: left;
    font-variant-numeric: tabular-nums;
}

#stats-table th { user-select: none; }
#stats-table th:hover { background: var(--surface-hover); color: var(--primary); }
#stats-table th.sort-asc::after { content: " ▲"; font-size: 10px; color: var(--primary); }
#stats-table th.sort-desc::after { content: " ▼"; font-size: 10px; color: var(--primary); }

.upload-progress { margin-top: 14px; }
.upload-progress-track { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.upload-progress-fill {
    height: 100%;
    width: 0;
    background: var(--primary);
    border-radius: 6px;
    transition: width .15s ease;
}
.upload-progress.processing .upload-progress-fill {
    width: 100%;
    background-image: repeating-linear-gradient(45deg, var(--primary), var(--primary) 12px, var(--primary-dark) 12px, var(--primary-dark) 24px);
    background-size: 34px 34px;
    animation: upload-stripes 1s linear infinite;
}
@keyframes upload-stripes {
    from { background-position: 0 0; }
    to { background-position: 34px 0; }
}
.upload-progress-label { font-size: 13px; color: var(--muted); margin-top: 6px; }

.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    background: var(--card);
}
.filter-chip:has(input:checked) {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-dark);
}
.filter-chip input { margin: 0; }

.bar-chart-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.record-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px;
}
.record-nav-pos {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    min-width: 110px;
    text-align: center;
}

.btn.qv-inline-mark { background: var(--success); border-color: var(--success); color: #fff; }
.btn.qv-inline-voted { background: var(--alert-success-bg); border-color: var(--alert-success-border); color: var(--alert-success-text); }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .container { max-width: 100%; margin: 0; }
    .card { border: none; }
}

/* ===== מובייל ===== */
@media (max-width: 700px) {
    .container { margin: 12px auto; padding: 0 10px; }
    .card { padding: 14px; }

    .topbar {
        flex-wrap: wrap;
        gap: 8px 10px;
        padding: 10px 14px;
    }
    .topbar-start { min-width: 0; flex: 1 1 auto; }
    .topbar .brand {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }
    .brand-logo { height: 24px; width: 24px; }
    .nav-toggle { display: flex; flex-shrink: 0; }
    .theme-toggle-mobile { display: inline-flex; flex-shrink: 0; }
    .theme-toggle-desktop { display: none; }
    .topbar-end { display: none; }
    .mobile-user-info {
        display: block;
        font-size: 13px;
        color: var(--muted);
        padding: 8px 10px;
        margin-bottom: 4px;
        border-bottom: 1px solid var(--border);
    }
    .main-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }
    .main-nav.open { display: flex; }
    .nav-link { width: 100%; }
    .nav-dropdown-menu {
        position: static;
        display: flex;
        box-shadow: none;
        border: none;
        background: transparent;
        padding-inline-start: 20px;
        margin-top: 2px;
    }
    .nav-dropdown-toggle { width: 100%; justify-content: space-between; }

    .search-bar { flex-direction: column; align-items: stretch; }
    .search-bar input, .search-bar select, .search-bar .btn { width: 100%; min-width: 0; }

    .list-footer { flex-direction: column; align-items: stretch; text-align: center; }
    .pagination { justify-content: center; }

    .filter-chip { font-size: 14px; padding: 7px 12px; }

    .bar-row .bar-label { width: 90px; font-size: 12px; }
    .bar-value { width: 56px; font-size: 12px; }

    td.row-actions { display: flex; flex-direction: column; gap: 6px; }
    td.row-actions .btn { margin-inline-end: 0; width: 100%; }
}

.combo-table td { padding: 5px 8px; vertical-align: middle; }
.combo-table td.combo-name { font-weight: 600; white-space: nowrap; width: 1%; }
.combo-table td.combo-chart { width: 99%; }
.combo-line { display: flex; align-items: center; gap: 8px; color: inherit; padding: 1px 4px; border-radius: 6px; }
.combo-line:hover { background: var(--surface-hover); text-decoration: none; }
.combo-line .bar-track { flex: 1; height: 9px; display: block; }
.combo-line .bar-fill { display: block; }
.combo-val { display: flex; align-items: center; gap: 6px; min-width: 150px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.combo-val b { font-weight: 600; color: var(--text); }
.combo-lbl { display: inline-flex; align-items: center; gap: 4px; min-width: 62px; }
.combo-lbl i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.wrap-cells th, .wrap-cells td { white-space: normal; overflow-wrap: anywhere; word-break: break-word; vertical-align: top; }

/* ===== מובייל: טבלאות הופכות לכרטיסים קומפקטיים (התוויות נוספות ע"י הסקריפט ב-footer.php) ===== */
@media screen and (max-width: 700px) {
    input[type=text], input[type=email], input[type=password], input[type=tel],
    input[type=date], input[type=time], select, textarea { font-size: 16px; }
    .container { margin: 10px auto; }
    h1 { font-size: 22px; }
    .card { padding: 12px; }

    .table-scroll { margin: 0; padding: 0; overflow-x: visible; }
    table.rt, table.rt tbody { display: block; }
    table.rt thead { display: none; }
    table.rt tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px 10px;
        padding: 8px 10px;
        margin-bottom: 8px;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--card);
    }
    table.rt tbody tr:nth-child(even) td,
    table.rt tr:hover td { background: transparent; }
    table.rt td {
        display: block;
        padding: 0;
        border: none;
        white-space: normal;
        word-break: break-word;
        min-width: 0;
        font-size: 13px;
    }
    table.rt td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
    table.rt td[data-label=""]::before { display: none; }
    table.rt td:first-child { grid-column: 1 / -1; font-weight: 600; font-size: 14px; }
    table.rt td:first-child::before { display: none; }
    table.rt td[colspan] { grid-column: 1 / -1; }
    table.rt td.row-actions { grid-column: 1 / -1; display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; }
    table.rt td.row-actions::before { display: none; }
    table.rt td.row-actions .btn { width: auto; flex: 1; margin: 0; }

    table.rt.perm-table tr { grid-template-columns: repeat(4, 1fr); }
    table.rt.perm-table td:not(:first-child) { text-align: center; }
    table.rt.perm-table input[type=checkbox] { width: 22px; height: 22px; }

}

/* ===== הגנה מפני גלישת תוכן מחוץ למסגרת (כרטיסים, אריחים, תגיות) ===== */
.stat-tile { container-type: inline-size; overflow: hidden; }
.stat-tile > div:not(.icon) { min-width: 0; flex: 1; }
.stat-tile .label, .stat-tile .sub { overflow-wrap: anywhere; }
.stat-tile .value { font-size: clamp(16px, 13cqw, 26px); white-space: nowrap; }
@container (max-width: 215px) {
    .stat-tile { gap: 8px; padding: 12px; }
    .stat-tile .icon { width: 30px; height: 30px; font-size: 15px; border-radius: 8px; }
    .stat-tile .label { font-size: 12px; }
}
.card, .stat-tile, .field, .grid > * { min-width: 0; }
.card { overflow-wrap: break-word; }
.badge { max-width: 100%; overflow-wrap: anywhere; }
.filter-chip { max-width: 100%; }
img, video { max-width: 100%; height: auto; }

/* קישורי חיוג / WhatsApp */
.phone-cell { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; }
.phone-cell .inline-edit { flex: 1; min-width: 0; }
.call-link { text-decoration: none; font-size: 15px; line-height: 1; padding: 4px; border-radius: 6px; }
.call-link:hover { background: var(--surface-hover); text-decoration: none; }
.call-link[hidden] { display: none; }
@media screen and (max-width: 700px) {
    .call-link { font-size: 20px; padding: 6px; }
}

/* מצב שיחות */
.call-card { max-width: 560px; margin: 0 auto 16px; text-align: center; }
.call-name { font-size: 26px; font-weight: 800; }
.call-meta { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }
.call-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.call-big { min-height: 52px; font-size: 18px; flex: 1; min-width: 150px; }
.call-note-existing { background: var(--surface-alt); border-radius: 8px; padding: 8px 10px; font-size: 13px; text-align: right; }
.call-history { font-size: 12px; color: var(--muted); text-align: right; margin-top: 8px; }
.call-outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.call-out { min-height: 54px; font-size: 17px; font-weight: 700; }
.call-out-yes { background: var(--success); border-color: var(--success); color: #fff; }
.call-out-answered { background: var(--alert-info-bg); border-color: var(--alert-info-border); color: var(--alert-info-text); }
.call-out-no { background: var(--surface-alt); border-color: var(--border); color: var(--text); }
.call-out-never { background: var(--alert-error-bg); border-color: var(--alert-error-border); color: var(--alert-error-text); }

@media screen and (max-width: 700px) {
    .combo-table, .combo-table tbody, .combo-table tr, .combo-table td { display: block; width: auto; }
    .combo-table tr { padding: 6px 0; border-bottom: 1px solid var(--border); }
    .combo-table tr:last-child { border-bottom: none; }
    .combo-table td { padding: 1px 4px; border: none; background: transparent; }
    .combo-table td.combo-name { width: auto; }
    .combo-val { min-width: 128px; }
}

/* רשימת הרשומות בטלפון: שורה אחת לרשומה עם גלילה אופקית; תיבת הסימון והשם נעוצים בצד */
@media screen and (max-width: 700px) {
    .table-scroll.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
    table.compact.no-cards { min-width: 760px; }
    table.compact.no-cards th:nth-child(1), table.compact.no-cards td:nth-child(1),
    table.compact.no-cards th:nth-child(2), table.compact.no-cards td:nth-child(2) {
        position: sticky; background: var(--card); z-index: 1;
    }
    table.compact.no-cards th:nth-child(1), table.compact.no-cards td:nth-child(1) { right: 0; min-width: 30px; }
    table.compact.no-cards th:nth-child(2), table.compact.no-cards td:nth-child(2) { right: 30px; box-shadow: -6px 0 6px -6px rgba(0,0,0,.25); font-weight: 600; }
    table.compact.no-cards tbody tr:nth-child(even) td:nth-child(1),
    table.compact.no-cards tbody tr:nth-child(even) td:nth-child(2) { background: var(--surface-alt); }
    table.compact.no-cards .qv-toggle { min-height: 34px; min-width: 44px; font-size: 16px; }
}

@media screen and (max-width: 700px) {
    table.compact.no-cards td.row-actions { display: table-cell; white-space: nowrap; }
    table.compact.no-cards td.row-actions .btn { width: auto; margin: 0 0 0 4px; }
}

#users-table th { user-select: none; }
#users-table th[data-sort]:hover { background: var(--surface-hover); color: var(--primary); }
#users-table th.sort-asc::after { content: " ▲"; font-size: 10px; color: var(--primary); }
#users-table th.sort-desc::after { content: " ▼"; font-size: 10px; color: var(--primary); }

/* גרף הצבעה לפי שעה */
.hour-chart { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 8px; }
.hour-col { flex: 1; min-width: 18px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.hour-count { font-size: 11px; color: var(--muted); min-height: 14px; }
.hour-bar { flex: 1; width: 100%; display: flex; align-items: flex-end; background: var(--bg); border-radius: 4px; overflow: hidden; }
.hour-fill { width: 100%; height: 0; background: var(--success); min-height: 2px; border-radius: 4px 4px 0 0; transition: height .8s cubic-bezier(.22,1,.36,1); }
.hour-label { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* סינון ברשומות: במובייל מקופל מאחורי כפתור */
.filters-toggle { display: none; }
@media screen and (max-width: 700px) {
    .filters-toggle { display: flex; width: 100%; justify-content: space-between; align-items: center; margin-bottom: 10px; }
    #filters-form { display: none; }
    #filters-form.open { display: flex; }
    .filters-toggle[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }
}

/* קישור "המכשירים שלי" בתפריט: בדסקטופ הוא נגיש דרך שם המשתמש */
.nav-mobile-only { display: none; }
@media screen and (max-width: 700px) { .nav-mobile-only { display: flex; } }

/* מעבר בין מפלגות */
.party-switch { margin: 0; }
.party-switch select { max-width: 170px; padding: 6px 8px; font-size: 13px; font-weight: 600; }
.brand-switch { display: none; }
@media screen and (min-width: 701px) {
    .brand.has-switch .brand-name { display: none; }
    .brand.has-switch .brand-switch { display: inline-flex; }
    .brand-switch .party-switch select { font-size: 17px; font-weight: 800; max-width: 230px; padding: 4px 8px; }
}
@media screen and (max-width: 700px) {
    .nav-mobile-only .party-switch select { max-width: none; width: 100%; }
}

/* ===== טבלת משתמשים: פריסה אחידה ונקייה ===== */
#users-table { width: 100%; border-collapse: collapse; }
#users-table th, #users-table td { vertical-align: middle; padding: 10px 12px; }
#users-table td { border-top: 1px solid var(--border); }
#users-table .muted { color: var(--muted); }
#users-table .user-cell { display: flex; align-items: center; gap: 10px; margin: 0; color: inherit; cursor: pointer; }
#users-table .user-cell-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
#users-table .user-cell-text strong { font-weight: 600; }
#users-table .user-cell-text small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
#users-table td.col-name { min-width: 220px; }
#users-table td.col-phone { white-space: nowrap; }
#users-table td.col-role, #users-table td.col-status { white-space: nowrap; }
#users-table td.col-tags { min-width: 150px; }
#users-table td.col-tags .badge { margin: 2px 0 2px 4px; }
/* תגיות בשורה אחת, בלי לשבור מילים ובלי גלולות צרות וגבוהות */
#users-table .badge { white-space: nowrap; overflow-wrap: normal; max-width: none; }
#users-table .badge.on { background: #dcfce7; color: #166534; }
#users-table .badge.idle { background: transparent; color: var(--muted); font-weight: 500; padding-inline: 0; }
#users-table .badge.off { background: #fee2e2; color: #991b1b; }
#users-table .badge.role-super_admin { background: #ede9fe; color: #5b21b6; }
#users-table .badge.role-party_admin { background: #dbeafe; color: #1e40af; }
#users-table .badge.role-admin { background: #e0f2fe; color: #075985; }
#users-table .badge.role-user { background: var(--badge-view-bg); color: var(--badge-view-text); }
/* עמודת הפעולות: כפתורים בשורה אחת, מיושרים לקצה */
#users-table td.row-actions { display: table-cell; white-space: nowrap; text-align: end; width: 1%; }
#users-table td.row-actions form { display: inline-block; margin: 0; }
#users-table td.row-actions .btn { margin: 0 0 0 4px; }
@media (prefers-color-scheme: dark) {
    #users-table .badge.on { background: #14532d; color: #bbf7d0; }
    #users-table .badge.off { background: #7f1d1d; color: #fecaca; }
    #users-table .badge.role-super_admin { background: #4c1d95; color: #ddd6fe; }
    #users-table .badge.role-party_admin { background: #1e3a8a; color: #bfdbfe; }
    #users-table .badge.role-admin { background: #0c4a6e; color: #bae6fd; }
}
:root[data-theme="dark"] #users-table .badge.on { background: #14532d; color: #bbf7d0; }
:root[data-theme="dark"] #users-table .badge.off { background: #7f1d1d; color: #fecaca; }
:root[data-theme="dark"] #users-table .badge.role-super_admin { background: #4c1d95; color: #ddd6fe; }
:root[data-theme="dark"] #users-table .badge.role-party_admin { background: #1e3a8a; color: #bfdbfe; }
:root[data-theme="dark"] #users-table .badge.role-admin { background: #0c4a6e; color: #bae6fd; }
:root[data-theme="light"] #users-table .badge.on { background: #dcfce7; color: #166534; }

/* טבלת משתמשים: תגיות עוטפות בשורות נקיות, ועמודות קומפקטיות */
#users-table .tags { display: flex; flex-wrap: wrap; gap: 4px; max-width: 230px; }
#users-table td.col-tags .badge { margin: 0; }
#users-table td.col-name { min-width: 200px; }
#users-table th, #users-table td { padding: 10px 8px; }

/* תפריט הניהול: קבוצות עם כותרות ומפרידים. פעולות שוטפות בולטות, פעולות נדירות בהירות וקטנות יותר */
.nav-dropdown-menu { min-width: 220px; }
.nav-menu-label { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--muted); padding: 6px 12px 2px; }
.nav-menu-sep { height: 1px; background: var(--border); margin: 6px 4px 2px; }
.nav-dropdown-menu .nav-link-minor { font-size: 14px; color: var(--muted); }
.nav-dropdown-menu .nav-link-minor.active, .nav-dropdown-menu .nav-link-minor:hover { color: var(--primary); }
.nav-dropdown-menu .nav-link-minor .nav-icon { opacity: .75; }
@media screen and (max-width: 700px) {
    .nav-menu-label { padding-inline-start: 4px; }
}

/* תווית המפלגה בראש דוחות ומסכי ניהול */
.party-chip-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 -6px; }
.party-chip { display: inline-flex; gap: 6px; align-items: center; background: var(--badge-edit-bg); color: var(--badge-edit-text); padding: 4px 12px; border-radius: 999px; font-size: 13px; }
.party-chip-note { color: var(--muted); font-size: 12px; }

/* תפריט משתמש (שם + המכשירים שלי + התנתקות) */
.user-menu { position: relative; }
.user-menu-toggle { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 5px 10px; cursor: pointer; color: var(--muted); font-size: 14px; font-family: inherit; }
.user-menu-toggle:hover, .user-menu.open .user-menu-toggle { background: var(--surface-hover); border-color: var(--border); color: var(--text); }
.user-menu-toggle small { font-size: 12px; opacity: .8; }
.user-menu-list { display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 190px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); padding: 6px; flex-direction: column; gap: 2px; z-index: 60; }
.user-menu.open .user-menu-list { display: flex; }
.user-menu-list .nav-link { width: 100%; justify-content: flex-start; }
@media screen and (max-width: 700px) { .user-menu { display: none; } }
