* {
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 30px;
}

.form-section, .data-section {
    margin-bottom: 30px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    flex: 1 1 200px;
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

input, select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background-color 0.3s;
    margin-right: 10px;
}

button:hover {
    background-color: #2980b9;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f2f2f2;
    font-weight: 600;
}

tr:hover {
    background-color: #f9f9f9;
}

.actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.export-btn {
    background-color: #27ae60;
}

.export-btn:hover {
    background-color: #219653;
}

.primary-save {
    background-color: var(--primary-color);
    font-size: 18px;
    padding: 14px 24px;
    box-shadow: var(--shadow-light);
}
.primary-save:hover {
    background-color: var(--primary-dark);
}

.refresh-btn {
    background-color: #3498db;
}

.refresh-btn:hover {
    background-color: #2980b9;
}

.clear-btn {
    background-color: #e74c3c;
}

.clear-btn:hover {
    background-color: #c0392b;
}

.hidden {
    display: none;
}

.notification {
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
    text-align: center;
}

.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.empty-message {
    text-align: center;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 4px;
    color: #666;
}

/* ===== Migrated from templates/index.html ===== */
:root {
    --primary-color: #2ecc71;
    --primary-dark: #27ae60;
    --primary-light: #e8f5e9;
    --secondary-color: #3498db;
    --secondary-dark: #2980b9;
    --accent-color: #e74c3c;
    --text-dark: #2c3e50;
    --text-medium: #34495e;
    --text-light: #7f8c8d;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #e3eaf5;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-light: 0 2px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-sm: 4px;
    --transition: all 0.3s ease;
}

/* Tipografia e layout básico */
h1, h2, h3, h4, h5, h6 { font-weight: 600; margin-bottom: 0.5rem; line-height: 1.3; }
.section-title { margin: 20px 0 15px; color: var(--text-dark); font-size: 1.4rem; padding-bottom: 8px; border-bottom: 1px solid var(--border-color); }
.subsection-title { margin: 15px 0 10px; color: var(--text-medium); font-size: 1.1rem; font-weight: 500; }
.note { font-size: 0.85rem; color: var(--text-light); margin-top: 4px; display: block; }

.container { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; background: var(--bg-white); box-shadow: var(--shadow-light); margin-bottom: 20px; border-radius: var(--radius); }
.logo-container { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 32px; color: var(--primary-color); }
.title { margin: 0; font-size: 1.6rem; font-weight: 700; color: var(--text-dark); }
.subtitle { margin: 2px 0 6px; font-size: 0.9rem; color: var(--text-light); }
.partner-logos { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.8rem; color: var(--text-light); }
.user-actions { display: flex; align-items: center; gap: 12px; }
.user-badge { display: inline-flex; align-items: center; gap: 8px; background: var(--primary-light); color: var(--text-dark); padding: 8px 12px; border-radius: var(--radius); margin-right: 8px; cursor: pointer; transition: var(--transition); }
.user-badge:hover { background: var(--primary-color); color: white; }
.user-badge .name { font-weight: 600; }
.user-menu { position: relative; }
.user-dropdown { position: absolute; right: 0; top: 100%; margin-top: 6px; background: var(--bg-white); border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: var(--shadow); display: none; min-width: 200px; z-index: 1000; overflow: hidden; }
.user-dropdown a { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: var(--text-dark); text-decoration: none; transition: var(--transition); }
.user-dropdown a:hover { background: var(--primary-light); }
.btn { border: none; background: var(--bg-light); padding: 8px 12px; border-radius: var(--radius); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: var(--transition); font-weight: 500; }
.btn:hover { background: var(--secondary-color); color: white; }
.btn-primary { background: var(--primary-color); color: blue; }
.btn-primary:hover { background: var(--primary-dark); }
.main-content { display: grid; grid-template-columns: 240px 1fr; gap: 20px; margin-bottom: 30px; }
.sidebar { background: var(--bg-white); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-light); height: fit-content; position: sticky; top: 20px; }
.sidebar-menu { list-style: none; padding: 0; margin: 0; }
.sidebar-menu .menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); color: var(--text-dark); text-decoration: none; transition: var(--transition); margin-bottom: 4px; }
.sidebar-menu .menu-item.active, .sidebar-menu .menu-item:hover { background: var(--primary-light); color: var(--primary-dark); }
.content-area { background: var(--bg-white); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-light); }
footer { margin-top: 30px; font-size: 0.85rem; color: var(--text-light); text-align: center; padding: 16px; border-top: 1px solid var(--border-color); }

/* Formulários */
.form-section { padding: 0; }
.form-row { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 200px; }
label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-medium); }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 14px; transition: var(--transition); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.2); }
input[readonly] { background-color: #f5f5f5; color: var(--text-light); }

/* Tabelas */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 16px 0; border-radius: var(--radius-sm); border: 1px solid var(--border-color); max-height: 60vh; overflow-y: auto; }
.compact-table { width: 100%; border-collapse: collapse; }
.compact-table th, .compact-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border-color); }
.compact-table th { background: var(--bg-light); font-weight: 600; color: var(--text-medium); position: sticky; top: 0; }
.compact-table tr:hover { background: var(--primary-light); }
.compact-table td.num { text-align: right; }
.compact-table input.table-input { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid #ddd; border-radius: 3px; }

/* Abas */
.tab-nav { display: flex; gap: 8px; margin: 20px 0; justify-content: center; border-bottom: 1px solid var(--border-color); padding-bottom: 0; }
.tab-button { padding: 10px 20px; border: none; background: transparent; color: var(--text-light); cursor: pointer; border-radius: var(--radius) var(--radius) 0 0; transition: var(--transition); font-weight: 500; position: relative; bottom: -1px; }
.tab-button.active { background: var(--bg-white); color: var(--primary-color); border-bottom: 2px solid var(--primary-color); }
.tab-button:hover:not(.active) { color: var(--text-medium); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Controles de grade */
.grid-controls { display: flex; gap: 10px; align-items: center; margin: 16px 0; flex-wrap: wrap; justify-content: space-between; }
.grid-left, .grid-right { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid-right { margin-left: auto; }
/* Horizontal scroll for wide tables */
.table-responsive { overflow-x: auto; }
.compact-table { width: max-content; }

/* Modal (popup planilha) */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center; z-index: 2000; }
.modal:not(.hidden) { display: flex; }
.modal-content { background: var(--bg-white); width: 95vw; max-width: 1600px; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border-color); }
.modal-body { padding: 12px; max-height: 78vh; overflow: auto; }
.modal-body table { width: max-content; }
.modal-actions { display: flex; gap: 8px; }
.grid-controls input { padding: 8px 12px; width: 220px; flex: 1; min-width: 200px; }
.sortable { cursor: pointer; position: relative; padding-right: 20px !important; }
.sortable:after { content: "↕"; position: absolute; right: 8px; color: var(--text-light); font-size: 12px; }

/* Gráficos e visualizações */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 20px; margin-top: 20px; }
.chart-box { border: 1px solid var(--border-color); border-radius: var(--radius); padding: 16px; background: var(--bg-white); box-shadow: var(--shadow-light); }
.chart-title { font-size: 1rem; color: var(--text-dark); margin-bottom: 10px; font-weight: 600; }
.viz-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.viz-card { background: var(--bg-white); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-light); text-align: center; }
.viz-metric { font-weight: 700; font-size: 1.5rem; color: var(--primary-color); }

/* Tela de autenticação */
.auth-screen { position: fixed; inset: 0; background: rgba(17,24,39,0.7); display: flex; align-items: center; justify-content: center; z-index: 9999; backdrop-filter: blur(4px); }
.auth-card { background: var(--bg-white); border-radius: var(--radius); padding: 24px; width: 380px; max-width: 90vw; box-shadow: var(--shadow); }
.auth-card h2 { margin: 0 0 16px; text-align: center; color: var(--text-dark); }
.auth-card h3 { margin: 16px 0 10px; font-size: 1rem; color: var(--text-medium); }
.auth-card form { display: grid; gap: 12px; }
.auth-card input { padding: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.auth-card button { padding: 12px; border: none; background: var(--primary-color); color: var(--bg-white); border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; transition: var(--transition); }
.auth-card button:hover { background: var(--primary-dark); }
.auth-sep { text-align: center; font-size: 0.9rem; color: var(--text-light); margin: 12px 0; position: relative; }
.auth-sep:before { content: ""; position: absolute; left: 0; top: 50%; width: 45%; height: 1px; background: var(--border-color); }
.auth-sep:after { content: ""; position: absolute; right: 0; top: 50%; width: 45%; height: 1px; background: var(--border-color); }
.auth-note { font-size: 0.85rem; color: var(--text-light); margin-top: 12px; text-align: center; }

/* Notificações (mais específicas para sobrescrever globais) */
.notification { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.notification.success { background: var(--primary-light); color: var(--primary-dark); border: 1px solid var(--primary-color); }
.notification.error { background: #ffeaea; color: #c0392b; border: 1px solid #e74c3c; }
.notification.info, .notification.neutral { background: var(--bg-light); color: var(--text-medium); border: 1px solid var(--border-color); }
.notification.hidden { display: none; }

/* Botões de ação */
.actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.actions button { padding: 12px 20px; border: none; border-radius: var(--radius); cursor: pointer; font-weight: 600; transition: var(--transition); }
.actions button[type="submit"] { background: var(--primary-color); color: white; }
.actions button[type="submit"]:hover { background: var(--primary-dark); }
.actions button[type="button"] { background: var(--bg-light); color: var(--text-medium); }
.actions button[type="button"]:hover { background: var(--secondary-color); color: white; }

/* Estados visuais */
.inline { display: inline-block; margin-right: 12px; }
.empty-message { text-align: center; padding: 40px 20px; color: var(--text-light); font-style: italic; }
.hidden { display: none !important; }

/* Responsividade */
@media (min-width: 1400px) { .content-area { width: 100%; } }
@media (max-width: 1024px) {
    .main-content { grid-template-columns: 1fr; }
    .sidebar { order: -1; position: static; }
    .content-area { width: 100%; }
}
@media (max-width: 768px) {
    body { font-size: 13px; }
    .container { padding: 0 12px; }
    header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .user-actions { width: 100%; justify-content: space-between; }
    .content-area { padding: 16px; }
    .form-row { flex-direction: column; gap: 12px; }
    .form-group { flex: 1 1 100%; }
    .charts { grid-template-columns: 1fr; }
    .viz-summary { grid-template-columns: 1fr; }
    .grid-controls { flex-direction: column; align-items: stretch; }
    .grid-controls input { width: 100%; }
    .tab-nav { flex-wrap: wrap;}
    .tab-button { flex: 1; text-align: center; min-width: 120px; }
    .actions { flex-direction: column; }
    .actions button { width: 100%; }
}
@media (max-width: 480px) {
    .sidebar-menu .menu-item span { display: none; }
    .sidebar-menu .menu-item { justify-content: center; padding: 12px; }
    .sidebar { padding: 12px; }
    .partner-logos { display: none; }
    .tab-button { padding: 8px 12px; font-size: 0.9rem; }
}
/* Largura fixa e fonte menor para a planilha dinâmica */
#tab-grid .table-responsive.fixed-grid-width {
  width: 1100px;
  max-width: 1100px;
  overflow-x: auto;
}
#tab-grid .compact-table {
  font-size: 13px;
}
#tab-grid .compact-table th,
#tab-grid .compact-table td {
  padding: 8px 10px;
}

/* Largura reduzida para o formulário da primeira aba */
#tab-form .form-section,
#tab-form #analysisForm {
  max-width: 860px; /* ajuste conforme desejado (ex.: 720px, 960px) */
  margin: 0 auto;   /* centraliza dentro da área de conteúdo */
}

/* Garantir que em telas pequenas ocupe toda a largura disponível */
@media (max-width: 768px) {
  #tab-form .form-section,
  #tab-form #analysisForm {
    max-width: 100%;
    margin: 0 auto;
  }
}
.app-landing { max-width: 1100px; margin: 0 auto; padding: 24px; }
.landing-header { display:flex; align-items:baseline; justify-content:space-between; margin-bottom:16px; }
.landing-sub { color:#555; font-size:14px; }
.cards-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap:16px; }
.app-card { background:#fff; border:1px solid #e5e7eb; border-radius:12px; padding:16px; box-shadow: var(--shadow-light); display:flex; flex-direction:column; align-items:flex-start; }
.app-card .card-icon { font-size:28px; color: var(--primary-color); margin-bottom:8px; }
.app-card .card-title { font-size:18px; font-weight:600; margin-bottom:6px; }
.app-card .card-desc { font-size:14px; color:#666; margin-bottom:12px; }
.app-card .card-action { display:inline-block; padding:10px 14px; border-radius:8px; background: var(--primary-color); color:#fff; text-decoration:none; }
.app-card .card-action:hover { background: var(--primary-dark); }
.app-card.disabled { opacity: 0.6; }
.app-card.disabled .card-action { background:#999; cursor:not-allowed; }