:root {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body, 'Inter', sans-serif);
  background: var(--color-light, #f0f5f1);
  color: var(--color-dark, #0f1a12);
  overflow-x: hidden;
}

.container {
  width: min(1200px, 92%);
  margin: 0 auto;
}

.topbar {
  display: block;
  width: 100%;
  background: var(--gradient-primary, linear-gradient(135deg, #1a6b3c 0%, #0d4225 100%));
  color: var(--color-white, #fff);
  padding: 1rem 0;
  box-shadow: var(--shadow-md, 0 8px 30px rgba(0, 0, 0, 0.15));
}

.topbar .container {
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-size: 0.84rem;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-heading, 'Outfit', sans-serif);
}

h1 {
  font-size: clamp(1.2rem, 2.2vw, 1.8rem);
}

.back-link {
  color: var(--color-white, #fff);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-full, 9999px);
  padding: 0.45rem 0.9rem;
}

.single-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1.25rem 0 2rem;
}

.card {
  background: var(--color-white, #fff);
  border-radius: var(--radius-md, 16px);
  padding: 1rem;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.12));
  min-width: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(250px, 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.field-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.7rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid #e7efe8;
  border-radius: 10px;
  background: #fcfefd;
}

.field-row > span {
  min-width: 132px;
  font-size: 0.84rem;
  color: var(--color-dark-3, #2d3f32);
}

.field-row input,
.field-row select {
  flex: 1;
  min-width: 0;
  width: 100%;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
  color: var(--color-dark-2, #1c2b20);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid #d0ddd2;
  border-radius: 10px;
  padding: 0.62rem 0.7rem;
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 86px;
  margin-top: 0.75rem;
}

.tour-block {
  margin-top: 1rem;
}

.help-text {
  margin: 0.35rem 0 0.8rem;
  color: var(--color-mid, #6b7f70);
  font-size: 0.88rem;
}

.tour-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.65rem;
}

.tour-item {
  border: 1px solid #deeadf;
  border-radius: var(--radius-sm, 8px);
  padding: 0.6rem;
  background: #fafdfa;
}

.tour-item > div {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.tour-title {
  font-weight: 600;
}

.totals {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-radius: 10px;
  background: #eff8f1;
}

.totals strong {
  color: var(--color-primary, #1a6b3c);
  font-size: 1.1rem;
}

.actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1rem;
}

.btn {
  border: 0;
  border-radius: var(--radius-full, 9999px);
  padding: 0.65rem 1.05rem;
  cursor: pointer;
  font-weight: 600;
}

.btn.primary {
  background: var(--gradient-primary, linear-gradient(135deg, #1a6b3c 0%, #0d4225 100%));
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: 1px solid #b4c8b8;
  color: var(--color-dark-2, #1c2b20);
}

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin-top: 0.85rem;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  text-align: left;
  font-size: 0.9rem;
  padding: 0.6rem;
  border-bottom: 1px solid #e4ede5;
  vertical-align: top;
}

thead th {
  color: var(--color-dark-3, #2d3f32);
  background: #f5faf6;
}

.status {
  display: inline-block;
  padding: 0.2rem 0.52rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status.pendiente {
  background: #fff4db;
  color: #8c6212;
}

.status.aprobada {
  background: #dff5e4;
  color: #1c6b36;
}

.status.rechazada {
  background: #ffe2e2;
  color: #962c2c;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.mini-btn {
  border: 1px solid #cfded2;
  background: #fff;
  border-radius: 7px;
  padding: 0.33rem 0.55rem;
  cursor: pointer;
  font-size: 0.78rem;
}

.mini-btn.pdf {
  border-color: #f2c36c;
  color: #8b5700;
}

.mini-btn.delete {
  border-color: #e5b2b2;
  color: #8d2424;
}

.empty-state {
  color: var(--color-mid, #6b7f70);
  text-align: center;
  padding: 1rem;
}

.login-body {
  min-height: 100dvh;
  margin: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, #eff8f1 0%, #f0f5f1 55%, #eaf1ec 100%);
}

.login-wrap {
  width: min(460px, 92%);
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.2rem;
  box-shadow: var(--shadow-md, 0 8px 30px rgba(0, 0, 0, 0.15));
}

.login-card p {
  margin: 0.4rem 0 1rem;
  color: var(--color-mid, #6b7f70);
}

.login-form {
  display: grid;
  gap: 0.75rem;
}

.login-error {
  margin-bottom: 0.8rem;
  background: #ffe2e2;
  color: #7f2222;
  border: 1px solid #efb5b5;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
}

.login-success {
  margin-bottom: 0.8rem;
  background: #e1f4e6;
  color: #1f6d38;
  border: 1px solid #b4dfc0;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
}

.login-help {
  display: block;
  margin-top: 0.9rem;
  color: #516157;
  line-height: 1.4;
}

.back-link.dark {
  color: var(--color-dark, #0f1a12);
  border-color: #cfded2;
  margin-top: 0.9rem;
  display: inline-flex;
}

body.modal-open {
  overflow: hidden;
}

.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: grid;
  place-items: center;
}

.pdf-modal[hidden] {
  display: none;
}

.pdf-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 17, 12, 0.72);
  backdrop-filter: blur(2px);
}

.pdf-modal__dialog {
  position: relative;
  width: min(1100px, 94vw);
  height: min(88vh, 900px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.4);
  border: 1px solid #d8e6dc;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.pdf-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  background: var(--gradient-primary, linear-gradient(135deg, #1a6b3c 0%, #0d4225 100%));
  color: #fff;
}

.pdf-modal__header h3 {
  font-size: 1.02rem;
}

.pdf-modal__actions {
  display: flex;
  gap: 0.4rem;
}

.pdf-modal__actions .mini-btn {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

#pdf-viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #f4f6f7;
}

@media (max-width: 760px) {
  .container {
    width: 96%;
  }

  .topbar {
    padding: 0.7rem 0;
  }

  .topbar .container {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  h1 {
    font-size: 1.05rem;
  }

  .topbar-actions {
    width: 100%;
    gap: 0.4rem;
    justify-content: flex-start;
  }

  .user-pill,
  .back-link {
    font-size: 0.78rem;
    padding: 0.34rem 0.62rem;
  }

  .single-layout {
    gap: 0.75rem;
    padding: 0.75rem 0 1.2rem;
  }

  .card {
    padding: 0.75rem;
    border-radius: 12px;
  }

  .field-grid {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .field-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    padding: 0.42rem;
  }

  .field-row > span {
    min-width: 0;
    font-size: 0.8rem;
  }

  .tour-list {
    grid-template-columns: 1fr;
  }

  .tour-item {
    padding: 0.5rem;
  }

  .totals {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    padding: 0.62rem;
  }

  .totals strong {
    font-size: 0.96rem;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 700px;
  }

  .mini-btn {
    white-space: nowrap;
  }

  th,
  td {
    font-size: 0.8rem;
    padding: 0.45rem;
  }

  .row-actions {
    gap: 0.3rem;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .pdf-modal__dialog {
    width: 96vw;
    height: 90vh;
  }

  .pdf-modal__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .pdf-modal__actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .topbar-actions {
    display: flex;
    flex-wrap: wrap;
  }

  .topbar-actions .back-link,
  .topbar-actions .user-pill {
    justify-content: flex-start;
    text-align: center;
  }

  .topbar-actions .back-link {
    flex: 1 1 calc(50% - 0.2rem);
    min-width: 130px;
  }

  .pdf-modal__dialog {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}

@media (min-width: 761px) and (max-width: 1200px) {
  .field-grid {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }
}
