/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    font-size: 16px;
    line-height: 1.5;
}

/* ===== NAV ===== */
.topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1a2e;
    padding: 0 24px;
    height: 56px;
    border-bottom: 2px solid #2a2a4a;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #e74c3c;
}

.nav-links { display: flex; gap: 4px; }

.nav-links a {
    color: #999;
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s;
}

.nav-links a:hover { color: #fff; background: #2a2a4a; }
.nav-links a.active { color: #fff; background: #e74c3c; }

/* ===== LAYOUT ===== */
.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

.section { margin-bottom: 32px; }

h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 24px;
    color: #fff;
}

h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #ccc;
}

/* ===== BANNER OFFLINE ===== */
.banner-offline {
    background: #e74c3c;
    color: #fff;
    text-align: center;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
}

/* ===== CARDS ===== */
.cards-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.card {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 20px 24px;
    min-width: 160px;
    flex: 1;
    border-left: 5px solid #444;
    transition: transform 0.15s;
}

.card:hover { transform: translateY(-2px); }

.card-number {
    font-size: 48px;
    font-weight: 800;
    line-height: 1.1;
}

.card-label {
    font-size: 15px;
    font-weight: 700;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-sub {
    font-size: 13px;
    color: #888;
    margin-top: 4px;
}

/* Card cores */
.card-red    { border-left-color: #e74c3c; }
.card-red    .card-number { color: #e74c3c; }
.card-orange { border-left-color: #e67e22; }
.card-orange .card-number { color: #e67e22; }
.card-yellow { border-left-color: #f1c40f; }
.card-yellow .card-number { color: #f1c40f; }
.card-green  { border-left-color: #2ecc71; }
.card-green  .card-number { color: #2ecc71; }
.card-blue   { border-left-color: #3498db; }
.card-blue   .card-number { color: #3498db; }
.card-gray   { border-left-color: #555; }
.card-gray   .card-number { color: #aaa; }

/* Card filial split layout */
.card-label-top {
    margin-bottom: 12px;
}

.filial-split {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filial-col { text-align: center; flex: 1; }

.filial-num {
    font-size: 32px;
    font-weight: 800;
    line-height: 1.1;
}

.filial-desc {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filial-divider {
    width: 1px;
    height: 40px;
    background: #333;
}

.text-blue { color: #3498db; }

/* Card badges (WMS) */
.card-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-ok   { background: #1a4a2e; color: #2ecc71; }
.badge-warn { background: #4a3a1a; color: #e67e22; }

/* Mini cards (resumo na pagina de pedidos) */
.cards-small { gap: 8px; }

.card-mini {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    background: #1a1a2e;
    border-left: 4px solid #444;
}

.card-mini.card-red    { border-left-color: #e74c3c; color: #e74c3c; }
.card-mini.card-orange { border-left-color: #e67e22; color: #e67e22; }
.card-mini.card-yellow { border-left-color: #f1c40f; color: #f1c40f; }
.card-mini.card-green  { border-left-color: #2ecc71; color: #2ecc71; }
.card-mini.card-blue   { border-left-color: #3498db; color: #3498db; }

.card-mini-num { font-size: 20px; font-weight: 800; }

/* ===== PIPELINE BAR ===== */
.pipeline-bar {
    display: flex;
    gap: 4px;
    align-items: stretch;
    overflow-x: auto;
    padding: 8px 0;
}

.pipeline-step {
    background: #1a1a2e;
    padding: 12px 16px;
    border-radius: 8px;
    text-align: center;
    min-width: 80px;
    flex: 1;
    border-top: 3px solid #444;
    cursor: default;
}

.pipeline-step.pipeline-etr {
    border-top-color: #e74c3c;
    background: #2a1a1e;
}

.pipeline-count {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
}

.pipeline-name {
    font-size: 13px;
    font-weight: 700;
    color: #999;
    letter-spacing: 1px;
}

.pipeline-dias {
    font-size: 12px;
    color: #666;
}

/* ===== TABLES ===== */
.table-scroll { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    background: #1a1a2e;
    color: #999;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
    padding: 12px 16px;
    text-align: left;
    position: sticky;
    top: 56px;
    z-index: 10;
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #1a1a2e;
}

.data-table tbody tr { background: #12121f; cursor: pointer; transition: background 0.15s; }
.data-table tbody tr:nth-child(4n+1) { background: #16162a; }
.data-table tbody tr:hover { background: #222240; }

/* Row highlight por semaforo */
.row-red    { border-left: 3px solid #e74c3c; }
.row-orange { border-left: 3px solid #e67e22; }
.row-yellow { border-left: 3px solid #f1c40f; }
.row-green  { border-left: 3px solid #2ecc71; }
.row-blue   { border-left: 3px solid #3498db; }

.mono { font-family: 'Consolas', 'Monaco', monospace; font-size: 13px; }
.num  { font-weight: 700; text-align: right; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-red    { background: #3a1a1a; color: #e74c3c; }
.badge-orange { background: #3a2a1a; color: #e67e22; }
.badge-yellow { background: #3a3a1a; color: #f1c40f; }
.badge-green  { background: #1a3a1a; color: #2ecc71; }
.badge-blue   { background: #1a2a3a; color: #3498db; }
.badge-gray   { background: #2a2a2a; color: #999; }

/* ===== FILTERS ===== */
.filters-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: #1a1a2e;
    border-radius: 12px;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }

.filter-group label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 1px;
}

.filter-group select,
.filter-group input {
    background: #0f0f1a;
    border: 1px solid #333;
    color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    min-width: 100px;
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: #3498db;
    outline: none;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary   { background: #3498db; color: #fff; }
.btn-primary:hover { background: #2980b9; }
.btn-secondary { background: #333; color: #ccc; }
.btn-secondary:hover { background: #444; }
.btn-sm        { padding: 4px 10px; font-size: 12px; }
.btn-action    { background: #e67e22; color: #fff; }
.btn-action:hover { background: #d35400; }
.btn-green     { background: #27ae60; color: #fff; }
.btn-green:hover { background: #219a52; }

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

.results-count {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

/* ===== TIMELINE ===== */
.timeline {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 0;
    flex-wrap: wrap;
}

.tl-step {
    background: #1a1a2e;
    padding: 8px 14px;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    min-width: 60px;
}

.tl-step small { font-weight: 400; color: #888; }
.tl-etr { background: #3a1a1e; color: #e74c3c; border: 1px solid #e74c3c; }
.tl-exp { background: #2a2a1a; color: #e67e22; border: 1px solid #e67e22; }
.tl-track { background: #1a2a3a; color: #3498db; }
.tl-done { background: #1a3a1a; color: #2ecc71; border: 1px solid #2ecc71; }
.tl-arrow { color: #555; font-size: 18px; }

.detail-row td {
    background: #16162a !important;
    padding: 0 16px !important;
}

.detail-info {
    display: flex;
    gap: 24px;
    padding: 8px 0 12px;
    font-size: 13px;
    color: #888;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background: #1a1a2e;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 480px;
    border: 1px solid #333;
}

.modal h3 {
    font-size: 22px;
    margin-bottom: 20px;
    color: #fff;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 4px;
}

.form-group select,
.form-group input,
.form-group textarea {
    width: 100%;
    background: #0f0f1a;
    border: 1px solid #333;
    color: #e0e0e0;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.form-group textarea { resize: vertical; }

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* ===== CHARTS ===== */
.chart-container {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 20px;
    position: relative;
    height: 350px;
}

.chart-small { height: 300px; }

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ===== TRANSPORTADORAS ===== */
.transp-card { min-width: 220px; }

.transp-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #333;
    margin: 10px 0;
}

.bar-seg { height: 100%; min-width: 1px; }
.bar-green  { background: #2ecc71; }
.bar-blue   { background: #3498db; }
.bar-orange { background: #e67e22; }
.bar-red    { background: #e74c3c; }

.transp-metrics {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.transp-metric { text-align: center; flex: 1; min-width: 60px; }

.transp-metric-num {
    display: block;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
}

.transp-metric-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Heatmap table */
.heatmap-table th { font-size: 11px; white-space: nowrap; }

.heatmap-cell { padding: 6px 10px !important; }

.heat-high { background: rgba(231,76,60,0.25); }
.heat-med  { background: rgba(231,76,60,0.12); }
.heat-low  { background: rgba(231,76,60,0.05); }

.heat-link {
    color: #e0e0e0;
    text-decoration: none;
    font-weight: 700;
}

.heat-link:hover { color: #fff; text-decoration: underline; }

/* ===== HINTS ===== */
.section-hint {
    font-size: 13px;
    color: #666;
    margin-top: 8px;
}

/* ===== UTILITIES ===== */
.hidden     { display: none !important; }
.text-muted { color: #555; }
.text-red   { color: #e74c3c; }
.text-orange { color: #e67e22; }

/* ===== LOGIN ===== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: #1a1a2e;
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    border: 1px solid #2a2a4a;
}

.login-brand {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 3px;
    color: #e74c3c;
    text-align: center;
    margin-bottom: 4px;
}

.login-sub {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 32px;
}

.login-error {
    background: rgba(231,76,60,0.15);
    border: 1px solid #e74c3c;
    color: #e74c3c;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
    text-align: center;
}

.btn-full { width: 100%; text-align: center; margin-top: 8px; padding: 12px; font-size: 16px; }

.nav-user {
    color: #666;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-user a { color: #888; font-size: 12px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .container { padding: 12px; }
    .cards-row { flex-direction: column; }
    .charts-grid { grid-template-columns: 1fr; }
    .filters-row { flex-direction: column; }
    .card-number { font-size: 36px; }
    h1 { font-size: 22px; }
    .topnav { flex-direction: column; height: auto; padding: 12px; gap: 8px; }
    .pipeline-bar { flex-wrap: wrap; }
}
