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

:root {
    --bg: #f0f2f5;
    --sidebar-bg: #ffffff;
    --header-bg: #1a2332;
    --header-text: #ffffff;
    --accent: #1976d2;
    --accent-light: #e3f2fd;
    --text: #333333;
    --text-muted: #666666;
    --text-light: #999999;
    --border: #e0e0e0;
    --card-bg: #ffffff;
    --success: #2e7d32;
    --warning: #f57c00;
    --error: #c62828;
    --info: #0288d1;
    --table-stripe: #fafafa;
    --table-hover: #f0f7ff;
    --shadow: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --sidebar-width: 260px;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--header-bg);
    color: var(--header-text);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

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

.header-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-title {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.header-title span:first-child {
    font-size: 16px;
    font-weight: 700;
}

.header-title .header-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    font-weight: 400;
}

.header-info {
    margin-left: auto;
    font-size: 12px;
    color: rgba(255,255,255,0.6);
}

.header-info .header-vip {
    color: rgba(255,255,255,0.9);
    font-weight: 600;
}

.btn-logout {
    background: transparent;
    color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.3);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 12px;
}
.btn-logout:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* Login Overlay */
#login-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a237e 0%, #1565c0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}
.login-logo {
    width: 64px;
    height: 64px;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    margin: 0 auto 16px;
    letter-spacing: -1px;
}
.login-card h2 { margin: 0 0 4px; color: #333; font-size: 20px; }
.login-card .login-sub { color: #666; font-size: 13px; margin: 0 0 24px; }
.login-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    margin-bottom: 12px;
}
.login-card input:focus { border-color: var(--accent); outline: none; }
.login-card button {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.login-card button:hover { background: #1259a5; }
.login-card #login-error { color: #c62828; font-size: 13px; min-height: 18px; margin-top: 8px; }
.login-card .login-footer { color: #999; font-size: 11px; margin: 24px 0 0; }

/* Sidebar */
.sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 50;
}

.sidebar-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child { border-bottom: none; }

.sidebar-title {
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.sidebar-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
    border-left-color: var(--accent);
}

.sidebar-item .src-tags {
    margin-left: auto;
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}

.sidebar-item .src {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.3;
    letter-spacing: 0.3px;
}

.src.bpa { background: #e3f2fd; color: #1565c0; }
.src.fpo { background: #e8f5e9; color: #2e7d32; }
.src.sia { background: #fff3e0; color: #e65100; }

/* Como Funciona - stats and flow */
.stats-wrap { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.stat-box {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px 16px;
    min-width: 140px;
    flex: 1;
}
.stat-box .stat-num { font-size: 22px; font-weight: 700; color: #1976d2; }
.stat-box .stat-lbl { font-size: 11px; color: #666; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.3px; }

.flow-box {
    background: #fff;
    border: 2px solid #1976d2;
    border-radius: 8px;
    padding: 14px 18px;
    flex: 1;
    min-width: 200px;
    font-size: 12px;
    line-height: 1.8;
}
.flow-box.fonte { border-color: #f57c00; background: #fff8e1; }
.flow-box.processo { border-color: #6a1b9a; background: #f3e5f5; }
.flow-box.destino { border-color: #2e7d32; background: #e8f5e9; }
.flow-box .flow-title {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    color: #333;
}
.flow-arrow {
    font-size: 28px;
    color: #1976d2;
    font-weight: 700;
}

.sidebar-item .icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
}

/* Main Content */
.main {
    margin-left: var(--sidebar-width);
    margin-top: 56px;
    padding: 24px;
    min-height: calc(100vh - 56px);
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

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

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.card-icon.bpa { background: #e3f2fd; color: #1565c0; }
.card-icon.fpo { background: #e8f5e9; color: #2e7d32; }
.card-icon.sia { background: #fff3e0; color: #e65100; }
.card-icon.info { background: #f3e5f5; color: #7b1fa2; }

.card-title {
    font-size: 15px;
    font-weight: 600;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.card-label {
    font-size: 12px;
    color: var(--text-muted);
}

.card-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Tables */
.table-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.table-toolbar h3 {
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    max-width: 300px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

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

.table-info {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

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

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    background: #f5f7fa;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

th:hover { color: var(--accent); background: #eef2f7; }
th .sort-arrow { font-size: 10px; margin-left: 2px; }

td {
    padding: 9px 14px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

tr:nth-child(even) { background: var(--table-stripe); }
tr:hover { background: var(--table-hover); }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.pagination button {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}

.pagination button:hover:not(:disabled) {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .current-page {
    font-weight: 600;
    color: var(--accent);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

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

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

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: #e8f5e9; color: var(--success); }
.badge-warning { background: #fff3e0; color: var(--warning); }
.badge-error { background: #ffebee; color: var(--error); }
.badge-info { background: #e3f2fd; color: var(--info); }

/* Report viewer */
.report-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    overflow-x: auto;
    line-height: 1.6;
    max-height: 600px;
    overflow-y: auto;
}

/* Info page */
.info-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.info-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent);
}

.info-section ul {
    padding-left: 20px;
}

.info-section li {
    margin-bottom: 8px;
    line-height: 1.6;
}

/* Workflow */
.workflow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--accent-light);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
}

.workflow-arrow {
    font-size: 18px;
    color: var(--text-light);
}

/* Stats row */
.stats-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* Chart container */
.chart-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 24px;
}

.chart-container h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

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

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-muted);
    font-size: 14px;
}

.loading::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 12px;
}

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

/* File list */
.file-list {
    display: grid;
    gap: 8px;
}

.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 6px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--card-bg);
    border-radius: 6px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
}

.file-item:hover {
    box-shadow: var(--shadow-lg);
    background: var(--accent-light);
}

.file-item .file-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.file-item .file-name {
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item .file-meta {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    flex-shrink: 0;
}

/* Select */
select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: white;
    cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f0f0f0; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }
