@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --- VARIÁVEIS E BASE --- */
:root {
    --bg-color: #f1f4f9;
    --primary-color: #5e63f2;
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #94a3b8;
    --border-radius: 20px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    padding: 20px 0;
    color: var(--text-main);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

input, table {
    user-select: text;
}

/* --- CONTAINER PRINCIPAL (70%) --- */
.main-container {
    width: 70%;
    max-width: 750px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.controls-wrapper,
.results-container {
    width: 100%;
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.03);
    box-sizing: border-box;
    margin-bottom: 25px;
}

/* --- FORMULÁRIO --- */
.input-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 10px;
    width: 100%;
}

.input-group {
    display: flex;
    flex-direction: column;
    flex: 1;
}

label {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 5px;
}

input, select {
    background-color: #f8fafd;
    border: 1px solid #eef2f7;
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-main);
}

#pecas-hora-input,
#pecas-mesa-input,
#pecas-atuais-input {
    width: 90px;
    flex-grow: 0 !important;
}

/* --- BOTÕES --- */
#calcular-btn, #live-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 15px;
    background-color: var(--primary-color);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.2s;
}

#calcular-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* --- TABELA DE RESULTADOS (CORREÇÃO DE CENTRALIZAÇÃO) --- */
.results-container table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
    table-layout: fixed; /* Força as colunas a terem tamanhos matematicamente iguais */
}

.results-container th {
    text-align: center !important; /* Garante a centralização do texto do cabeçalho */
    vertical-align: middle;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0 0 8px 0;
    width: 50%; /* Metade exata para cada coluna */
}

.results-container td {
    background-color: #fcfdfe;
    padding: 18px;
    border: 1px solid #f0f3f7;
    font-weight: 600;
    text-align: center !important; /* Garante a centralização do conteúdo */
    vertical-align: middle;
}

.results-container h2 {
    text-align: center;
    width: 100%;
    margin-top: 0;      /* Remove espaços extras no topo */
    margin-bottom: 20px; /* Dá um respiro para a tabela abaixo */
    color: #1a237e;     /* Mantendo o tom de azul do seu projeto */
    font-weight: 700;
}

/* Bordas arredondadas das linhas */
.results-container td:first-child {
    border-radius: 15px 0 0 15px;
    border-right: none;
}

.results-container td:last-child {
    border-radius: 0 15px 15px 0;
    border-left: none;
}

/* --- ESTILOS EXCLUSIVOS PARA O MODO LIVE --- */

/* Linha divisória sutil */
.live-divider {
    border: 0;
    border-top: 1px solid #eef2f7;
    margin: 20px 0;
}

/* --- ESTILO DO DASHBOARD LIVE --- */

/* Estrutura de Informação de Tempo (Parte Superior) */
.live-time-grid {
    display: flex;
    justify-content: space-around;
    padding-bottom: 15px;
    border-bottom: 1px solid #f1f4f9;
    margin-bottom: 20px;
    text-align: center;
}

.live-item {
    display: flex;
    flex-direction: column;
}

.live-item span:first-child {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.live-item span[id] {
    font-size: 1.3rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-top: 5px;
}

/* Grid de Métricas (Cards Inferiores) */
.live-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.live-card {
    background-color: #f8fafd;
    padding: 20px;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid #eef2f7;
    transition: transform 0.2s ease;
}

.live-card span:first-child {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 800;
    margin-bottom: 8px;
    text-align: center;
}

.live-card span[id] {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Card de Status (Largura Total) */
.live-card.full-width {
    grid-column: span 2;
    background-color: #ffffff;
    border: 2px solid #f1f4f9;
}

.live-card.full-width span[id] {
    font-size: 1.4rem;
}

/* --- CLASSES DE CORES DINÂMICAS --- */
/* Usamos !important para garantir que o JS consiga sobrescrever cores padrão */
.status-pos { color: #27ae60 !important; } 
.status-neg { color: #e74c3c !important; }

/* Ajuste para o H2 não interferir na tabela do index */
.results-container h2 {
    text-align: center;
    width: 100%;
    margin-bottom: 25px;
    font-size: 1.5rem;
}

/* Responsividade */
@media (max-width: 600px) {
    .live-metrics-grid {
        gap: 10px;
    }
    .live-card span[id] {
        font-size: 1.4rem;
    }
}

/* --- RESPONSIVIDADE --- */
@media (max-width: 768px) {
    .main-container { width: 92%; }
    .input-row { flex-direction: row !important; }
}