/* ── Hermes Ops Portal — Design System ──────────────────────── */
:root {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #273449;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-green: #22c55e;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-card: rgba(255, 255, 255, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Header ─────────────────────────────────────────────────── */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-left h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-left span {
    color: var(--accent-blue);
}

.header-meta {
    text-align: right;
    font-size: 13px;
    color: var(--text-secondary);
}

.header-meta .live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    margin-right: 6px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Navigation tabs ──────────────────────────────────────── */
.nav-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
}

.nav-tab {
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--accent-blue);
    color: white;
}

/* ── Main content ─────────────────────────────────────────── */
.main-content {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Page containers (for rotation) ───────────────────────── */
.page {
    display: none;
    animation: fadeSlideIn 0.4s ease;
}

.page.active {
    display: block;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── KPI Cards ────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
}

.kpi-value.accent-blue { color: var(--accent-blue); }
.kpi-value.accent-green { color: var(--accent-green); }
.kpi-value.accent-amber { color: var(--accent-amber); }
.kpi-value.accent-red { color: var(--accent-red); }
.kpi-value.accent-purple { color: var(--accent-purple); }

.kpi-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* ── Progress Bar ─────────────────────────────────────────── */
.progress-section {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
}

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

.progress-title {
    font-size: 16px;
    font-weight: 600;
}

.progress-pct {
    font-size: 24px;
    font-weight: 800;
    font-family: var(--font-mono);
}

.progress-bar-outer {
    height: 14px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-inner {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.6s ease;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Transportadoras Table ────────────────────────────────── */
.transportadoras-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.transp-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 20px;
}

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

.transp-name {
    font-weight: 700;
    font-size: 15px;
}

.transp-status {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-weight: 600;
    text-transform: uppercase;
}

.transp-status.meta-atingida { background: #064e3b; color: #6ee7b7; }
.transp-status.no-ritmo { background: #1e3a5f; color: #93c5fd; }
.transp-status.atencao { background: #78350f; color: #fcd34d; }
.transp-status.critico { background: #7f1d1d; color: #fca5a5; }

.transp-metric {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.transp-metric strong {
    color: var(--text-primary);
}

.transp-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 9999px;
    overflow: hidden;
    margin: 8px 0;
}

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

/* ── Timeline ─────────────────────────────────────────────── */
.timeline {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 20px;
}

.timeline-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timeline-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
    gap: 12px;
    font-size: 13px;
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-time {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
    min-width: 50px;
}

.timeline-placa {
    font-weight: 700;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 80px;
    text-align: center;
}

.timeline-transp {
    color: var(--accent-blue);
    font-weight: 500;
    min-width: 90px;
}

.timeline-peso {
    font-weight: 700;
    font-family: var(--font-mono);
    margin-left: auto;
}

/* ── Documents Grid (Page 2) ──────────────────────────────── */
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.doc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
}

.doc-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.doc-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.doc-value {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
}

.doc-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ── Donut Chart (MTR) ────────────────────────────────────── */
.donut-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

.donut-ring {
    position: relative;
    width: 120px;
    height: 120px;
}

.donut-ring svg {
    transform: rotate(-90deg);
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-center .big {
    font-size: 28px;
    font-weight: 800;
}

.donut-center .label {
    font-size: 11px;
    color: var(--text-muted);
}

.donut-legend {
    text-align: left;
    font-size: 13px;
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.donut-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ── Monthly Chart (Page 3) ───────────────────────────────── */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
}

.chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 200px;
    padding-top: 10px;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.bar {
    width: 100%;
    max-width: 40px;
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
    position: relative;
    cursor: pointer;
}

.bar:hover {
    filter: brightness(1.3);
}

.bar-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
    font-family: var(--font-mono);
}

.bar-value {
    font-size: 10px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    margin-bottom: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.bar:hover + .bar-value,
.bar-col:hover .bar-value {
    opacity: 1;
}

/* ── Heatmap ──────────────────────────────────────────────── */
.heatmap {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
    margin-top: 12px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    transition: transform 0.2s;
    cursor: pointer;
}

.heatmap-cell:hover {
    transform: scale(1.3);
}

.heatmap-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
    font-family: var(--font-mono);
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 16px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    margin-top: 24px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .header { padding: 12px 16px; }
    .header-left h1 { font-size: 16px; }
    .main-content { padding: 16px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi-value { font-size: 24px; }
    .transportadoras-grid { grid-template-columns: 1fr; }
    .docs-grid { grid-template-columns: 1fr; }
    .bar-chart { height: 140px; }
}

/* ── Page transition ──────────────────────────────────────── */
.page-transition {
    animation: crossfade 0.5s ease;
}

@keyframes crossfade {
    0% { opacity: 0; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}