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

body {
  font-family: 'DM Sans', sans-serif;
  background: #f7f5f0;
  color: #1a1612;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
.app-header {
  padding: 1.1rem 2rem;
  border-bottom: 1.5px solid #e8d9b0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 38px; height: 38px;
  background: #c9851a;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
  flex-shrink: 0;
}
.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 21px; font-weight: 600; color: #1a1612;
}
.logo-sub { font-size: 10px; color: #a08040; letter-spacing: 0.1em; }
.badge {
  background: #fff7e6;
  border: 1.5px solid #e0a030;
  color: #b07010;
  font-size: 11px; padding: 4px 14px;
  border-radius: 20px; letter-spacing: 0.08em; font-weight: 500;
  flex-shrink: 0;
}

/* ── TABS ── */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1.5px solid #e8d9b0;
}
.tab-btn {
  padding: 10px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px; font-weight: 500;
  color: #888070; background: transparent;
  border: none; border-bottom: 2.5px solid transparent;
  cursor: pointer; transition: all 0.18s; letter-spacing: 0.02em;
}
.tab-btn:hover { color: #c9851a; }
.tab-btn.active { color: #c9851a; border-bottom-color: #c9851a; }

.tab-panel { display: none; flex: 1; flex-direction: column; }
.tab-panel.active { display: flex; }

/* ── MAIN LAYOUT ── */
.main {
  display: grid;
  grid-template-columns: 340px 1fr;
  flex: 1;
  min-height: calc(100vh - 112px);
}

/* ── SIDEBAR ── */
.sidebar {
  border-right: 1.5px solid #e8d9b0;
  padding: 1.1rem 1.1rem 2rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.1rem;
  background: #ffffff;
  max-height: calc(100vh - 112px);
  position: sticky;
  top: 112px;
  align-self: start;
}

.section-block { display: flex; flex-direction: column; gap: 7px; }
.section-label {
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: #c9851a; font-weight: 600;
}
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-group label { font-size: 12px; color: #555045; font-weight: 500; }

select, input[type="text"], textarea {
  background: #fdfaf4;
  border: 1.5px solid #ddd0a0;
  border-radius: 8px;
  color: #1a1612;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 8px 11px;
  width: 100%; outline: none;
  transition: border-color 0.2s;
}
select:focus, input:focus, textarea:focus { border-color: #c9851a; }
select option { background: #fff; color: #1a1612; }
textarea { resize: vertical; min-height: 65px; line-height: 1.5; }

.divider { height: 1.5px; background: #ede4c8; flex-shrink: 0; }

/* ── POLO BUTTONS ── */
.polo-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.polo-btn {
  padding: 9px; border-radius: 8px;
  border: 1.5px solid #ccc0a0;
  background: #fdfaf4; color: #333;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.18s; text-align: center;
}
.polo-btn:hover,
.polo-btn.active-autor,
.polo-btn.active-reu {
  background: #c9851a; border-color: #a86a10; color: #fff; font-weight: 600;
}

/* ── LITERATURA ── */
.lit-counter { font-size: 11px; color: #a08040; text-align: right; }
.link-row { display: flex; gap: 6px; align-items: center; }
.link-row input { flex: 1; }

.btn-add-link {
  padding: 8px 14px; background: #1a1612;
  border: 1.5px solid #1a1612; border-radius: 8px;
  color: #fff; font-size: 20px; line-height: 1;
  cursor: pointer; transition: all 0.18s; font-weight: 600;
}
.btn-add-link:hover { background: #c9851a; border-color: #c9851a; }
.btn-add-link:disabled { background: #ccc; border-color: #ccc; cursor: not-allowed; }

.btn-add-pdf {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 8px 12px;
  background: #fdfaf4; border: 1.5px dashed #c9a84c;
  border-radius: 8px; color: #8a6010;
  font-family: 'DM Sans', sans-serif; font-size: 12px;
  cursor: pointer; transition: all 0.18s; font-weight: 500;
}
.btn-add-pdf:hover { background: #fff7e6; border-color: #c9851a; color: #c9851a; }
.btn-add-pdf:disabled { opacity: 0.45; cursor: not-allowed; }

.sources-list { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; }
.source-chip {
  display: flex; align-items: center; gap: 6px;
  background: #fff7e6; border: 1px solid #e0c070;
  border-radius: 7px; padding: 5px 9px;
  font-size: 11px; color: #8a5e10;
}
.source-chip.pdf-chip { background: #fff4f0; border-color: #e8b0a0; color: #8a3010; }
.source-chip span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-remove {
  background: none; border: none; color: #c0a060;
  cursor: pointer; font-size: 13px; padding: 0; line-height: 1;
}
.source-remove:hover { color: #c0320a; }

.link-status { font-size: 11px; padding: 4px 9px; border-radius: 6px; }
.link-status.loading { background: #fff7e6; color: #b07010; border: 1px solid #e0c070; }
.link-status.ok { background: #f0fae8; color: #4a8a20; border: 1px solid #90c060; }
.link-status.err { background: #fdf0e8; color: #c04010; border: 1px solid #e0a080; }

/* ── QUANTITY ── */
.qty-row { display: flex; align-items: center; gap: 10px; }
.qty-row input[type=range] { flex: 1; accent-color: #c9851a; }
.qty-label { font-size: 13px; font-weight: 600; color: #c9851a; min-width: 32px; text-align: right; }
.qty-hint { font-size: 11px; color: #a09070; }

/* ── GERAR BUTTON ── */
.btn-gerar {
  width: 100%; padding: 12px;
  background: #1a1612; border: 1.5px solid #1a1612;
  border-radius: 10px; color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px; font-weight: 500;
  cursor: pointer; letter-spacing: 0.04em; transition: all 0.18s;
}
.btn-gerar:hover { background: #c9851a; border-color: #c9851a; }
.btn-gerar:active { background: #a86a10; border-color: #a86a10; }
.btn-gerar:disabled {
  background: #e8e4dc; border-color: #d8d0bc; color: #b0a888; cursor: not-allowed;
}
.btn-gerar:disabled:hover { background: #e8e4dc; border-color: #d8d0bc; color: #b0a888; }

/* ── CONTENT AREA ── */
.content-area {
  padding: 1.75rem; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.4rem;
  background: #f7f5f0;
}

.welcome-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1; gap: 12px; text-align: center; padding: 3rem 2rem;
}
.welcome-icon { font-size: 52px; opacity: 0.35; }
.welcome-state h2 {
  font-family: 'Playfair Display', serif;
  font-size: 22px; font-weight: 400; color: #1a1612;
}
.welcome-state p { font-size: 13px; color: #8a8070; max-width: 320px; line-height: 1.65; }

.loading-state {
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1; gap: 1.5rem;
}
.loading-spinner {
  width: 40px; height: 40px;
  border: 2px solid #e8d9b0; border-top-color: #c9851a;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: #a08040; letter-spacing: 0.04em; }

.result-state { display: none; flex-direction: column; gap: 1.4rem; }

/* ── RESULT CARDS ── */
.result-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  background: #fff; padding: 1.2rem 1.4rem;
  border-radius: 12px; border: 1.5px solid #e8d9b0;
  flex-wrap: wrap;
}
.result-title { font-family: 'Playfair Display', serif; font-size: 19px; color: #1a1612; }
.result-desc { font-size: 12px; color: #8a8070; margin-top: 4px; }
.result-actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn-action {
  padding: 8px 15px; background: #1a1612;
  border: 1.5px solid #1a1612; border-radius: 8px;
  color: #fff; font-family: 'DM Sans', sans-serif;
  font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: all 0.18s;
}
.btn-action:hover { background: #c9851a; border-color: #c9851a; }
.btn-action.secondary { background: #fff; border-color: #ccc0a0; color: #333; }
.btn-action.secondary:hover { background: #c9851a; border-color: #c9851a; color: #fff; }
.btn-action.danger { background: #a03010; border-color: #a03010; }
.btn-action.danger:hover { background: #c04010; border-color: #c04010; }

.strategy-strip {
  background: #fff7e6; border: 1.5px solid #e0c070;
  border-left: 4px solid #c9851a; border-radius: 10px;
  padding: 1rem 1.2rem; font-size: 13px; color: #5a4010; line-height: 1.65;
}
.strategy-strip strong { color: #c9851a; font-weight: 600; }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #6a6050; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

.quesitos-list { display: flex; flex-direction: column; gap: 9px; }
.quesito-item {
  background: #fff; border: 1.5px solid #e8e0cc;
  border-radius: 10px; padding: 1rem 1.2rem;
  display: flex; gap: 1rem; align-items: flex-start;
  animation: fadeUp 0.35s ease both; transition: border-color 0.2s, box-shadow 0.2s;
}
.quesito-item:hover { border-color: #c9851a; box-shadow: 0 2px 10px rgba(201,133,26,0.08); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.quesito-num {
  font-family: 'Playfair Display', serif; font-size: 20px;
  color: #e0c080; min-width: 26px; font-weight: 400; line-height: 1.2;
}
.quesito-content { flex: 1; }
.quesito-text { font-size: 13.5px; color: #1a1612; line-height: 1.65; margin-bottom: 4px; }
.quesito-rationale { font-size: 11px; color: #a09070; line-height: 1.5; font-style: italic; }
.quesito-ref { font-size: 11px; color: #5a7a9a; line-height: 1.5; margin-top: 3px; }

.quesito-tag {
  font-size: 10px; padding: 3px 9px; border-radius: 20px;
  letter-spacing: 0.06em; text-transform: uppercase;
  align-self: flex-start; margin-top: 2px; white-space: nowrap; font-weight: 600;
}
.tag-estrategico { background: #fff3d6; border: 1.5px solid #e0a830; color: #9a6800; }
.tag-tecnico { background: #f0f4ff; border: 1.5px solid #a0b4e8; color: #2a4090; }
.tag-literatura { background: #f0faff; border: 1.5px solid #80c0e0; color: #1a6080; }
.tag-desfavoravel { background: #fff0ec; border: 1.5px solid #e08060; color: #a03010; }

.error-box {
  background: #fff0ec; border: 1.5px solid #e08060;
  border-radius: 10px; padding: 1rem 1.2rem;
  font-size: 13px; color: #a03010;
}

/* ── BACKUP TAB ── */
.backup-area {
  padding: 1.75rem; flex: 1;
  display: flex; flex-direction: column; gap: 1.4rem;
  overflow-y: auto; background: #f7f5f0;
  max-width: 900px; margin: 0 auto; width: 100%;
}
.backup-header {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.backup-title { font-family: 'Playfair Display', serif; font-size: 20px; color: #1a1612; }
.backup-actions { display: flex; gap: 8px; }

.backup-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  background: #fff; border: 1.5px solid #e8d9b0;
  border-radius: 10px; padding: 1rem; text-align: center;
}
.stat-num { font-family: 'Playfair Display', serif; font-size: 28px; color: #c9851a; font-weight: 400; }
.stat-label { font-size: 11px; color: #a09070; margin-top: 2px; }

.backup-search {
  width: 100%; padding: 10px 14px;
  background: #fff; border: 1.5px solid #ddd0a0;
  border-radius: 8px; font-family: 'DM Sans', sans-serif;
  font-size: 13px; color: #1a1612; outline: none; transition: border-color 0.2s;
}
.backup-search:focus { border-color: #c9851a; }

.backup-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1; gap: 10px; text-align: center; padding: 3rem; color: #a09070;
}
.backup-empty-icon { font-size: 44px; opacity: 0.3; }
.backup-empty p { font-size: 13px; line-height: 1.6; max-width: 280px; }

.backup-group {
  background: #fff; border: 1.5px solid #e8d9b0;
  border-radius: 12px; overflow: hidden;
}
.backup-group-header {
  padding: 10px 16px; background: #fff7e6;
  border-bottom: 1px solid #e8d9b0;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 6px;
}
.backup-group-title { font-size: 12px; font-weight: 600; color: #8a5e10; }
.backup-group-meta { font-size: 11px; color: #b09060; }

.backup-quesito {
  padding: 10px 16px; border-bottom: 1px solid #f0e8d0;
  display: flex; gap: 10px; align-items: flex-start; transition: background 0.15s;
}
.backup-quesito:last-child { border-bottom: none; }
.backup-quesito:hover { background: #fffbf2; }
.backup-quesito-num { font-family: 'Playfair Display', serif; font-size: 16px; color: #e0c080; min-width: 22px; }
.backup-quesito-text { font-size: 13px; color: #1a1612; line-height: 1.55; flex: 1; }
.backup-copy-btn {
  padding: 3px 9px; background: transparent;
  border: 1px solid #ddd0a0; border-radius: 6px;
  font-size: 11px; color: #888070;
  cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.backup-copy-btn:hover { background: #c9851a; border-color: #c9851a; color: #fff; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .main { grid-template-columns: 1fr; }
  .sidebar {
    position: static; max-height: none;
    border-right: none; border-bottom: 1.5px solid #e8d9b0;
  }
  .app-header { padding: 1rem; }
  .logo-text { font-size: 18px; }
  .logo-sub { display: none; }
  .backup-stats { grid-template-columns: repeat(3, 1fr); }
}
