﻿* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f4f6f8;
    color: #1f2933;
    font-family: Arial, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 0;
    border-radius: 6px;
    background: #0f766e;
    color: white;
    cursor: pointer;
    padding: 10px 16px;
}

code {
    white-space: pre-wrap;
    word-break: break-word;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
}

.login-box {
    width: min(420px, calc(100% - 32px));
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    background: white;
    padding: 28px;
}

.login-box h1 {
    margin: 0 0 24px;
}

.login-box form {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 6px;
}

input,
select {
    width: 100%;
    border: 1px solid #bcccdc;
    border-radius: 6px;
    background: white;
    padding: 10px;
}

.erro {
    color: #b42318;
    margin: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #d9e2ec;
    background: white;
    padding: 14px 24px;
}

.topbar div {
    display: grid;
    gap: 2px;
}

.topbar span {
    color: #627d98;
    font-size: 14px;
}

.navlinks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.navlinks a {
    border-radius: 6px;
    color: #0f766e;
    font-weight: 700;
    padding: 8px 10px;
    text-decoration: none;
}

.navlinks a.active,
.navlinks a:hover {
    background: #d9f2ef;
}

.container {
    margin: 0 auto;
    max-width: 1180px;
    padding: 28px 24px;
}

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

.toolbar h1 {
    margin: 0;
}

.muted {
    color: #627d98;
    margin: 6px 0 0;
}

.status-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.status-panel div,
.cards article,
.chart-panel {
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    background: white;
}

.status-panel div {
    padding: 16px 20px;
}

.status-panel span,
.cards span {
    color: #627d98;
    display: block;
}

.status-panel strong {
    display: block;
    font-size: 22px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.cards-analytics {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.cards article {
    min-height: 138px;
    padding: 20px;
}

.cards strong {
    display: block;
    font-size: 34px;
    margin-top: 10px;
}

.cards small {
    color: #627d98;
    display: block;
    margin-top: 8px;
}

.cards .card-period {
    display: inline;
    font-size: 12px;
    font-weight: 500;
    margin-left: 4px;
    margin-top: 0;
    white-space: nowrap;
}

.filters {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    align-items: end;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-panel {
    margin-bottom: 24px;
    padding: 20px;
}

.chart-panel h2 {
    font-size: 18px;
    margin: 0 0 16px;
}

.bar-chart {
    display: grid;
    gap: 12px;
}

.bar-row {
    display: grid;
    grid-template-columns: 64px 1fr 80px;
    align-items: center;
    gap: 12px;
}

.bar-row span {
    color: #52606d;
}

.bar-row strong {
    text-align: right;
}

.bar-track {
    height: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: #e6edf3;
}

.bar-fill {
    height: 100%;
    min-width: 2px;
    border-radius: 999px;
    background: #0f766e;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    background: white;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.mqtt-table {
    min-width: 1100px;
}

th,
td {
    border-bottom: 1px solid #e6edf3;
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #f8fafc;
    color: #52606d;
    font-size: 14px;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.badge {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
    text-transform: uppercase;
}

.badge-ok {
    background: #d9f2ef;
    color: #0f766e;
}

.badge-erro {
    background: #fee4e2;
    color: #b42318;
}

@media (max-width: 1050px) {
    .cards,
    .cards-analytics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

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

@media (max-width: 760px) {
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .cards,
    .cards-analytics,
    .status-panel {
        grid-template-columns: 1fr;
    }

    .bar-row {
        grid-template-columns: 54px 1fr 60px;
    }
}

.cards-four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.machine-status {
    border-left: 6px solid #9aa5b1 !important;
}

.machine-status.online {
    border-left-color: #0f766e !important;
}

.machine-status.offline {
    border-left-color: #b42318 !important;
}

.machine-status.online strong {
    color: #0f766e;
}

.machine-status.offline strong {
    color: #b42318;
}

.machine-status small {
    color: #627d98;
    display: block;
    margin-top: 6px;
}

.temperature-row {
    grid-template-columns: 110px 1fr 86px;
}

.temperature-track {
    background: #eef2ff;
}

.temperature-fill {
    background: #2563eb;
}

@media (max-width: 760px) {
    .status-panel-compact,
    .cards-four {
        grid-template-columns: 1fr;
    }

    .temperature-row {
        grid-template-columns: 86px 1fr 70px;
    }
}

.chart-header {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.chart-range {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.chart-range span {
    background: #eef2ff;
    border-radius: 999px;
    color: #1d4ed8;
    font-weight: 700;
    padding: 6px 10px;
}

.line-chart-wrap {
    overflow-x: auto;
}

.line-chart {
    display: block;
    min-width: 760px;
    width: 100%;
}

.chart-axis {
    stroke: #cbd5e1;
    stroke-width: 1;
}

.temperature-line {
    fill: none;
    stroke: #2563eb;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 3;
}

.temperature-point {
    fill: white;
    stroke: #2563eb;
    stroke-width: 2;
}

@media (max-width: 760px) {
    .chart-header {
        display: grid;
    }

    .chart-range {
        justify-content: flex-start;
    }
}


/* Dashboard visual upgrade */
.dashboard-page {
    max-width: 1240px;
}

.dashboard-toolbar {
    align-items: flex-end;
    margin-bottom: 18px;
}

.eyebrow {
    color: #0f766e;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 6px;
    text-transform: uppercase;
}

.dashboard-hero,
.metric-cards {
    display: grid;
    gap: 16px;
}

.dashboard-hero {
    grid-template-columns: 1.25fr repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
}

.metric-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.hero-card,
.metric-cards article {
    background: #ffffff;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
    min-height: 134px;
    padding: 18px 20px;
}

.hero-card span,
.metric-cards span {
    color: #52606d;
    display: block;
    font-size: 15px;
}

.hero-card strong,
.metric-cards strong {
    color: #102a43;
    display: block;
    font-size: 32px;
    line-height: 1.08;
    margin-top: 12px;
}

.hero-card small,
.metric-cards small {
    color: #627d98;
    display: block;
    margin-top: 9px;
}

.hero-card-main {
    border-left: 6px solid #0f766e;
    background: #f8fffd;
}

.hero-card-main strong {
    color: #0b3b5a;
    font-size: 48px;
}

.hero-card-rate {
    border-left: 6px solid #2563eb;
}

.hero-card-temperature {
    border-left: 6px solid #d97706;
}

.hero-card.machine-status {
    border-left-width: 6px !important;
}

.metric-cards article:nth-child(1) {
    border-left: 6px solid #0f766e;
}

.metric-cards article:nth-child(2) {
    border-left: 6px solid #2563eb;
}

.metric-cards article:nth-child(3) {
    border-left: 6px solid #7c3aed;
}

.metric-cards article:nth-child(4) {
    border-left: 6px solid #64748b;
}

.metric-cards .last-update {
    font-size: 28px;
}

@media (max-width: 1050px) {
    .dashboard-hero,
    .metric-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .dashboard-toolbar {
        align-items: stretch;
    }

    .dashboard-hero,
    .metric-cards {
        grid-template-columns: 1fr;
    }

    .hero-card-main strong {
        font-size: 40px;
    }
}
