:root {
    --primary: #0f6b57;
    --primary-dark: #0b5243;
    --primary-soft: #e8f5f1;
    --secondary: #1c8c72;
    --bg: #f4f7f6;
    --white: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #dbe3df;
    --danger: #c0392b;
    --danger-dark: #992d22;
    --shadow: 0 10px 25px rgba(15, 107, 87, 0.08);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    background: #f6faf8;
    color: var(--text);
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 270px;
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 22px;
    margin-bottom: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-brand img {
    width: 72px;
    background: white;
    border-radius: 14px;
    padding: 7px;
}

.sidebar-brand h2 {
    margin: 0;
    font-size: 19px;
}

.sidebar-brand p {
    margin: 3px 0 0;
    font-size: 13px;
    opacity: 0.9;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-menu a {
    color: white;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 10px;
    transition: 0.2s ease;
    font-weight: 600;
    font-size: 14px;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.14);
}

.sidebar-footer {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.profile-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.profile-info strong {
    font-size: 14px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-info span {
    font-size: 12px;
    opacity: 0.85;
    text-transform: capitalize;
}

.sidebar-logout {
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.10);
    color: white;
    padding: 11px 14px;
    border-radius: 10px;
    font-weight: 600;
    transition: 0.2s ease;
}

.sidebar-logout:hover {
    background: rgba(255, 255, 255, 0.18);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-topbar {
    background: white;
    border-bottom: 1px solid #e8efeb;
    padding: 22px 30px;
}

.content-topbar h1 {
    margin: 0;
    font-size: 24px;
    color: var(--primary);
}

.content-topbar p {
    margin: 5px 0 0;
    color: var(--muted);
}

.page-content {
    padding: 26px;
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px;
}

.login-box,
.form-card,
.detail-card,
.card,
.table-wrapper {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(15, 107, 87, 0.06);
}

.login-box {
    padding: 34px;
    max-width: 430px;
    width: 100%;
    margin: 0 auto;
}

.login-box h2 {
    margin: 0 0 18px;
    color: var(--primary);
    font-size: 28px;
}

.login-box p {
    color: var(--muted);
    margin-bottom: 22px;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-sizing: border-box;
    font-size: 14px;
    background: #fcfdfd;
    transition: 0.2s ease;
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(28, 140, 114, 0.10);
    background: white;
}

button {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 107, 87, 0.16);
}

.dashboard h2,
.page-header h2 {
    color: var(--primary);
    margin: 0 0 6px;
    font-size: 28px;
}

.dashboard p,
.page-header p {
    color: var(--muted);
}

.cards {
    display: flex;
    gap: 18px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.card {
    padding: 22px;
    min-width: 240px;
    flex: 1;
    background: linear-gradient(180deg, #ffffff 0%, #f8fcfb 100%);
}

.card h3 {
    margin: 0 0 10px;
    font-size: 16px;
    color: var(--primary);
    font-weight: 700;
}

.card p {
    font-size: 30px;
    margin: 0;
    font-weight: 800;
    color: var(--text);
}

.acoes {
    margin-top: 26px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn,
.btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    text-decoration: none;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    transition: 0.2s ease;
    cursor: pointer;
}

.btn:hover,
.btn-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(15, 107, 87, 0.15);
}

.btn-small {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-danger {
    background: linear-gradient(135deg, #c0392b, #992d22);
    color: white;
    border: none;
}

.alert {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
}

.alert.danger {
    background: #fdeaea;
    color: #9f1d1d;
    border: 1px solid #f2c8c8;
}

.alert.success {
    background: #e8f8ee;
    color: #166534;
    border: 1px solid #bfe6cc;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.form-card {
    padding: 24px;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 700;
    color: #21463b;
    font-size: 14px;
}

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

.table-wrapper {
    padding: 16px;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.custom-table th,
.custom-table td {
    padding: 13px 12px;
    border-bottom: 1px solid #edf2ef;
    text-align: left;
    vertical-align: middle;
}

.custom-table thead th {
    background: #f3faf7;
    color: var(--primary);
    font-weight: 800;
    position: sticky;
    top: 0;
}

.custom-table tbody tr:hover {
    background: #f9fcfb;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
}

.detail-card {
    padding: 24px;
}

.detail-card h3 {
    margin: 0 0 18px;
    color: var(--primary);
    font-size: 20px;
}

.detail-card p {
    margin: 10px 0;
    line-height: 1.5;
}

.mt-30 {
    margin-top: 30px;
}

.status-badge {
    display: inline-block;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.status-aguardando-aprovacao,
.status-aguardando-compra,
.status-em-digitacao {
    background: #fff4db;
    color: #9a6700;
}

.status-aprovado,
.status-fechada {
    background: #dcfce7;
    color: #166534;
}

.status-reprovado,
.status-cancelada,
.status-contrato-encerrado {
    background: #fee2e2;
    color: #991b1b;
}

.status-peca-de-alto-custo,
.status-custo-muito-baixo {
    background: #e0f2fe;
    color: #075985;
}

.login-logo {
    text-align: center;
    margin-bottom: 18px;
}

.login-logo img {
    width: 110px;
    background: #fff;
    padding: 8px;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

@media (max-width: 950px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .grid-form,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* ITEM ATIVO NO MENU */
.sidebar-menu a.active {
    background: rgba(255, 255, 255, 0.18);
    border-left: 4px solid #ffffff;
    padding-left: 10px;
    font-weight: 700;
}

/* Hover melhorado */
.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateX(2px);
}

.menu-badge {
    background: #ef4444;
    color: white;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    padding: 0 6px;
    margin-left: auto;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}

.hidden {
    display: none !important;
}

.sidebar-alert-toggle {
    width: 100%;
    margin-bottom: 14px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: white;
    padding: 11px 14px;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: none;
    transform: none !important;
}

.sidebar-alert-toggle:hover {
    background: rgba(255, 255, 255, 0.18);
    box-shadow: none;
}

.toast-notificacao {
    position: fixed;
    top: 24px;
    right: 24px;
    background: #0f6b57;
    color: white;
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.18);
    z-index: 9999;
    opacity: 0;
    transform: translateY(-10px);
    transition: 0.3s ease;
    font-weight: 600;
}

.toast-notificacao.show {
    opacity: 1;
    transform: translateY(0);
}

.menu-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.menu-toggle {
    display: none;
    width: auto;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 20px;
    line-height: 1;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
    margin-top: 28px;
}

.chart-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(15, 107, 87, 0.06);
    padding: 22px;
}

.chart-card h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--primary);
}

@media (max-width: 950px) {
    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        width: 280px;
    }

    .sidebar.sidebar-open {
        left: 0;
    }

    .main-content {
        width: 100%;
    }

    .chart-grid,
    .grid-form,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

.chart-grid-2x2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-chart {
    min-height: 320px;
}

.compact-chart canvas {
    width: 100% !important;
    height: 240px !important;
}

.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-toggle {
    width: auto;
}

.export-menu {
    position: absolute;
    top: calc(100% + 8px)
    right: 0;
    min-width: 190px;
    background: #fff;
    border: 1px solid #dbe3df;
    border-radius: 12px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.10);
    padding: 8px;
    display: none;
    z-index: 20;
}

.export-menu.show {
    display: block;
}

.export-menu a {
    display: block;
    padding: 10px 12px;
    text-decoration: none;
    color: #1f2937;
    border-radius: 8px;
    font-size: 14px;
}

.export-menu a:hover {
    background: #f3faf7;
}

@media (max-width: 1100px) {
    .chart-grid-2x2 {
        grid-template-columns: 1fr;
    }

    .compact-chart {
        min-height: 300px;
    }

    .compact-chart canvas {
        height: 220px !important;
    }
}

/* ===== PADRÃO BOTÕES (VOLTar / EXPORTAR) ===== */

.btn,
.export-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    height: 44px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 500;

    border-radius: 10px;
    border: none;
    cursor: pointer;

    background-color: #0F6B57;
    color: #fff;

    transition: all 0.2s ease;
}

.btn:hover,
.export-toggle:hover {
    background-color: #0c5445;
}

.export-toggle {
    min-width: 120px;
}

/* alinhamento dos botões lado a lado */
.acoes {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ===== LOGIN MODERNO ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #eef7f3 0%, #f8fbfa 100%);
}

.login-box-modern {
    width: 100%;
    max-width: 460px;
    padding: 36px 34px;
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(15, 107, 87, 0.10);
    border: 1px solid rgba(15, 107, 87, 0.08);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-header h2 {
    margin: 0 0 8px;
    color: #0F6B57;
    font-size: 28px;
    font-weight: 700;
}

.login-header p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form .form-group {
    margin: 0;
}

.login-form input {
    background: #f8fbfc;
    border: 1px solid #d8e4df;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 15px;
}

.login-form input:focus {
    outline: none;
    border-color: #1c8c72;
    box-shadow: 0 0 0 4px rgba(28, 140, 114, 0.10);
    background: #fff;
}

.login-links {
    display: flex;
    justify-content: flex-end;
    margin-top: -4px;
}

.login-links a {
    font-size: 14px;
    color: #0F6B57;
    text-decoration: none;
    font-weight: 600;
}

.login-links a:hover {
    text-decoration: underline;
}

.login-button-group {
    margin-top: 6px;
}

.login-form button {
    width: 100%;
    height: 50px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
}

.login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo img {
    width: 110px;
    background: #fff;
    padding: 8px;
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}

.table-wrapper form {
    display: inline;
    margin: 0;
}

.table-wrapper form .btn-small,
.table-wrapper form .btn-danger,
.table-wrapper form button {
    width: auto !important;
    min-width: auto !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
}

.bg-login {
    background: linear-gradient(135deg, #0f5f4b, #1d8f6f);
}

.primeiro-acesso-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.primeiro-acesso-container {
    width: 100%;
    max-width: 560px;
}

.primeiro-acesso-container .form-card {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
    padding: 32px;
}

/* ===== FORÇA DA SENHA ===== */
.password-strength {
    margin-top: 10px;
}

.password-strength-bar {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.password-strength-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    transition: all 0.25s ease;
}

.password-strength-text {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 600;
}

.password-rules {
    margin-top: 10px;
    display: grid;
    gap: 6px;
}

.password-rule {
    font-size: 13px;
    color: #6b7280;
}

.password-rule.ok {
    color: #0F6B57;
    font-weight: 600;
}

.password-rule.fail {
    color: #b91c1c;
    font-weight: 600;
}

.strength-fraca .password-strength-fill {
    width: 25%;
    background: #dc2626;
}

.strength-media .password-strength-fill {
    width: 55%;
    background: #f59e0b;
}

.strength-boa .password-strength-fill {
    width: 75%;
    background: #3b82f6;
}

.strength-forte .password-strength-fill {
    width: 100%;
    background: #16a34a;
}

.strength-fraca .password-strength-text {
    color: #dc2626;
}

.strength-media .password-strength-text {
    color: #f59e0b;
}

.strength-boa .password-strength-text {
    color: #2563eb;
}

.strength-forte .password-strength-text {
    color: #16a34a;
}

.password-field .password-toggle,
.password-field .password-toggle:hover,
.password-field .password-toggle:focus,
.password-field .password-toggle:active {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    flex: 0 0 24px !important;
}

/* ===== CAMPOS DE SENHA ===== */
.password-field {
    position: relative;
    width: 100%;
}

.password-field input {
    width: 100%;
    padding-right: 52px !important;
    box-sizing: border-box;
}

.password-toggle {
    position: absolute !important;
    top: 50% !important;
    right: 14px !important;
    transform: translateY(-50%) !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    z-index: 5;
}

.password-toggle:hover,
.password-toggle:focus,
.password-toggle:active {
    top: 50% !important;
    right: 14px !important;
    transform: translateY(-50%) !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

.password-toggle i {
    font-size: 18px;
    color: #6b7280;
    line-height: 1;
    transition: color 0.2s ease;
}

.password-toggle:hover i,
.password-toggle:focus i,
.password-toggle:active i {
    color: #0F6B57;
}

/* ===== SIDEBAR MOBILE COM ARRASTE ===== */
.sidebar-drag-handle {
    display: none;
}

.drag-pill,
.drag-arrow {
    display: block;
}

@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1100;
        transition: left 0.28s ease;
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.12);
    }

    .sidebar.sidebar-open {
        left: 0;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar-drag-handle {
        display: flex;
        position: absolute;
        top: 50%;
        right: -32px; /* mais afastado da borda */
        transform: translateY(-50%);
        width: 32px;
        height: 96px;
        background: #0F6B57;
        border-top-right-radius: 14px;
        border-bottom-right-radius: 14px;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 6px;
        cursor: grab;
        box-shadow: 4px 0 14px rgba(0, 0, 0, 0.16);
        z-index: 1200;

        /* 🔥 ESSENCIAL PRA iPHONE */
        touch-action: none;
        user-select: none;
    }

    .drag-pill {
        width: 4px;
        height: 28px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.55);
    }

    .drag-arrow {
        color: #fff;
        font-size: 20px;
        font-weight: 700;
        line-height: 1;
        transition: transform 0.2s ease;
    }

    .sidebar.sidebar-open .drag-arrow {
        transform: rotate(180deg);
    }

    .menu-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* ===== OVERLAY DO MENU MOBILE ===== */
.sidebar-overlay {
    display: none;
}

.sidebar-drag-handle {
    display: none;
}

@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1100;
        transition: left 0.28s ease;
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.12);
    }

    .sidebar.sidebar-open {
        left: 0;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.25s ease, visibility 0.25s ease;
        z-index: 1090;
    }

    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar-drag-handle {
        display: flex;
        position: absolute;
        top: 50%;
        right: -26px;
        transform: translateY(-50%);
        width: 26px;
        height: 90px;
        background: #0F6B57;
        border-top-right-radius: 14px;
        border-bottom-right-radius: 14px;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 6px;
        cursor: pointer;
        box-shadow: 4px 0 14px rgba(0, 0, 0, 0.16);
        z-index: 1200;
    }

    .drag-pill {
        width: 4px;
        height: 28px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.55);
    }

    .drag-arrow {
        color: #fff;
        font-size: 20px;
        font-weight: 700;
        line-height: 1;
        transition: transform 0.2s ease;
    }

    .sidebar.sidebar-open .drag-arrow {
        transform: rotate(180deg);
    }

    .menu-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
}

.sidebar-edge-zone {
    display: none 
}

@media (max-width: 991px) {
    .sidebar-edge-zone {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 24px;
        height: 100vh;
        z-index: 1085;
        background: transparent;
        touch-action: none;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.25s ease, visibility 0.25s ease;
        z-index: 1090;
    }

    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1100;
        transition: left 0.28s ease;
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.12);
    }

    .sidebar.sidebar-open {
        left: 0;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar-drag-handle {
        display: flex;
        position: absolute;
        top: 50%;
        right: -26px;
        transform: translateY(-50%);
        width: 26px;
        height: 90px;
        background: #0F6B57;
        border-top-right-radius: 14px;
        border-bottom-right-radius: 14px;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 6px;
        cursor: grab;
        box-shadow: 4px 0 14px rgba(0, 0, 0, 0.16);
        z-index: 1200;
        touch-action: none;
        user-select: none;
    }

    .sidebar-drag-handle:active {
        cursor: grabbing;
    }

    .drag-pill {
        width: 4px;
        height: 28px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.55);
    }

    .drag-arrow {
        color: #fff;
        font-size: 20px;
        font-weight: 700;
        line-height: 1;
        transition: transform 0.2s ease;
        pointer-events: none;
    }

    .sidebar.sidebar-open .drag-arrow {
        transform: rotate(180deg);
    }

    .menu-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
}

.chat-whatsapp {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #f3f4f6;
    border-radius: 18px;
    padding: 18px;
    min-height: 320px;
    max-height: 520px;
    overflow-y: auto;
}

.chat-row {
    display: flex;
    width: 100%;
}

.chat-row.mine {
    justify-content: flex-end;
}

.chat-row.other {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 72%;
    padding: 12px 14px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    word-wrap: break-word;
}

.chat-bubble.mine {
    background: #dcfce7;
    border-bottom-right-radius: 4px;
}

.chat-bubble.other {
    background: #ffffff;
    border-bottom-left-radius: 4px;
}

.chat-author {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #0F6B57;
}

.chat-text {
    font-size: 14px;
    color: #111827;
    margin-bottom: 6px;
}

.chat-time {
    font-size: 11px;
    color: #6b7280;
    text-align: right;
}

.ticket-modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    z-index: 3000;
    padding: 20px;
}

.ticket-modal-overlay.show {
    display: flex;
}

.ticket-modal {
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 20px;
    padding: 28px;
    position: relative;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.ticket-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.ticket-modal-actions {
    display: grid;
    gap: 18px;
    margin-top: 20px;
}

.ticket-modal textarea,
.ticket-modal select {
    width: 100%;
    margin-top: 8px;
}

.ticket-modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    z-index: 3000;
    padding: 20px;
}

.ticket-modal-overlay.show {
    display: flex;
}

.ticket-modal {
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 20px;
    padding: 28px;
    position: relative;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.ticket-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.ticket-modal-close:hover {
    background: #e5e7eb;
}

.ticket-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 18px;
    margin: 16px 0 20px;
}

.ticket-modal-actions {
    display: grid;
    gap: 16px;
}

.ticket-action-card {
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 14px;
    padding: 14px;
}

.ticket-action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 8px;
}

.ticket-action-row select {
    flex: 1;
    min-width: 220px;
}

.ticket-modal textarea,
.ticket-modal select {
    width: 100%;
    margin-top: 8px;
}

.tickets-scroll-box {
    max-height: 360px;
    overflow: auto;
}

.tickets-scroll-box table {
    min-width: 980px;
}

@media (max-width: 768px) {
    .ticket-info-grid {
        grid-template-columns: 1fr;
    }

    .ticket-modal {
        padding: 22px;
    }

    .ticket-action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ticket-action-row select {
        min-width: 100%;
    }
}

/* ===== TABELAS ROLÁVEIS NO SISTEMA TODO ===== */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 520px;
    -webkit-overflow-scrolling: touch;
}

.table-wrapper .custom-table {
    min-width: 900px;
}

.tickets-scroll-box {
    max-height: 360px;
    overflow: auto;
}

.tickets-scroll-box table {
    min-width: 1100px;
}

/* ===== AÇÕES DOS TICKETS ===== */
.ticket-inline-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ticket-inline-actions form {
    margin: 0;
}

.ticket-inline-actions button {
    height: 34px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===== MODAL DE TICKET ===== */
.ticket-modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    z-index: 3000;
    padding: 20px;
}

.ticket-modal-overlay.show {
    display: flex;
}

.ticket-modal {
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 20px;
    padding: 28px;
    position: relative;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.ticket-modal-close {
    position: absolute !important;
    top: 14px !important;
    right: 16px !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 50% !important;
    background: #fee2e2 !important;
    color: #b91c1c !important;
    cursor: pointer;
    font-size: 24px !important;
    font-weight: 700;
    line-height: 36px !important;
    text-align: center !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
}

.ticket-modal-close:hover {
    background: #fecaca !important;
    color: #991b1b !important;
    transform: none !important;
}

.ticket-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 18px;
    margin: 16px 0 20px;
}

.ticket-modal-actions {
    display: grid;
    gap: 16px;
}

.ticket-action-card {
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 14px;
    padding: 14px;
}

.ticket-action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 8px;
}

.ticket-action-row select {
    flex: 1;
    min-width: 220px;
}

.ticket-modal textarea,
.ticket-modal select {
    width: 100%;
    margin-top: 8px;
}

/* ===== DASHBOARD SUPORTE ===== */
.dashboard-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.chart-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    min-height: 340px;
}

.chart-card canvas {
    width: 100% !important;
    height: 280px !important;
}

@media (max-width: 900px) {
    .dashboard-charts-grid {
        grid-template-columns: 1fr;
    }

    .ticket-info-grid {
        grid-template-columns: 1fr;
    }

    .ticket-modal {
        padding: 22px;
    }

    .ticket-action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ticket-action-row select {
        min-width: 100%;
    }
}

.ticket-inline-actions {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
}

.ticket-inline-actions form {
    margin: 0 !important;
    padding: 0 !important;
}

.ticket-inline-actions .btn-small,
.ticket-inline-actions button {
    width: 90px !important;
    min-width: 90px !important;
    max-width: 90px !important;
    height: 34px !important;
    padding: 0 !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    font-size: 13px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

.table-wrapper {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;

    overflow-x: auto !important;
    overflow-y: auto !important;

    max-height: 460px !important;

    -webkit-overflow-scrolling: touch;
}

.table-wrapper table,
.table-wrapper .custom-table {
    width: max-content !important;
    min-width: 1000px !important;
    border-collapse: collapse;
}

.table-wrapper th,
.table-wrapper td {
    white-space: nowrap !important;
}

.table-wrapper td {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-wrapper td:hover {
    white-space: normal !important;
    overflow: visible;
}

.ticket-inline-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ticket-inline-actions form {
    margin: 0;
}

.ticket-inline-actions button {
    min-width: 110px; /* 👈 largura padrão igual para os dois */
    height: 36px;

    padding: 0 18px; /* 👈 aumenta espaço lateral */

    display: inline-flex;
    align-items: center;
    justify-content: center;

    font-size: 13px;
    white-space: nowrap;
}

.ticket-inline-actions {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
}

.ticket-inline-actions form {
    margin: 0 !important;
    padding: 0 !important;
    display: inline-flex !important;
}

.ticket-inline-actions .ticket-action-btn {
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;

    height: 38px !important;
    min-height: 38px !important;

    padding: 0 18px !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}

/* =========================================================
   CORREÇÃO FINAL - ROLAGEM GLOBAL DAS TABELAS
   ========================================================= */

.table-wrapper {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;

    overflow-x: auto !important;
    overflow-y: auto !important;

    max-height: 340px !important; /* cerca de 5 linhas + cabeçalho */
    padding: 16px !important;

    -webkit-overflow-scrolling: touch;
}

.table-wrapper table,
.table-wrapper .custom-table {
    width: max-content !important;
    min-width: 1000px !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

.table-wrapper thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: #f3faf7 !important;
}

.table-wrapper th,
.table-wrapper td {
    white-space: nowrap !important;
}

/* Mantém textos longos controlados sem quebrar o scroll */
.table-wrapper td {
    max-width: 280px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.table-wrapper td:hover {
    white-space: normal !important;
    overflow: visible !important;
}

/* Remove comportamento próprio da tabela de tickets encerrados */
.tickets-scroll-box {
    max-height: 340px !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
}

.tickets-scroll-box table {
    width: max-content !important;
    min-width: 1100px !important;
}


/* =========================================================
   CORREÇÃO FINAL - BOTÕES ACEITAR / RECUSAR
   ========================================================= */

.ticket-inline-actions {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
}

.ticket-inline-actions form {
    margin: 0 !important;
    padding: 0 !important;
    display: inline-flex !important;
}

.ticket-inline-actions .ticket-action-btn {
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;

    height: 38px !important;
    min-height: 38px !important;

    padding: 0 18px !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}

/* ===== PAGE HEADER RESPONSIVO AJUSTADO (ESTILO PC NO MOBILE) ===== */
@media (max-width: 768px) {
    .page-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .page-header h2 {
        width: 100% !important;
        font-size: 22px !important;
    }

    .page-header .acoes {
        width: 100% !important;

        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;

        gap: 8px !important;
        flex-wrap: wrap !important;
    }

    .page-header .acoes .btn,
    .page-header .acoes button,
    .page-header .acoes a {
        width: auto !important;
        max-width: none !important;

        padding: 6px 14px !important;
        font-size: 13px !important;

        white-space: nowrap !important;
    }
}

/* 🔥 REMOVE o comportamento de botão full width */
@media (max-width: 420px) {
    .page-header .acoes {
        justify-content: flex-end !important;
    }

    .page-header .acoes .btn,
    .page-header .acoes button,
    .page-header .acoes a {
        flex: unset !important;
        width: auto !important;
    }
}

/* ===== CORREÇÃO GLOBAL DE BOTÕES NO MOBILE ===== */
@media (max-width: 768px) {

    /* Qualquer container de ações */
    .acoes,
    .header-actions,
    .top-actions {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        gap: 8px !important;
        flex-wrap: wrap !important;
    }

    /* Botões dentro desses containers */
    .acoes .btn,
    .header-actions .btn,
    .top-actions .btn,
    .acoes button,
    .header-actions button,
    .top-actions button,
    .acoes a,
    .header-actions a,
    .top-actions a {
        width: auto !important;
        max-width: none !important;

        padding: 6px 14px !important;
        font-size: 13px !important;

        white-space: nowrap !important;
    }

    /* 🔥 BOTÕES SOLTOS (tipo "Voltar" fora de header) */
    .btn,
    button,
    a.btn {
        width: auto !important;
        max-width: 100% !important;
    }

    /* 🔥 EVITA CENTRALIZAÇÃO AUTOMÁTICA */
    .btn.center,
    .text-center .btn {
        margin-left: auto !important;
        margin-right: 0 !important;
        display: inline-flex !important;
    }

}

/* ===== BOTÃO ALERTA SONORO - PADRÃO SISTEMA ===== */
.sidebar-alert-toggle {
    width: 100% !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    padding: 10px 14px !important;
    margin-top: 10px !important;

    font-size: 14px !important;
    font-weight: 500 !important;

    border-radius: 8px !important;

    background: #0F6B57 !important;
    color: #ffffff !important;
    border: none !important;

    cursor: pointer;
    transition: all 0.2s ease;
}

/* Hover bonito */
.sidebar-alert-toggle:hover {
    background: #0c5445 !important;
}

/* Estado ativo (opcional se você já usa JS) */
.sidebar-alert-toggle.ativo {
    background: #16a34a !important;
}

/* ===== ESTADO DO BOTÃO DE ALERTA ===== */
.sidebar-alert-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;

    padding: 10px 14px;
    margin-top: 10px;

    font-size: 14px;
    font-weight: 500;

    border-radius: 8px;
    border: none;

    cursor: pointer;
    transition: all 0.2s ease;
}

/* 🔴 DESATIVADO */
.sidebar-alert-toggle.off {
    background: #dc2626;
    color: #fff;
}

/* 🟢 ATIVADO */
.sidebar-alert-toggle.on {
    background: #16a34a;
    color: #fff;
}

.sidebar-alert-toggle.off {
    background: #dc2626 !important;
    color: #ffffff !important;
}

.sidebar-alert-toggle.on {
    background: #16a34a !important;
    color: #ffffff !important;
}

/* =========================
   🌙 DARK MODE
========================= */

body.dark-mode {
    background: #0f172a;
    color: #e2e8f0;
}

/* Cards */
body.dark-mode .card,
body.dark-mode .form-card,
body.dark-mode .chart-card,
body.dark-mode .table-wrapper {
    background: #1e293b !important;
    color: #e2e8f0;
}

/* Sidebar */
body.dark-mode .sidebar {
    background: #020617 !important;
}

/* Header */
body.dark-mode .page-header h2 {
    color: #f1f5f9;
}

/* Tabelas */
body.dark-mode table {
    color: #e2e8f0;
}

body.dark-mode thead {
    background: #0f172a !important;
}

body.dark-mode tbody tr {
    border-bottom: 1px solid #334155;
}

/* Inputs */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #334155;
}

/* Modais */
body.dark-mode .ticket-modal {
    background: #1e293b;
    color: #e2e8f0;
}

/* Botões */
body.dark-mode .btn {
    background: #0f766e;
    color: #fff;
}

body.dark-mode .btn-danger {
    background: #dc2626;
}

/* Scroll */
body.dark-mode ::-webkit-scrollbar-thumb {
    background: #334155;
}

html,
body {
    overscroll-behavior-x: none;
}

.app-layout,
.main-content,
.page-content {
    overscroll-behavior-x: contain;
}

/* BLOQUEIA GESTO HORIZONTAL DO SAFARI/PWA */
html,
body {
    overscroll-behavior-x: none !important;
    touch-action: pan-y !important;
}

/* Área invisível para capturar arraste da esquerda */
.sidebar-edge-zone {
    display: none;
} 

@media (max-width: 991px) {
    .sidebar-edge-zone {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 42px !important;
        height: 100vh !important;
        z-index: 99999 !important;
        background: transparent !important;
        touch-action: none !important;
    }
}

/* 🔥 DESATIVA COMPLETAMENTE A EDGE ZONE (iPhone fix) */
.sidebar-edge-zone {
    display: none !important;
    pointer-events: none !important;
}

/* iPhone/iPad: remove setinha e arraste lateral para evitar voltar página */
body.ios-device .sidebar-drag-handle,
body.ios-device .sidebar-edge-zone {
    display: none !important;
    pointer-events: none !important;
}

.primeiro-acesso-card {
    width: 100%;
    max-width: 460px;
    margin: 40px auto;
    background: #ffffff;
    padding: 28px;
    border-radius: 18px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.08);
}

.primeiro-acesso-card h2 {
    margin-bottom: 8px;
}

.primeiro-acesso-card p {
    margin-bottom: 20px;
    color: #555;
}

.password-rules {
    list-style: none;
    padding: 0;
    margin: 12px 0 20px;
}

.password-rules li {
    margin-bottom: 8px;
    font-size: 14px;
}

.password-rules li.fail {
    color: #d93025;
}

.password-rules li.ok {
    color: #188038;
    font-weight: 600;
}

.btn-primary-full {
    width: 100%;
    border: none;
    padding: 14px;
    border-radius: 12px;
    background: #0F6B57;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

@media (max-width: 600px) {
    .primeiro-acesso-card {
        margin: 20px 12px;
        padding: 22px;
        max-width: none;
    }
}