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

:root {
  --bg:       #fdf5f6;        /* blanco con toque rosa muy sutil — blanco predomina */
  --surface:  #ffffff;
  --border:   #f0d0d5;        /* borde rosa claro */
  --text:     #283080;        /* azul — texto principal */
  --muted:    #8b6070;        /* neutro cálido */
  --accent:   #e03530;        /* bermejón — detalles llamativos */
  --accent-h: #c42020;        /* bermejón oscuro — hover */
  --coral:    #f0607a;        /* rosa — elementos suaves, chips, tags */
  --primary:  #e03530;
  --green:    #16a34a;
  --amber:    #d97706;
  --red:      #e03530;
  --blue:     #283080;        /* azul */
  --teal:     #0d8888;        /* aguamarina — solo sobre blanco */
  --radius:   10px;
  --shadow:   0 1px 6px rgba(224,53,48,.10);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ── */
.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.app-wide {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* ── Header (blanco con línea bermejón) ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.3px;
  color: var(--text);
  text-decoration: none;
}

.logo span { color: var(--accent); }

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

.credits-badge {
  background: rgba(240,96,122,.14);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.user-email {
  color: var(--muted);
  font-size: 13px;
  display: none;
}

@media (min-width: 480px) { .user-email { display: block; } }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-p {
  padding: 20px;
}

/* ── Auth card ── */
.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.4px;
  margin-bottom: 24px;
  color: var(--text);
}

.auth-logo span { color: var(--accent); }

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

.tab {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}

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

/* ── Form ── */
.field {
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

input[type=text],
input[type=email],
input[type=password],
input[type=date],
input[type=number],
select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224,53,48,.14);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-h); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) { background: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
}

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

.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-full { width: 100%; }

/* ── Status badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-queued    { background: #f3f4f6; color: #6b7280; }
.badge-running   { background: #e6f7f7; color: var(--teal); }
.badge-completed { background: #f0fdf4; color: var(--green); }
.badge-failed    { background: #fef2f2; color: var(--red); }

/* ── Reports list ── */
.report-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.report-row:last-child { border-bottom: none; }
.report-row:hover { background: var(--bg); }

.report-info { flex: 1; min-width: 0; }
.report-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-meta  { font-size: 12px; color: var(--muted); margin-top: 2px; }

.report-right   { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.report-actions { display: flex; gap: 6px; flex-shrink: 0; }

.report-row-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }

.outlet-chip {
  font-size: 11px;
  font-weight: 500;
  background: rgba(224,53,48,.08);
  color: var(--accent);
  padding: 1px 7px;
  border-radius: 4px;
}

/* ── Tag input ── */
.tag-input-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.tag-input-row .tag-input-wrap {
  flex: 1;
  min-width: 0;
}

.tag-add-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
}

.tag-add-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tag-hint {
  font-size: 12px;
  color: var(--amber);
  margin-top: 5px;
  padding: 4px 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.tag-hint::before { content: '⚠️'; font-size: 11px; }

.tag-input-wrap {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 40px;
  cursor: text;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}

.tag-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224,53,48,.14);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(240,96,122,.13);
  color: #c42020;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 5px;
}

.tag button {
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

.tag button:hover { opacity: 1; }

.tag-input {
  border: none !important;
  box-shadow: none !important;
  padding: 2px 4px !important;
  width: auto;
  min-width: 120px;
  flex: 1;
}

/* ── Theme accordion ── */
.theme-item {
  border-bottom: 1px solid var(--border);
}

.theme-item:last-child { border-bottom: none; }

.theme-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background .1s;
}

.theme-header:hover { background: var(--bg); }

.theme-num {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.theme-title { font-weight: 500; flex: 1; }
.theme-freq  { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.theme-chevron { color: var(--muted); font-size: 12px; transition: transform .2s; }
.theme-item.open .theme-chevron { transform: rotate(90deg); }

.theme-body {
  display: none;
  padding: 0 16px 16px 48px;
}

.theme-item.open .theme-body { display: block; }

.theme-desc { color: var(--muted); margin-bottom: 12px; line-height: 1.6; }

.quotes { display: flex; flex-direction: column; gap: 8px; }

.quote {
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
  border-left: 3px solid var(--teal);
  padding-left: 10px;
  opacity: .8;
}

/* ── Pack cards ── */
.packs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.pack-card {
  padding: 20px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s;
  cursor: default;
}

.pack-card.featured {
  border-color: var(--accent);
}

.pack-card.featured .pack-name::after {
  content: 'Popular';
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  margin-left: 8px;
  vertical-align: middle;
}

.pack-name  { font-weight: 700; font-size: 15px; }
.pack-desc  { color: var(--muted); font-size: 13px; }
.pack-price { font-size: 22px; font-weight: 700; margin-top: 8px; }
.pack-price span { font-size: 13px; font-weight: 400; color: var(--muted); }
.pack-price-sub { font-size: 12px; color: var(--muted); margin-top: 2px; margin-bottom: 4px; }
.pack-trm-note  { font-size: 11px; color: var(--muted); margin-top: 12px; line-height: 1.5; }
.pack-btn   { margin-top: 12px; }

/* ── Progress steps ── */
.steps { display: flex; flex-direction: column; gap: 8px; }

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.step-done  .step-icon { background: #f0fdf4; color: var(--green); }
.step-active .step-icon { background: #e6f7f7; color: var(--teal); }
.step-wait  .step-icon { background: #f3f4f6; color: #9ca3af; }

/* ── Extraction progress bar ── */
.extraction-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.ep-bar {
  flex: 1;
  height: 4px;
  background: #f0d0d5;
  border-radius: 2px;
  overflow: hidden;
  max-width: 120px;
}

.ep-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 2px;
  transition: width .4s ease;
}

.ep-label {
  font-size: 12px;
  color: var(--teal);
  font-weight: 500;
  white-space: nowrap;
}

/* ── Analysis pulse ── */
.analysis-pulse {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.analysis-pulse::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}

/* ── Misc ── */
.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 10px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state p { margin-top: 6px; font-size: 13px; }

.alert {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 14px;
}

.alert-error   { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.alert-ok      { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
.alert-success { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }

.divider { height: 1px; background: var(--border); margin: 20px 0; }
.mt-4  { margin-top: 16px; }
.mt-2  { margin-top: 8px; }
.text-muted { color: var(--muted); }
.text-sm    { font-size: 13px; }
.flex { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
