/* ── Variables ─────────────────────────────────────── */
:root {
  --bg:          #f0f2f5;
  --surface:     #ffffff;
  --border:      #dde1e7;
  --text:        #1a1d23;
  --text-muted:  #6b7280;
  --accent:      #0c2c5c;
  --accent-dark: #091f42;
  --accent-light:#e8eef7;
  --success:     #059669;
  --success-bg:  #ecfdf5;
  --error:       #dc2626;
  --error-bg:    #fef2f2;
  --warning:     #92400e;
  --warning-bg:  #fffbeb;
  --warning-border: #fcd34d;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --font:        'IBM Plex Sans', sans-serif;
  --mono:        'IBM Plex Mono', monospace;

  /* Navbar / Footer */
  --brand:       #0c2c5c;
  --brand-dark:  #091f42;
  --brand-text:  #ffffff;
  --brand-sub:   rgba(255,255,255,0.6);
  --brand-border:rgba(255,255,255,0.1);
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.6;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('/img/LOGO_VECTOR_AZUL.png');
  background-size: 140px auto;
  background-repeat: repeat;
  opacity: 0.05;
  filter: grayscale(100%);
  transform: rotate(-15deg) scale(1.3);
  pointer-events: none;
  z-index: 0;
}

body > * {
  position: relative;
  z-index: 1;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ─────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

.main-content {
  flex: 1;
  padding: 20px 0 20px;
}

/* ── Navbar ─────────────────────────────────────────── */
.navbar {
  background: var(--brand);
  border-bottom: 1px solid var(--brand-border);
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

.navbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

.navbar-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.navbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--brand-text);
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.navbar-subtitle {
  font-size: 12px;
  color: var(--brand-sub);
  letter-spacing: 0.02em;
}

/* ── Footer ─────────────────────────────────────────── */
.footer {
  background: var(--brand-dark);
  border-top: 1px solid var(--brand-border);
  padding: 18px 24px;
  text-align: center;
}

.footer-inner {
  font-size: 13px;
  color: var(--brand-sub);
}

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 32px 32px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 6px;
}

.card-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

/* ── Form ────────────────────────────────────────────── */
.form {
  padding: 28px 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.01em;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input::placeholder { color: #b0b7c3; }

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}

.form-input.has-error {
  border-color: var(--error);
}

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 7px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover  { background: var(--accent-dark); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover { background: var(--bg); }

/* ── Alerts ──────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 7px;
  font-size: 13.5px;
  line-height: 1.5;
}

.alert svg { flex-shrink: 0; margin-top: 2px; }

.alert-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #fca5a5;
  margin: 0 32px;
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
  margin-bottom: 8px;
}

/* ── Página consulta ─────────────────────────────────── */
.page-consulta {
  max-width: 480px;
  margin: 0 auto;
  animation: fadeUp 0.3s ease both;
}

/* ── Página resultado ────────────────────────────────── */
.page-resultado {
  animation: fadeUp 0.3s ease both;
}

.resultado-header {
  text-align: center;
  margin-bottom: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.status-badge.valid {
  background: var(--success-bg);
  color: var(--success);
}

.resultado-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.resultado-subtitle {
  font-size: 15px;
  max-width: 600px;
  margin: 0 auto;
  color: black;
}

.fecha-creacion {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 8px;
}

.fecha-creacion strong {
  color: var(--text);
  font-family: var(--mono);
}

/* Visor de documento */
.doc-viewer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 8px;
  height: calc(100vh - 420px);
  min-height: 340px;
}

.doc-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.doc-nota {
  font-size: 13px;
  color: black;
  text-align: center;
  margin-bottom: 12px;
}

.resultado-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Tabla fallback */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 500;
  color: var(--text-muted);
  width: 40%;
  font-family: var(--mono);
  font-size: 13px;
}

.data-table tr:last-child th,
.data-table tr:last-child td {
  border-bottom: none;
}

/* ── Página error ─────────────────────────────────────── */
.page-error {
  text-align: center;
  padding: 80px 0;
}

.error-code {
  font-size: 96px;
  font-weight: 600;
  color: var(--accent-light);
  letter-spacing: -4px;
  line-height: 1;
  margin-bottom: 12px;
}

.error-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.error-msg {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.error-detail {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 10px 16px;
  margin-bottom: 28px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  word-break: break-word;
}

/* ── Animación ───────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 520px) {
  .card-header,
  .form { padding-left: 20px; padding-right: 20px; }
  .alert-error { margin: 0 20px; }
  .resultado-title { font-size: 20px; }
  .doc-viewer { height: calc(100vh - 380px); min-height: 280px; }
}
