:root {
  --ink: #17212b;
  --muted: #617084;
  --line: #cfd9e6;
  --paper: #ffffff;
  --canvas: #eef4fb;
  --panel: #ffffff;
  --primary: #08756f;
  --primary-strong: #06514c;
  --blue: #1967c2;
  --sky: #1ba7d8;
  --accent: #d9423a;
  --gold: #f3aa24;
  --green: #12a66a;
  --soft: #e7f6f3;
  --soft-blue: #e9f2ff;
  --shadow: 0 18px 42px rgba(28, 45, 72, 0.14);
  --shadow-soft: 0 8px 22px rgba(28, 45, 72, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(8, 117, 111, 0.13) 0 18%, transparent 18% 100%),
    linear-gradient(315deg, rgba(211, 42, 48, 0.10) 0 15%, transparent 15% 100%),
    linear-gradient(180deg, #f8fbff 0%, var(--canvas) 42%, #eef7f3 100%);
  background-attachment: fixed;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: block;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 430px);
  padding: 28px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(207, 217, 230, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card img {
  width: min(100%, 300px);
  display: block;
  margin: 0 auto 18px;
}

.login-card h1 {
  margin-bottom: 8px;
  text-align: center;
}

.login-card p {
  color: var(--muted);
  text-align: center;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.login-form button {
  min-height: 44px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--blue));
  border-radius: 6px;
  font-weight: 900;
}

.login-error,
.settings-message {
  min-height: 20px;
  margin: 0;
  color: var(--green);
  font-weight: 800;
}

.login-error,
.settings-message.is-error {
  color: var(--accent);
}

.workspace {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px;
}

.view-hidden {
  display: none;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(207, 217, 230, 0.88);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-brand img {
  width: min(260px, 36vw);
  max-height: 82px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid #d8e2ee;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 10px 20px rgba(25, 103, 194, 0.11);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  color: #101c2b;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 1rem;
}

.doc-mode {
  display: flex;
  gap: 8px;
  padding: 5px;
  background: #eff5fb;
  border: 1px solid #d7e2ef;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.doc-mode label {
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.doc-mode label:has(input:checked) {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--blue));
  box-shadow: 0 8px 16px rgba(8, 117, 111, 0.22);
}

.doc-mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(207, 217, 230, 0.82);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

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

.panel {
  position: relative;
  overflow: hidden;
  padding: 20px;
  background: var(--panel);
  border: 1px solid rgba(207, 217, 230, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--sky), var(--gold), var(--accent));
}

.panel > * {
  position: relative;
}

.span-2 {
  grid-column: span 2;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin-bottom: 0;
  color: #112033;
  font-size: 1.04rem;
}

.grid-2,
.grid-3,
.totals-grid {
  display: grid;
  gap: 14px;
}

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

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

.span-3 {
  grid-column: span 3;
}

.totals-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0;
}

label {
  display: grid;
  gap: 7px;
  color: #405064;
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: #f9fbfe;
  border: 1px solid #cfdbe9;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(8, 117, 111, 0.13);
}

.ghost-button,
.danger-button,
.top-actions button,
.preview-actions button {
  min-height: 38px;
  padding: 0 15px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), #0b8f88);
  border-radius: 6px;
  font-weight: 800;
  box-shadow: 0 8px 16px rgba(8, 117, 111, 0.20);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.ghost-button {
  color: var(--primary);
  background: linear-gradient(135deg, #e7f6f3, #edf8ff);
  box-shadow: none;
}

.danger-button {
  background: linear-gradient(135deg, var(--accent), #f16a3f);
}

.top-actions button:nth-child(1) {
  background: linear-gradient(135deg, var(--blue), var(--sky));
}

.top-actions button:nth-child(2) {
  background: linear-gradient(135deg, var(--accent), #f16a3f);
}

.top-actions button:nth-child(3) {
  background: linear-gradient(135deg, var(--primary), var(--green));
}

.top-actions button:nth-child(4) {
  background: linear-gradient(135deg, #28364a, var(--blue));
}

.top-actions button:nth-child(5) {
  background: linear-gradient(135deg, var(--gold), var(--accent));
}

.language-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  width: auto;
  min-height: 38px;
  padding: 0 10px;
  color: #1e3348;
  background: #ffffff;
  border: 1px solid rgba(207, 217, 230, 0.95);
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 800;
}

.language-picker select {
  width: auto;
  min-width: 126px;
  min-height: 32px;
  padding: 6px 28px 6px 10px;
}

.ghost-button:hover,
.danger-button:hover,
.top-actions button:hover,
.preview-actions button:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(28, 45, 72, 0.18);
}

.line-items {
  display: grid;
  gap: 9px;
}

.client-list,
.connection-list {
  display: grid;
  gap: 9px;
}

.inline-check {
  width: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-strong);
}

.inline-check input {
  width: 18px;
  min-height: 18px;
}

.additional-services {
  display: grid;
  gap: 12px;
}

.additional-services-list {
  display: grid;
  gap: 10px;
}

.additional-service-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(130px, 0.7fr) 40px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  border: 1px solid #d9e4f1;
  border-radius: 8px;
}

.additional-service-row .icon-button {
  width: 40px;
}

.line-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 86px 120px 40px;
  gap: 8px;
}

.client-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(120px, 1fr) minmax(110px, 0.9fr) minmax(150px, 1fr) 40px;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  border: 1px solid #d9e4f1;
  border-radius: 8px;
}

.connection-panel {
  padding: 15px;
  background: linear-gradient(180deg, #f8fcff, #eef8f6);
  border: 1px solid #cfe1ee;
  border-radius: 8px;
}

.compact-heading {
  margin-bottom: 10px;
}

.compact-heading h2 {
  font-size: 0.95rem;
}

.connection-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  align-items: start;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #d9e4f1;
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(28, 45, 72, 0.06);
}

.airport-name,
.airline-name {
  min-height: 18px;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 700;
}

.icon-button {
  width: 40px;
  height: 40px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), #f16a3f);
  border-radius: 6px;
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: 0 8px 14px rgba(217, 66, 58, 0.20);
}

.connection-row .icon-button {
  width: 100%;
  align-self: end;
}

.conditional-field.is-hidden {
  display: none;
}

.archive-panel {
  margin-top: 16px;
}

.archive-controls {
  margin-bottom: 14px;
}

.archive-list {
  display: grid;
  gap: 10px;
}

.archive-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(150px, 0.7fr) minmax(260px, auto);
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  border: 1px solid #d9e4f1;
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(28, 45, 72, 0.06);
}

.archive-row div {
  display: grid;
  gap: 3px;
}

.archive-row span {
  color: var(--muted);
  font-size: 0.84rem;
}

.archive-actions {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.archive-empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  background: #f7fbff;
  border: 1px dashed #cbd8e7;
  border-radius: 8px;
}

.preview-shell {
  margin-top: 20px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(25, 103, 194, 0.13), rgba(8, 117, 111, 0.13));
  border: 1px solid #cddcea;
  border-radius: 8px;
}

.preview-hidden {
  display: none;
}

.preview-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.document-preview {
  position: relative;
  min-height: calc(100vh - 82px);
  padding: 30px;
  background: var(--paper);
  border-radius: 8px;
  box-shadow: var(--shadow);
  border-top: 6px solid var(--primary);
}

.document-preview::before {
  content: "";
  position: absolute;
  inset: 180px 32px 160px;
  background: url("dominican-servidesk-logo.png") center / contain no-repeat;
  opacity: 0.06;
  pointer-events: none;
}

.document-preview > * {
  position: relative;
  z-index: 1;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 20px;
  border-bottom: 4px solid var(--primary);
}

.receipt-header {
  padding-bottom: 14px;
  border-bottom: 3px solid var(--primary);
  text-align: center;
}

.receipt-logo {
  width: min(320px, 90%);
  max-height: 92px;
  object-fit: contain;
  margin: 0 auto 8px;
}

.receipt-header p {
  margin: 0 0 6px;
  color: #3c444c;
  font-size: 0.85rem;
}

.receipt-header h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  color: #16263a;
}

.receipt-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 28px;
  padding: 14px 0;
  border-bottom: 1px solid #d3deea;
}

.receipt-meta p {
  margin: 0;
  color: #343b43;
  font-size: 0.86rem;
  line-height: 1.35;
}

.preview-logo {
  display: block;
  width: min(290px, 100%);
  max-height: 86px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 12px;
}

.brand-block h3 {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.brand-block p,
.meta-block p,
.preview-section p {
  margin: 0 0 5px;
  color: var(--muted);
  line-height: 1.45;
}

.doc-badge {
  display: inline-block;
  min-width: 138px;
  padding: 8px 12px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--blue));
  border-radius: 6px;
  text-align: center;
  font-weight: 900;
  text-transform: uppercase;
}

.receipt-header .doc-badge {
  min-width: 170px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue), var(--primary));
}

.preview-section {
  margin-top: 22px;
}

.preview-section h4 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--primary-strong);
  text-transform: uppercase;
  letter-spacing: 0;
  border-left: 4px solid var(--accent);
  padding-left: 8px;
}

.service-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 18px;
}

.service-summary p {
  padding: 9px 10px;
  background: #f7fbff;
  border: 1px solid #e0e9f3;
  border-radius: 6px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
}

.items-table th,
.items-table td {
  padding: 8px 7px;
  border-bottom: 1px solid #d6e0eb;
  text-align: left;
}

.items-table small {
  color: var(--muted);
  font-size: 0.72rem;
}

.flight-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.flight-table th,
.flight-table td {
  padding: 6px 5px;
  border-top: 1px solid #d6e0eb;
  border-bottom: 1px solid #d6e0eb;
  text-align: left;
  vertical-align: top;
}

.flight-table th {
  color: #ffffff;
  background: var(--primary-strong);
  font-weight: 900;
}

.flight-table small {
  color: var(--muted);
  font-size: 0.68rem;
}

.flight-table td:nth-child(4),
.flight-table td:nth-child(5),
.flight-table td:nth-child(6),
.flight-table td:nth-child(7),
.flight-table td:nth-child(8) {
  white-space: nowrap;
}

.items-table th {
  color: #ffffff;
  background: #20354d;
  font-size: 0.78rem;
  text-transform: uppercase;
  border-top: 1px solid #20354d;
}

.items-table td:nth-child(n+2),
.items-table th:nth-child(n+2),
.totals-table td:nth-child(2) {
  text-align: right;
}

.totals-table {
  width: min(100%, 310px);
  margin: 18px 0 0 auto;
  border-collapse: collapse;
}

.totals-table td {
  padding: 7px 0;
}

.totals-table .grand-total td {
  padding-top: 12px;
  color: var(--primary-strong);
  border-top: 2px solid var(--primary);
  font-size: 1.15rem;
  font-weight: 900;
}

.receipt-qr {
  display: flex;
  align-items: center;
  gap: 14px;
  width: fit-content;
  max-width: 100%;
  margin-top: 22px;
  padding: 12px;
  background: #f7fbff;
  border: 1px solid #d6e0eb;
  border-radius: 8px;
}

.receipt-qr img {
  width: 112px;
  height: 112px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid #d6e0eb;
}

.receipt-qr div {
  display: grid;
  gap: 4px;
}

.receipt-qr span {
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 1080px) {
  .preview-shell {
    height: auto;
  }
}

@media (max-width: 720px) {
  .workspace,
  .preview-shell {
    padding: 14px;
  }

  .topbar,
  .panel-heading,
  .preview-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .app-brand img {
    width: min(100%, 330px);
  }

  .form-grid,
  .grid-2,
  .grid-3,
  .totals-grid,
  .service-summary,
  .receipt-meta {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .span-3 {
    grid-column: auto;
  }

  .client-row,
  .connection-row,
  .archive-row,
  .additional-service-row {
    grid-template-columns: 1fr;
  }

  .client-row .icon-button,
  .connection-row .icon-button,
  .additional-service-row .icon-button {
    width: 100%;
  }

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

  .archive-actions {
    justify-content: stretch;
  }

  .archive-actions button {
    width: 100%;
  }

  .document-preview {
    padding: 20px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .topbar,
  .top-actions,
  .form-grid,
  .archive-panel,
  .preview-actions {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .preview-shell {
    display: block !important;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: #ffffff;
    border: 0;
  }

  .document-preview {
    min-height: auto;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
  }
}
