:root {
  --bg: #f2f7fb;
  --ink: #0d2a40;
  --muted: #547289;
  --card: rgba(255, 255, 255, 0.84);
  --card-solid: #ffffff;
  --line: #d5e3ee;
  --line-strong: #b8cede;
  --accent: #109b78;
  --accent-2: #f19d38;
  --danger: #c93e3e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Public Sans", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, #e4f7f4 0%, transparent 30%),
    radial-gradient(circle at 91% 4%, #fff0df 0%, transparent 33%),
    linear-gradient(155deg, #f4f8fb, #eef4f9 42%, #f6fafc 100%);
  padding: 0 12px 36px;
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(0.5px);
  pointer-events: none;
  z-index: -1;
}

body::before {
  width: 280px;
  height: 280px;
  top: -90px;
  right: -30px;
  background: radial-gradient(circle, rgba(16, 155, 120, 0.2), rgba(16, 155, 120, 0));
}

body::after {
  width: 240px;
  height: 240px;
  left: -80px;
  bottom: 20%;
  background: radial-gradient(circle, rgba(241, 157, 56, 0.16), rgba(241, 157, 56, 0));
}

.hero {
  max-width: 1120px;
  margin: 18px auto 0;
  padding: 16px 18px 8px;
  animation: rise-in 0.55s ease both;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(16, 155, 120, 0.36);
  background: rgba(16, 155, 120, 0.1);
  color: #0e7a60;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 12px 0 6px;
  font-family: "Sora", "Franklin Gothic Medium", sans-serif;
  font-size: clamp(1.6rem, 2.8vw, 2.25rem);
  line-height: 1.15;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 640px;
}

.workspace {
  max-width: 1120px;
  margin: 12px auto 0;
}

.surface {
  border: 1px solid rgba(184, 206, 222, 0.74);
  border-radius: 22px;
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.92), rgba(249, 253, 255, 0.78));
  box-shadow:
    0 10px 32px rgba(6, 35, 56, 0.09),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  padding: 14px;
  animation: rise-in 0.58s ease 0.08s both;
}

.doc-tabs {
  display: inline-flex;
  width: 100%;
  max-width: 500px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(234, 244, 251, 0.75);
  padding: 5px;
  gap: 6px;
}

.doc-tab {
  flex: 1;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #3f5a71;
  font-family: "Sora", "Century Gothic", sans-serif;
  font-size: 0.89rem;
  font-weight: 600;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.doc-tab:hover {
  transform: translateY(-1px);
  color: #1e3e55;
}

.doc-tab.is-active {
  background: linear-gradient(140deg, #109b78, #0d8968);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(16, 155, 120, 0.28);
}

.tab-panel {
  margin-top: 14px;
}

.tab-panel[hidden] {
  display: none;
}

.tab-panel.is-active .documento {
  animation: fade-up 0.36s ease both;
}

.documento {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  padding: 16px;
}

.doc-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 4px;
}

.doc-logo-box {
  width: 76px;
  height: 76px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  box-shadow: 0 8px 20px rgba(24, 57, 82, 0.08);
  overflow: hidden;
  flex-shrink: 0;
}

.doc-logo-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.doc-titulo h2 {
  margin: 0;
  font-family: "Sora", "Century Gothic", sans-serif;
  font-size: 1.18rem;
}

.doc-titulo small {
  color: var(--muted);
  font-size: 0.82rem;
}

label {
  display: grid;
  gap: 7px;
  font-size: 0.87rem;
  color: #345168;
}

.grid-5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 11px;
  color: #17344b;
  background: var(--card-solid);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  border-color: #4cae95;
  box-shadow: 0 0 0 3px rgba(16, 155, 120, 0.16);
}

input[readonly] {
  background: #f4f8fc;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 12px;
  color: #1c3f5b;
  background: linear-gradient(180deg, #ffffff, #f3f8fc);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: #a6bfd2;
  box-shadow: 0 6px 14px rgba(22, 62, 90, 0.1);
}

.btn-primary {
  border-color: #0f8f6f;
  background: linear-gradient(140deg, #109b78, #0e7e62);
  color: #ffffff;
  font-weight: 600;
}

.btn-primary:hover {
  border-color: #0f8f6f;
  box-shadow: 0 8px 20px rgba(16, 155, 120, 0.27);
}

.btn-row-delete {
  border-color: #e6b0b0;
  color: #8a2b2b;
  background: linear-gradient(180deg, #fff5f5, #ffe8e8);
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: auto;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  border-bottom: 1px solid #e6eff6;
  text-align: left;
  padding: 9px 8px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #295071;
  background: #eff6fc;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

td .line-input {
  width: 100%;
  min-width: 84px;
}

td .line-subtotal {
  width: 100%;
  min-width: 118px;
  text-align: right;
}

.doc-totales {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  justify-content: flex-end;
}

.total-letras {
  margin-top: 12px;
  border: 1px dashed rgba(16, 155, 120, 0.4);
  border-radius: 10px;
  padding: 8px 10px;
  color: #156b56;
  background: rgba(16, 155, 120, 0.08);
  font-style: italic;
}

body.print-preview-open {
  overflow: hidden;
}

.print-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(6, 21, 34, 0.68);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 10px;
}

.print-preview-shell {
  width: min(960px, 100%);
  height: min(96vh, 100%);
  background: #ffffff;
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  box-shadow: 0 20px 45px rgba(3, 16, 29, 0.25);
}

.print-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #d5e3ee;
  background: #f7fbff;
  color: #16334a;
}

.print-preview-actions {
  display: flex;
  gap: 8px;
}

.print-preview-btn {
  border: 1px solid #b8cede;
  background: #ffffff;
  color: #23455f;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font: inherit;
}

.print-preview-btn.close {
  border-color: #e1b7b7;
  color: #8b3131;
}

.print-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  body {
    padding-left: 10px;
    padding-right: 10px;
  }

  .surface {
    border-radius: 18px;
    padding: 12px;
  }

  .grid-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .hero {
    padding-left: 8px;
    padding-right: 8px;
  }

  .doc-tabs {
    max-width: none;
  }

  .doc-tab {
    font-size: 0.82rem;
    padding: 9px 8px;
  }

  .documento {
    border-radius: 14px;
    padding: 12px;
  }

  .doc-header {
    align-items: flex-start;
  }

  .doc-logo-box {
    width: 64px;
    height: 64px;
    border-radius: 12px;
  }

  .grid-5 {
    grid-template-columns: 1fr;
  }

  .doc-totales {
    justify-content: stretch;
  }

  .doc-totales > * {
    width: 100%;
  }

  .print-preview-overlay {
    padding: 0;
    background: rgba(6, 21, 34, 0.78);
  }

  .print-preview-shell {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .print-preview-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
  }
}
