/* ============ GliderForge ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --sky1: #aedcff; --sky2: #eaf7ff;
  --ink: #1d3244; --ink2: #557089;
  --panel: rgba(255,255,255,.72);
  --accent: #ff6b4a; --accent2: #ff8f5e;
  --blue: #2f7fd0; --balsa: #ecd3a3;
  --good: #2e9e6b; --warn: #d98a12; --bad: #d0453a;
  --radius: 16px;
  font-size: 15px;
}
html, body { height: 100%; }
body {
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky1), var(--sky2) 70%, #f7f2e4);
  overflow: hidden;
}
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- header ---------- */
header {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px;
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(29,50,68,.08);
}
.logo { display: flex; align-items: baseline; gap: 8px; font-size: 21px; }
.logo b { letter-spacing: -.5px; }
.logoPlane { font-size: 24px; transform: translateY(2px); display: inline-block; }
.logo .tag { font-size: 12px; color: var(--ink2); }
.nameWrap { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nameWrap label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink2); }
#planeName {
  font: 700 16px/1 "Avenir Next", system-ui, sans-serif;
  letter-spacing: 2px; text-transform: uppercase;
  border: 2px solid rgba(29,50,68,.15); border-radius: 10px;
  padding: 7px 12px; width: 190px; background: rgba(255,255,255,.85); color: var(--ink);
  outline: none; transition: border-color .15s;
}
#planeName:focus { border-color: var(--blue); }
button {
  font: 600 14px/1 inherit; color: var(--ink);
  border: none; border-radius: 12px; padding: 10px 16px;
  background: rgba(255,255,255,.9); cursor: pointer;
  box-shadow: 0 1px 3px rgba(29,50,68,.15);
  transition: transform .08s, box-shadow .15s, background .15s;
}
button:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(29,50,68,.18); }
button:active { transform: translateY(0); }
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 700;
}
button.mini { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
button.on { background: var(--blue); color: #fff; }

/* ---------- layout ---------- */
#body { flex: 1; display: flex; min-height: 0; }
#panel {
  width: 302px; min-width: 302px; overflow-y: auto;
  padding: 14px 14px 24px;
  background: var(--panel); backdrop-filter: blur(10px);
  border-right: 1px solid rgba(29,50,68,.08);
}
#stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#cwrap { flex: 1; position: relative; min-height: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- tabs ---------- */
#tabs { display: flex; gap: 6px; padding: 10px 14px 4px; }
#tabs button {
  border-radius: 999px; padding: 9px 18px; font-weight: 600;
  background: rgba(255,255,255,.6); color: var(--ink2); box-shadow: none;
}
#tabs button.on { background: var(--ink); color: #fff; }

/* ---------- sliders ---------- */
.sgroup { margin-bottom: 6px; }
.sgroup h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.6px;
  color: var(--ink2); margin: 14px 4px 8px;
}
.srow {
  background: rgba(255,255,255,.65); border-radius: 14px;
  padding: 9px 12px 7px; margin-bottom: 8px;
}
.srow .top { display: flex; justify-content: space-between; align-items: baseline; }
.srow .lbl { font-size: 13.5px; font-weight: 600; }
.srow .val { font-size: 12.5px; color: var(--blue); font-weight: 700; font-variant-numeric: tabular-nums; }
.srow .ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink2); margin-top: -2px; }
input[type=range] { -webkit-appearance: none; width: 100%; height: 26px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, #cfe3f5, #9ec9ec);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px;
  border-radius: 50%; background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(29,50,68,.3); cursor: grab;
}
input[type=range]:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.12); }

/* ---------- readouts ---------- */
#readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 16px; }
.chip {
  background: rgba(255,255,255,.8); border-radius: 12px; padding: 8px 10px;
}
.chip .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink2); }
.chip .v { font-size: 16px; font-weight: 700; margin-top: 1px; font-variant-numeric: tabular-nums; }
.chip .v small { font-size: 11px; font-weight: 600; color: var(--ink2); }
.chip.wide { grid-column: span 2; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; color: #fff; font-size: 12.5px; font-weight: 700; }
#warnings { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.warnItem {
  background: #fff3e2; border: 1px solid #f2c98d; color: #8a5b13;
  border-radius: 10px; padding: 8px 10px; font-size: 12.5px;
}

/* ---------- bottom bar ---------- */
#bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; min-height: 58px;
  background: rgba(255,255,255,.6); backdrop-filter: blur(8px);
  border-top: 1px solid rgba(29,50,68,.08);
}
#bar .barSlider { display: flex; align-items: center; gap: 8px; }
#bar .barSlider label { font-size: 12.5px; font-weight: 600; color: var(--ink2); white-space: nowrap; }
#bar .barSlider input[type=range] { width: 130px; }
#bar .barSlider .bval { font-size: 12.5px; font-weight: 700; color: var(--blue); min-width: 44px; font-variant-numeric: tabular-nums; }
#bar select {
  font: 600 13px/1 inherit; padding: 8px 10px; border-radius: 10px;
  border: 1px solid rgba(29,50,68,.18); background: #fff; color: var(--ink);
}
#bar input[type=text] {
  font: 600 14px/1 inherit; padding: 8px 10px; border-radius: 10px;
  border: 2px solid rgba(29,50,68,.15); background: #fff; color: var(--ink); width: 140px; outline: none;
}
button.fly {
  background: linear-gradient(135deg, #ffd23f, var(--accent));
  color: #5b2000; font-size: 17px; font-weight: 800; padding: 12px 30px;
  border-radius: 999px; letter-spacing: 1px;
  box-shadow: 0 4px 14px rgba(255,107,74,.45);
}
button.fly:hover { transform: translateY(-2px) scale(1.03); }
.spacer { flex: 1; }
.stampBtn { font-size: 18px; padding: 7px 10px; }
.hint { font-size: 12px; color: var(--ink2); }

/* ---------- hud / overlays ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
.resultCard {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%,-50%);
  background: rgba(255,255,255,.94); border-radius: 22px; padding: 26px 40px;
  text-align: center; pointer-events: auto;
  box-shadow: 0 12px 50px rgba(29,50,68,.28);
  animation: pop .35s cubic-bezier(.2,1.6,.4,1);
}
@keyframes pop { from { transform: translate(-50%,-40%) scale(.7); opacity: 0; } }
.resultCard .big { font-size: 44px; font-weight: 800; letter-spacing: -1px; }
.resultCard .stars { font-size: 26px; margin: 4px 0; letter-spacing: 4px; }
.resultCard .sub { color: var(--ink2); font-size: 14px; margin-bottom: 6px; }
.resultCard .tip { font-size: 12.5px; color: var(--ink2); max-width: 300px; margin: 6px auto 12px; }
.settingsCard .setGrid { display: flex; flex-direction: column; gap: 10px; text-align: left; margin: 4px 0; }
.settingsCard .setRow { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 13px; }
.settingsCard .setRow label { font-weight: 600; color: var(--ink2); }
.settingsCard .setRow input[type=number] {
  font: 600 14px/1 inherit; padding: 7px 9px; border-radius: 10px;
  border: 2px solid rgba(29,50,68,.15); background: #fff; color: var(--ink);
  width: 90px; outline: none;
}
.settingsCard .setRow select {
  font: 600 13px/1 inherit; padding: 7px 9px; border-radius: 10px;
  border: 2px solid rgba(29,50,68,.15); background: #fff; color: var(--ink); outline: none;
}
.settingsCard .setRow input[type=number]:focus,
.settingsCard .setRow select:focus { border-color: var(--blue); }
#toast {
  position: absolute; left: 50%; bottom: 18px;
  transform: translate(-50%, 16px);
  background: rgba(29,50,68,.93); color: #fff;
  font: 600 13.5px/1 "Avenir Next", system-ui, sans-serif;
  padding: 13px 22px; border-radius: 999px;
  opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; z-index: 60; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#errbox {
  position: absolute; left: 8px; bottom: 8px; right: 8px; display: none;
  background: #c0392b; color: #fff; font: 12px/1.4 monospace;
  padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; z-index: 50;
}
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: rgba(29,50,68,.18); border-radius: 5px; }
@media (max-width: 900px) {
  #body { flex-direction: column; }
  #panel { width: 100%; min-width: 0; max-height: 38vh; order: 2; }
}

/* ---------- header session (accounts) ---------- */
#authArea { display: flex; align-items: center; gap: 8px; }
#authArea .sessEmail {
  font-size: 12.5px; font-weight: 600; color: var(--ink2);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#authArea #authLogout { padding: 8px 12px; font-size: 13px; }

/* ---------- auth modal ---------- */
#authModal {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center;
  background: rgba(29,50,68,.42); backdrop-filter: blur(3px);
}
#authModal.show { display: flex; }
.authCard {
  position: relative; width: 360px; max-width: calc(100vw - 32px);
  background: #fff; border-radius: 20px; padding: 26px 26px 22px;
  box-shadow: 0 20px 70px rgba(29,50,68,.4);
  animation: pop .3s cubic-bezier(.2,1.6,.4,1);
}
.authClose {
  position: absolute; top: 12px; right: 12px; padding: 6px 10px;
  border-radius: 999px; background: rgba(29,50,68,.06); font-size: 13px; box-shadow: none;
}
.authTitle { font-size: 19px; font-weight: 800; letter-spacing: -.3px; margin: 2px 0 16px; }
.authField { display: block; margin-bottom: 12px; }
.authField span {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--ink2); margin-bottom: 4px;
}
.authField input {
  width: 100%; font: 600 15px/1 inherit; color: var(--ink);
  border: 2px solid rgba(29,50,68,.15); border-radius: 10px; padding: 10px 12px;
  background: #fff; outline: none; transition: border-color .15s;
}
.authField input:focus { border-color: var(--blue); }
.authSubmit { width: 100%; padding: 12px; font-size: 15px; margin-top: 2px; }
.authSubmit.busy { opacity: .6; pointer-events: none; }
.authGoogle {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px; font-size: 14px; font-weight: 700; background: #fff;
  border: 2px solid rgba(29,50,68,.15); box-shadow: none;
}
.authGoogle .gG {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0);
  color: #fff; font-weight: 900; font-size: 12px;
}
.authOr { text-align: center; margin: 14px 0; position: relative; color: var(--ink2); font-size: 12px; }
.authOr::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: rgba(29,50,68,.12); }
.authOr span { position: relative; background: #fff; padding: 0 10px; }
.authError { color: var(--bad); font-size: 12.5px; min-height: 16px; margin: 2px 0 8px; }
.authTip { font-size: 12.5px; color: var(--ink2); margin: -4px 0 12px; }
.authSwitch { display: flex; flex-direction: column; gap: 6px; align-items: center; margin-top: 14px; font-size: 12.5px; color: var(--ink2); }
.authSwitch a { color: var(--blue); font-weight: 600; cursor: pointer; }
.authSwitch a:hover { text-decoration: underline; }

/* ---------- My Fleet ---------- */
.fleetCard { text-align: left; min-width: 340px; max-width: 460px; }
.fleetSave { display: flex; gap: 8px; margin-bottom: 12px; }
.fleetSave input {
  flex: 1; font: 700 14px/1 inherit; letter-spacing: 1px; text-transform: uppercase;
  border: 2px solid rgba(29,50,68,.15); border-radius: 10px; padding: 9px 11px; outline: none; color: var(--ink);
}
.fleetSave input:focus { border-color: var(--blue); }
.fleetList { max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.fleetRow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(255,255,255,.85); border: 1px solid rgba(29,50,68,.08);
  border-radius: 10px; padding: 8px 10px;
}
.fleetRowName { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fleetRowActions { display: flex; gap: 6px; flex-shrink: 0; }
.fleetRowActions button { padding: 6px 10px; font-size: 12.5px; box-shadow: none; background: rgba(29,50,68,.06); }
.fleetRowActions button.danger { color: var(--bad); }

/* ---------- print pages (D-2): hidden on screen, shown only when printing ---------- */
#printRoot { display: none; }
@media print {
  @page { size: letter portrait; margin: 10mm; }
  html, body { height: auto; overflow: visible; background: #fff; }
  #app, #authModal, #toast { display: none !important; }
  #printRoot { display: block; }
  .printPage { page-break-after: always; break-after: page; }
  .printPage:last-child { page-break-after: auto; break-after: auto; }
  .printPage svg { display: block; }
  #cartArea, #checkoutModal { display: none !important; }
}

/* ============================================================
   commerce (P2.C) — header cart badge, Cart tab, Orders tab,
   checkout-return confirmation modal.
   ============================================================ */

/* ---------- header cart badge ---------- */
#cartArea { display: flex; align-items: center; }
#cartArea #cartOpen { display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px; font-size: 13px; }
#cartArea .cartCount {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: rgba(29,50,68,.12); color: var(--ink2);
  font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums;
}
#cartArea .cartCount.has { background: var(--accent); color: #fff; }

/* ---------- Cart tab ---------- */
.cartCard { text-align: left; min-width: 360px; max-width: 480px; }
.cartHead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cartHead .sub { margin: 0; }
.cartHead .mini { box-shadow: none; background: rgba(29,50,68,.06); }
.cartEmpty { font-size: 13px; color: var(--ink2); padding: 10px 2px 4px; line-height: 1.5; }
.cartLines { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
.cartLine {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.85); border: 1px solid rgba(29,50,68,.08);
  border-radius: 10px; padding: 8px 10px;
}
.cartLineInfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cartLineName { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cartLineUnit { font-size: 11px; color: var(--ink2); }
.cartQty { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.cartQty .qtyBtn {
  width: 26px; height: 28px; padding: 0; font-size: 16px; font-weight: 700;
  border-radius: 8px; background: rgba(29,50,68,.06); box-shadow: none; color: var(--ink);
}
.cartQty .qtyInput {
  width: 44px; height: 28px; text-align: center; font: 700 13px/1 inherit; color: var(--ink);
  border: 2px solid rgba(29,50,68,.15); border-radius: 8px; background: #fff; outline: none;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.cartQty .qtyInput:focus { border-color: var(--blue); }
.cartQty .qtyInput::-webkit-outer-spin-button,
.cartQty .qtyInput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cartLineTotal { font-weight: 700; font-size: 14px; min-width: 58px; text-align: right; font-variant-numeric: tabular-nums; }
.cartLineRemove { padding: 6px 9px; font-size: 12px; box-shadow: none; background: rgba(29,50,68,.06); color: var(--bad); flex-shrink: 0; }
.cartSummary { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(29,50,68,.1); display: flex; flex-direction: column; gap: 5px; }
.cartRow { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink2); }
.cartRow span:last-child { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.cartRow small { font-weight: 500; }
.cartRow.cartTaxNote span:last-child { font-weight: 500; font-style: italic; color: var(--ink2); }
.cartRow.cartTotal { font-size: 15px; color: var(--ink); margin-top: 2px; }
.cartCheckout { width: 100%; margin-top: 14px; padding: 13px; font-size: 15px; }
.cartCheckout:disabled { opacity: .6; pointer-events: none; }
.cartFinePrint { font-size: 11.5px; color: var(--ink2); margin-top: 8px; line-height: 1.45; }

/* ---------- Orders tab ---------- */
.ordersCard { text-align: left; min-width: 360px; max-width: 480px; }
.ordersList { max-height: 48vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.orderRow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer;
  background: rgba(255,255,255,.85); border: 1px solid rgba(29,50,68,.08);
  border-radius: 10px; padding: 9px 11px; transition: background .12s, transform .08s;
}
.orderRow:hover { background: #fff; transform: translateY(-1px); }
.orderRowMain { display: flex; flex-direction: column; gap: 1px; }
.orderRowId { font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.orderRowDate { font-size: 11px; color: var(--ink2); }
.orderRowMeta { display: flex; align-items: center; gap: 10px; }
.orderRowTotal { font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.orderStatus {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; background: rgba(47,127,208,.14); color: var(--blue);
}
.orderStatus.status-shipped { background: rgba(46,158,107,.16); color: var(--good); }
.orderStatus.status-refunded, .orderStatus.status-disputed { background: rgba(208,69,58,.14); color: var(--bad); }
.orderDetail { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.orderDetailHead { display: flex; align-items: center; justify-content: space-between; }
.orderDetailDate { font-size: 12px; color: var(--ink2); }
.orderItems { display: flex; flex-direction: column; gap: 5px; }
.orderItem {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.7); border-radius: 8px; padding: 7px 10px; font-size: 13px;
}
.orderItemName { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orderItemQty { color: var(--ink2); font-weight: 700; font-variant-numeric: tabular-nums; }
.orderItemPrice { font-weight: 700; min-width: 54px; text-align: right; font-variant-numeric: tabular-nums; }
.orderTracking { font-size: 12.5px; color: var(--ink2); }
.orderTotals { padding-top: 8px; border-top: 1px solid rgba(29,50,68,.1); display: flex; flex-direction: column; gap: 4px; }
.orderTimeline { display: flex; flex-direction: column; gap: 3px; }
.orderTimelineRow { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink2); }
#ordersBack2, [data-testid="order-back"] { align-self: flex-start; box-shadow: none; background: rgba(29,50,68,.06); }

/* ---------- checkout-return confirmation modal ---------- */
#checkoutModal {
  position: fixed; inset: 0; z-index: 110; display: none;
  align-items: center; justify-content: center;
  background: rgba(29,50,68,.42); backdrop-filter: blur(3px);
}
#checkoutModal.show { display: flex; }
.checkoutCard {
  position: relative; width: 380px; max-width: calc(100vw - 32px); text-align: center;
  background: #fff; border-radius: 20px; padding: 30px 28px 24px;
  box-shadow: 0 20px 70px rgba(29,50,68,.4);
  animation: pop .3s cubic-bezier(.2,1.6,.4,1);
}
.checkoutCard .authClose {
  position: absolute; top: 12px; right: 12px; padding: 6px 10px;
  border-radius: 999px; background: rgba(29,50,68,.06); font-size: 13px; box-shadow: none;
}
.checkoutIcon { font-size: 40px; }
.checkoutTitle { font-size: 20px; font-weight: 800; letter-spacing: -.3px; margin: 8px 0 6px; }
.checkoutTip { font-size: 13px; color: var(--ink2); line-height: 1.5; max-width: 300px; margin: 0 auto 14px; }
.checkoutOrderId { font-size: 13px; color: var(--ink2); margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.checkoutOrderId b { color: var(--ink); }
.checkoutCard .primary { width: 100%; padding: 12px; font-size: 15px; }
.checkoutSpinner {
  width: 34px; height: 34px; margin: 2px auto 4px; border-radius: 50%;
  border: 4px solid rgba(29,50,68,.12); border-top-color: var(--accent);
  animation: gfspin .8s linear infinite;
}
@keyframes gfspin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .cartCard, .ordersCard { min-width: 0; width: calc(100vw - 36px); }
}
