/* SUS360 Painel Cirurgias v0.8.0 — sidebar */

        /* ═══════ FILTER SIDEBAR ═══════ */
        .filter-advanced-btn {
            display: flex; align-items: center; gap: 6px;
            padding: 7px 14px; border: 1px solid var(--border-color);
            border-radius: var(--radius-full); background: transparent;
            font-size: 12px; font-weight: 600; color: var(--text-secondary);
            cursor: pointer; transition: all 0.15s; white-space: nowrap;
        }
        .filter-advanced-btn:hover { border-color: #6b7280; color: var(--text-primary); }
        .filter-advanced-btn i { font-size: 14px; }
        .filter-advanced-count {
            display: inline-flex; align-items: center; justify-content: center;
            min-width: 18px; height: 18px; border-radius: 9px;
            background: #4a5568; color: white; font-size: 10px; font-weight: 700;
        }

        .sb-overlay {
            position: fixed; inset: 0; z-index: 9998;
            background: rgba(0,0,0,0.4); backdrop-filter: blur(2px);
            transition: opacity 0.2s;
        }
        .sb-panel {
            position: fixed; top: 0; right: 0; bottom: 0; z-index: 9999;
            width: 380px; max-width: 90vw;
            background: var(--bg-card); border-left: 1px solid var(--border-color);
            box-shadow: -8px 0 32px rgba(0,0,0,0.2);
            display: flex; flex-direction: column;
            transform: translateX(100%); transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .sb-panel.open { transform: translateX(0); }

        .sb-header {
            display: flex; align-items: center; justify-content: space-between;
            padding: 16px 20px; border-bottom: 1px solid var(--border-color);
        }
        .sb-header-title {
            font-size: 14px; font-weight: 800; color: var(--text-primary);
            text-transform: uppercase; letter-spacing: 0.5px;
            display: flex; align-items: center; gap: 8px;
        }
        .sb-header-title i { font-size: 16px; color: #6b7280; }
        .sb-close {
            width: 32px; height: 32px; border: 1px solid var(--border-color);
            border-radius: 8px; background: transparent; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            font-size: 16px; color: var(--text-muted); transition: all 0.15s;
        }
        .sb-close:hover { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.06); }

        .sb-body { flex: 1; overflow-y: auto; padding: 8px 0; }

        .sb-section { border-bottom: 1px solid var(--border-color); }
        .sb-section:last-child { border-bottom: none; }
        .sb-section-header {
            display: flex; align-items: center; gap: 10px; width: 100%;
            padding: 12px 20px; border: none; background: transparent;
            cursor: pointer; transition: background 0.12s;
            color: var(--text-primary); font-size: 13px; font-weight: 600;
        }
        .sb-section-header:hover { background: rgba(128,128,128,0.04); }
        .sb-section-icon { font-size: 15px; color: #6b7280; width: 20px; text-align: center; }
        .sb-section-title { flex: 1; text-align: left; }
        .sb-section-badge {
            display: inline-flex; align-items: center; justify-content: center;
            min-width: 18px; height: 18px; border-radius: 9px;
            background: #4a5568; color: white; font-size: 9px; font-weight: 700; padding: 0 5px;
        }
        .sb-section-header i:last-child { font-size: 10px; color: var(--text-muted); }

        .sb-section-body { padding: 0 20px 14px; }

        .sb-search {
            display: flex; align-items: center; gap: 8px;
            padding: 8px 12px; border: 1px solid var(--border-color);
            border-radius: 8px; margin-bottom: 8px;
        }
        .sb-search i { color: var(--text-muted); font-size: 13px; }
        .sb-search input {
            flex: 1; border: none; background: none; outline: none;
            font-size: 12px; color: var(--text-primary);
        }
        .sb-search input::placeholder { color: var(--text-muted); }

        .sb-list { max-height: 200px; overflow-y: auto; margin-bottom: 8px; }
        .sb-item {
            display: flex; align-items: center; gap: 8px;
            padding: 7px 10px; border-radius: 6px; cursor: pointer;
            font-size: 12px; color: var(--text-secondary); transition: all 0.1s;
        }
        .sb-item:hover { background: rgba(128,128,128,0.06); }
        .sb-item.active {
            background: rgba(74,85,104,0.12); color: var(--text-primary); font-weight: 700;
            border-left: 3px solid #4a5568;
        }
        .sb-item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .sb-item-tag {
            font-size: 9px; font-weight: 700; color: var(--text-muted);
            background: var(--bg-body); padding: 1px 6px; border-radius: 4px;
        }

        .sb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
        .sb-chip {
            display: flex; align-items: center; gap: 5px;
            padding: 6px 12px; border: 1px solid var(--border-color);
            border-radius: 20px; font-size: 11px; font-weight: 600;
            color: var(--text-muted); background: transparent;
            cursor: pointer; transition: all 0.12s;
        }
        .sb-chip:hover { border-color: #6b7280; color: var(--text-primary); }
        .sb-chip.active {
            background: #4a5568; border-color: #4a5568; color: white;
        }
        body:not(.dark) .sb-chip.active { background: #374151; border-color: #374151; }

        .sb-toggle-group {
            display: flex; gap: 3px; background: var(--bg-body);
            border-radius: 6px; padding: 3px; margin-top: 8px;
        }
        .sb-toggle-group button {
            flex: 1; padding: 5px 8px; border: none; border-radius: 4px;
            font-size: 10px; font-weight: 600; cursor: pointer;
            background: transparent; color: var(--text-muted); transition: all 0.12s;
        }
        .sb-toggle-group button.active {
            background: var(--bg-card); color: var(--text-primary);
            box-shadow: 0 1px 2px rgba(0,0,0,0.1);
        }

        .sb-footer {
            display: flex; justify-content: space-between; align-items: center;
            padding: 14px 20px; border-top: 1px solid var(--border-color);
        }
        .sb-footer-clear {
            padding: 7px 18px; border: 1px solid var(--border-color);
            border-radius: 6px; background: transparent;
            font-size: 11px; font-weight: 600; color: var(--text-muted);
            cursor: pointer; transition: all 0.12s;
        }
        .sb-footer-clear:hover { border-color: #ef4444; color: #ef4444; }
        .sb-footer-apply {
            padding: 7px 24px; border: none; border-radius: 6px;
            background: #374151; color: white;
            font-size: 11px; font-weight: 700; cursor: pointer;
            transition: background 0.12s;
        }
        .sb-footer-apply:hover { background: #1f2937; }

        .sb-empty { padding: 12px; text-align: center; font-size: 11px; color: var(--text-muted); }

        body.sb-no-scroll { overflow: hidden; }

        
        /* ═══ CATEGORIAS DO SIDEBAR ═══ */
        .sb-category {
            padding: 16px 20px 8px;
            margin-top: 6px;
            border-top: 2px solid var(--border-color);
            background: rgba(128,128,128,0.03);
        }
        .sb-category:first-child {
            border-top: none;
            margin-top: 0;
        }
        .sb-category-title {
            font-size: 10px;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 2px;
            color: var(--text-muted);
            opacity: 0.7;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .sb-category-title i {
            font-size: 12px;
            opacity: 0.8;
        }
        .sb-category-title::after {
            content: '';
            flex: 1;
            height: 1px;
            background: var(--border-color);
        }
        .sb-category + .sb-section {
            border-top: none;
        }
        .sb-section {
            border-bottom: 1px solid rgba(128,128,128,0.08);
        }
        .sb-section:last-child { border-bottom: none; }

        .sb-footer-left {
            display: flex;
            align-items: center;
        }
        .sb-footer-right {
            display: flex;
            gap: 8px;
            align-items: center;
        }

        @media (max-width: 480px) { .sb-panel { width: 100%; max-width: 100%; } }


        /* ═══════ TERRITORY LEFT SIDEBAR ═══════ */
        .tl-overlay {
            position: fixed; inset: 0; z-index: 9998;
            background: rgba(0,0,0,0.4); backdrop-filter: blur(2px);
            transition: opacity 0.2s;
        }
        .tl-panel {
            position: fixed; top: 0; left: 0; bottom: 0; z-index: 9999;
            width: 340px; max-width: 85vw;
            background: var(--bg-card); border-right: 1px solid var(--border-color);
            box-shadow: 8px 0 32px rgba(0,0,0,0.2);
            display: flex; flex-direction: column;
            transform: translateX(-100%); transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .tl-panel.open { transform: translateX(0); }

        .tl-header {
            display: flex; align-items: center; justify-content: space-between;
            padding: 16px 20px; border-bottom: 1px solid var(--border-color);
        }
        .tl-header-title {
            font-size: 14px; font-weight: 800; color: var(--text-primary);
            text-transform: uppercase; letter-spacing: 0.5px;
            display: flex; align-items: center; gap: 8px;
        }
        .tl-header-title i { font-size: 16px; color: #6b7280; }
        .tl-close {
            width: 32px; height: 32px; border: 1px solid var(--border-color);
            border-radius: 8px; background: transparent; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            font-size: 16px; color: var(--text-muted); transition: all 0.15s;
        }
        .tl-close:hover { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.06); }

        .tl-body { flex: 1; overflow-y: auto; padding: 12px 0; }

        .tl-section { padding: 10px 20px; }
        .tl-section + .tl-section { border-top: 1px solid rgba(128,128,128,0.08); }

        .tl-section-label {
            font-size: 10px; font-weight: 800; text-transform: uppercase;
            letter-spacing: 1.5px; color: var(--text-muted); opacity: 0.7;
            margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
        }
        .tl-section-label i { font-size: 12px; }

        .tl-empty {
            font-size: 11px; color: var(--text-muted); opacity: 0.5;
            font-style: italic; padding: 2px 0;
        }

        .tl-item {
            display: flex; align-items: center; gap: 8px;
            padding: 6px 10px; margin: 4px 0;
            background: rgba(128,128,128,0.06); border-radius: 8px;
            font-size: 12px; color: var(--text-primary); font-weight: 500;
            transition: background 0.12s;
        }
        .tl-item:hover { background: rgba(128,128,128,0.1); }
        .tl-item-flag {
            width: 22px; height: 15px; border-radius: 2px;
            object-fit: cover; border: 1px solid rgba(255,255,255,0.1);
            flex-shrink: 0;
        }
        body:not(.dark) .tl-item-flag { border-color: rgba(0,0,0,0.1); }
        .tl-item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .tl-item-code {
            font-size: 9px; font-weight: 700; color: var(--text-muted);
            background: var(--bg-body); padding: 2px 6px; border-radius: 4px;
            font-variant-numeric: tabular-nums; flex-shrink: 0;
        }
        .tl-item-remove {
            width: 22px; height: 22px; border: none; background: transparent;
            border-radius: 4px; cursor: pointer; color: var(--text-muted);
            display: flex; align-items: center; justify-content: center;
            font-size: 12px; transition: all 0.12s; flex-shrink: 0; padding: 0;
        }
        .tl-item-remove:hover { color: #ef4444; background: rgba(239,68,68,0.08); }

        .tl-regiao-label {
            font-size: 12px; font-weight: 600; color: var(--text-secondary);
            padding: 2px 0;
        }

        /* Population section */
        .tl-pop-section {
            padding: 14px 20px; border-top: 1px solid var(--border-color);
            margin-top: 4px;
        }
        .tl-pop-title {
            font-size: 10px; font-weight: 800; text-transform: uppercase;
            letter-spacing: 1.5px; color: var(--text-muted); opacity: 0.7;
            margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
        }
        .tl-pop-title::after {
            content: ''; flex: 1; height: 1px; background: var(--border-color);
        }
        .tl-pop-row {
            display: flex; align-items: center; justify-content: space-between;
            padding: 3px 0; font-size: 12px;
        }
        .tl-pop-label { color: var(--text-muted); font-weight: 500; }
        .tl-pop-value { color: var(--text-primary); font-weight: 700; font-variant-numeric: tabular-nums; }
        .tl-pop-value.sus { color: #22c55e; }
        .tl-pop-value.priv { color: #f59e0b; }

        .tl-pop-bar {
            display: flex; height: 6px; border-radius: 3px; overflow: hidden;
            margin-top: 10px; background: rgba(128,128,128,0.1);
        }
        .tl-pop-bar-sus {
            background: linear-gradient(90deg, #22c55e, #16a34a);
            transition: width 0.3s ease;
        }
        .tl-pop-bar-priv {
            background: linear-gradient(90deg, #f59e0b, #d97706);
            transition: width 0.3s ease;
        }
        .tl-pop-pct {
            text-align: center; font-size: 11px; font-weight: 700;
            color: #22c55e; margin-top: 6px;
        }

        .tl-footer {
            padding: 14px 20px; border-top: 1px solid var(--border-color);
        }
        .tl-footer-clear {
            width: 100%; padding: 8px 18px;
            border: 1px solid var(--border-color); border-radius: 8px;
            background: transparent; font-size: 12px; font-weight: 600;
            color: var(--text-muted); cursor: pointer; transition: all 0.12s;
            display: flex; align-items: center; justify-content: center; gap: 6px;
        }
        .tl-footer-clear:hover { border-color: #ef4444; color: #ef4444; }
        .tl-footer-clear i { font-size: 14px; }

        /* Territory button badge */
        .tl-badge {
            position: absolute; top: -2px; right: -2px;
            width: 8px; height: 8px; border-radius: 50%;
            background: #22c55e; border: 2px solid var(--bg-card);
        }

        @media (max-width: 480px) { .tl-panel { width: 100%; max-width: 100%; } }

        /* ═══ Territory sidebar categories ═══ */
        .tl-category {
            padding: 14px 20px 6px;
            margin-top: 4px;
            border-top: 2px solid var(--border-color);
            background: rgba(128,128,128,0.03);
        }
        .tl-category:first-child {
            border-top: none;
            margin-top: 0;
        }
        .tl-category-title {
            font-size: 10px;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 2px;
            color: var(--text-muted);
            opacity: 0.7;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .tl-category-title i { font-size: 12px; opacity: 0.8; }
        .tl-category-title::after {
            content: '';
            flex: 1;
            height: 1px;
            background: var(--border-color);
        }
        .tl-category + .tl-section { border-top: none; }
        .tl-section { padding: 4px 20px 8px; }
        .tl-hint {
            font-size: 11px;
            color: var(--text-muted);
            opacity: 0.6;
            padding: 8px 0;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .tl-hint i { font-size: 12px; }
