/* CORREÇÃO DO LAYOUT PRINCIPAL */
html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 228px;
    height: 100vh;
    box-sizing: border-box;
}

.main {
    margin-left: 228px;
    width: calc(100% - 228px);
    min-height: 100vh;
    box-sizing: border-box;
}

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

:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #718096;
    --border: #e7ebf2;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --green: #16a34a;
    --yellow: #d97706;
    --red: #dc2626;
    --sidebar: #111827;
}

body {
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: var(--bg);
    color: var(--text);
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.sidebar {
    width: 250px;
    min-height: 100vh;
    background: var(--sidebar);
    color: white;
    padding: 22px 15px;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 5px 10px 28px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
}

.brand strong {
    display: block;
    font-size: 15px;
}

.brand span {
    display: block;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 3px;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-item {
    width: 100%;
    border: 0;
    background: transparent;
    color: #aeb7c7;
    text-align: left;
    padding: 12px 13px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: .2s;
}

.nav-item:hover {
    background: #1f2937;
    color: white;
}

.nav-item.active {
    background: #2563eb;
    color: white;
}

.nav-item span {
    width: 20px;
    text-align: center;
}

.sidebar-bottom {
    margin-top: auto;
    padding: 15px 10px 5px;
}

.connection {
    font-size: 12px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 8px;
}

.connection-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
}

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    height: 86px;
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 34px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h1 {
    font-size: 23px;
}

.topbar p {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

.refresh-btn {
    border: 1px solid var(--border);
    background: white;
    padding: 9px 15px;
    border-radius: 8px;
    color: #374151;
}

.refresh-btn:hover {
    background: #f8fafc;
}

.section {
    display: none;
    padding: 30px 34px;
}

.section.active {
    display: block;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 22px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-card span {
    color: var(--muted);
    font-size: 12px;
    display: block;
}

.stat-card strong {
    display: block;
    font-size: 26px;
    margin-top: 5px;
}

.stat-icon {
    width: 43px;
    height: 43px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.stat-icon.blue {
    background: #eff6ff;
    color: #2563eb;
}

.stat-icon.yellow {
    background: #fff7ed;
    color: #d97706;
}

.stat-icon.green {
    background: #f0fdf4;
    color: #16a34a;
}

.stat-icon.red {
    background: #fef2f2;
    color: #dc2626;
}

.grid-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.panel,
.form-panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 23px;
    margin-bottom: 20px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.panel-header h2 {
    font-size: 16px;
}

.panel-header p {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.small-btn {
    border: 1px solid var(--border);
    background: white;
    border-radius: 7px;
    padding: 8px 12px;
    font-size: 12px;
}

.small-btn:hover {
    background: #f8fafc;
}

.account-summary {
    min-height: 80px;
}

.account-card {
    display: flex;
    align-items: center;
    gap: 13px;
}

.account-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #eff6ff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.account-info strong {
    display: block;
    font-size: 14px;
}

.account-info span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 20px;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 600;
}

.status.success {
    color: #15803d;
    background: #f0fdf4;
}

.status.queued {
    color: #1d4ed8;
    background: #eff6ff;
}

.status.running {
    color: #b45309;
    background: #fff7ed;
}

.status.failed {
    color: #b91c1c;
    background: #fef2f2;
}

.job-row {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 14px;
    margin-bottom: 9px;
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.job-main {
    min-width: 0;
}

.job-message {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}

.job-meta {
    color: var(--muted);
    font-size: 11px;
    margin-top: 5px;
}

.job-status {
    flex-shrink: 0;
}

.empty,
.loading {
    color: var(--muted);
    font-size: 13px;
    padding: 20px 0;
}

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

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

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    border: 1px solid #dce2eb;
    border-radius: 8px;
    padding: 11px 12px;
    background: white;
    color: var(--text);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px #2563eb14;
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.form-group small {
    color: var(--muted);
    font-size: 11px;
}

.char-count {
    text-align: right;
    color: var(--muted);
    font-size: 11px;
}

.timezone-info {
    margin-top: 20px;
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: 8px;
    color: #64748b;
    font-size: 12px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.primary-btn {
    border: 0;
    background: var(--primary);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
}

.primary-btn:hover {
    background: var(--primary-dark);
}

.primary-btn:disabled {
    opacity: .6;
    cursor: wait;
}

.result {
    margin-top: 20px;
    padding: 15px;
    border-radius: 9px;
    font-size: 13px;
}

.result.success {
    background: #f0fdf4;
    color: #166534;
}

.result.error {
    background: #fef2f2;
    color: #991b1b;
}

.hidden {
    display: none;
}

.toast {
    position: fixed;
    right: 25px;
    bottom: 25px;
    background: #111827;
    color: white;
    padding: 12px 17px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: .25s;
    z-index: 1000;
}

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

@media (max-width: 900px) {
    .sidebar {
        width: 205px;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-two {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 650px) {
    .app {
        display: block;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
    }

    nav {
        flex-direction: row;
        overflow-x: auto;
    }

    .nav-item {
        white-space: nowrap;
    }

    .sidebar-bottom {
        display: none;
    }

    .topbar {
        padding: 20px;
        height: auto;
    }

    .section {
        padding: 20px;
    }

    .stats {
        grid-template-columns: 1fr;
    }

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

    .form-group.full {
        grid-column: auto;
    }
}
