@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Source+Serif+4:wght@400;600&display=swap");

:root {
  --bg-1: #f7f1e7;
  --bg-2: #efe4d7;
  --ink: #1f1b16;
  --muted: #6f6557;
  --accent: #0b6b6f;
  --accent-strong: #0a4f52;
  --accent-2: #c86a2b;
  --card: #ffffff;
  --line: #e4d9cb;
  --radius: 14px;
  --shadow: 0 18px 45px rgba(31, 27, 22, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fffaf2 0%, var(--bg-1) 35%, var(--bg-2) 100%);
  min-height: 100vh;
}

.bg-orbit {
  position: fixed;
  inset: -20% auto auto -10%;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle at 30% 30%, rgba(11, 107, 111, 0.2), transparent 65%);
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 14px 22px;
  box-shadow: var(--shadow);
}

.topbar.auth {
  justify-content: center;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.1rem;
}

.nav-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-links a {
  padding: 8px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.nav-links a:hover {
  border-color: var(--line);
  background: #fff6ec;
}

.nav-links a.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-label {
  font-weight: 600;
}

.content {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.hero.compact {
  align-items: flex-end;
}

.hero h1 {
  font-family: "Source Serif 4", serif;
  font-size: 2.4rem;
  margin: 0 0 6px;
}

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

.session-status {
  display: none;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(228, 217, 203, 0.8);
  border-radius: var(--radius);
  padding: 12px 18px;
  box-shadow: var(--shadow);
  margin-top: 16px;
}

.session-status.is-visible {
  display: block;
}

.session-status__content {
  font-weight: 600;
  color: var(--accent-strong);
}

.session-status__content strong {
  color: var(--accent);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.grid.single {
  grid-template-columns: minmax(280px, 520px);
}

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

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(228, 217, 203, 0.8);
  animation: rise 0.6s ease both;
}

.card h2 {
  margin: 0 0 12px;
}

.helper-block h3 {
  margin: 18px 0 8px;
  font-size: 1rem;
}

.helper-block ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.helper-block li {
  margin-bottom: 6px;
}

.table-footer {
  margin-top: 14px;
}

.table-card.is-sticky {
  position: sticky;
  top: 22px;
  z-index: 6;
}

.table-card {
  scroll-margin-top: 22px;
}

.table-tools {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.filter-bar {
  display: grid;
  gap: 12px;
}

.filter-bar__row {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) auto auto;
  gap: 24px;
  align-items: end;
}

.filter-field {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.filter-field--grow {
  min-width: 0;
}

.filter-bar__row .ghost-btn {
  height: 44px;
}

.filter-pagination {
  padding: 0 6px;
}

.filter-pagination .pagination {
  gap: 12px;
}

.filter-pagination .pagination .muted {
  white-space: nowrap;
}

.filter-field--compact input {
  font-size: 0.9rem;
}

.filter-field input {
  font-size: 0.9rem;
  background: #fff;
}

.select-field--compact select {
  padding: 10px 38px 10px 12px;
  font-size: 0.9rem;
}

.filter-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chip-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  border-color: var(--accent-2);
  color: var(--ink);
}

.chip.is-active {
  background: rgba(11, 107, 111, 0.15);
  border-color: rgba(11, 107, 111, 0.4);
  color: var(--accent-strong);
}

th.sortable {
  cursor: pointer;
  position: relative;
  padding-right: 20px;
}

th.sortable::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid var(--muted);
  opacity: 0.4;
}

th.sortable.is-active::after {
  opacity: 1;
  border-top-color: var(--accent);
}

th.sortable.is-active.is-asc::after {
  transform: translateY(-50%) rotate(180deg);
}

.filter-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.table-meta {
  display: flex;
  justify-content: flex-end;
}

.filter-drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 32;
}

.filter-drawer.is-open {
  display: block;
}

.filter-drawer__overlay {
  position: absolute;
  inset: 0;
  background: rgba(31, 27, 22, 0.35);
}

.filter-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(380px, 90vw);
  height: 100%;
  background: var(--card);
  border-left: 1px solid rgba(228, 217, 203, 0.8);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.filter-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pending-row {
  opacity: 0.7;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination .ghost-btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.card-header h1 {
  margin: 0 0 6px;
  font-family: "Source Serif 4", serif;
}

.card-header p {
  margin: 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.dropzone {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.dropzone-title {
  font-weight: 600;
  color: var(--ink);
}

.dropzone input {
  display: none;
}

.upload-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.upload-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
}

.upload-list__empty {
  margin: 0;
}

.upload-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border-radius: calc(var(--radius) - 6px);
  background: rgba(238, 231, 221, 0.5);
}

.upload-list__name {
  font-weight: 600;
}

.upload-list__meta {
  font-size: 12px;
  color: var(--muted);
}

.img-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.img-preview__empty {
  display: none;
  margin: 6px 0 0;
}

.img-preview.is-empty .img-preview__empty {
  display: block;
}

.img-preview.is-empty .img-preview__grid {
  display: none;
}

.img-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.img-preview__grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.preview-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
}

.preview-card img {
  width: 100%;
  height: auto;
  border-radius: calc(var(--radius) - 6px);
  border: 1px solid var(--line);
}

.preview-card .ghost-btn {
  align-self: flex-start;
}

.crop-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.crop-modal.is-open {
  display: flex;
}

.crop-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(24, 22, 19, 0.5);
  backdrop-filter: blur(6px);
}

.crop-modal__panel {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  width: min(720px, 92vw);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.crop-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.crop-modal__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#img-crop-canvas {
  width: 100%;
  max-height: 70vh;
  border: 1px dashed var(--line);
  border-radius: calc(var(--radius) - 6px);
  background: #f6f2ea;
}

.crop-modal__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.crop-modal__tools,
.crop-modal__buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.img-pdf-preview .img-preview__header {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.img-icon {
  font-size: 18px;
  line-height: 1;
}

.img-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.crop-modal .img-icon {
  font-size: 20px;
}
.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.form-row--split {
  grid-template-columns: minmax(0, 1fr) auto;
}

.form-field {
  display: grid;
  gap: 6px;
  font-weight: 500;
}

.form-actions {
  display: flex;
  align-items: flex-end;
}

.form-actions .primary-btn {
  height: 44px;
  padding: 0 22px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 500;
}

.is-hidden {
  display: none;
}

input {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 1rem;
}

.select-field {
  position: relative;
}

.select-field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  padding: 12px 42px 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff6ec;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
}

.select-field::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid var(--muted);
  pointer-events: none;
}

.select-field select:focus {
  outline: 2px solid rgba(11, 107, 111, 0.25);
  border-color: var(--accent);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(31, 27, 22, 0.35);
  z-index: 30;
}

.modal.is-open {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.modal-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  width: min(420px, 92vw);
  box-shadow: var(--shadow);
  border: 1px solid rgba(228, 217, 203, 0.8);
  position: relative;
  z-index: 1;
}

.modal-card--wide {
  width: min(720px, 94vw);
}

.error-detail {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff7ee;
  color: var(--ink);
  font-size: 0.9rem;
  max-height: 50vh;
  overflow: auto;
  white-space: pre-wrap;
}

.ghost-btn.small-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.modal-error {
  color: #a34343;
  font-size: 0.9rem;
  margin-top: 8px;
}

input[type="password"],
input[type="text"] {
  width: 100%;
}

.input-with-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-with-toggle input {
  flex: 1;
}

.toggle-password {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.toggle-password:hover {
  border-color: var(--accent-2);
}

.toggle-password svg {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-btn {
  padding: 8px;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-btn.is-asc svg {
  transform: rotate(180deg);
}

.inline-form {
  display: inline-flex;
}

.toggle-password .icon-eye-off {
  display: none;
}

.toggle-password.is-active .icon-eye {
  display: none;
}

.toggle-password.is-active .icon-eye-off {
  display: block;
}

input:focus {
  outline: 2px solid rgba(11, 107, 111, 0.3);
  border-color: var(--accent);
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 10px 18px;
  border: none;
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(11, 107, 111, 0.2);
}

.primary-btn:hover {
  transform: translateY(-1px);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

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

.ghost-btn.wide {
  width: 100%;
}

.primary-btn.wide {
  width: 100%;
}

button:disabled,
input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead {
  text-align: left;
  color: var(--muted);
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.badge {
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: #f0ebe2;
  color: var(--muted);
}

.badge.done {
  background: rgba(11, 107, 111, 0.15);
  color: var(--accent-strong);
}

.badge.processing,
.badge.pending {
  background: rgba(200, 106, 43, 0.2);
  color: #98521f;
}

.badge.queued {
  background: rgba(111, 101, 87, 0.2);
  color: var(--muted);
}

.badge.en-proceso {
  background: rgba(200, 106, 43, 0.2);
  color: #98521f;
  position: relative;
  padding-right: 22px;
  animation: pulse 1.2s ease-in-out infinite;
}

.badge.completado {
  background: rgba(11, 107, 111, 0.15);
  color: var(--accent-strong);
}

.badge.error {
  background: rgba(188, 60, 60, 0.15);
  color: #a34343;
}

.badge.result-renovacion {
  background: rgba(233, 185, 45, 0.22);
  color: #a9740f;
}

.badge.result-habilitado {
  background: rgba(11, 107, 111, 0.18);
  color: var(--accent-strong);
}

.badge.result-hidraulica {
  background: rgba(200, 106, 43, 0.2);
  color: #98521f;
}

.badge.result-no-registrada {
  background: rgba(111, 101, 87, 0.2);
  color: var(--muted);
}

.badge.result-sesion {
  background: rgba(66, 122, 191, 0.2);
  color: #2f5d8f;
}

.badge.result-credenciales {
  background: rgba(188, 60, 60, 0.15);
  color: #a34343;
}

.badge.result-neutral {
  background: #f0ebe2;
  color: var(--muted);
}

.badge.en-proceso::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 8px;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: #b35b22;
  box-shadow: 0 0 0 0 rgba(179, 91, 34, 0.5);
  animation: dot-pulse 1.2s ease-in-out infinite;
}

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

.flash-stack {
  display: grid;
  gap: 8px;
}

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #fff4e3;
  border: 1px solid #f5d7b3;
  max-height: 200px;
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, max-height 0.2s ease,
    padding 0.2s ease, border-width 0.2s ease;
}

.flash.success {
  background: rgba(11, 107, 111, 0.12);
  border-color: rgba(11, 107, 111, 0.3);
}

.flash.error {
  background: rgba(188, 60, 60, 0.15);
  border-color: rgba(188, 60, 60, 0.3);
}

.flash.dismissed {
  opacity: 0;
  transform: translateY(-6px);
  max-height: 0;
  padding: 0;
  border-width: 0;
}

.toast-stack {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 120;
  display: grid;
  gap: 10px;
  max-width: min(320px, 90vw);
}

.toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #fff4e3;
  border: 1px solid #f5d7b3;
  box-shadow: var(--shadow);
  animation: rise 0.3s ease;
}

.toast.error {
  background: rgba(188, 60, 60, 0.15);
  border-color: rgba(188, 60, 60, 0.3);
}

.toast__text {
  font-weight: 600;
  line-height: 1.4;
}

.toast__close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
}

.toast--hide {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 32px;
  align-items: center;
}

.auth-aside h2 {
  font-family: "Source Serif 4", serif;
  font-size: 2rem;
  margin-top: 0;
}

.auth-aside ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.divider {
  text-align: center;
  margin: 18px 0;
  color: var(--muted);
}

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

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes dot-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(179, 91, 34, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(179, 91, 34, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(179, 91, 34, 0);
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    border-radius: var(--radius);
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-layout {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-actions .primary-btn {
    width: 100%;
  }

  .grid.two-col {
    grid-template-columns: 1fr;
  }

  .table-meta {
    justify-content: flex-start;
  }

  .filter-bar__row {
    grid-template-columns: 1fr;
  }

  .filter-chips {
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card {
    animation: none;
  }
  .badge.en-proceso,
  .badge.en-proceso::after {
    animation: none;
  }
}
