:root {
    --bg-main: #0b0f19;
    --bg-card: #131b2e;
    --bg-sidebar: #0f172a;
    --border-color: #1e293b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --radius: 12px;
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.5rem 1.5rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    font-size: 1.8rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    padding: 6px;
    border-radius: 10px;
}

.brand h2 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-menu a:hover,
.nav-menu a.active {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-left: 3px solid var(--primary);
}

/* Content */
.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.topbar {
    margin-bottom: 2rem;
}

.topbar h1 {
    font-size: 1.85rem;
    font-weight: 700;
}

.topbar p {
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-size: 0.95rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

/* Metric Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.metric-card.success::before { background: var(--success); }
.metric-card.warning::before { background: var(--warning); }
.metric-card.danger::before { background: var(--danger); }

.metric-card span {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.metric-card h2 {
    font-size: 2rem;
    margin-top: 0.5rem;
    font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.95rem;
}

.table th,
.table td {
    padding: 0.9rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge-info { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.alert-success { background: rgba(16, 185, 129, 0.15); border: 1px solid var(--success); color: #a7f3d0; }
.alert-warning { background: rgba(245, 158, 11, 0.15); border: 1px solid var(--warning); color: #fde68a; }
.alert-danger { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--danger); color: #fecaca; }

/* Upload Box */
.upload-box {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    transition: all 0.2s;
}

.upload-box:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Grid Utilities */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

/* Token Box */
.token-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0f172a;
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    gap: 1rem;
    flex-wrap: wrap;
}

.token-val {
    font-size: 1.15rem;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 0.5px;
    word-break: break-all;
}

.btn-copy {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--primary);
    color: #60a5fa;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

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

/* Mobile Header & Drawer Navigation */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 999;
}

.brand-mobile {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.brand-mobile .logo-icon {
    font-size: 1.4rem;
    padding: 4px;
    border-radius: 8px;
}

.brand-mobile h2 {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn-menu-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-menu-toggle:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--primary);
}

.btn-sidebar-close {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    margin-left: auto;
    padding: 0.25rem 0.5rem;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* =========================================================================
   RESPONSIVIDADE COMPLETA PARA SMARTPHONES E TABLETS
   ========================================================================= */
@media (max-width: 900px) {
    .layout {
        flex-direction: column;
        min-height: 100vh;
    }

    .mobile-header {
        display: flex;
    }

    .btn-sidebar-close {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.6);
        overflow-y: auto;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        padding: 1.25rem 1rem;
        width: 100%;
        overflow-x: hidden;
    }

    .topbar {
        margin-bottom: 1.25rem;
    }

    .topbar h1 {
        font-size: 1.4rem;
        line-height: 1.3;
    }

    .topbar p {
        font-size: 0.85rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.85rem;
        margin-bottom: 1.25rem;
    }

    .metric-card {
        padding: 1rem 0.85rem;
    }

    .metric-card h2 {
        font-size: 1.5rem;
    }

    .metric-card span {
        font-size: 0.75rem;
    }

    .card {
        padding: 1.25rem 1rem;
        border-radius: 10px;
    }

    /* Grids colapsam para 1 coluna */
    .grid-2, .grid-2-1, .grid-3 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Tabelas responsivas com rolagem suave no toque */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
    }

    .table th, .table td {
        padding: 0.75rem 0.85rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* Botões adaptados para toque */
    .btn {
        padding: 0.65rem 1rem;
        font-size: 0.9rem;
        min-height: 42px;
    }

    /* Inputs confortáveis no celular (evita auto-zoom do iOS/Android) */
    .form-control {
        font-size: 16px;
        padding: 0.7rem 0.85rem;
    }

    /* Modais responsivos */
    .modal-content, [id^="modal"] .card, [id$="Modal"] .card {
        width: 95% !important;
        max-width: 95% !important;
        margin: 1rem auto !important;
        padding: 1.25rem 1rem !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    .token-box {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-copy {
        width: 100%;
        text-align: center;
        padding: 0.7rem;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 1rem 0.75rem;
    }

    .topbar > div {
        width: 100%;
    }

    .topbar a.btn, .topbar button.btn {
        width: 100%;
        justify-content: center;
    }
}
