:root {
  --sabre-red: #dc2626;
  --sabre-red-dark: #b91c1c;
  --slate-950: #090e17;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #e9eef5;
  color: var(--slate-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ================= TOPBAR ================= */
.topbar {
  background: linear-gradient(90deg, #0b1120 0%, #172136 100%);
  border-bottom: 3px solid var(--sabre-red);
  color: #fff;
  padding: 11px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.22);
}

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

.brand-badge {
  background: var(--sabre-red);
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  padding: 8px 10px;
  border-radius: 8px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 10px rgba(220, 38, 38, 0.45);
}

.brand-badge span {
  font-weight: 600;
  opacity: 0.92;
  margin-left: 1px;
}

.brand h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.brand h1 span {
  color: #f87171;
  font-weight: 600;
}

.brand p {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  display: inline-block;
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 11.5px;
  border-radius: 6px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--slate-900);
  color: #fff;
}
.btn-primary:hover {
  background: var(--slate-800);
}

.btn-sabre-red {
  background: var(--sabre-red);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(220, 38, 38, 0.32);
}
.btn-sabre-red:hover {
  background: var(--sabre-red-dark);
  transform: translateY(-1px);
}

.btn-vscode {
  background: #007acc;
  color: #fff;
  font-weight: 700;
}
.btn-vscode:hover {
  background: #0062a3;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.18);
  color: #f8fafc;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn-ghost-dark {
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-outline {
  background: #fff;
  color: var(--slate-800);
  border-color: var(--slate-300);
}
.topbar .btn-outline {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.22);
}
.btn-outline:hover {
  border-color: var(--slate-500);
  background: var(--slate-50);
  color: var(--slate-900);
}

/* ================= MAIN SPLIT LAYOUT ================= */
.workspace {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 18px;
  padding: 18px 20px;
  max-width: 1620px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
  gap: 8px;
}

.section-header h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--slate-900);
}

.badge-hint {
  font-size: 11px;
  color: var(--slate-500);
  background: var(--slate-100);
  padding: 2px 8px;
  border-radius: 99px;
}

/* ================= TABS & UPLOAD DROPZONE ================= */
.card-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--slate-100);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate-600);
  border-radius: 6px;
  cursor: pointer;
}

.tab-btn.active {
  background: #fff;
  color: var(--slate-900);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

.dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 10px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--sabre-red);
  background: #fff5f5;
}

.upload-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.dropzone-empty h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--slate-900);
}

.dropzone-empty p {
  font-size: 11.8px;
  color: var(--slate-500);
  margin-top: 5px;
  line-height: 1.45;
}

kbd {
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.dropzone-preview {
  position: relative;
}

.dropzone-preview img {
  width: 100%;
  max-height: 190px;
  object-fit: contain;
  border-radius: 6px;
  background: #0f172a;
}

.preview-overlay {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.samples-bar {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--slate-200);
}

.samples-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--slate-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sample-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sample-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--slate-300);
  background: var(--slate-50);
  color: var(--slate-800);
  cursor: pointer;
  transition: all 0.14s;
}
.sample-pill:hover {
  border-color: var(--sabre-red);
  background: #fef2f2;
  color: var(--sabre-red-dark);
}

/* AI Status */
.ai-status {
  margin-top: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-status.success {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.ai-status.error {
  background: #fef2f2;
  border-color: #fecaca;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid #cbd5e1;
  border-top-color: var(--sabre-red);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ai-status-text {
  display: flex;
  flex-direction: column;
  font-size: 12px;
}
.ai-status-text strong {
  color: var(--slate-900);
}
.ai-status-text span {
  color: var(--slate-600);
  font-size: 11.2px;
  margin-top: 1px;
}

/* ================= FORM FIELDS ================= */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

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

.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--slate-600);
  margin-bottom: 3px;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 7px 9px;
  font-size: 12.5px;
  border: 1px solid var(--slate-300);
  border-radius: 6px;
  background: #fff;
  color: var(--slate-900);
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--sabre-red);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sub-card {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 10px;
}

.sub-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--slate-800);
}

.btn-remove {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--slate-700);
}

.ocr-details {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--slate-600);
}
.ocr-details summary {
  cursor: pointer;
  font-weight: 600;
}
.ocr-details pre {
  margin-top: 6px;
  padding: 8px;
  background: #0f172a;
  color: #38ff7a;
  border-radius: 6px;
  font-size: 11px;
  max-height: 150px;
  overflow: auto;
  white-space: pre-wrap;
}

/* ================= RIGHT PANEL & LIVE SABRE A4 SHEET ================= */
.right-panel {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-toolbar {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.template-group,
.download-group {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.template-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--slate-600);
}

.tpl-btn {
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--slate-300);
  background: var(--slate-50);
  color: var(--slate-700);
  cursor: pointer;
}

.tpl-btn.active {
  background: var(--slate-900);
  color: #fff;
  border-color: var(--slate-900);
}

.paper-stage {
  background: #cbd5e1;
  border-radius: 12px;
  padding: 22px 16px;
  display: flex;
  justify-content: center;
  overflow-x: auto;
  box-shadow: inset 0 2px 10px rgba(15, 23, 42, 0.12);
}

/* ================= EXACT SABRE RED 360 A4 TICKET SHEET ================= */
.sabre-paper {
  width: 794px;
  min-height: 1040px;
  background: #ffffff;
  color: #0f172a;
  padding: 34px 38px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.22);
  border-radius: 2px;
  position: relative;
  font-family: Helvetica, Arial, sans-serif;
}

.sabre-paper.tpl-red {
  border-top: 7px solid var(--sabre-red);
}

.sb-micro-top {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #64748b;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.tpl-red .sb-micro-top {
  color: var(--sabre-red);
}

.sb-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 12px;
  border-bottom: 2.5px solid #1e293b;
}
.tpl-red .sb-header {
  border-bottom-color: var(--sabre-red);
}

.sb-issue-date {
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}

.sb-prep-label {
  font-size: 9.5px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.sb-pax-list {
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.35;
  margin-bottom: 10px;
}

.sb-codes-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 18px;
  align-items: baseline;
}

.sb-code-lbl {
  font-size: 10px;
  font-weight: 700;
  color: #475569;
}

.sb-code-val {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.5px;
}
.tpl-red .sb-code-val.primary {
  color: var(--sabre-red);
}

.sb-agency {
  text-align: right;
  max-width: 290px;
}

.sb-agency-logo {
  max-width: 140px;
  max-height: 44px;
  object-fit: contain;
  margin-bottom: 5px;
}

.sb-agency-name {
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 3px;
  text-transform: uppercase;
}
.tpl-red .sb-agency-name {
  color: var(--sabre-red);
}

.sb-agency-line {
  font-size: 10.5px;
  color: #334155;
  line-height: 1.4;
}

/* SABRE FLIGHT SEGMENT BLOCK */
.sb-segment {
  margin-top: 16px;
}

.sb-ribbon {
  background: #e2e8f0;
  color: #0f172a;
  padding: 6px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 0 100%);
}
.tpl-red .sb-ribbon {
  background: #1e293b;
  color: #ffffff;
}

.sb-ribbon-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.sb-ribbon-right {
  font-size: 9.5px;
  font-style: italic;
  color: #475569;
}
.tpl-red .sb-ribbon-right {
  color: #cbd5e1;
}

.sb-flight-grid {
  display: grid;
  grid-template-columns: 185px 1fr 1fr 172px;
  border: 1px solid #cbd5e1;
  border-top: none;
  min-height: 112px;
}

.sb-col-airline {
  background: #f1f5f9;
  border-right: 1px solid #cbd5e1;
  padding: 10px 12px;
  position: relative;
}
.tpl-red .sb-col-airline {
  background: #fef2f2;
}

/* Iconic Sabre Chevron Notch */
.sb-col-airline::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 7px solid #cbd5e1;
  z-index: 2;
}

.sb-airline-name {
  font-size: 10px;
  font-weight: 800;
  color: #334155;
  line-height: 1.25;
  margin-bottom: 3px;
}

.sb-flight-no {
  font-size: 15px;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 6px;
}
.tpl-red .sb-flight-no {
  color: var(--sabre-red);
}

.sb-kv {
  font-size: 9.8px;
  color: #64748b;
  line-height: 1.45;
}
.sb-kv strong {
  color: #0f172a;
}
.sb-kv strong.ok {
  color: #15803d;
}

.sb-col-station {
  padding: 10px 14px;
  position: relative;
}

.sb-col-station.origin {
  border-right: 1px dashed #cbd5e1;
}

.sb-route-arrow {
  position: absolute;
  right: -6px;
  top: 26px;
  background: #fff;
  color: #475569;
  font-size: 11px;
  line-height: 1;
  padding: 1px;
}

.sb-iata {
  font-size: 15.5px;
  font-weight: 900;
  color: #0f172a;
}

.sb-city {
  font-size: 10.2px;
  font-weight: 700;
  color: #334155;
  margin-left: 4px;
}

.sb-airport-name {
  font-size: 9px;
  color: #64748b;
  margin-top: 2px;
  padding-bottom: 7px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-time-lbl {
  font-size: 9px;
  color: #64748b;
  margin-top: 6px;
}

.sb-time-val {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

.sb-term {
  font-size: 9.2px;
  color: #475569;
  margin-top: 3px;
}

.sb-col-specs {
  border-left: 1px solid #cbd5e1;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

/* Attached Sabre Passenger Table */
.sb-pax-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #cbd5e1;
  border-top: none;
  font-size: 10px;
}

.sb-pax-table th {
  background: #f1f5f9;
  color: #475569;
  text-align: left;
  padding: 5px 9px;
  font-size: 9.2px;
  font-weight: 700;
  border-bottom: 1px solid #cbd5e1;
}

.sb-pax-table td {
  padding: 5.5px 9px;
  border-bottom: 1px solid #e2e8f0;
  color: #0f172a;
}

.sb-pax-table tr:nth-child(even) td {
  background: #f8fafc;
}

/* Fare Box */
.sb-fare-box {
  margin-top: 16px;
  border: 1px solid #cbd5e1;
}
.sb-fare-head {
  background: #e2e8f0;
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 800;
}
.tpl-red .sb-fare-head {
  background: #1e293b;
  color: #fff;
}
.sb-fare-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 10px 12px;
  gap: 10px;
  font-size: 10.5px;
}
.sb-fare-grid span {
  display: block;
  color: #64748b;
  font-size: 9.5px;
}
.sb-fare-grid strong {
  font-size: 12px;
  color: #0f172a;
}

/* Footer & Barcode */
.sb-remarks {
  margin-top: 14px;
  font-size: 10px;
  color: #334155;
}
.sb-remarks h4 {
  font-size: 10px;
  margin-bottom: 4px;
}
.sb-remarks ul {
  padding-left: 16px;
  line-height: 1.45;
}

.sb-footer {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid #cbd5e1;
  font-size: 9.2px;
  color: #64748b;
  line-height: 1.45;
}

.sb-footer-title {
  font-weight: 800;
  color: #334155;
  margin-bottom: 4px;
  font-size: 9.8px;
}

.sb-barcode-row {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

/* ================= MODALS ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-box {
  background: #fff;
  width: 100%;
  max-width: 520px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.modal-box.modal-xl {
  max-width: 940px;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-size: 15px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--slate-500);
}

.modal-body {
  padding: 16px 18px;
}

.modal-note {
  font-size: 12.5px;
  color: var(--slate-600);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  line-height: 1.45;
}

.modal-footer {
  padding: 12px 18px;
  background: var(--slate-50);
  border-top: 1px solid var(--slate-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.hidden {
  display: none !important;
}

/* ================= PRINT MEDIA ================= */
@media print {
  body {
    background: #fff;
  }
  .no-print {
    display: none !important;
  }
  .workspace {
    display: block;
    padding: 0;
    margin: 0;
  }
  .right-panel {
    position: static;
  }
  .paper-stage {
    padding: 0;
    background: #fff;
    box-shadow: none;
  }
  .sabre-paper {
    width: 100%;
    min-height: auto;
    box-shadow: none;
    padding: 12px 16px;
  }
}
