/* ═══════════════════════════════════════════════════════════════════════════
   style.css — Acompanhamento de Contratos v3.0
   Dark / Light theme via CSS custom properties
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Theme variables ──────────────────────────────────────────────────── */
:root,
[data-theme="dark"] {
    --bg:          #0a0e1a;
    --bg-alt:      #060912;
    --surface:     #111827;
    --surface2:    #1a2236;
    --surface3:    #1f2937;
    --border:      #1f2e4a;
    --border-light:#2d3f66;
    --blue:        #1F4E79;
    --accent:      #3b82f6;
    --accent2:     #60a5fa;
    --accent-bg:   rgba(59,130,246,.08);
    --accent-border: rgba(59,130,246,.2);
    --verde:       #10b981;
    --verde-bg:    rgba(16,185,129,.12);
    --amarelo:     #f59e0b;
    --amarelo-bg:  rgba(245,158,11,.12);
    --vermelho:    #ef4444;
    --vermelho-bg: rgba(239,68,68,.10);
    --texto:       #e2e8f0;
    --texto2:      #cbd5e1;
    --muted:       #64748b;
    --muted2:      #475569;
    --shadow:      rgba(0,0,0,.4);
    --shadow-lg:   rgba(0,0,0,.6);
    --glass:       rgba(17,24,39,.75);
    --glass-border:rgba(59,130,246,.15);
    --overlay:     rgba(10,14,26,.85);
    --grid-line:   rgba(59,130,246,.04);
    --chart-grid:  rgba(31,46,74,.4);
    --scrollbar-bg:#1a2236;
    --scrollbar-thumb:#2d3f66;
    --input-bg:    rgba(17,24,39,.8);
}

[data-theme="light"] {
    --bg:          #f8fafc;
    --bg-alt:      #f1f5f9;
    --surface:     #ffffff;
    --surface2:    #f1f5f9;
    --surface3:    #e2e8f0;
    --border:      #e2e8f0;
    --border-light:#cbd5e1;
    --blue:        #1e40af;
    --accent:      #2563eb;
    --accent2:     #3b82f6;
    --accent-bg:   rgba(37,99,235,.06);
    --accent-border: rgba(37,99,235,.15);
    --verde:       #059669;
    --verde-bg:    rgba(5,150,105,.08);
    --amarelo:     #d97706;
    --amarelo-bg:  rgba(217,119,6,.08);
    --vermelho:    #dc2626;
    --vermelho-bg: rgba(220,38,38,.06);
    --texto:       #0f172a;
    --texto2:      #334155;
    --muted:       #64748b;
    --muted2:      #94a3b8;
    --shadow:      rgba(0,0,0,.06);
    --shadow-lg:   rgba(0,0,0,.1);
    --glass:       rgba(255,255,255,.85);
    --glass-border:rgba(37,99,235,.1);
    --overlay:     rgba(248,250,252,.9);
    --grid-line:   rgba(37,99,235,.03);
    --chart-grid:  rgba(226,232,240,.6);
    --scrollbar-bg:#e2e8f0;
    --scrollbar-thumb:#cbd5e1;
    --input-bg:    #ffffff;
}

/* ── Base ──────────────────────────────────────────────────────────────── */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--texto);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background .3s, color .3s;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Grid background ──────────────────────────────────────────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: .6;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: transform .3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--blue), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px rgba(59,130,246,.3);
    flex-shrink: 0;
}

.sidebar-logo img {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    object-fit: cover;
}

.sidebar-brand {
    flex: 1;
    min-width: 0;
}

.sidebar-brand-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.sidebar-brand-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--texto);
    line-height: 1.2;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    color: var(--texto2);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all .2s;
    border: 1px solid transparent;
}

.nav-link:hover {
    background: var(--accent-bg);
    color: var(--accent2);
    border-color: var(--accent-border);
}

.nav-link.active {
    background: var(--accent-bg);
    color: var(--accent);
    border-color: var(--accent-border);
    font-weight: 600;
}

.nav-link i { width: 20px; height: 20px; stroke-width: 2; flex-shrink: 0; }

.nav-section {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: 16px 14px 6px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface2);
    cursor: pointer;
    color: var(--texto2);
    font-size: 13px;
    font-weight: 500;
    transition: all .2s;
}

.theme-toggle:hover {
    border-color: var(--accent-border);
    background: var(--accent-bg);
}

.theme-toggle i { width: 18px; height: 18px; }

.sidebar-credit {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted2);
    text-align: center;
    letter-spacing: .06em;
    padding: 4px 0;
}

/* ── Main content ──────────────────────────────────────────────────────── */
.main {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    padding: 0;
}

.page-header {
    padding: 24px 32px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 30;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.page-title h1 {
    font-size: 20px;
    font-weight: 800;
    color: var(--texto);
}

.page-title-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--muted);
}

.page-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-clock {
    text-align: right;
}

.header-clock-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--texto);
}

.header-clock-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
}

.page-content {
    padding: 24px 32px 80px;
}

/* ── Badges / Labels ──────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .02em;
}

.badge-verde   { background: var(--verde-bg);    color: var(--verde);    border: 1px solid rgba(16,185,129,.2); }
.badge-amarelo { background: var(--amarelo-bg);   color: var(--amarelo);  border: 1px solid rgba(245,158,11,.2); }
.badge-vermelho{ background: var(--vermelho-bg);  color: var(--vermelho); border: 1px solid rgba(239,68,68,.2); }
.badge-accent  { background: var(--accent-bg);    color: var(--accent);   border: 1px solid var(--accent-border); }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px var(--shadow);
    transition: all .3s ease;
    height: 100%;   /* preenche o card-link → todos os cards com a mesma altura */
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--blue), transparent);
}

.card:hover {
    border-color: var(--accent-border);
    box-shadow: 0 8px 32px var(--shadow-lg);
    transform: translateY(-2px);
}

.card-neon-verde    { border-color: rgba(16,185,129,.3) !important; box-shadow: 0 0 12px rgba(16,185,129,.15), 0 4px 16px var(--shadow); }
.card-neon-amarelo  { border-color: rgba(245,158,11,.3) !important; box-shadow: 0 0 12px rgba(245,158,11,.15), 0 4px 16px var(--shadow); }
.card-neon-vermelho { border-color: rgba(239,68,68,.3) !important;  box-shadow: 0 0 12px rgba(239,68,68,.15),  0 4px 16px var(--shadow); animation: pulseRed 2.5s infinite; }

@keyframes pulseRed {
    0%, 100% { box-shadow: 0 0 12px rgba(239,68,68,.15), 0 4px 16px var(--shadow); }
    50%      { box-shadow: 0 0 24px rgba(239,68,68,.3),  0 4px 16px var(--shadow); }
}

/* Apenas os títulos dos cards do painel centralizados */
.grid-3 .card-title,
.grid-3 .card-subtitle {
    text-align: center;
}

.card-prod {
    margin-top: 12px;
}

.card-prod-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.card-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--texto);
    margin-bottom: 2px;
}

.card-subtitle {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.card-star {
    position: absolute;
    top: 10px;
    right: 12px;
    color: var(--amarelo);
    filter: drop-shadow(0 0 6px rgba(245,158,11,.5));
}

/* ── Card link (painel) ───────────────────────────────────────────────── */
a.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;   /* preenche a célula do grid para manter os cards uniformes */
}

/* ── Grid ──────────────────────────────────────────────────────────────── */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    grid-auto-rows: 1fr;   /* todas as linhas com a mesma altura → cards uniformes */
    gap: 16px;
    align-items: stretch;
}

/* ── Progress bar ──────────────────────────────────────────────────────── */
.progress-bar {
    height: 8px;
    background: var(--surface3);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0 4px;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .6s ease;
}

.progress-fill-verde   { background: var(--verde);   box-shadow: 0 0 6px rgba(16,185,129,.4); }
.progress-fill-amarelo { background: var(--amarelo);  box-shadow: 0 0 6px rgba(245,158,11,.4); }
.progress-fill-vermelho{ background: var(--vermelho); box-shadow: 0 0 6px rgba(239,68,68,.4); }

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
}

/* ── Metric cards ──────────────────────────────────────────────────────── */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
}

.metric-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    color: var(--accent);
}

.metric-info { flex: 1; min-width: 0; }

.metric-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    color: var(--texto);
}

.metric-unit {
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
    margin-left: 4px;
}

.metric-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    margin-top: 4px;
}

.metric-trend {
    font-size: 12px;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend-up   { color: var(--verde); }
.trend-down { color: var(--vermelho); }
.trend-stable { color: var(--muted); }

/* ── Produto tag ───────────────────────────────────────────────────────── */
.produto-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--accent-bg);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--accent2);
    text-transform: uppercase;
    letter-spacing: .08em;
}

/* ── Status banner ─────────────────────────────────────────────────────── */
.status-banner {
    border-radius: 14px;
    padding: 20px 28px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 4px 16px var(--shadow);
}

.status-banner-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.status-banner-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--muted);
}

/* ── Timeline ──────────────────────────────────────────────────────────── */
.timeline-wrap {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.timeline-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-bar {
    height: 6px;
    background: var(--surface3);
    border-radius: 3px;
    overflow: hidden;
    margin: 6px 0;
}

.timeline-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--verde));
}

.timeline-ends {
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
}

/* ── Charts wrapper ────────────────────────────────────────────────────── */
.chart-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 16px var(--shadow);
    display: flex;
    flex-direction: column;
}

/* Container de altura FIXA para os gráficos — impede o Chart.js de crescer
   descontroladamente (mantém os tamanhos do sistema antigo: barras 280 / rosca 240). */
.chart-box {
    position: relative;
    width: 100%;
    height: 280px;
    flex: 1 1 auto;
}
.chart-box.is-donut {
    height: 240px;
}
.chart-box > canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

/* No modo TV os gráficos acompanham a altura da tela (melhor visualização à distância) */
.tv-slide .chart-box {
    height: clamp(240px, 34vh, 440px);
}
.tv-slide .chart-box.is-donut {
    height: clamp(220px, 30vh, 380px);
}

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

.chart-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* ── Filter (year) ─────────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-btn {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    cursor: pointer;
    transition: all .2s;
}

.filter-btn:hover { border-color: var(--accent-border); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Table ─────────────────────────────────────────────────────────────── */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 16px var(--shadow);
    overflow-x: auto;
    margin: 16px 0;
}

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

.data-table th {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--texto2);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: var(--accent-bg); }

.row-verde   td { background: var(--verde-bg); }
.row-amarelo td { background: var(--amarelo-bg); }
.row-pendente td { opacity: .6; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px var(--shadow);
}

.form-card-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--texto2);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--texto);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    transition: all .2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.form-control::placeholder { color: var(--muted2); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .2s;
    text-decoration: none;
}

.btn i { width: 18px; height: 18px; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent2);
    box-shadow: 0 4px 16px rgba(59,130,246,.3);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent-border);
}

.btn-outline:hover {
    background: var(--accent-bg);
    border-color: var(--accent);
}

.btn-danger {
    background: var(--vermelho-bg);
    color: var(--vermelho);
    border-color: rgba(239,68,68,.25);
}

.btn-danger:hover {
    background: var(--vermelho);
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 8px;
}

/* ── Toast / Notification ──────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 32px var(--shadow-lg);
    animation: toastIn .3s ease;
    min-width: 280px;
}

.toast-success { background: var(--verde);   color: #fff; }
.toast-error   { background: var(--vermelho); color: #fff; }
.toast-info    { background: var(--accent);  color: #fff; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Count summary ─────────────────────────────────────────────────────── */
.count-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Detail header (detalhe page) ──────────────────────────────────────── */
.detail-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px 28px;
    margin-bottom: 24px;
    box-shadow: 0 4px 24px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.detail-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.detail-header-verde::before    { background: var(--verde); }
.detail-header-amarelo::before  { background: var(--amarelo); }
.detail-header-vermelho::before { background: var(--vermelho); }

.detail-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--texto);
}

.detail-pct {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
}

/* ── Charts row ────────────────────────────────────────────────────────── */
.charts-row {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 16px;
    margin: 16px 0;
}

/* ── Section divider ───────────────────────────────────────────────────── */
.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* ── Danger zone ───────────────────────────────────────────────────────── */
.danger-zone {
    border-color: rgba(239,68,68,.25) !important;
}

.danger-zone-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--vermelho);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
    background: var(--surface2);
    border: 1px dashed var(--border);
    border-radius: 14px;
    padding: 48px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--muted);
}

.empty-state i { width: 32px; height: 32px; margin-bottom: 12px; opacity: .5; }

/* ── Mobile sidebar toggle ─────────────────────────────────────────────── */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 60;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--texto);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--shadow);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 40;
}

/* ── Botão recolher/expandir sidebar (desktop) ─────────────────────────── */
.collapse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--texto);
    cursor: pointer;
    flex-shrink: 0;
    transition: all .2s ease;
}
.collapse-btn:hover {
    border-color: var(--accent-border);
    color: var(--accent);
}
.collapse-btn i { width: 18px; height: 18px; }

/* Estado colapsado (apenas no desktop) — esconde a sidebar e reaproveita o espaço.
   Restrito a min-width:769px para não conflitar com o menu ☰ do celular. */
@media (min-width: 769px) {
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }
    body.sidebar-collapsed .main {
        margin-left: 0;
    }
    body.sidebar-collapsed .app-ticker {
        left: 0;
    }
}

/* No celular o menu já vira ☰ — o botão de recolher não se aplica */
@media (max-width: 768px) {
    .collapse-btn { display: none; }
}

/* ── TV mode ───────────────────────────────────────────────────────────── */
.tv-layout {
    min-height: 100vh;
    background: var(--bg);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.tv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.tv-progress {
    text-align: center;
    flex: 1;
}

.tv-progress-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.tv-progress-bar {
    height: 3px;
    background: var(--surface3);
    border-radius: 2px;
    overflow: hidden;
    max-width: 300px;
    margin: 0 auto;
}

.tv-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width .5s linear;
    box-shadow: 0 0 6px rgba(59,130,246,.4);
}

.tv-nav-btns {
    display: flex;
    gap: 8px;
}

.tv-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--texto);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
}

.tv-nav-btn:hover { border-color: var(--accent); color: var(--accent); }

.tv-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tv-slide {
    flex: 1;
    animation: tvFadeIn .5s ease;
}

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

.tv-orgao-name {
    font-size: 48px;
    font-weight: 900;
    color: var(--texto);
    margin-bottom: 8px;
    line-height: 1.1;
}

.tv-produto-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: var(--accent2);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 6px 16px;
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.tv-pct {
    font-size: 80px;
    font-weight: 900;
    line-height: 1;
}

.tv-status-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    padding: 6px 16px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.tv-dots {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

.tv-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all .3s;
}

.tv-dot.active { background: var(--accent); box-shadow: 0 0 8px rgba(59,130,246,.4); }

.tv-ticker {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--overlay);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    padding: 6px 0;
    overflow: hidden;
    z-index: 100;
}

.tv-ticker-inner {
    display: inline-block;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    animation: tickerScroll 120s linear infinite;
    will-change: transform;
}

@keyframes tickerScroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ── App ticker (rodapé do painel) ─────────────────────────────────────── */
.app-ticker {
    position: fixed;
    bottom: 0;
    left: 260px;   /* começa após a sidebar no desktop */
    right: 0;
    background: var(--overlay);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    padding: 7px 0;
    overflow: hidden;
    z-index: 45;
}

.app-ticker-inner {
    display: inline-block;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    color: var(--muted);
    animation: tickerScroll 90s linear infinite;
    will-change: transform;
}

.app-ticker-inner:hover {
    animation-play-state: paused;   /* pausa ao passar o mouse */
}

.app-ticker .tk {
    padding: 0 6px;
    color: var(--texto);
}
.app-ticker .tk-verde    { color: var(--verde); }
.app-ticker .tk-amarelo  { color: var(--amarelo); }
.app-ticker .tk-vermelho { color: var(--vermelho); }
.app-ticker .tk-sep      { color: var(--muted); opacity: .5; }

/* espaço para o conteúdo não ficar escondido atrás do ticker fixo */
.page-content {
    padding-bottom: 52px;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .app-ticker {
        left: 0;   /* ocupa a largura toda no celular */
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main {
        margin-left: 0;
    }

    .page-content {
        padding: 16px;
    }

    .grid-3 {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;   /* no celular cada card volta a acompanhar o conteúdo */
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tv-orgao-name {
        font-size: 32px;
    }

    .tv-pct {
        font-size: 56px;
    }
}

/* ── Loading spinner ───────────────────────────────────────────────────── */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Value display (inserir) ───────────────────────────────────────────── */
.current-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--muted);
    margin: 4px 0;
}

.current-value.has-value { color: var(--verde); }

/* ── Fullscreen TV ─────────────────────────────────────────────────────── */
.fullscreen-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--texto);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
}

.fullscreen-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Animations ────────────────────────────────────────────────────────── */
.fade-in { animation: fadeIn .5s ease both; }

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

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all .2s;
}

.tab:hover { color: var(--texto); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Contratos inativos ─────────────────────────────────────────────────── */
.badge-inativo { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
/* O esmaecido fica no link, e nao no .card: a animacao .fade-in do card
   termina em opacity:1 e sobrescreveria. */
.card-link-inativo { opacity: .55; filter: grayscale(.85); transition: opacity .2s ease, filter .2s ease; }
.card-link-inativo:hover { opacity: .9; filter: grayscale(.2); }
.card-inativo .card-star { filter: none; }
.inativos-secao { margin-top: 32px; }
.inativos-secao > summary { cursor: pointer; list-style: none; user-select: none; }
.inativos-secao > summary::-webkit-details-marker { display: none; }
.inativos-secao .inativos-seta { transition: transform .2s ease; }
.inativos-secao[open] .inativos-seta { transform: rotate(180deg); }
.aviso-inativo {
    display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
    padding: 10px 14px; border-radius: 10px;
    background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
    font-size: 13px;
}

/* ── TV: alternar meta mensal no grafico ────────────────────────────────── */
.tv-meta-btn { width: auto; padding: 0 12px; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tv-meta-btn.active { border-color: var(--amarelo); color: var(--amarelo); }
@media (max-width: 1100px) {
    .tv-meta-btn { width: 36px; padding: 0; }
    .tv-meta-btn span { display: none; }   /* so o icone; o title explica */
}

/* ── Logo do contrato ───────────────────────────────────────────────────── */
.logo-contrato {
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0; overflow: hidden; border-radius: 12px;
    background: linear-gradient(135deg, var(--blue), var(--accent));
    border: 1px solid var(--border);
}
/* Fundo claro atras da imagem: logo de orgao costuma ser escuro ou transparente
   e sumiria no tema escuro. */
.logo-contrato.tem-imagem { background: #fff; }
.logo-contrato img { width: 100%; height: 100%; object-fit: contain; padding: 8%; }
.logo-iniciais { color: #fff; font-weight: 800; letter-spacing: .02em; }
.logo-sm { width: 32px;  height: 32px;  border-radius: 8px; }  .logo-sm .logo-iniciais { font-size: 12px; }
.logo-md { width: 48px;  height: 48px; }                       .logo-md .logo-iniciais { font-size: 17px; }
.logo-lg { width: 64px;  height: 64px;  border-radius: 14px; } .logo-lg .logo-iniciais { font-size: 22px; }
.logo-xl { width: 96px;  height: 96px;  border-radius: 18px; } .logo-xl .logo-iniciais { font-size: 34px; }
.card-logo { display: flex; justify-content: center; margin-bottom: 8px; }
.logo-editor { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin: 8px 0 16px; }
.logo-editor-seta { color: var(--muted); }
