:root {
  --bg: #f6efe5;
  --surface: rgba(255, 252, 246, 0.95);
  --card: #fffdf9;
  --line: #ead9c6;
  --ink: #30251e;
  --muted: #6c5b50;
  --accent: #c96f49;
  --accent-dark: #a95a38;
  --ok: #2d7d4e;
  --shadow: 0 18px 44px rgba(94, 65, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Nunito", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(232, 201, 166, 0.38), transparent 28%),
    linear-gradient(180deg, #f8f0e6 0%, var(--bg) 100%);
}

h1,
h2,
.stat-card strong,
.badge {
  font-family: "Fraunces", serif;
}

.page-header,
.page {
  width: min(1140px, calc(100% - 32px));
  margin: 0 auto;
}

.page-header {
  padding: 34px 0 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-dark);
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(2.4rem, 4vw, 4.2rem);
  line-height: 1.06;
}

h2 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.intro,
.panel p,
.hero p,
label,
th,
td,
.helper,
.download-item span {
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--muted);
}

.page-header > div {
  max-width: 920px;
}

.badge {
  padding: 14px 20px;
  border-radius: 999px;
  background: #f2dfcd;
  box-shadow: var(--shadow);
  font-size: 1.2rem;
}

.notice,
.hero,
.panel,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.notice {
  padding: 16px 20px;
  margin-bottom: 18px;
}

.notice p,
.notice strong {
  margin: 0;
}

.hero {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
}

.inline-path {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #fff5e8;
  color: var(--ink);
}

.editable-path-form {
  margin-top: 12px;
}

.editable-link-input {
  width: 100%;
  padding: 15px 16px;
  border: 2px solid #efdcc8;
  border-radius: 16px;
  background: #fff7ee;
  color: var(--ink);
  font: inherit;
  font-size: 1.08rem;
}

.editable-link-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(201, 111, 73, 0.12);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 22px;
}

.wide-gap {
  align-items: start;
}

.panel {
  padding: 24px;
}

.link-panel {
  margin-bottom: 22px;
}

.external-link-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  border-radius: 20px;
  background: #fff8f0;
  border: 1px solid var(--line);
}

.external-link-box span {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
  word-break: break-all;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
  margin-bottom: 28px;
}

.stat-card {
  padding: 22px;
}

.stat-card span {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 2.6rem;
}

.stack {
  display: grid;
  gap: 14px;
}

select,
input[type="file"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  font: inherit;
  background: #fffdf9;
  color: var(--ink);
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 16px 26px;
  background: var(--accent);
  color: white;
  font-size: 1.08rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.button:hover,
.button:focus-visible {
  background: var(--accent-dark);
  outline: none;
}

.button.secondary {
  background: #f0dfcd;
  color: var(--ink);
}

.ruc-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ruc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #fff8f0;
  border: 1px solid var(--line);
}

.ruc-item input {
  width: 22px;
  height: 22px;
}

.ruc-item span {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink);
}

.download-list {
  display: grid;
  gap: 12px;
}

.download-item {
  padding: 14px 16px;
  border-radius: 18px;
  background: #fff8f0;
}

.download-item strong,
.download-item span {
  display: block;
}

.table-wrap {
  display: block;
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, #fffdf9 0%, #fff8f1 100%);
  max-width: 100%;
  width: min(100%, calc(10 * 140px));
  max-height: 560px;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
  margin-inline: auto;
  padding-bottom: 6px;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 16px;
}

.search-box {
  display: grid;
  gap: 8px;
  flex: 1;
  font-weight: 700;
  color: var(--ink);
}

.search-box span {
  font-size: 0.98rem;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.search-box input {
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdf9;
  font: inherit;
  color: var(--ink);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(201, 111, 73, 0.12);
}

.table-note {
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff8f0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

table {
  width: calc(var(--column-count, 10) * 140px);
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
}

th,
td {
  min-width: 150px;
  padding: 16px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid rgba(234, 217, 198, 0.55);
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
  line-height: 1.55;
}

th:last-child,
td:last-child {
  border-right: 0;
}

th {
  position: sticky;
  top: 0;
  background: #f6eadc;
  color: var(--ink);
  font-weight: 800;
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  z-index: 2;
}

tbody tr:nth-child(even) td {
  background: rgba(255, 248, 240, 0.7);
}

tbody tr:hover td {
  background: #fff1df;
}

.cell-soft {
  display: inline-flex;
  align-items: flex-start;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff8ef;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 118px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.status-ok {
  background: rgba(45, 125, 78, 0.14);
  color: var(--ok);
}

.status-pending {
  background: rgba(201, 111, 73, 0.16);
  color: var(--accent-dark);
}

.status-missing {
  background: rgba(150, 76, 56, 0.12);
  color: #8f4d36;
}

.empty-text {
  margin: 0;
}

.table-wrap::-webkit-scrollbar {
  height: 14px;
  width: 14px;
}

.table-wrap::-webkit-scrollbar-track {
  background: #f1e4d3;
  border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #c98b63;
  border-radius: 999px;
  border: 2px solid #f1e4d3;
}

.pretty-table td[data-label="RUC_EMISOR"],
.pretty-table td[data-label="SERIE"],
.pretty-table td[data-label="NUMERO"],
.pretty-table td[data-label="INTENTOS"] {
  white-space: nowrap;
}

.success-button {
  background: linear-gradient(135deg, #24bb55, #17a847);
}

.success-button:hover,
.success-button:focus-visible {
  background: linear-gradient(135deg, #1faa4b, #14913c);
}

.generated-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
  padding: 22px 24px;
  border-radius: 24px;
  background: linear-gradient(135deg, #2850c5, #4176f0);
  box-shadow: 0 18px 40px rgba(51, 88, 191, 0.22);
}

.summary-metric {
  display: grid;
  gap: 4px;
  align-content: center;
  color: white;
}

.summary-metric strong {
  font-size: 2.3rem;
  font-weight: 800;
  line-height: 1;
}

.summary-metric span {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
}

.download-excel-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 18px 24px;
  border-radius: 18px;
  background: #ffffff;
  color: #2850c5;
  font-size: 1.2rem;
  font-weight: 800;
  text-decoration: none;
  align-self: center;
}

@media (max-width: 920px) {
  .page-header,
  .hero,
  .grid-two,
  .stats,
  .ruc-list,
  .table-toolbar {
    grid-template-columns: 1fr;
  }

  .page-header,
  .hero {
    display: grid;
  }

  .stats {
    display: grid;
  }

  .table-toolbar {
    display: grid;
    align-items: stretch;
  }

  .generated-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .pretty-table table,
  .pretty-table thead,
  .pretty-table tbody,
  .pretty-table th,
  .pretty-table td,
  .pretty-table tr {
    display: block;
  }

  .pretty-table thead {
    display: none;
  }

  .pretty-table tbody {
    display: grid;
    gap: 14px;
    padding: 12px;
  }

  .pretty-table tr {
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    background: #fffdf9;
  }

  .pretty-table td {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    border-bottom: 1px solid rgba(234, 217, 198, 0.65);
  }

  .pretty-table td:last-child {
    border-bottom: 0;
  }

  .pretty-table td::before {
    content: attr(data-label);
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--accent-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
}

@media (max-width: 640px) {
  .page-header,
  .page {
    width: min(100% - 20px, 1140px);
  }

  .external-link-box {
    flex-direction: column;
    align-items: stretch;
  }

  .button {
    width: 100%;
  }

  .panel,
  .hero,
  .stat-card,
  .notice {
    border-radius: 22px;
  }
}
