:root {
    --bg: #f6f4ef;
    --surface: #ffffff;
    --surface-soft: #f1eee8;
    --text: #2f2f2f;
    --muted: #77736d;
    --primary: #4f6f64;
    --primary-dark: #3f5c53;
    --primary-soft: #e7efea;
    --escom-blue: #0737a8;
    --escom-red: #d7192d;
    --border: #e8e1d7;
    --danger: #a95f5f;
    --danger-soft: #f3e4e4;
    --warning: #b58a43;
    --warning-soft: #f7efd8;
    --success: #5f806f;
    --success-soft: #e6f1e9;
    --radius: 18px;
    --shadow: 0 12px 36px rgba(44, 50, 47, 0.07);
}

html {
    font-size: 15px;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

/* =========================================================
   BARRA SUPERIOR
========================================================= */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 18px rgba(47, 47, 47, 0.04);
}

.brand-link {
    display: flex;
    align-items: center;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}

    .brand-link:hover {
        color: var(--text);
        text-decoration: none;
    }

.logo-escom {
    display: block;
    width: 175px;
    height: 64px;
    max-width: 100%;
    object-fit: contain;
    object-position: left center;
}

/* Mantidas para telas antigas que ainda utilizem essas classes */

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.1;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--muted);
}

/* =========================================================
   MENU PRINCIPAL
========================================================= */

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.main-nav-link {
    color: var(--muted);
    text-decoration: none;
    padding: 9px 11px;
    border-radius: 10px;
    white-space: nowrap;
    transition: color 0.2s ease, background-color 0.2s ease;
}

    .main-nav-link:hover {
        color: var(--escom-blue);
        background: rgba(7, 55, 168, 0.08);
    }

/* =========================================================
   CONTEÚDO E RODAPÉ
========================================================= */

.page-shell {
    min-height: calc(100vh - 140px);
}

.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    padding: 16px 0;
}

/* =========================================================
   TÍTULOS
========================================================= */

h1,
h2,
h3,
h4,
h5 {
    letter-spacing: -0.02em;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

    .page-heading h1 {
        font-size: 28px;
    }

.page-title {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--muted);
    margin-bottom: 0;
}

.text-muted {
    color: var(--muted) !important;
}

/* =========================================================
   CARDS
========================================================= */

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(47, 47, 47, 0.04);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 18px 20px;
}

.card-body {
    padding: 20px;
}

.surface-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.surface-card-header {
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

.surface-card-body {
    padding: 22px;
}

/* =========================================================
   BOTÕES
========================================================= */

.btn {
    border-radius: 12px;
    padding: 9px 15px;
    font-weight: 600;
}

.btn-primary-custom {
    background: var(--escom-blue);
    border: 1px solid var(--escom-blue);
    color: white;
}

    .btn-primary-custom:hover {
        background: #052a82;
        border-color: #052a82;
        color: white;
    }

.btn-soft {
    background: rgba(7, 55, 168, 0.08);
    border: 1px solid transparent;
    color: var(--escom-blue);
}

    .btn-soft:hover {
        background: rgba(7, 55, 168, 0.14);
        color: var(--escom-blue);
    }

.btn-primary {
    background: var(--escom-blue);
    border-color: var(--escom-blue);
}

    .btn-primary:hover,
    .btn-primary:focus {
        background: #052a82;
        border-color: #052a82;
    }

.btn-outline-primary {
    color: var(--escom-blue);
    border-color: var(--escom-blue);
}

    .btn-outline-primary:hover {
        background: var(--escom-blue);
        border-color: var(--escom-blue);
        color: white;
    }

.btn-outline-danger {
    color: var(--escom-red);
    border-color: var(--escom-red);
}

    .btn-outline-danger:hover {
        background: var(--escom-red);
        border-color: var(--escom-red);
        color: white;
    }

/* =========================================================
   FORMULÁRIOS
========================================================= */

.form-label {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.form-control,
.form-select {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: white;
}

    .form-control:focus,
    .form-select:focus {
        border-color: var(--escom-blue);
        box-shadow: 0 0 0 0.2rem rgba(7, 55, 168, 0.12);
    }

.client-status-box {
    padding: 18px 18px 18px 52px;
    background: var(--primary-soft);
    border-radius: 14px;
}

    .client-status-box .form-check-input {
        margin-left: -34px;
    }

hr {
    border-color: var(--border);
    opacity: 1;
}

/* =========================================================
   TABELAS
========================================================= */

.table {
    color: var(--text);
}

    .table thead th {
        color: var(--muted);
        font-size: 13px;
        font-weight: 600;
        border-bottom: 1px solid var(--border);
    }

    .table tbody td {
        border-color: var(--border);
    }

.table-hover tbody tr:hover {
    background: #faf9f6;
}

.app-table {
    margin-bottom: 0;
}

    .app-table thead th {
        background: var(--surface-soft);
        color: var(--muted);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        border-bottom: 1px solid var(--border);
        padding: 14px 16px;
    }

    .app-table tbody td {
        padding: 16px;
        border-color: var(--border);
        vertical-align: middle;
    }

    .app-table tbody tr:hover {
        background: #fbfaf7;
    }

.table-danger {
    --bs-table-bg: var(--danger-soft);
}

.table-warning {
    --bs-table-bg: var(--warning-soft);
}

.table-success {
    --bs-table-bg: var(--success-soft);
}

/* =========================================================
   BADGES E STATUS
========================================================= */

.badge {
    border-radius: 999px;
    padding: 7px 10px;
    font-weight: 600;
}

.bg-success {
    background: var(--success) !important;
}

.bg-warning {
    background: #e8c875 !important;
}

.bg-danger {
    background: #b56b6b !important;
}

.bg-info {
    background: #8fb3b0 !important;
}

.bg-primary {
    background: var(--escom-blue) !important;
}

.bg-secondary {
    background: #8a8782 !important;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 11px;
    font-size: 12px;
    font-weight: 700;
}

.status-success {
    background: #e4efe8;
    color: #486956;
}

.status-warning {
    background: #f5ead3;
    color: #8c682b;
}

.status-danger {
    background: #f2dfdf;
    color: #8a4d4d;
}

.status-info {
    background: #e2ecec;
    color: #4f7270;
}

.status-neutral {
    background: #ebe9e5;
    color: #66635e;
}

/* =========================================================
   DASHBOARD
========================================================= */

.metric-card {
    padding: 22px;
    min-height: 138px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

    .metric-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 16px 42px rgba(44, 50, 47, 0.1);
    }

.metric-label {
    color: var(--muted);
    font-size: 14px;
}

.metric-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
    margin-top: 12px;
}

.metric-accent {
    width: 38px;
    height: 5px;
    border-radius: 999px;
    background: var(--escom-blue);
    margin-top: 18px;
}

/* =========================================================
   PESQUISA E ESTADO VAZIO
========================================================= */

.search-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 8px 24px rgba(44, 50, 47, 0.04);
}

.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 42px 24px;
    text-align: center;
    color: var(--muted);
}

/* =========================================================
   NOTIFICAÇÕES
========================================================= */

.app-toast {
    position: fixed;
    top: 92px;
    right: 24px;
    z-index: 2000;
    min-width: 300px;
    max-width: 420px;
    padding: 16px 18px;
    border-radius: 14px;
    color: white;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
}

.app-toast-success {
    background: var(--success);
}

.app-toast-danger {
    background: var(--danger);
}

.fade-in {
    animation: fadeIn 0.24s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================
   RESPONSIVIDADE
========================================================= */

@media (max-width: 1200px) {
    .logo-escom {
        width: 145px;
        height: 56px;
    }

    .main-nav-link {
        padding: 8px 8px;
        font-size: 14px;
    }
}

@media (max-width: 1000px) {
    .main-nav {
        display: none;
    }

    .topbar .btn-soft {
        display: none;
    }

    .brand-subtitle {
        display: none;
    }
}

@media (max-width: 700px) {
    .topbar {
        padding: 8px 0;
    }

        .topbar .container-fluid {
            padding-left: 14px !important;
            padding-right: 14px !important;
        }

    .logo-escom {
        width: 115px;
        height: 48px;
    }

    .page-heading {
        flex-direction: column;
    }

    .topbar .btn-primary-custom {
        display: none;
    }

    .topbar .btn-outline-danger {
        padding: 7px 11px;
    }

    .footer .d-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 5px;
    }

    .app-toast {
        top: 78px;
        left: 14px;
        right: 14px;
        min-width: 0;
        max-width: none;
    }
}
