/* ====================================================================
   PAINEL FINANCEIRO - SQUARE UI (DARK THEME)
   Reference: Square Administration Dark Mode
==================================================================== */

/* ====================================================================
   1. VARIÁVEIS CSS
==================================================================== */
:root {
    /* --- PALETA DE CORES (DARK MODE) --- */
    --bg-body: #121212;
    --bg-sidebar: #1a1a1a;
    --bg-card: #1e1e1e;
    --bg-input: #2b2b2b;
    
    /* --- CORES DE TEXTO --- */
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --text-disabled: #555555;
    
    /* --- CORES DE DESTAQUE (BRANDING) --- */
    --primary: #006aff;
    --primary-hover: #0056cc;
    --primary-light: rgba(0, 106, 255, 0.15);
    
    /* --- STATUS --- */
    --success: #00c853;
    --success-bg: rgba(0, 200, 83, 0.15);
    --warning: #ffab00;
    --warning-bg: rgba(255, 171, 0, 0.15);
    --danger: #ff3d00;
    --danger-bg: rgba(255, 61, 0, 0.15);
    
    /* --- BORDAS & SEPARADORES --- */
    --border: #333333;
    --border-light: #444444;
    
    /* --- DIMENSÕES --- */
    --sidebar-width: 250px;
    --header-height: 70px;
    --radius: 12px;
}

/* ====================================================================
   2. RESET & BASE
==================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

body,
html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
    height: 100%;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.2s;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* ====================================================================
   3. ESTRUTURA DE LAYOUT
==================================================================== */

/* --- Wrapper Principal --- */
.wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header img {
    max-height: 35px;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 15px;
    overflow-y: auto;
}

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

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: var(--text-muted);
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
}

.sidebar-menu a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.sidebar-menu li.active a {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 106, 255, 0.3);
}

.menu-header {
    padding: 10px 15px 5px 15px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-info {
    padding: 20px;
    border-top: 1px solid var(--border);
    background-color: rgba(0, 0, 0, 0.2);
}

.user-info span {
    display: block;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
}

.user-info a {
    color: var(--danger);
    font-size: 0.85rem;
}

/* --- Conteúdo Principal --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 30px;
    transition: margin-left 0.3s ease;
}

/* --- Header Superior --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    margin-top:0;
    height: 40px;
}

.main-header h1 {
    font-size: 1.8rem;
    color: var(--text-main);
    font-weight: 700;
}

.header-icons {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Sino de Notificação */
.notification-bell {
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    padding: 5px;
}

.notification-bell:hover {
    color: var(--text-main);
}

.notification-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background-color: var(--danger);
    border: 2px solid var(--bg-body);
    border-radius: 50%;
}

/* ====================================================================
   4. COMPONENTES - CARDS
==================================================================== */
.card-form,
.card-list,
.dash-item,
.card-summary {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.card-form h2,
.card-list h2,
.card-summary h2 {
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 20px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
    margin-left: -24px;
    margin-right: -24px;
    padding-left: 24px;
}

/* ====================================================================
   5. COMPONENTES - BOTÕES
==================================================================== */
.btn-submit,
.btn-login,
button[type="submit"] {
    background-color: var(--primary);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-submit:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(0, 106, 255, 0.4);
}

.btn-edit {
    color: var(--primary);
    font-weight: 600;
    margin-right: 12px;
    font-size: 0.9rem;
}

.btn-delete {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-delete:hover {
    background: var(--danger);
    color: #fff;
}

.btn-manage-cats {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.btn-manage-cats:hover {
    border-color: var(--text-main);
    color: var(--text-main);
}

/* Botões de Ação (Cards) */
.btn-action-main {
    flex: 1;
    background: rgba(88, 101, 242, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

.btn-action-main:hover {
    background: var(--primary);
    color: #fff;
}

.btn-preview {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid #10b981;
    color: #10b981;
}

.btn-preview:hover {
    background: #10b981;
    color: #fff;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: 0.2s;
    text-decoration: none;
}

.btn-icon:hover {
    background: var(--bg-input);
    color: var(--text-main);
    border-color: var(--text-muted);
}

.btn-icon.delete:hover {
    background: rgba(255, 61, 0, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

/* Botões de Preview (Modal) */
.device-btn {
    background: transparent;
    border: none;
    color: #666;
    font-size: 1.5rem;
    cursor: pointer;
    transition: 0.2s;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.device-btn:hover,
.device-btn.active {
    color: #fff;
    background: #333;
}

.preview-close {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    background: #333;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-close:hover {
    background: var(--danger);
}

/* ====================================================================
   6. COMPONENTES - FORMULÁRIOS
==================================================================== */
.form-group {
    margin-bottom: 20px;
    width: 100%;
}

.form-row {
    display: flex;
    gap: 20px;
    width: 100%;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    transition: 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

input::placeholder {
    color: #555;
}

/* ====================================================================
   7. COMPONENTES - BADGES & TAGS
==================================================================== */
.badge {
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

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

.badge-pendente,
.badge.pendente {
    background: var(--warning-bg);
    color: var(--warning);
}

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

.badge-cancelado,
.badge.cancelado {
    background: #333;
    color: #777;
}

.badge.recorrente {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.badge.unica {
    background: rgba(255, 255, 255, 0.1);
    color: #aaa;
}

.tag-span {
    font-size: 0.7rem;
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.card-type-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-type-badge.json {
    color: #d8b4fe;
    border-color: #a855f7;
}

.card-type-badge.css {
    color: #93c5fd;
    border-color: #3b82f6;
}

/* ====================================================================
   8. COMPONENTES - TABELAS
==================================================================== */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 15px;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: middle;
}

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

tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* ====================================================================
   9. LAYOUTS ESPECIAIS
==================================================================== */

/* Dashboard Grid */
.dashboard-financeiro,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dash-item,
.stat-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dash-item span,
.stat-card h3 {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 10px;
    font-weight: 500;
}

.dash-item strong,
.stat-card .value {
    font-size: 1.6rem;
    color: var(--text-main);
}

/* Layout 2 Colunas */
.layout-2-cols {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    align-items: start;
}

/* Config Layout */
.config-layout-container {
    columns: 2 350px;
    column-gap: 24px;
}

.config-layout-container .card-form {
    break-inside: avoid;
}

/* ====================================================================
   10. KANBAN
==================================================================== */
.kanban-board {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
}

.kanban-column {
    min-width: 300px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: 75vh;
}

.kanban-column-header {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-column-header h2 {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text-muted);
    border: none;
    padding: 0;
}

.kanban-column-tasks {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}

.kanban-card {
    background: #2b2b2b;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid #333;
    cursor: pointer;
    transition: 0.2s;
}

.kanban-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.kanban-card-title {
    color: #fff;
    font-weight: 500;
    font-size: 0.95rem;
    margin-top: 10px;
    display: block;
}

.card-tag-space {
    background: #333;
    color: #aaa;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}

.card-tag-date {
    background: #333;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* ====================================================================
   11. BIBLIOTECA - TOOLBAR & BUSCA
==================================================================== */
.library-toolbar {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    align-items: center;
    flex-wrap: wrap;
}

.search-wrapper {
    flex: 1;
    position: relative;
    min-width: 250px;
}

.search-input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: 0.2s;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.15);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* Context Toggles */
.context-toggles {
    display: flex;
    background: var(--bg-input);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.context-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}

.context-btn:hover {
    color: var(--text-main);
}

.context-btn.active {
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.context-btn.active i {
    color: var(--primary);
}

/* ====================================================================
   12. BIBLIOTECA - FILTROS
==================================================================== */
.filters-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    gap: 15px;
    position: relative;
}

.filters-list {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
}

.cat-pill {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    background-color: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.cat-pill:hover {
    background-color: var(--border);
    color: var(--text-main);
}

.cat-pill.active {
    background-color: var(--text-main);
    color: var(--bg-card);
    font-weight: 600;
}

.cat-pill-extra {
    display: none;
}

.cat-more-wrapper {
    position: relative;
}

.cat-pill-more {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    background: transparent;
    border: 1px dashed var(--text-muted);
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}

.cat-pill-more:hover,
.cat-pill-more.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(88, 101, 242, 0.1);
}

.more-filters-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    padding: 8px;
    min-width: 220px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.more-filters-dropdown a {
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: 0.2s;
}

.more-filters-dropdown a:hover {
    background: var(--bg-input);
    color: var(--text-main);
}

.more-filters-dropdown a.active {
    background: var(--primary);
    color: #fff;
}

/* ====================================================================
   13. BIBLIOTECA - GRID DE CARDS
==================================================================== */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.library-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
}

.library-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    border-color: var(--primary);
}

.card-cover {
    height: 160px;
    background-size: cover;
    background-position: center;
    background-color: #202225;
    position: relative;
    border-bottom: 1px solid var(--border);
}

.card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-category {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: block;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 15px;
}

.card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    gap: 10px;
}

.card-actions-icons {
    display: flex;
    gap: 8px;
}

/* ====================================================================
   14. MODAIS
==================================================================== */
.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-card);
    color: var(--text-main);
    width: 90%;
    max-width: 600px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close-btn {
    color: var(--text-muted);
    top: 15px;
    right: 20px;
    position: absolute;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
}

.modal-content h2,
.modal-content h3 {
    color: var(--text-main);
    border-bottom-color: var(--border);
}

/* Modal Preview */
.modal-preview-container {
    width: 95vw;
    height: 90vh;
    max-width: 1600px;
    background: #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    border: 1px solid var(--border);
}

.preview-toolbar {
    height: 60px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0 20px;
    gap: 20px;
}

.preview-area {
    flex: 1;
    background: #121212;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 20px;
}

.preview-iframe {
    background: #fff;
    border: none;
    transition: width 0.3s ease;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.preview-iframe.desktop {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.preview-iframe.tablet {
    width: 768px;
    height: 95%;
    border-radius: 12px;
    border: 10px solid #333;
    border-top: 30px solid #333;
    border-bottom: 30px solid #333;
}

.preview-iframe.mobile {
    width: 375px;
    height: 95%;
    border-radius: 20px;
    border: 10px solid #333;
    border-top: 30px solid #333;
    border-bottom: 30px solid #333;
}

/* Choice Cards */
.choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.choice-card {
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
}

.choice-card:hover {
    border-color: var(--primary);
    background: rgba(0, 106, 255, 0.05);
    transform: translateY(-2px);
}

.choice-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
    display: block;
    color: var(--text-main);
}

.choice-title {
    font-weight: 700;
    color: var(--text-main);
    font-size: 1.1rem;
}

.choice-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Category Management */
.cat-list-manage {
    list-style: none;
    padding: 0;
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.cat-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.cat-list-item:last-child {
    border-bottom: none;
}

.cat-actions {
    display: flex;
    gap: 10px;
}

/* ====================================================================
   15. PAGINAÇÃO
==================================================================== */
.pagination-wrapper {
    margin-top: 40px;
    padding: 20px 0;
    display: flex;
    justify-content: center;
}

.pagination-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 5px;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.pagination-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
}

.pagination-btn.active {
    background-color: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ====================================================================
   16. ELEMENTOS MOBILE (ESCONDIDOS NO DESKTOP)
==================================================================== */
.mobile-menu-btn,
.overlay {
    display: none;
}

/* ====================================================================
   17. MEDIA QUERIES - RESPONSIVIDADE
==================================================================== */

/* --- Tablets e Desktops Pequenos --- */
@media (max-width: 992px) {
    .layout-2-cols {
        grid-template-columns: 1fr;
    }
}

/* --- Mobile --- */
@media (max-width: 768px) {
    /* --- PREVENÇÃO DE SCROLL HORIZONTAL --- */
    body,
    html {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .wrapper {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* --- LAYOUT GERAL --- */
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
        padding-top: 80px;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* --- HEADER --- */
    .main-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        z-index: 90;
        padding: 30px 20px 30px 60px;
        border-bottom: 1px solid var(--border);
        margin: 0;
    }

    .main-header h1 {
        font-size: 1.1rem;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
    }

    /* --- BOTÃO HAMBÚRGUER --- */
    .mobile-menu-btn {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: fixed;
        left: 15px;
        z-index: 1100;
        background: var(--bg-input);
        border: 1px solid var(--border);
        width: 30px;
        height: 30px;
        padding: 4px;
        border-radius: 4px;
        cursor: pointer;
    }

    .mobile-menu-btn span {
        width: 18px;
        height: 2px;
        background: #fff;
        margin: 2px 0;
        border-radius: 2px;
    }

    /* --- OVERLAY --- */
    .overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.8);
        z-index: 98;
        backdrop-filter: blur(2px);
    }

    .overlay.open {
        display: block;
    }

    /* --- FORMS & GRIDS --- */
    .form-row {
        flex-direction: column;
        gap: 15px;
    }

    .config-layout-container {
        columns: 1;
    }

    /* --- KANBAN --- */
    .kanban-board {
        flex-direction: column;
        padding-bottom: 50px;
    }

    .kanban-column {
        width: 100%;
        max-height: none;
        margin-bottom: 20px;
    }

    /* --- TABELAS VERTICALIZADAS --- */
    .table-responsive {
        border: none;
        overflow: visible;
    }

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tbody tr {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 15px;
        padding: 15px;
        position: relative;
    }

    td {
        border: none;
        position: relative;
        padding: 8px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        font-size: 0.9rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    td:last-child {
        border-bottom: none;
        display: block;
        margin-top: 10px;
        text-align: center;
    }

    td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        margin-right: 10px;
        text-align: left;
    }

    td:last-child a,
    td:last-child form,
    td:last-child button {
        width: 100%;
        display: block;
        margin: 5px 0;
        text-align: center;
    }

    .btn-edit,
    .btn-delete {
        margin-right: 0;
    }

    /* --- BIBLIOTECA: TOOLBAR --- */
    .library-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .search-wrapper {
        min-width: auto;
        width: 100%;
        max-width: 100%;
    }

    .search-wrapper form {
        width: 100%;
        max-width: 100%;
    }

    .search-input {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .context-toggles {
        width: 100%;
    }

    .context-btn {
        justify-content: center;
    }

    /* --- BIBLIOTECA: FILTROS COM SCROLL --- */
    .filters-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        overflow: hidden;
        width: 100%;
        max-width: 100%;
    }

    .filters-list {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        align-items: center;
        scroll-snap-type: x mandatory;
    }

    .filters-list::-webkit-scrollbar {
        display: none;
    }

    .cat-more-wrapper {
        display: none;
    }

    .cat-pill-extra {
        display: block;
    }

    .cat-pill {
        scroll-snap-align: start;
        flex-shrink: 0;
    }

    .btn-manage-cats {
        width: 100%;
        max-width: 100%;
        text-align: center;
        margin-top: 10px;
        display: flex;
        justify-content: center;
        box-sizing: border-box;
    }

    /* --- BIBLIOTECA: GRID --- */
    .library-grid {
        grid-template-columns: 1fr;
        width: 100%;
        max-width: 100%;
        padding: 0;
        gap: 20px;
    }

    .library-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* --- PAGINAÇÃO --- */
    .pagination-wrapper {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        padding: 20px 0;
    }

    .pagination-scroll {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .pagination-scroll::-webkit-scrollbar {
        height: 4px;
    }

    .pagination-scroll::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
    }

    /* --- MODAIS MOBILE --- */
    .modal-content {
        width: 95%;
        max-width: 95vw;
        box-sizing: border-box;
    }

    .modal-preview-container {
        width: 95vw;
        max-width: 95vw;
    }

    .choice-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 767px) {
    /* Ajustes específicos para mobile muito pequeno */
}

/* =========================================================
   HOTFIX — TOGGLE MOBILE ACIMA DE STACKING CONTEXTS
   Motivo: páginas com overflow / animation criam
   stacking context e escondem o botão
========================================================= */

@media (max-width: 768px) {

    .mobile-menu-btn {
        position: fixed !important;
        z-index: 9999 !important;
    }

    .main-header {
        z-index: 900;
    }

    .overlay {
        z-index: 9998;
    }
}