* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light theme (padrão) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-red: #ef4444;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

:root[data-theme="dark"] {
    /* Dark theme */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #475569;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    background-image: radial-gradient(circle at top right, var(--bg-secondary), transparent),
        radial-gradient(circle at bottom left, var(--bg-tertiary), transparent);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem;
    line-height: 1.5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Full HD Optimization */
@media (min-width: 1600px) {
    .container {
        max-width: 1800px;
    }
}

/* HD Optimization (Compact Vertical) */
@media (max-height: 800px) {
    body {
        padding: 1rem;
    }

    .header {
        padding: 1rem 2rem;
        margin-bottom: 1rem;
    }

    .title {
        font-size: 1.75rem;
    }

    .section-title {
        margin-bottom: 1rem;
    }

    .summary-section,
    .technicians-section {
        padding: 1.5rem;
    }

    .card {
        padding: 1rem 1.5rem;
    }

    .card-icon {
        width: 50px;
        height: 50px;
        font-size: 2rem;
    }

    .card-value {
        font-size: 1.75rem;
    }

    .dashboard {
        gap: 1rem;
    }

    .pop-cards {
        margin-top: 1rem;
    }
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.title {
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
}

.title span:not(.icon) {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.icon {
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.update-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.update-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.update-time {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

.refresh-btn {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
}

.refresh-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.refresh-btn:active {
    transform: translateY(0);
}

/* Loading */
.loading {
    text-align: center;
    padding: 4rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Error */
.error-container {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--accent-red);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
}

.error-content {
    max-width: 500px;
    margin: 0 auto;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.error-container h3 {
    color: var(--accent-red);
    margin-bottom: 0.5rem;
}

.error-container p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.retry-btn {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-primary);
}

.count-badge {
    background: var(--accent-blue);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Grupo de Botões de Ordenação */
.sort-buttons-group {
    display: flex;
    background: var(--bg-tertiary);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    gap: 0.25rem;
}

.sort-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 0.4rem 0.8rem;
    border-radius: calc(var(--radius-sm) - 2px);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.sort-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.05);
}

:root[data-theme="dark"] .sort-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sort-btn.active {
    background: var(--bg-primary);
    color: var(--accent-blue);
    box-shadow: var(--shadow-sm);
    border-color: var(--border-color);
}

/* Cards Grid */
.summary-section {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.card-full-width {
    grid-column: 1 / -1;
}

.card {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    overflow: hidden;
}

.split-divider {
    width: 1px;
    height: 60px;
    background: var(--border-color);
    margin: 0 10px;
}

.card-split-wrapper {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 1.5rem;
}

.card-split-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-blue);
}

.card-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.1);
    border-radius: var(--radius-sm);
}

.card-total .card-icon {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
}

.card-finalizada-hoje .card-icon {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    font-size: 2rem;
}

.card-finalizada-hoje .card-value {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.card-content {
    flex: 1;
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.status-cards {
    display: contents;
}

/* POP Cards */
.pop-cards {
    margin-top: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.card-pop {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-pop:hover {
    transform: translateY(-2px);
    border-color: var(--accent-purple);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
}

.card-pop .card-label {
    margin-bottom: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.card-pop .card-value {
    font-size: 1.5rem;
    color: var(--accent-purple);
}

/* Top Tecnico Card Special Styling */
.card-top-tecnico .card-icon {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: white;
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.3);
}

.card-top-tecnico .card-value {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.5rem;
    /* Ajustado para caber nomes longos */
}

/* Technicians Section */
.technicians-section {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.technician-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-tertiary);
}

.technician-table thead {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
}

.technician-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.th-rank {
    width: 60px;
    text-align: center;
}

.th-total {
    width: 120px;
    text-align: center;
}

.technician-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.technician-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.technician-table tbody tr:last-child {
    border-bottom: none;
}

.technician-table td {
    padding: 1rem;
    color: var(--text-secondary);
}

.rank-cell {
    text-align: center;
    font-weight: 700;
    color: var(--accent-blue);
    font-size: 1.25rem;
}

.name-cell {
    font-weight: 500;
    color: var(--text-primary);
}

.total-cell {
    text-align: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--accent-green);
}

.status-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
}

.status-pill-label {
    color: var(--text-muted);
}

.status-pill-value {
    color: var(--text-primary);
    font-weight: 700;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

.modal-icon {
    font-size: 2rem;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-search-container {
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 10;
}

.modal-search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    /* Espaço para o ícone */
    border: 2px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    /* Ícone de busca como background image (simples) ou via HTML */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 1rem center;
    background-size: 1.25rem;
}

.modal-search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background-color: var(--bg-secondary);
}

.modal-search-input::placeholder {
    color: var(--text-muted);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.modal-loading {
    text-align: center;
    padding: 2rem;
}

.modal-os-list {
    display: none;
}

.modal-os-list.show {
    display: block;
}

.os-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.os-card:hover {
    transform: translateX(4px);
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-md);
}

.os-card:last-child {
    margin-bottom: 0;
}

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

.os-id {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-blue);
}

.os-status-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
}

.os-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.os-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.os-detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.os-detail-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

.os-conteudo {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.os-conteudo-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    font-style: italic;
}

/* === Estilos do Modal Colapsável === */

/* Remover padding do os-card original quando colapsável */
.os-card {
    padding: 0 !important;
}

/* Header clicável da O.S. (resumo) */
.os-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.os-card-header:hover {
    background: rgba(59, 130, 246, 0.05);
    border-bottom-color: var(--border-color);
}

/* Resumo da O.S. */
.os-card-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.os-summary-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.os-id-mini {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--accent-blue);
}

.os-status-badge-mini {
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid;
}

.os-cliente {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.os-motivo {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.os-endereco {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Ícone de expansão */
.os-expand-icon {
    color: var(--text-muted);
    font-size: 1.25rem;
    transition: transform 0.3s ease, color 0.3s ease;
    flex-shrink: 0;
    -webkit-user-select: none;
    user-select: none;
}

.os-card:hover .os-expand-icon {
    color: var(--accent-blue);
}

.os-card.expanded .os-expand-icon {
    transform: rotate(180deg);
}

/* Detalhes expandidos */
.os-card-details {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-color);
    animation: slideDown 0.3s ease;
    overflow: hidden;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
    }

    to {
        opacity: 1;
        max-height: 2000px;
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }
}

/* Ajustes no card quando expandido */
.os-card.expanded {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue);
}


.modal-footer {
    padding: 1rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1.125rem;
}

/* Responsive */

/* Tablet */
@media (max-width: 1024px) {
    body {
        padding: 1.5rem;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 1.25rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

/* Mobile */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .header {
        padding: 1.5rem 1rem;
        margin-bottom: 1.5rem;
        text-align: center;
    }

    .header-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .title {
        font-size: 1.5rem;
        justify-content: center;
    }

    .icon {
        font-size: 2rem;
    }

    .update-info {
        width: 100%;
        justify-content: center;
        flex-direction: column;
        gap: 0.5rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        padding: 1.25rem;
    }

    .card-icon {
        width: 50px;
        height: 50px;
        font-size: 1.8rem;
    }

    .card-full-width {
        max-height: none;
        height: auto;
    }

    .card-split-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        width: 100%;
    }

    .split-divider {
        width: 100%;
        height: 1px;
        margin: 5px 0;
    }

    .card-split-section {
        width: 100%;
    }

    .card-label {
        font-size: 0.75rem;
    }

    .card-value {
        font-size: 1.5rem;
    }

    .summary-section,
    .technicians-section {
        padding: 1.25rem 1rem;
    }

    .section-title {
        font-size: 1.25rem;
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .technician-table {
        display: block;
    }

    .technician-table thead {
        display: none;
    }

    .technician-table tbody tr {
        display: block;
        padding: 1rem;
        border-bottom: 2px solid var(--border-color);
    }

    .technician-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        text-align: right;
    }

    .technician-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        text-align: left;
    }

    .status-pills {
        justify-content: flex-end;
    }

    /* Modal adjustments for mobile */
    .modal-header {
        padding: 1rem;
    }

    .modal-title {
        font-size: 1rem;
    }

    .os-card {
        padding: 1rem;
    }

    .os-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .os-details {
        grid-template-columns: 1fr;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .header-content {
        gap: 0.75rem;
    }

    .refresh-btn {
        width: 100%;
        justify-content: center;
    }

    .modal-search-container {
        flex-direction: column;
        align-items: stretch !important;
    }

    .modal-sort-select {
        width: 100%;
    }
}

/* Refactoring Utility Classes */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.card-block {
    display: block;
    padding: 1.5rem;
}

.card-block-full {
    display: block;
    padding: 1.5rem;
    grid-column: 1 / -1;
}

.section-title-sm {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.table-container-scroll {
    max-height: 400px;
    overflow-y: auto;
}

.th-right {
    text-align: right;
}

.th-center {
    text-align: center;
}

.chart-container-wrapper {
    height: 350px;
    position: relative;
    width: 100%;
}

/* Drag and Drop Styles */
.card.dragging {
    opacity: 0.4;
    border: 2px dashed var(--accent-blue);
    transform: scale(0.95);
}

.card.over {
    border: 2px dashed var(--accent-blue);
    transform: scale(1.02);
}

/* Agrupamento por Cidade (Retiradas) */
.city-group {
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.city-header {
    background: var(--bg-tertiary);
    padding: 1rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.city-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.city-count {
    background: var(--accent-blue);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.8rem;
}

.city-content {
    display: none;
    padding: 1rem;
    background: var(--bg-primary);
}

.city-content.expanded {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* Notifica��es */
.notification-bell-container {
    position: relative;
    cursor: pointer;
    margin-right: 1rem;
}

.notification-badge {
    position: absolute;
    top: 5px;
    right: 10px;
    background: var(--accent-red);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 99px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 5px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.notifications-panel {
    position: fixed;
    top: 60px;
    right: 20px;
    left: auto;
    width: 350px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.notifications-panel.active {
    display: flex;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notifications-header {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.notifications-list {
    overflow-y: auto;
    flex: 1;
    max-height: 400px;
}

.notification-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.notification-item:hover {
    background: var(--bg-tertiary);
}

.notification-item.critical {
    border-left: 4px solid var(--accent-red);
}

.notification-item.warning {
    border-left: 4px solid var(--accent-yellow);
}

.notification-content h4 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.notification-content p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.notification-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    .notifications-panel {
        left: 20px;
        right: 20px;
        width: auto;
    }

    /* ========================================= */
    /* RESPONSIVO (Mobile First Adjustments)     */
    /* ========================================= */

    @media (max-width: 768px) {
        :root {
            --radius-lg: 12px;
            --radius-md: 8px;
        }

        body {
            padding: 1rem;
        }

        .header {
            padding: 1.5rem;
            margin-bottom: 1.5rem;
        }

        .header-content {
            flex-direction: column;
            align-items: flex-start;
            gap: 1rem;
        }

        .title {
            font-size: 1.5rem;
        }

        .icon {
            font-size: 2rem;
        }

        .summary-section {
            padding: 1.5rem;
        }

        .cards-grid {
            gap: 1rem;
        }

        .card {
            padding: 1rem;
        }
    }

    @media (max-width: 480px) {
        body {
            padding: 0.5rem;
        }

        .header {
            padding: 1rem;
            margin-bottom: 1rem;
            border-radius: var(--radius-md);
        }

        .title {
            font-size: 1.25rem;
        }

        .update-info {
            width: 100%;
            justify-content: space-between;
        }

        .summary-section {
            padding: 1rem;
            border-radius: var(--radius-md);
        }

        /* Ajuste de Modais para ocupar quase toda a tela */
        .modal-content {
            width: 95% !important;
            max-height: 90vh;
            margin: 2.5% auto;
            padding: 0 !important;
            border-radius: var(--radius-md) !important;
        }

        .modal-header {
            padding: 1rem !important;
        }

        .modal-body {
            padding: 1rem !important;
        }

        /* Cards de OS no modal */
        .os-card-header {
            flex-direction: column;
            align-items: flex-start;
            gap: 0.5rem;
        }

        .os-summary-top {
            flex-wrap: wrap;
            width: 100%;
            gap: 0.5rem;
        }

        .os-id-mini {
            font-size: 0.9rem;
        }

        .os-points-badge {
            font-size: 0.7rem !important;
            padding: 2px 6px !important;
        }

        /* Ajustes específicos para botões e inputs */
        .modal-search-container {
            flex-direction: column;
            gap: 0.5rem;
        }

        #modalSearchInput {
            width: 100%;
        }

        .modal-controls {
            flex-direction: column;
            width: 100%;
        }

        .modal-footer {
            padding: 1rem !important;
        }
    }

    /* Context Items (Technician Dashboard) */
    .context-item {
        flex: 1 1 100%;
        /* Default mobile */
        min-width: 100%;
    }

    @media (min-width: 769px) {
        .context-item-large {
            flex: 0 1 calc(33.33% - 0.75rem);
            min-width: 250px;
        }

        .context-item-small {
            flex: 1 1 calc(25% - 0.75rem);
            min-width: 140px;
        }
    }


    /* Mobile Table Card View - Technician Ranking */
    @media (max-width: 768px) {
        .technician-table thead {
            display: none;
        }

        .technician-table,
        .technician-table tbody,
        .technician-table tr,
        .technician-table td {
            display: block;
            width: 100%;
        }

        .technician-table tr {
            margin-bottom: 1rem;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            padding: 1rem;
        }

        .technician-table td {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0.5rem 0;
            border-bottom: 1px solid var(--border-color);
            text-align: right;
            min-height: 40px;
        }

        .technician-table td:last-child {
            border-bottom: none;
        }

        .technician-table td::before {
            content: attr(data-label);
            font-weight: 600;
            color: var(--text-muted);
            text-align: left;
            margin-right: 1rem;
            flex-shrink: 0;
            font-size: 0.9rem;
        }

        /* Tweaks for specific columns */
        .technician-table .th-name {
            font-weight: bold;
            color: var(--text-primary);
            font-size: 1.1rem;
            justify-content: flex-start;
            border-bottom: 2px solid var(--border-color);
            margin-bottom: 0.5rem;
            padding-bottom: 0.75rem;
        }

        .technician-table .th-name::before {
            display: none;
            /* Hide label for Name row (Avatar+Name is self-explanatory) */
        }

        .technician-table .th-rank {
            display: none;
            /* Hide rank row if redundant or move to badge */
        }
    }


    /* TV Mode / Header Adjustments */
    .header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .header-left {
        flex: 1;
    }

    .header-right {
        display: flex;
        align-items: center;
        gap: 1.5rem;
    }

    .live-clock {
        font-family: 'JetBrains Mono', 'Courier New', monospace;
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--text-primary);
        background: var(--bg-primary);
        padding: 0.5rem 1rem;
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--border-color);
    }

    .logo-img {
        height: 50px;
        width: auto;
        object-fit: contain;
    }

    /* TV Overview Section */
    .tv-overview-section {
        margin-bottom: 2rem;
    }

    .tv-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1.5rem;
    }

    .tv-card {
        background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
        padding: 1.5rem;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
        border: 1px solid var(--border-color);
        text-align: center;
        transition: transform 0.2s;
    }

    .tv-card:hover {
        transform: translateY(-5px);
        border-color: var(--accent-blue);
    }

    .tv-label {
        display: block;
        color: var(--text-secondary);
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .tv-value {
        display: block;
        font-size: 2rem;
        font-weight: 800;
        color: var(--text-primary);
        line-height: 1.2;
    }
}

/* ===================================================
   MOBILE RESPONSIVENESS (360px - 768px)
   =================================================== */

@media (max-width: 768px) {
    body {
        padding: 0.75rem !important;
    }

    .container {
        padding: 0;
        margin: 0;
        width: 100%;
        max-width: 100%;
    }

    /* Header */
    .header {
        padding: 1.25rem !important;
        margin-bottom: 1rem !important;
        border-radius: var(--radius-md) !important;
    }

    .header-content {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .title {
        font-size: 1.25rem !important;
        line-height: 1.2;
        width: 100%;
    }

    .title span:not(.icon) {
        white-space: normal !important;
    }

    .icon {
        font-size: 1.5rem !important;
        min-width: 32px;
    }

    .update-info {
        width: 100%;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-color);
    }

    .refresh-btn {
        width: 100%;
        margin: 0 !important;
        padding: 0.75rem !important;
        justify-content: center;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .live-clock {
        font-size: 1.1rem;
    }

    .logo-img {
        height: 36px;
    }

    /* Dashboard Layout */
    .summary-section {
        padding: 1rem !important;
        border-radius: var(--radius-md) !important;
    }

    .cards-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .pop-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    .card {
        padding: 1rem !important;
        flex-direction: row !important;
        align-items: center !important;
    }

    .card-icon {
        width: 48px !important;
        height: 48px !important;
        font-size: 1.5rem !important;
        flex-shrink: 0;
    }

    .card-label {
        font-size: 0.7rem !important;
    }

    .card-value {
        font-size: 1.35rem !important;
    }

    /* Tables */
    .technicians-section {
        padding: 1rem !important;
        margin-top: 1rem !important;
        border-radius: var(--radius-md) !important;
    }

    .section-title {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
        font-size: 1.25rem !important;
    }

    .table-actions {
        width: 100%;
    }

    .sort-buttons-group {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }

    .sort-btn {
        flex: 1;
        justify-content: center;
        padding: 0.6rem !important;
    }

    .table-container {
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
        border-radius: 0;
    }

    .technician-table th,
    .technician-table td {
        padding: 0.75rem 0.5rem !important;
        font-size: 0.8rem !important;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95% !important;
        margin: 1rem auto !important;
        padding: 1.25rem !important;
        max-height: 90vh;
    }

    .modal-header {
        padding-bottom: 0.75rem !important;
    }

    .modal-title {
        font-size: 1.1rem !important;
    }

    .modal-body {
        padding: 1rem 0 !important;
    }

    .modal-footer {
        padding-top: 1rem !important;
    }

    .modal-search-container {
        flex-direction: column;
        gap: 0.75rem !important;
        padding: 0.75rem !important;
    }

    .modal-search-input,
    .modal-group-select,
    .modal-sort-select {
        width: 100% !important;
        min-width: 0 !important;
    }
}

@media (max-width: 480px) {
    .pop-cards {
        grid-template-columns: 1fr !important;
    }

    .title {
        font-size: 1.1rem !important;
    }

    .technician-table .th-rank,
    .technician-table .rank-cell {
        display: none !important;
    }
}

/* Visibility Utilities */
.hide-mobile {
    display: block;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
}

/* AI Insider Section */
.ai-insider-section {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.ai-insider-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.1) 0%, transparent 70%);
    z-index: -1;
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.ai-insider-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ai-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 8px rgba(124, 58, 237, 0.5));
}

.ai-title {
    color: var(--text-primary);
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.ai-badge {
    background: linear-gradient(90deg, #7c3aed, #3b82f6);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-insider-content {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 1rem;
}

.ai-insider-content blockquote {
    border-left: 3px solid #7c3aed;
    margin-left: 0;
    padding-left: 1rem;
    color: var(--text-primary);
    font-style: italic;
}

/* AI Loading Spinner */
.ai-loading {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}

.ai-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(124, 58, 237, 0.3);
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: ai-spin 1s linear infinite;
}

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

[data-theme="dark"] .ai-insider-section {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);
    border-color: rgba(124, 58, 237, 0.4);
}

/* AI Config Button */
.ai-config-btn:hover {
    color: var(--text-primary) !important;
    background: rgba(124, 58, 237, 0.1) !important;
    transform: rotate(45deg);
}

.teams-container {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

.teams-container::-webkit-scrollbar {
    width: 4px;
}

.teams-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}