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

:root {
    --bg: #f5f6fa; --surface: #fff; --border: #e2e5ed;
    --text: #1a1d26; --text2: #5f6577;
    --primary: #4361ee; --primary-h: #3651d4;
    --green: #10b981; --green-bg: #ecfdf5;
    --red: #ef4444; --red-bg: #fef2f2;
    --orange: #f59e0b; --orange-bg: #fffbeb;
    --yellow: #eab308; --yellow-bg: #fefce8;
    --blue-bg: #eff6ff;
    --r: 12px; --rs: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.06);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

/* ── Header ── */
.header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px; display: flex; align-items: center; position: sticky; top: 0; z-index: 100; }
.header-inner { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 1100px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--primary); }
.nav { display: flex; gap: 4px; }
.nav-link { padding: 7px 18px; border-radius: 20px; font-size: 13px; font-weight: 600; color: var(--text2); background: none; border: none; cursor: pointer; transition: .15s; }
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--primary); color: #fff; }

/* ── Pages (SPA) ── */
.page { display: none; }
.page.active { display: block; animation: fadeUp .3s ease; }

/* ── Container & Steps ── */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.step { display: none; animation: fadeUp .3s ease; }
.step.active { display: block; }
@keyframes fadeUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

.step-header { text-align: center; margin-bottom: 32px; }
.step-badge { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; font-size: 14px; margin-bottom: 12px; }
.step-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.step-desc { color: var(--text2); font-size: 14px; }

/* ── Alert (feedback banco) ── */
.alert { padding: 12px 16px; border-radius: var(--rs); font-size: 13px; font-weight: 500; margin-bottom: 20px; }
.alert-ok { background: var(--green-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-err { background: var(--red-bg); color: #991b1b; border: 1px solid #fecaca; }

/* ── Upload ── */
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.upload-card { background: var(--surface); border: 2px dashed var(--border); border-radius: var(--r); padding: 36px 24px; text-align: center; transition: .2s; }
.upload-card.has-file { border-color: var(--primary); border-style: solid; background: var(--blue-bg); }
.upload-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.upload-hint { font-size: 12px; color: var(--text2); margin-bottom: 16px; }
.upload-icon { margin: 0 auto 16px; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.contabil-icon { background: #ede9fe; color: #7c3aed; }
.financeiro-icon { background: #d1fae5; color: #059669; }
.upload-btn { display: inline-block; padding: 10px 20px; border-radius: var(--rs); background: var(--primary); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; }
.upload-btn:hover { background: var(--primary-h); }
.file-name { display: block; margin-top: 10px; font-size: 13px; color: var(--green); font-weight: 500; min-height: 20px; }

/* ── Buttons ── */
.btn-primary, .btn-secondary { display: inline-flex; align-items: center; gap: 8px; padding: 12px 28px; border-radius: var(--rs); font-size: 14px; font-weight: 600; border: none; cursor: pointer; transition: .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-row { display: flex; justify-content: center; gap: 12px; margin-top: 28px; }
#btn-enviar { display: flex; margin: 0 auto; }
.btn-ver { padding: 5px 16px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--primary); color: #fff; border: none; cursor: pointer; }
.btn-ver:hover { background: var(--primary-h); }

/* ── Mapping ── */
.map-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: center; }
.map-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 24px; box-shadow: var(--shadow); }
.map-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--primary); }
.map-arrow { color: var(--text2); display: flex; align-items: center; justify-content: center; }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--rs); font-size: 14px; background: var(--bg); color: var(--text); appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%235f6577' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }

/* ── KPIs ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text2); margin-bottom: 4px; }
.kpi-value { font-size: 22px; font-weight: 700; }
.kpi-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.kpi.green { border-left: 3px solid var(--green); } .kpi.green .kpi-value { color: var(--green); }
.kpi.red { border-left: 3px solid var(--red); } .kpi.red .kpi-value { color: var(--red); }
.kpi.orange { border-left: 3px solid var(--orange); } .kpi.orange .kpi-value { color: var(--orange); }
.kpi.blue { border-left: 3px solid var(--primary); } .kpi.blue .kpi-value { color: var(--primary); }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 4px; margin-bottom: 16px; }
.tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 8px; border: none; background: transparent; border-radius: var(--rs); font-size: 13px; font-weight: 500; color: var(--text2); cursor: pointer; transition: .15s; }
.tab.active { background: var(--primary); color: #fff; }
.tab-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-red { background: var(--red); } .dot-orange { background: var(--orange); }
.dot-yellow { background: var(--yellow); } .dot-green { background: var(--green); }
.tab.active .dot-red, .tab.active .dot-orange, .tab.active .dot-yellow, .tab.active .dot-green { background: rgba(255,255,255,.6); }
.tab-count { background: rgba(0,0,0,.08); padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.tab.active .tab-count { background: rgba(255,255,255,.2); }

/* ── Table ── */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.table-empty { padding: 40px 20px; text-align: center; color: var(--text2); font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--bg); }
th { padding: 11px 14px; text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover { background: #f8f9fd; }
td.val-pos { color: var(--green); font-weight: 600; }
td.val-neg { color: var(--red); font-weight: 600; }
.badge-status { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-div { background: var(--red-bg); color: var(--red); }
.badge-sc { background: var(--orange-bg); color: var(--orange); }
.badge-sf { background: var(--yellow-bg); color: var(--yellow); }
.badge-ok { background: var(--green-bg); color: var(--green); }

/* ── Modal ── */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal-bg.hidden { display: none; }
.modal { background: var(--surface); border-radius: var(--r); width: 100%; max-width: 920px; max-height: 85vh; overflow-y: auto; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border: none; background: var(--bg); border-radius: 50%; font-size: 20px; cursor: pointer; color: var(--text2); display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--border); }

/* ── Loading ── */
.loading { position: fixed; inset: 0; background: rgba(245,246,250,.88); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 999; }
.loading.hidden { display: none; }
.spinner { width: 38px; height: 38px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { font-size: 14px; color: var(--text2); font-weight: 500; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .upload-grid { grid-template-columns: 1fr; }
    .map-grid { grid-template-columns: 1fr; }
    .map-arrow { transform: rotate(90deg); }
    .tabs { flex-wrap: wrap; }
    .tab { font-size: 11px; padding: 8px 4px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .container { padding: 20px 16px; }
    .modal { padding: 16px; }
}
