:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e8eef5;
  --muted: #9aa8b8;
  --accent: #3d8bfd;
  --accent-dim: #2563c4;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --partial: #a78bfa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
}

.subtitle {
  max-width: 42rem;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.95rem;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.25rem;
  align-items: start;
}

.main-column {
  min-width: 0;
}

.preview-panel {
  position: sticky;
  top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  max-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
}

.preview-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.preview-selector {
  display: block;
  margin-bottom: 0.75rem;
}

.preview-selector span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.preview-selector select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

.preview-filename {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

.preview-content {
  flex: 1;
  min-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-content img {
  display: block;
  max-width: 100%;
  height: auto;
}

.preview-content iframe {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: none;
  border-radius: 8px;
}

.preview-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
    max-height: none;
    order: -1;
  }

  .preview-content iframe {
    min-height: 320px;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.upload-card .field {
  display: block;
  margin-bottom: 1rem;
}

.upload-card .field span {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="file"] {
  width: 100%;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--bg);
  color: var(--muted);
}

.btn {
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
}

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

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

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

.estado {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.error {
  border-color: var(--bad);
}

.error pre {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--bad);
  margin: 0;
  font-size: 0.85rem;
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.doc-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.doc-titulo {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.95rem;
}

.doc-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.doc-card h4 {
  margin: 1.25rem 0 0.6rem;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.resumen {
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem;
}

.campos-table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.campos-table th,
.campos-table td,
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.campos-table thead th,
.data-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.campos-table tbody th {
  font-weight: 600;
  color: var(--text);
  width: 28%;
}

.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.pill.ok {
  background: rgba(52, 211, 153, 0.2);
  color: var(--ok);
}

.pill.bad {
  background: rgba(248, 113, 113, 0.2);
  color: var(--bad);
}

.pill.partial {
  background: rgba(167, 139, 250, 0.2);
  color: var(--partial);
}

.tabla-block {
  margin-bottom: 1rem;
}

.tabla-block h4 {
  margin: 0 0 0.5rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}

.tabla-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.obs-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--warn);
  font-size: 0.9rem;
}

.muted {
  color: var(--muted);
}

.doc-badge {
  display: inline-block;
  margin-bottom: 0.5rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(61, 139, 253, 0.18);
  color: var(--accent);
}

.doc-card--estado-cuenta h4:first-of-type {
  margin-top: 1rem;
}

.resumen-cuenta {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.resumen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.resumen-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.resumen-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.resumen-valor {
  font-size: 0.92rem;
  font-weight: 600;
}

.conciliacion-totales {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.conciliacion-totales > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.conciliacion-totales span {
  font-size: 0.75rem;
  color: var(--muted);
}

.conciliacion-totales strong {
  font-size: 0.95rem;
}

.conciliacion-estado.ok strong {
  color: var(--ok);
}

.conciliacion-estado.warn strong {
  color: var(--warn);
}

.monto-cargo {
  color: var(--bad);
}

.monto-abono {
  color: var(--ok);
}

.transacciones-block {
  margin-top: 0.5rem;
}

.transacciones-table th:nth-child(4),
.transacciones-table th:nth-child(5),
.transacciones-table td:nth-child(4),
.transacciones-table td:nth-child(5),
.transacciones-table td:nth-child(6) {
  text-align: right;
  white-space: nowrap;
}

.transacciones-table td:nth-child(2) {
  min-width: 180px;
}

.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}
