:root {
    --primary: #0d6b57;
    --primary-dark: #075345;
    --primary-light: #e4f3ef;
    --background: #f3f6f7;
    --surface: #ffffff;
    --border: #dfe7e9;
    --text: #182326;
    --muted: #647579;
    --positive: #17875f;
    --negative: #c33b3b;
    --warning: #d58b15;
    --critical: #9c2335;
    --sidebar: #102b28;
    --sidebar-muted: #a9c1bd;
    --shadow: 0 8px 26px rgba(13, 45, 41, 0.07);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--text);
    background: var(--background);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 255px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    color: #ffffff;
    background: var(--sidebar);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 28px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    border-radius: 13px;
    color: #ffffff;
    background: var(--primary);
    font-size: 23px;
    font-weight: 800;
}

.brand strong,
.brand span {
    display: block;
}

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

.brand span {
    margin-top: 3px;
    color: var(--sidebar-muted);
    font-size: 12px;
}

.sidebar nav {
    display: grid;
    gap: 8px;
}

.nav-item {
    width: 100%;
    padding: 13px 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 0;
    border-radius: 11px;
    color: var(--sidebar-muted);
    background: transparent;
    text-align: left;
}

.nav-item:hover,
.nav-item.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 18px;
}

.service-status {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 12px;
}

.service-status strong,
.service-status small {
    display: block;
}

.service-status small {
    margin-top: 2px;
    color: var(--sidebar-muted);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d2a13e;
}

.status-dot.online {
    background: #53d89d;
    box-shadow: 0 0 0 4px rgba(83, 216, 157, 0.12);
}

.status-dot.offline {
    background: #e16262;
}

.main {
    min-width: 0;
    padding: 26px 30px 50px;
}

.topbar {
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
}

.topbar p {
    margin: 5px 0 0;
    color: var(--muted);
}

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

select,
input {
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    outline: none;
    background: #ffffff;
}

select:focus,
input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 107, 87, 0.1);
}

.button {
    min-height: 42px;
    padding: 9px 16px;
    border: 0;
    border-radius: 10px;
    font-weight: 700;
}

.button.primary {
    color: #ffffff;
    background: var(--primary);
}

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

.button.secondary {
    color: var(--text);
    border: 1px solid var(--border);
    background: #ffffff;
}

.button.danger {
    color: #ffffff;
    background: var(--negative);
}

.button.full {
    width: 100%;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.metrics-grid {
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 15px;
}

.metric-card {
    min-height: 138px;
    padding: 19px;
    border: 1px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 15px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric-card.positive {
    border-top-color: var(--positive);
}

.metric-card.negative {
    border-top-color: var(--negative);
}

.metric-card.warning {
    border-top-color: var(--warning);
}

.metric-card.critical {
    border-top-color: var(--critical);
}

.metric-card span,
.metric-card small {
    display: block;
    color: var(--muted);
}

.metric-card span {
    font-size: 13px;
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin: 9px 0 6px;
    font-size: 32px;
}

.metric-card small {
    font-size: 12px;
}

.panel {
    padding: 21px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel-header {
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
}

.panel-header h2 {
    margin: 0;
    font-size: 17px;
}

.panel-header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.charts-grid,
.dashboard-bottom-grid {
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.timeline-panel {
    margin-bottom: 20px;
}

.chart-wrapper {
    position: relative;
    height: 285px;
}

.timeline-chart {
    height: 330px;
}

.topics-list {
    display: grid;
    gap: 13px;
}

.topic-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px;
    align-items: center;
    gap: 12px;
}

.topic-label {
    overflow: hidden;
    color: var(--text);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topic-value {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-align: right;
}

.topic-progress {
    grid-column: 1 / -1;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf2f2;
}

.topic-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.text-button {
    padding: 0;
    border: 0;
    color: var(--primary);
    background: transparent;
    font-weight: 700;
}

.compact-comments,
.comments-list {
    display: grid;
    gap: 13px;
}

.comment-card {
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #ffffff;
}

.comment-card.priority {
    border-left: 5px solid var(--warning);
}

.comment-card.critical {
    border-left-color: var(--critical);
}

.comment-meta,
.comment-footer,
.badges,
.comment-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.comment-meta {
    justify-content: space-between;
}

.comment-author {
    font-weight: 800;
}

.comment-date {
    color: var(--muted);
    font-size: 12px;
}

.comment-text {
    margin: 13px 0;
    color: #273538;
    line-height: 1.55;
    white-space: pre-wrap;
}

.badge {
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    text-transform: capitalize;
}

.badge.facebook {
    color: #275aa6;
    background: #e8f0ff;
}

.badge.instagram {
    color: #a12370;
    background: #f9e8f3;
}

.badge.positivo {
    color: var(--positive);
    background: #e6f6ef;
}

.badge.negativo {
    color: var(--negative);
    background: #fdecec;
}

.badge.neutro {
    color: #657478;
    background: #eef2f3;
}

.badge.critica,
.badge.alta {
    color: var(--critical);
    background: #fde8ec;
}

.badge.media {
    color: #9c6811;
    background: #fff3d9;
}

.badge.baja {
    color: #657478;
    background: #eef2f3;
}

.badge.resolved {
    color: var(--positive);
    background: #e6f6ef;
}

.comment-footer {
    justify-content: space-between;
    margin-top: 14px;
}

.comment-actions {
    justify-content: flex-end;
}

.small-button {
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #ffffff;
    font-size: 12px;
    font-weight: 700;
}

.small-button.resolve {
    color: #ffffff;
    border-color: var(--primary);
    background: var(--primary);
}

.suggested-reply {
    margin-top: 13px;
    padding: 13px;
    border-radius: 10px;
    color: #245047;
    background: var(--primary-light);
    font-size: 13px;
    line-height: 1.5;
}

.suggested-reply strong {
    display: block;
    margin-bottom: 5px;
}

.filters {
    margin-bottom: 18px;
    display: grid;
    grid-template-columns:
        minmax(240px, 2fr)
        repeat(4, minmax(130px, 1fr))
        auto
        auto;
    gap: 9px;
}

.result-count {
    padding: 6px 11px;
    border-radius: 999px;
    color: var(--primary);
    background: var(--primary-light);
    font-size: 13px;
    font-weight: 800;
}

.warning-count {
    color: #9c6811;
    background: #fff3d9;
}

.pagination {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.empty-state {
    padding: 36px 15px;
    color: var(--muted);
    text-align: center;
}

.loading-state {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(
            circle at top right,
            rgba(31, 142, 116, 0.45),
            transparent 40%
        ),
        var(--sidebar);
}

.login-card {
    width: min(430px, 100%);
    padding: 35px;
    border-radius: 19px;
    background: #ffffff;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

.login-card .brand-mark {
    margin-bottom: 20px;
}

.login-card h1 {
    margin: 0;
    font-size: 25px;
}

.login-card p {
    margin: 10px 0 24px;
    color: var(--muted);
    line-height: 1.5;
}

.login-card label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 800;
}

.login-card input {
    width: 100%;
    margin-bottom: 13px;
}

.error-message,
.global-error {
    color: var(--negative);
}

.error-message {
    min-height: 20px;
    margin-top: 10px;
    font-size: 13px;
    text-align: center;
}

.global-error {
    margin-bottom: 18px;
    padding: 13px;
    border: 1px solid #f4bcbc;
    border-radius: 10px;
    background: #fff0f0;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 100;
    max-width: 360px;
    padding: 13px 17px;
    border-radius: 11px;
    color: #ffffff;
    background: var(--sidebar);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(15px);
    transition: 0.2s ease;
}

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

.toast.error {
    background: var(--negative);
}

@media (max-width: 1250px) {
    .metrics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .filters {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    #filter-search {
        grid-column: span 3;
    }
}

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

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
    }

    .sidebar nav {
        display: flex;
        overflow-x: auto;
    }

    .sidebar-footer {
        display: none;
    }

    .main {
        padding: 20px 15px 40px;
    }

    .topbar,
    .topbar-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .metrics-grid,
    .charts-grid,
    .dashboard-bottom-grid {
        grid-template-columns: 1fr;
    }

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

    #filter-search {
        grid-column: auto;
    }
}
