:root {
    --bg: #f0f2f5;
    --card: #ffffff;
    --header-bg: #1B3A5C;
    --accent: #2E75B6;
    --text: #212529;
    --text2: #6c757d;
    --text-light: #ffffff;
    --positive: #28a745;
    --negative: #dc3545;
    --warning: #ffc107;
    --gap: 16px;
    --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
.container { max-width: 1440px; margin: 0 auto; padding: var(--gap); }

/* Upload */
#upload-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.upload-panel { background: var(--card); border-radius: 16px; padding: 48px; max-width: 680px; width: 100%; box-shadow: 0 8px 32px rgba(0,0,0,.08); text-align: center; }
.upload-panel h1 { font-size: 26px; color: var(--header-bg); margin-bottom: 4px; }
.upload-panel .subtitle { font-size: 16px; color: var(--accent); margin-bottom: 4px; }
.upload-panel > .hint { font-size: 13px; color: var(--text2); margin-bottom: 28px; }
.upload-zones { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.drop-zone { border: 2px dashed #ccc; border-radius: 12px; padding: 28px 16px; cursor: pointer; transition: all .2s; position: relative; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: rgba(46,117,182,.04); }
.drop-zone.loaded { border-color: var(--positive); border-style: solid; background: rgba(40,167,69,.04); }
.drop-zone .icon { font-size: 32px; margin-bottom: 6px; }
.drop-zone .label { font-size: 14px; font-weight: 600; color: var(--header-bg); }
.drop-zone .hint { font-size: 12px; color: var(--text2); margin-top: 4px; }
.drop-zone .filename { font-size: 12px; color: var(--positive); font-weight: 600; margin-top: 6px; }
.drop-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.status-msg { margin-top: 16px; font-size: 14px; color: var(--accent); }

/* Buttons */
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 12px 36px; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .2s; }
.btn-primary:hover { background: var(--header-bg); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3); padding: 6px 16px; border-radius: 4px; font-size: 13px; cursor: pointer; }
.btn-ghost:hover { background: rgba(255,255,255,.22); }
.btn-export { background: var(--positive); color: #fff; border: none; padding: 6px 16px; border-radius: 4px; font-size: 13px; cursor: pointer; }

/* Header */
.dash-header { background: var(--header-bg); color: var(--text-light); padding: 20px 24px; border-radius: var(--radius); margin-bottom: var(--gap); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.dash-header h1 { font-size: 20px; }
.header-sub { font-size: 12px; opacity: .7; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 4px; }
.filter-group label { font-size: 11px; color: rgba(255,255,255,.6); }
.filter-group select, .filter-group input[type="date"] { padding: 5px 8px; border: 1px solid rgba(255,255,255,.2); border-radius: 4px; background: rgba(255,255,255,.1); color: #fff; font-size: 12px; }
.filter-group select option { background: var(--header-bg); color: #fff; }

/* KPIs */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.kpi-card { background: var(--card); border-radius: var(--radius); padding: 18px 22px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.kpi-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }
.kpi-value { font-size: 28px; font-weight: 700; margin: 2px 0; }
.kpi-detail { font-size: 12px; color: var(--text2); }

/* Charts */
.chart-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.chart-card { background: var(--card); border-radius: var(--radius); padding: 20px 24px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chart-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.chart-card canvas { max-height: 280px; }

/* AI Section */
.ai-section { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: var(--gap); border: 2px solid #e8ecf1; }
.ai-header h3 { font-size: 16px; margin-bottom: 4px; }
.ai-header p { font-size: 13px; color: var(--text2); margin-bottom: 16px; }
.ai-input-row { display: flex; gap: 10px; margin-bottom: 12px; }
.ai-input { flex: 1; padding: 12px 16px; border: 2px solid #dde1e6; border-radius: 8px; font-size: 14px; transition: border-color .2s; }
.ai-input:focus { outline: none; border-color: var(--accent); }
.ai-suggestions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.ai-suggestions span { font-size: 12px; color: var(--text2); }
.chip { background: #e8ecf1; border: none; padding: 5px 12px; border-radius: 16px; font-size: 12px; cursor: pointer; transition: background .2s; color: var(--text); }
.chip:hover { background: #d0d5dd; }
.ai-chart-card { margin-top: 16px; }
.ai-explanation { background: #f0f7ff; border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 0 6px 6px 0; font-size: 13px; color: var(--header-bg); margin-bottom: 16px; }
.ai-loading { display: flex; align-items: center; gap: 10px; padding: 20px; justify-content: center; }
.spinner { width: 20px; height: 20px; border: 3px solid #dde1e6; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Table */
.table-section { background: var(--card); border-radius: var(--radius); padding: 20px 24px; box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow-x: auto; margin-bottom: var(--gap); }
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.table-header h3 { font-size: 14px; font-weight: 600; }
.table-actions { display: flex; gap: 8px; align-items: center; }
.search-input { padding: 6px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; width: 220px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table thead th { text-align: left; padding: 8px 10px; border-bottom: 2px solid #dee2e6; color: var(--text2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; cursor: pointer; user-select: none; }
.data-table thead th:hover { color: var(--text); background: #f8f9fa; }
.data-table tbody td { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; }
.data-table tbody tr:hover { background: #f8f9fa; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-a { background: #d4edda; color: #155724; }
.badge-b { background: #fff3cd; color: #856404; }
.badge-c { background: #ffe0cc; color: #c44e00; }
.badge-d { background: #f8d7da; color: #721c24; }
.badge-0 { background: #e2e3e5; color: #383d41; }
.badge-ok { background: #d4edda; color: #155724; }
.badge-cond { background: #fff3cd; color: #856404; }
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 12px; }
.pagination button { padding: 4px 10px; border: 1px solid #ddd; border-radius: 4px; background: #fff; cursor: pointer; font-size: 12px; }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination span { font-size: 12px; color: var(--text2); }

@media (max-width: 768px) {
    .upload-zones { grid-template-columns: 1fr; }
    .dash-header { flex-direction: column; align-items: flex-start; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .chart-row { grid-template-columns: 1fr; }
    .ai-input-row { flex-direction: column; }
}
