:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: #1f2937;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --border-color: #374151;
    --status-green: #10b981;
    --status-yellow: #f59e0b;
    --status-red: #ef4444;
    --status-gray: #6b7280;
    --glass-bg: rgba(17, 24, 39, 0.85);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    padding: 1rem;
    min-height: 100vh;
}

/* ── TELA DE LOGIN ── */
.login-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 2rem);
}

.login-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
    text-align: center;
    animation: fadeIn 0.4s ease-out;
}

.login-card h2 {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a5b4fc, #6366f1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-align: left;
    margin-bottom: 1.5rem;
}

.input-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.input-field {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    width: 100%;
}

.input-field:focus {
    border-color: var(--accent-color);
}

.login-btn {
    background-color: var(--accent-color);
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.75rem;
    width: 100%;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-btn:hover {
    background-color: var(--accent-hover);
}

.login-error {
    color: var(--status-red);
    font-size: 0.8rem;
    margin-top: 1rem;
    display: none;
}

/* ── DASHBOARD LAYOUT ── */
.app-layout {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a5b4fc, #6366f1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.btn-pdf {
    background-color: var(--accent-color);
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background-color 0.2s, transform 0.1s;
    text-decoration: none;
}

.btn-pdf:hover { opacity: 0.9; }
.btn-pdf:active { transform: scale(0.98); }

.header-status {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.35rem 0.75rem;
    text-align: right;
}

/* Grid de KPIs */
.grid-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent-color);
}

.kpi-card.kpi-critico::before { background: var(--status-red); }
.kpi-card.kpi-ok::before { background: var(--status-green); }

.kpi-title {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0.25rem 0;
    color: var(--text-main);
}

.kpi-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Linha de Gráficos */
.grid-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
}

.chart-card h3 {
    align-self: flex-start;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.chart-container {
    position: relative;
    width: 100%;
    max-width: 240px;
    height: 180px;
}

.chart-container-large {
    position: relative;
    width: 100%;
    height: 180px;
}

/* Painel de Filtros */
.control-panel {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.control-input {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.control-input:focus { border-color: var(--accent-color); }

select.control-input {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
    padding-right: 2rem;
}

.counter {
    text-align: center;
    padding: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Tabela */
.table-container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

th {
    background-color: rgba(31, 41, 55, 0.5);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr.tr-clicavel { cursor: pointer; transition: background-color 0.15s; }
tr.tr-clicavel:hover td { background-color: rgba(99, 102, 241, 0.08); }

/* Responsivo Mobile */
.cards-container { display: none; }

.printer-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s;
}

.printer-card:hover { transform: scale(1.01); }
.printer-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
}

.printer-card.card-critico::before { background: var(--status-red); }
.printer-card.card-normal::before { background: var(--status-green); }
.printer-card.card-nd::before { background: var(--status-gray); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.card-unidade {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.card-toner { font-size: 1.1rem; font-weight: 700; }

.card-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
    font-size: 0.8rem;
}

.card-label { color: var(--text-muted); }
.card-value { color: var(--text-main); font-weight: 500; text-align: right; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-green {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--status-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-red {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--status-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-gray {
    background-color: rgba(107, 114, 128, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(107, 114, 128, 0.2);
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 100px;
}

.progress-bar-bg {
    background-color: var(--border-color);
    height: 6px;
    width: 100%;
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.8rem;
    font-weight: 600;
    width: 32px;
    text-align: right;
}

.text-critico { color: var(--status-red); }
.text-alerta { color: var(--status-yellow); }
.text-ok { color: var(--status-green); }

.ip-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.ip-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.no-data {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 1rem;
}

/* Modal Histórico */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    width: 95%;
    max-width: 540px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    animation: modalFadeIn 0.2s ease-out;
}

.modal-header-popup {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.modal-header-popup h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.btn-close:hover { color: var(--status-red); }

/* Animações */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@media (max-width: 768px) {
    .table-container { display: none; }
    .cards-container { display: block; }
    .grid-charts { grid-template-columns: 1fr; }
    .header h1 { font-size: 1.1rem; }
    .kpi-value { font-size: 1.4rem; }
}

/* Regras para Impressão / PDF */
@media print {
    body { background-color: #ffffff !important; color: #000000 !important; padding: 0 !important; }
    .header h1 { background: none !important; -webkit-text-fill-color: initial !important; color: #000000 !important; }
    .control-panel, .btn-pdf, .header-status, .modal-overlay, .login-overlay { display: none !important; }
    .kpi-card, .chart-card, .table-container { background-color: #ffffff !important; border: 1px solid #dddddd !important; color: #000000 !important; box-shadow: none !important; }
    .kpi-card::before { display: none !important; }
    .kpi-value, .chart-card h3, td { color: #000000 !important; }
    .table-container { display: block !important; border: none !important; }
    .cards-container { display: none !important; }
    tr:hover td { background-color: transparent !important; }
    th { background-color: #f3f4f6 !important; color: #374151 !important; border-bottom: 2px solid #374151 !important; }
    td { border-bottom: 1px solid #e5e7eb !important; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
