@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    
    --font-primary: 'Inter', sans-serif;
    
    --bg-app: #f3f4f6;
    --bg-card: #ffffff;
    --text-primary: #111827;
    --text-muted: #6b7280;
    --accent: #3b82f6;
    --accent-light: #e0f2fe;
    --accent-glow: rgba(59, 130, 246, 0.15);
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.18);
    
    /* Semantic Statuses */
    --success-bg: hsl(142, 70%, 95%);
    --success-color: hsl(142, 76%, 24%);
    --warning-bg: hsl(35, 90%, 94%);
    --warning-color: hsl(35, 90%, 30%);
    --danger-bg: hsl(350, 80%, 95%);
    --danger-color: hsl(350, 80%, 38%);
    
    /* Sidebar styling */
    --sidebar-bg: #e2f0fc;
    --sidebar-link-hover: #cbe3f7;
    --sidebar-link-active: #3b82f6;
    --sidebar-border: #e5e7eb;
    --sidebar-text: #000000;

    
    /* Borders & Shadows */
    --border-color: hsl(215, 15%, 90%);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.1);
    
    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html,
body {
    min-height: 100%;
    height: 100%;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: hsl(215, 15%, 80%);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
    background: hsl(215, 15%, 70%);
}

.layout {
    display: flex;
    flex-wrap: nowrap;
    min-height: 100vh;
    width: 100%;
    align-items: stretch;
}

/* =========================================
SIDEBAR
========================================= */

.sidebar {
    min-width: 260px;
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start !important;
    position: relative;
    border-right: 1px solid var(--sidebar-border);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo {
    padding: 8px;
    margin-bottom: 24px;
}

.logo h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo h1 span {
    color: var(--sidebar-link-active);
}

.logo .versao {
    display: block;
    color: rgba(0, 0, 0, 0.5);
    font-size: 11px;
    margin-top: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-lateral,
.sidebar > nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.menu-grupo {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.menu-grupo strong,
.menu-grupo .menu-separator {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(0, 0, 0, 0.4);
    margin: 12px 14px 6px;
}

.menu-toggle,
.menu-link-direto,
.menu-inativo,
.menu-lateral a,
.sidebar > nav a {
    display: flex;
    align-items: center;
    width: 100%;
    color: rgba(0, 0, 0, 0.85);
    text-decoration: none;
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    border: none;
    transition: var(--transition);
    margin-bottom: 2px;
    text-align: left;
    cursor: pointer;
}

.menu-toggle {
    justify-content: space-between;
}

.menu-toggle::after {
    content: '▾';
    font-size: 11px;
    opacity: 0.6;
    transition: transform 0.2s;
}

.submenu-open + .menu-toggle::after,
.submenu.submenu-open::before {
    transform: rotate(180deg);
}

.menu-toggle:hover,
.menu-link-direto:hover,
.menu-inativo:hover,
.menu-lateral a:hover,
.sidebar > nav a:hover {
    background: var(--sidebar-link-hover);
    color: var(--sidebar-text);
}

.menu-lateral a.active,
.sidebar > nav a.active,
.menu-inativo.active,
.menu-toggle.active {
    background: var(--sidebar-link-active);
    color: var(--sidebar-text);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.menu-inativo {
    opacity: 0.6;
    cursor: not-allowed;
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding-left: 12px;
    gap: 2px;
}

.submenu-open {
    max-height: 500px;
    margin-top: 4px;
    margin-bottom: 8px;
}

.submenu a {
    padding: 9px 12px;
    font-size: 13px;
    color: rgba(0, 0, 0, 0.7);
    border-radius: var(--radius-sm);
}

.submenu a:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-link-hover);
}

.submenu a.active {
    background: rgba(0, 0, 0, 0.05);
    color: var(--sidebar-text);
    font-weight: 600;
    box-shadow: none;
}

/* Sub-submenu (terceiro nível — ex: Microvix > Relatórios > item) */
.menu-subgrupo {
    display: flex;
    flex-direction: column;
    margin-top: 2px;
}

.menu-subtoggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    color: rgba(0, 0, 0, 0.7);
    text-decoration: none;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.menu-subtoggle::after {
    content: '▾';
    font-size: 10px;
    opacity: 0.5;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.menu-subtoggle:hover {
    background: var(--sidebar-link-hover);
    color: var(--sidebar-text);
}

.subsubmenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding-left: 10px;
    gap: 2px;
}

.subsubmenu-open {
    max-height: 300px;
    margin-top: 2px;
    margin-bottom: 4px;
}

.subsubmenu a {
    padding: 7px 10px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-sm);
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    margin-left: 4px;
}

.subsubmenu a:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-link-hover);
    border-left-color: var(--sidebar-link-active);
}

.subsubmenu a.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--sidebar-text);
    font-weight: 600;
    border-left-color: var(--sidebar-link-active);
    box-shadow: none;
}


.sidebar-footer {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    line-height: 1.6;
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-footer strong {
    color: var(--sidebar-text);
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
}

.sidebar-collapse-btn {
    position: absolute;
    top: 18px;
    right: 12px;
    z-index: 100;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.15);
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.sidebar-collapse-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(0, 0, 0, 0.5);
    color: var(--sidebar-text);
}

/* Sidebar Collapsed State (Desktop) */
body.sidebar-collapsed .sidebar {
    min-width: 72px;
    width: 72px;
    padding: 24px 8px;
}

body.sidebar-collapsed .sidebar .logo,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .submenu {
    display: none !important;
}

body.sidebar-collapsed .menu-grupo {
    align-items: center;
}

body.sidebar-collapsed .menu-toggle,
body.sidebar-collapsed .menu-link-direto,
body.sidebar-collapsed .menu-lateral a,
body.sidebar-collapsed .sidebar > nav a {
    justify-content: center;
    padding: 12px 0;
    font-size: 0;
}

body.sidebar-collapsed .menu-toggle::after {
    display: none;
}

body.sidebar-collapsed .menu-toggle::before,
body.sidebar-collapsed .menu-link-direto::before,
body.sidebar-collapsed .menu-lateral a::before {
    font-size: 16px;
}

/* =========================================
CONTENT & TOPBAR
========================================= */

.content {
    flex: 1 1 auto;
    min-width: 0;
    padding: 28px;
}

.content-fixed {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100vh;
}

.form-editar {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    gap: 16px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.topbar-left {
    display: flex;
    flex-direction: column;
}

.topbar h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.topbar p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.xml-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.form-importar,
.form-buscar-xml {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.top-user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.campo-user {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.campo-user label {
    font-weight: 600;
    color: var(--text-muted);
}

.campo-user span {
    color: var(--text-primary);
    font-weight: 700;
}

.btn-logout {
    background: var(--danger-bg);
    color: var(--danger-color) !important;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    transition: var(--transition);
}

.btn-logout:hover {
    background: var(--danger-color);
    color: white !important;
    transform: translateY(-1px);
}

/* =========================================
CARDS & BLOCKS
========================================= */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Ajuste inteligente para todos os cards de métricas/resumo do sistema */
.card:has(span):has(strong) {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 105px !important;
    box-sizing: border-box !important;
    padding: 14px 18px !important;
}

.card:has(span):has(strong) span {
    display: block !important;
    margin-bottom: 6px !important;
    text-align: left !important; /* Alinhamento elegante à esquerda */
}

.card:has(span):has(strong) strong {
    display: block !important;
    font-size: 21px !important; /* Ligeiramente reduzido para acomodar valores monetários longos */
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    line-height: 1.2 !important;
    text-align: left !important; /* Alinhamento elegante à esquerda */
    margin-top: auto !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Card variants */
.card.info { border-left-color: var(--primary); }
.card.success { border-left-color: var(--success-color); }
.card.warning { border-left-color: var(--warning-color); }

.info-xml {
    border-left-color: var(--accent);
}

.info-xml strong {
    color: var(--accent);
}

.info-xml small {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
    text-align: center;
}

.info-xml-content {
    text-align: center;
}

.mini-cards {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.badge-card {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 42px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    font-size: 13px;
    white-space: nowrap;
}

.badge-card.info { border-left: 4px solid var(--primary); }
.badge-card.success { border-left: 4px solid var(--success-color); }
.badge-card.warning { border-left: 4px solid var(--warning-color); }
.badge-card.info-xml { border-left: 4px solid var(--accent); }

.badge-card span {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
}

.badge-card strong {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
}

.badge-card small {
    color: var(--text-muted);
    font-size: 11px;
    margin-left: 4px;
}

/* =========================================
FORM CONTROLS & UTILITIES
========================================= */

input,
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-family: var(--font-primary);
    font-size: 13px;
    color: var(--text-primary);
    background-color: var(--bg-card);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Buttons */
.btn-topo,
.btn-buscar-xml,
.btn-import,
.btn-sim,
.btn-nao,
button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--sidebar-text);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    box-shadow: 0 4px 10px var(--primary-glow);
}

.btn-topo:hover,
.btn-buscar-xml:hover,
.btn-import:hover,
button[type="submit"]:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px var(--primary-glow);
}

.btn-topo:active,
.btn-buscar-xml:active,
.btn-import:active,
button[type="submit"]:active {
    transform: translateY(0);
}

.btn-nao {
    background: hsl(215, 15%, 90%);
    color: var(--text-primary);
    box-shadow: none;
}
.btn-nao:hover {
    background: hsl(215, 15%, 80%);
    color: var(--text-primary);
    box-shadow: none;
    transform: none;
}

/* Custom Checkboxes */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* =========================================
TABLES
========================================= */

.table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: auto;
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    table-layout: auto;
}

table input[type="number"],
table select {
    min-width: 80px;
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: hsl(220, 20%, 97%);
    color: var(--text-primary);
    font-weight: 600;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    white-space: nowrap;
}

thead th:first-child {
    border-top-left-radius: var(--radius-md);
}

thead th:last-child {
    border-top-right-radius: var(--radius-md);
}

th {
    user-select: none;
}

td {
    padding: 8px 12px;
    border-bottom: 1px solid hsl(220, 15%, 94%);
    color: var(--text-primary);
    text-align: center;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: hsl(220, 30%, 98%);
}

.descricao {
    text-align: left;
    min-width: 250px;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Badges inside tables */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.novo-badge {
    background: var(--success-bg);
    color: var(--success-color);
}

.existente-badge {
    background: hsl(215, 15%, 90%);
    color: var(--text-muted);
}

.erro-badge {
    background: var(--danger-bg);
    color: var(--danger-color);
}

.existente {
    opacity: 0.75;
}

tr.existente td {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
}

tr.existente:hover td {
    background-color: #e2e8f0 !important;
}

.erro-importacao {
    background: var(--danger-bg) !important;
}

.erro-importacao td {
    color: var(--danger-color);
}

.erro-msg {
    margin-top: 4px;
    font-size: 11px;
    color: var(--danger-color);
    font-weight: 600;
}

/* =========================================
MODALS & OVERLAYS
========================================= */

.modal-cnpj,
.modal-fornecedor,
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-box {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    text-align: center;
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-box h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.modal-box p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 24px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* =========================================
   MODAL DE ATUALIZAÇÃO DE VERSÃO
   ========================================= */

.update-modal-body {
    background: #ffffff;
    padding: 40px 36px 32px;
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    border: 1px solid #e8ecf0;
    text-align: center;
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.update-modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #eef0fd;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.update-modal-title {
    font-size: 22px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 10px;
    letter-spacing: -0.4px;
}

.update-modal-text {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.65;
    margin-bottom: 24px;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
}

.update-modal-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 28px;
}

.update-meta-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    color: #6b7280;
    text-align: left;
    font-weight: 500;
}

.update-meta-item strong {
    color: #111827;
    font-weight: 700;
}

.update-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-update {
    height: 46px;
    padding: 0 28px;
    border: none;
    border-radius: 10px;
    font-family: var(--font-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
}

.btn-update-primary {
    background: #3d4cf5;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(61, 76, 245, 0.35);
}

.btn-update-primary:hover {
    background: #2d3be0;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(61, 76, 245, 0.45);
}

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

.btn-update-secondary {
    background: #f3f4f6;
    color: #374151;
    box-shadow: none;
}

.btn-update-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

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


/* =========================================
   DASHBOARD MENU (ABAS DE NAVEGAÇÃO)
   ========================================= */

.dashboard-menu {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.dashboard-menu-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    transition: var(--transition);
}

.dashboard-menu-item:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.dashboard-menu-item.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--sidebar-text);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* =========================================
   PAGE FILTERS (BARRA DE FILTROS PADRÃO)
   ========================================= */

.page-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    background: var(--bg-card);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.page-filters .filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1 1 170px;
    min-width: 140px;
}

.page-filters .filter-group label,
.filter-group > label:first-of-type {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
}

.page-filters .filter-group input,
.page-filters .filter-group select {
    width: 100%;
}

.date-separator {
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    align-self: flex-end;
    padding-bottom: 10px;
    white-space: nowrap;
}

/* =========================================
   CARD TITLE (TÍTULOS DE CARDS DE GRÁFICOS)
   ========================================= */

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--accent);
    font-family: var(--font-primary);
    text-align: center;
    margin: 0 0 12px;
    letter-spacing: -0.3px;
}

/* =========================================
   CHART CARD (CARD DE GRÁFICO GENÉRICO)
   ========================================= */

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.chart-card:hover {
    box-shadow: var(--shadow-lg);
}

.chart-card h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.chart-card p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 18px;
    line-height: 1.5;
}

.referencia-label {
    display: block;
    margin-top: 4px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* =========================================
RESPONSIVENESS (MOBILE & TABLET)
========================================= */

@media (max-width: 1280px) {
    /* Tablet largo: sidebar já colapsada mas conteúdo ainda amplo */
    .sidebar {
        min-width: 72px;
        width: 72px;
        padding: 24px 8px;
    }

    .sidebar .logo,
    .sidebar-footer,
    .sidebar .submenu {
        display: none !important;
    }

    .sidebar .menu-grupo {
        align-items: center;
    }

    .sidebar .menu-toggle,
    .sidebar .menu-link-direto,
    .sidebar a {
        justify-content: center;
        padding: 12px 0;
        font-size: 0;
    }

    .sidebar .menu-toggle::after {
        display: none;
    }
}

@media (max-width: 1024px) {
    /* Collapse sidebar automatically on smaller screens */
    .sidebar {
        min-width: 72px;
        width: 72px;
        padding: 24px 8px;
    }
    
    .sidebar .logo,
    .sidebar-footer,
    .sidebar .submenu {
        display: none !important;
    }
    
    .sidebar .menu-grupo {
        align-items: center;
    }
    
    .sidebar .menu-toggle,
    .sidebar .menu-link-direto,
    .sidebar a {
        justify-content: center;
        padding: 12px 0;
        font-size: 0;
    }
    
    .sidebar .menu-toggle::after {
        display: none;
    }
}

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
        padding-top: 60px; /* Spacer for fixed mobile topbar */
    }

    /* Fixed topbar for mobile */
    body::after {
        content: 'Easy Linx';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: hsl(217, 85%, 9%);
        color: var(--sidebar-text);
        font-family: var(--font-primary);
        font-weight: 700;
        font-size: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 998;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: var(--shadow-sm);
    }

    /* Off-canvas sidebar */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh !important;
        width: 280px !important;
        min-width: 280px !important;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 24px 16px !important;
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }

    /* Show elements again in off-canvas mode */
    .sidebar .logo,
    .sidebar-footer {
        display: block !important;
    }
    
    .sidebar .submenu.submenu-open {
        display: flex !important;
    }

    .sidebar .menu-grupo {
        align-items: stretch !important;
    }

    .sidebar .menu-toggle,
    .sidebar .menu-link-direto,
    .sidebar a {
        justify-content: flex-start !important;
        padding: 11px 14px !important;
        font-size: 14px !important;
    }

    .sidebar .menu-toggle::after {
        display: block !important;
    }

    /* Mobile Backdrop Overlay */
    body.sidebar-collapsed::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        backdrop-filter: blur(3px);
        z-index: 999;
        animation: fadeIn 0.2s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    /* Slide Sidebar in when toggled */
    body.sidebar-collapsed .sidebar {
        transform: translateX(0);
        min-width: 280px !important;
        width: 280px !important;
    }

    /* Hamburger Button position */
    .sidebar-collapse-btn {
        position: fixed !important;
        top: 13px;
        left: 15px;
        right: auto !important;
        z-index: 1001 !important;
        background: hsl(217, 85%, 9%) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        color: white !important;
        width: 34px;
        height: 34px;
        border-radius: 6px;
    }

    .content {
        padding: 16px !important;
        gap: 16px;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding-bottom: 14px;
    }

    .topbar-left {
        text-align: center;
    }

    .top-user-info {
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px;
    }

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

    /* Forms */
    .xml-actions,
    .form-importar,
    .form-buscar-xml {
        flex-direction: column;
        align-items: stretch !important;
        width: 100%;
        gap: 10px;
    }

    .input-chave,
    .select-certificado {
        width: 100% !important;
    }

    .mini-cards {
        width: 100%;
        justify-content: center;
    }
}

/* =========================================
   LOGIN PAGE
   ========================================= */

.content.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 60px 32px 40px;
    gap: 30px;
    width: 100%;
}

.login-page .topbar {
    width: 100%;
    justify-content: center;
    text-align: center;
    max-width: 560px;
    border-bottom: none;
}

.login-page .topbar div {
    width: 100%;
    max-width: 520px;
}

.login-page .topbar h2 {
    margin-bottom: 12px;
    font-size: 36px;
    letter-spacing: -0.02em;
}

.login-page .topbar p {
    margin: 0 auto;
    color: var(--text-muted);
    max-width: 520px;
    font-size: 15px;
    line-height: 1.7;
}

.login-card {
    width: 100%;
    max-width: 500px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 36px 34px;
    position: relative;
    overflow: hidden;
    border-left: none;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.login-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.login-field select {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 1rem;
    background: hsl(220, 20%, 97%);
    color: var(--text-primary);
}

.login-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.login-card .btn-primary {
    width: 100%;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--primary);
    color: var(--sidebar-text);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.login-card .btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 14px 30px var(--primary-glow);
}

/* Hide sidebar completely on mobile login screen */
body:has(.login-page)::after {
    content: none !important; /* Hide 'Easy Linx' text header on login mobile screen */
}
body:has(.login-page) .sidebar {
    display: none !important;
}
body:has(.login-page) .layout {
    padding-top: 0 !important;
}

