:root {
  color-scheme: light dark;

  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e2e4ec;
  --text: #1c1e26;
  --text-muted: #6b6f80;
  --accent: #2d6a4f;
  --accent-hover: #245a42;
  --accent-soft: #e8f3ee;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(20, 21, 26, 0.04), 0 8px 24px rgba(20, 21, 26, 0.06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151a;
    --surface: #1c1e26;
    --border: #2c2f3a;
    --text: #edeef2;
    --text-muted: #9a9db0;
    --accent: #57b98a;
    --accent-hover: #6ac89a;
    --accent-soft: #1f2e27;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.app-header {
  text-align: center;
  margin-bottom: 28px;
}

.app-header h1 {
  font-size: 1.6rem;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

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

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.card-desc {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.field {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.field input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input:invalid:not(:placeholder-shown) {
  border-color: var(--danger);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-primary {
  width: 100%;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 13px 16px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s ease, transform 0.05s ease;
}

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

.btn-primary:active {
  transform: scale(0.99);
}

.resultado {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.resultado-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.resultado-item {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.resultado-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.resultado-valor {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.resultado-nota {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.app-footer {
  text-align: center;
  margin-top: 28px;
}

.app-footer p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

@media (max-width: 420px) {
  .resultado-grid {
    grid-template-columns: 1fr;
  }
}

.field select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 420px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.btn-secondary {
  width: 100%;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--accent);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ofertas-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.oferta-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--bg);
}

.oferta-row .field {
  margin-bottom: 12px;
}

.oferta-row .field:last-child,
.oferta-row .field-row:last-child {
  margin-bottom: 0;
}

.oferta-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.oferta-row-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.btn-remove-oferta {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}

.btn-remove-oferta:hover {
  color: var(--danger);
  background: var(--accent-soft);
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  white-space: nowrap;
}

.tabla th,
.tabla td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.tabla thead th {
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg);
}

.tabla tbody tr:last-child td {
  border-bottom: none;
}

.tabla tbody tr.fila-mejor td {
  font-weight: 700;
  color: var(--accent);
}
