* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: #f0f2f5; color: #1a1a1a; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-container { background: #fff; padding: 2rem; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.08); width: 100%; max-width: 360px; }
.login-container h1 { margin: 0 0 .5rem; font-size: 1.5rem; }
.subtitle { color: #666; font-size: .9rem; margin-bottom: 1.5rem; }
.form-box input { display: block; width: 100%; padding: .75rem 1rem; margin-bottom: .75rem; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem; }
.form-box button { width: 100%; padding: .75rem; background: #2563eb; color: #fff; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; }
.form-box button:hover { background: #1d4ed8; }
.error { color: #dc2626; font-size: .875rem; margin-top: .5rem; }

/* Header */
.app-header { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.app-header-inner { padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.app-header h1 { margin: 0; font-size: 1.25rem; }
.user-info { font-size: .875rem; color: #666; }
.user-info button { margin-left: .5rem; padding: .25rem .5rem; font-size: .8rem; cursor: pointer; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 4px; }

/* Main */
.main { padding: 1.5rem 1.5rem; }
.block-rows { display: flex; flex-direction: column; gap: 1.5rem; }
.block-row { display: flex; gap: 1.5rem; align-items: stretch; }
.block-row .block { flex: 3 1 0; min-width: 0; margin-bottom: 0; }
.formation-cell { flex: 1 1 0; min-width: 200px; display: flex; flex-direction: column; }
.data-formation-panel { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); padding: 1.25rem; border: 1px dashed #cbd5e1; height: 100%; overflow-y: auto; box-sizing: border-box; }
.data-formation-panel--empty { display: flex; flex-direction: column; justify-content: center; }
.data-formation-panel h3 { margin: 0 0 1rem; font-size: 1rem; color: #1e293b; }
.data-formation-panel h4 { margin: 0 0 0.75rem; font-size: .9rem; color: #475569; }
.data-formation-panel .placeholder-text { font-size: .875rem; color: #94a3b8; margin: 0; font-style: italic; }
.formation-percent-list { list-style: none; margin: 0; padding: 0; }
.formation-percent-list li { display: flex; justify-content: space-between; align-items: center; padding: 0.35rem 0; font-size: .85rem; border-bottom: 1px solid #f1f5f9; }
.formation-percent-list li:last-child { border-bottom: none; }
.formation-stage { color: #475569; }
.formation-pct { font-weight: 600; color: #1e293b; }

/* Block */
.block { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 1.5rem; overflow: hidden; }
.block-header { padding: 1rem 1.25rem; background: #f8fafc; border-bottom: 1px solid #e2e8f0; font-weight: 600; font-size: 1.1rem; }
.block-filters { padding: 1rem 1.25rem; display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.period-hint { font-size: .85rem; color: #64748b; margin-right: 0.5rem; align-self: center; }
.period-hint--current { color: #059669; font-weight: 500; }
.block-filters label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: #64748b; }
.block-filters input, .block-filters select { padding: .5rem .75rem; border: 1px solid #e2e8f0; border-radius: 6px; font-size: .9rem; }
.block-filters button { padding: .5rem 1rem; background: #2563eb; color: #fff; border: none; border-radius: 6px; font-size: .9rem; cursor: pointer; }
.block-filters button.secondary { background: #64748b; }
.block-filters button:hover { opacity: .9; }
.block-content { padding: 1.25rem; }
.block-metrics { margin-bottom: 1rem; }
.report-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }
.period-desc { font-size: .875rem; color: #64748b; }
.total-badge { font-weight: 600; color: #1e293b; }
.report-table-wrap { overflow-x: auto; margin-bottom: 1rem; }
.report-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.report-table th, .report-table td { padding: .5rem .75rem; text-align: left; border: 1px solid #e2e8f0; }
.report-table th { background: #f8fafc; color: #64748b; font-weight: 500; }
.report-table .source-list { font-size: .8rem; color: #475569; max-width: 200px; white-space: normal; }
.report-table--horizontal th:first-child { min-width: 140px; background: #f8fafc; }
.report-table .total-cell { font-weight: 600; }
.report-table .error-cell { color: #dc2626; padding: 1rem; }
.report-table .loading-cell { color: #64748b; padding: 1rem; }
.extra-metrics { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #e2e8f0; }
.extra-metrics .metric { display: inline-flex; align-items: baseline; gap: 0.25rem; }
.extra-metrics .metric-label { font-size: .875rem; color: #64748b; }
.extra-metrics .metric-value { font-size: 1rem; font-weight: 600; color: #1e293b; }
.source-picker-hint { font-size: .85rem; color: #64748b; margin-left: 0.25rem; }
.source-picker-panel { margin: 1rem 0; padding: 1rem; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; max-height: 280px; overflow-y: auto; }
.source-picker-panel h4 { margin: 0 0 0.75rem; font-size: .9rem; }
.source-picker-panel .picker-desc { font-size: .8rem; color: #64748b; margin: 0 0 0.75rem; }
.source-picker-panel .picker-empty { color: #64748b; margin: 0; font-size: .9rem; }
.source-picker-panel .source-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.5rem; }
.source-picker-panel label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: .875rem; }
.source-picker-panel input[type="checkbox"] { width: 1rem; height: 1rem; }
.source-picker-panel .picker-actions { margin-top: 1rem; display: flex; gap: 0.5rem; }
.by-source { margin-top: 1rem; }
.by-source h4 { font-size: .9rem; margin: 0 0 .5rem; }
.by-source table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.by-source th, .by-source td { padding: .5rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
.by-source th { color: #64748b; font-weight: 500; }
.loading { color: #64748b; }
.error-msg { color: #dc2626; }

@media (max-width: 1280px) {
  .block-row { flex-direction: column; }
  .block-row .block { margin-bottom: 0; }
  .formation-cell { min-width: 0; }
}
