/* Airport Rep App — compact multi-booking ops UI (PROTOTYPE-SAFE) */
:root {
  --font: "Noto Sans Thai", "Noto Sans", "Segoe UI", Arial, sans-serif;
  --primary: #1a5fd4;
  --primary-hover: #1554bd;
  --primary-soft: #e8f1fe;
  --page-bg: #e8ecf1;
  --surface: #ffffff;
  --text-primary: #1f2329;
  --text-secondary: #5c6570;
  --text-muted: #6b7380;
  --border: #e5e9ef;
  --border-strong: #d5dbe5;
  --success: #157a4d;
  --success-bg: #e8f8f0;
  --warning: #b45309;
  --warning-bg: #fff6e8;
  --danger: #c0392b;
  --danger-bg: #fdecee;
  --accent: #0d9488;
  --accent-soft: #e6f7f5;
  --neutral-bg: #f3f4f6;
  --radius-md: 8px;
  --shadow-sm: 0 1px 2px rgba(31, 35, 41, 0.06);
  --shadow-md: 0 8px 28px rgba(31, 35, 41, 0.14);
  --touch-min: 44px;
  --app-max: 460px;
  --xfer-in: var(--success);
  --xfer-in-soft: var(--success-bg);
  --xfer-out: var(--danger);
  --xfer-out-soft: var(--danger-bg);
  --xfer-tr: #c2410c;
  --xfer-tr-soft: #fff4ed;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text-primary);
  background: var(--page-bg);
}

.desktop-canvas {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.mobile-app {
  width: 100%;
  max-width: var(--app-max);
  min-height: 100vh;
  background: #f4f6f9;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

@media (max-width: 480px) {
  .mobile-app { box-shadow: none; }
  body { background: #f4f6f9; }
}

#app-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.view { display: none; }
.view.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* —— Compact header —— */
.app-header {
  flex-shrink: 0;
  padding: 6px 10px 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.header-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-title strong {
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.header-dot {
  color: var(--text-muted);
  font-weight: 500;
}

.lang-toggle {
  display: inline-flex;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.lang-btn {
  min-width: 34px;
  min-height: 28px;
  padding: 0 8px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}

.lang-btn.is-active {
  background: var(--primary);
  color: #fff;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.date-nav-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 1.25rem;
  line-height: 1;
  color: var(--primary);
  cursor: pointer;
}

.date-nav-center {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  color: inherit;
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.date-nav-center:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.date-nav-center:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.date-nav-label {
  position: relative;
  z-index: 1;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Input sits under label; clicks hit the center control → showPicker() */
.date-input-hidden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
  font-size: 16px;
}

/* Direction tabs — compact */
.direction-toggle {
  display: flex;
  flex-shrink: 0;
  margin: 6px 10px 0;
  padding: 2px;
  background: var(--neutral-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.dir-btn {
  flex: 1;
  min-height: 34px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
}

.dir-btn.is-active {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.dir-btn.is-active.is-in { color: var(--xfer-in); }
.dir-btn.is-active.is-out { color: var(--xfer-out); }

.list-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 72px;
}

.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 12px 2px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.sec-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.op-list {
  padding: 0 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* —— Compact booking card —— */
.op-card {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  min-height: 0;
}

.op-card:active { background: var(--neutral-bg); }

.op-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.op-card.is-warning {
  border-color: var(--warning);
  background: linear-gradient(to bottom, var(--warning-bg) 0%, var(--surface) 40px);
}

.op-card.is-handled {
  opacity: 0.78;
  background: #fafbfc;
}

.op-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

.op-anchor {
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
  min-width: 0;
}

.op-top-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.op-kind {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 40px;
  padding: 1px 5px;
  border-radius: 5px;
  line-height: 1.05;
}

.op-kind-code {
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.op-kind-lbl {
  font-size: 0.5625rem;
  font-weight: 600;
  margin-top: 1px;
  opacity: 0.95;
}

.op-kind.kind-in {
  background: var(--xfer-in-soft);
  color: var(--xfer-in);
}
.op-kind.kind-out {
  background: var(--xfer-out-soft);
  color: var(--xfer-out);
}
.op-kind.kind-tr {
  background: var(--xfer-tr-soft);
  color: var(--xfer-tr);
}

.op-guest-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1px;
  min-width: 0;
}

.op-guest {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.op-pax {
  flex-shrink: 0;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.op-hotel {
  margin-bottom: 2px;
  min-width: 0;
}

.place-name {
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.15;
  word-break: break-word;
}

.place-name-th {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.15;
  word-break: break-word;
}

.op-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding-top: 3px;
  border-top: 1px solid var(--border);
  min-width: 0;
}

.op-car {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.op-car-ico {
  flex-shrink: 0;
  font-size: 0.75rem;
  line-height: 1;
}

.op-car-txt {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.op-car.is-warn {
  color: var(--warning);
  font-weight: 700;
}

.op-badges {
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-waiting { background: var(--primary-soft); color: var(--primary); }
.badge-done { background: var(--success-bg); color: var(--success); }
.badge-welcome { background: var(--accent-soft); color: var(--accent); }

.flow-section-completed {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 2px;
  background: #f7f8fa;
}

.section-toggle {
  display: flex;
  width: 100%;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px 4px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: var(--touch-min);
}

.section-toggle:active { background: var(--neutral-bg); }

.dep-note {
  margin: 8px 12px 12px;
  padding: 8px 10px;
  background: var(--neutral-bg);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* —— Detail —— */
.detail-view { background: #f4f6f9; }

.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  flex-shrink: 0;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.detail-title {
  flex: 1;
  font-weight: 600;
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 16px;
}

.ops-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 8px;
}

.ops-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.ops-flight {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  min-width: 0;
}

.ops-kind-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1.15;
  flex-shrink: 0;
}

.ops-kind-badge .ops-kind-code {
  font-size: 0.8125rem;
  font-weight: 800;
}

.ops-kind-badge .ops-kind-lbl {
  font-size: 0.625rem;
  font-weight: 600;
  margin-top: 1px;
}

.ops-kind-badge.kind-in {
  background: var(--xfer-in-soft);
  color: var(--xfer-in);
}
.ops-kind-badge.kind-out {
  background: var(--xfer-out-soft);
  color: var(--xfer-out);
}

.ops-status {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.ops-status.st-waiting {
  background: var(--primary-soft);
  color: var(--primary);
}
.ops-status.st-done {
  background: var(--success-bg);
  color: var(--success);
}

.ops-guest-full {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word;
  margin-bottom: 2px;
}

.ops-pax-line {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.ops-subline {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.ops-place {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.ops-place-lbl,
.ops-meta-lbl,
.ops-note-lbl {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.ops-place .place-name {
  font-size: 0.9375rem;
  font-weight: 700;
}

.ops-place .place-name-th {
  font-size: 0.8125rem;
}

.ops-assign {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.ops-assign-cell,
.ops-meta-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.ops-meta-row {
  margin-bottom: 8px;
}

.ops-meta-val {
  font-size: 0.875rem;
  font-weight: 600;
  word-break: break-word;
}

.is-warn-txt { color: var(--warning); }

.ops-note {
  background: var(--warning-bg);
  border: 1px solid #f0d4a8;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.ops-note-val {
  font-size: 0.8125rem;
  font-weight: 500;
  word-break: break-word;
}

.ops-ref {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 2px;
}

.detail-sticky {
  flex-shrink: 0;
  padding: 10px 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.detail-sticky.is-readonly { padding-bottom: 16px; }

.action-area-note {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--touch-min);
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-action.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.toast-proto {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  max-width: calc(var(--app-max) - 32px);
  width: calc(100% - 32px);
  padding: 10px 14px;
  background: #1f2329;
  color: #f8fafc;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 100;
}

.toast-proto.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.app-footer-note {
  display: none;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 40;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  min-height: 56px;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

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

.bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bnav-item.is-active { color: var(--primary); }

.bnav-ico {
  width: 22px;
  height: 22px;
  display: block;
}

.bnav-label {
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.draft-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #f4f6f9;
}

.draft-header {
  flex-shrink: 0;
  padding: 10px 12px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.draft-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.draft-back-spacer {
  width: 52px;
  flex-shrink: 0;
}

.draft-heading {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  min-width: 0;
}

.draft-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 72px;
}

.draft-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px 16px;
  text-align: center;
}

.draft-icon-wrap {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.draft-icon-wrap .bnav-ico {
  width: 24px;
  height: 24px;
}

.draft-card h2 {
  margin: 0 0 8px;
  font-size: 1.0625rem;
  font-weight: 700;
}

.draft-lead {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.draft-badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 0.6875rem;
  font-weight: 700;
}

.draft-shell-note {
  margin: 8px 0 0;
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.draft-doc-list {
  text-align: left;
  margin: 0 0 12px;
  padding: 0 0 0 1.1rem;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.draft-meta {
  text-align: left;
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
}

.draft-meta dt {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 700;
}

.draft-meta dd {
  margin: 2px 0 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.more-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.more-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

.more-item:last-child { border-bottom: 0; }
.more-item.is-danger { color: var(--danger); }

.more-chevron {
  color: var(--text-muted);
  font-size: 1.125rem;
  font-weight: 400;
}

.confirm-layer {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 27, 45, 0.45);
}

.confirm-sheet {
  position: relative;
  width: 100%;
  max-width: var(--app-max);
  background: var(--surface);
  border-radius: 12px 12px 0 0;
  padding: 16px 16px 20px;
  box-shadow: var(--shadow-md);
}

.confirm-title {
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 1rem;
}

.confirm-body {
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

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

.confirm-actions .btn-action.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
