:root{
  --bg:#FFFFFF;
  --surface:#FFFFFF;
  --surface2:#F7FAFF;
  --stroke:#E6ECF7;
  --text:#0B1220;
  --muted:#4C5B78;
  --brand:#1668FF;
  --brand2:#36C7FF;
  --danger:#D92D20;
  --dangerBg:#FFF1F3;
  --ok:#067647;
  --okBg:#ECFDF3;
  --warn:#B54708;
  --warnBg:#FFFAEB;
  --shadow: 0 18px 50px rgba(11,18,32,.10);
  --radius: 18px;
}

*{ box-sizing:border-box; }
[hidden]{ display: none !important; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.bg{
  position:fixed;
  inset:-45vmax;
  background:
    radial-gradient(closest-side, rgba(22,104,255,.10), transparent 62%),
    radial-gradient(closest-side, rgba(54,199,255,.08), transparent 62%),
    radial-gradient(closest-side, rgba(22,104,255,.06), transparent 62%);
  filter: blur(34px);
  transform: translate3d(0,0,0);
  pointer-events:none;
  z-index:-1;
}

.container{
  width:min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
  position:relative;
}

.header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 8px 0 18px;
}

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

.logoImg{
  width: 56px;
  height: 56px;
  object-fit: contain;
  display:block;
  filter: drop-shadow(0 10px 18px rgba(11,18,32,.10));
}

.brandName{ font-weight:750; }
.brandTag{ font-size: 13px; color: var(--muted); margin-top:2px;}

.card{
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
}

.card + .card{ margin-top: 18px; }

h1{
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: .2px;
}

h2{
  margin: 0;
  font-size: 16px;
  letter-spacing: .2px;
}

.muted{ color: var(--muted); }

.form{ margin-top: 16px; }
.label{
  display:block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.fieldRow{
  display:flex;
  gap:10px;
  align-items:stretch;
}

.input{
  flex: 1;
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--text);
  background: #FFFFFF;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  outline:none;
  letter-spacing:.4px;
}
.input:focus{
  border-color: rgba(22,104,255,.55);
  box-shadow: 0 0 0 4px rgba(22,104,255,.12);
}

.btn{
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(22,104,255,.22);
  background: linear-gradient(135deg, rgba(22,104,255,.96), rgba(54,199,255,.92));
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 650;
  cursor:pointer;
  min-width: 120px;
  transition: filter .15s ease, transform .05s ease;
}
.btn:hover{ filter: saturate(1.05) brightness(1.02); }
.btn:active{ transform: translateY(1px); }
.btn:focus-visible{ outline:none; box-shadow: 0 0 0 4px rgba(22,104,255,.22); }

.btnGhost{
  background: #FFFFFF;
  color: var(--text);
  border: 1px solid var(--stroke);
}
.btnGhost:hover{ background: var(--surface2); filter:none; }

.errorMsg{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(217,45,32,.22);
  background: var(--dangerBg);
  color: rgba(217,45,32,.95);
  font-size: 14px;
}
.errorDot{
  width:8px; height:8px; border-radius:999px;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(217,45,32,.15);
  flex-shrink:0;
}

/* ---------- Tracking result card ---------- */
.resultCard{
  animation: fadeUp .35s ease both;
}
@keyframes fadeUp{
  from{ opacity:0; transform: translateY(8px); }
  to{ opacity:1; transform: translateY(0); }
}

.resultHead{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  flex-wrap:wrap;
}
.resultHeadLeft .resultLabel{
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  font-weight:600;
}
.resultNumber{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text);
  letter-spacing: 1px;
}

.statusPill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .2px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.statusPill::before{
  content:"";
  width:8px; height:8px; border-radius:999px;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(0,0,0,.06);
}
.statusPill[data-tone="info"]{ background: rgba(22,104,255,.10); color:#1654d6; border-color: rgba(22,104,255,.18);}
.statusPill[data-tone="ok"]{ background: var(--okBg); color: var(--ok); border-color: rgba(6,118,71,.18);}
.statusPill[data-tone="warn"]{ background: var(--warnBg); color: var(--warn); border-color: rgba(181,71,8,.18);}
.statusPill[data-tone="muted"]{ background: #EEF2F9; color: var(--muted); border-color: var(--stroke);}

/* ---------- Route map ---------- */
.routeMap{
  margin-top: 18px;
  padding: 18px 12px 8px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(22,104,255,.05), rgba(54,199,255,.04));
  border: 1px dashed rgba(22,104,255,.18);
  display:flex;
  align-items:flex-start;
  gap: 6px;
}

.routePoint{
  flex: 0 0 auto;
  text-align:center;
  padding: 4px 6px 8px;
  min-width: 78px;
  position:relative;
}
.routePoint .flag{
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(11,18,32,.12));
}
.flagIcon{
  display:inline-flex;
  align-items:center; justify-content:center;
  width: 38px; height: 26px;
  border-radius: 5px;
  overflow:hidden;
  background:#fff;
  border: 1px solid var(--stroke);
  box-shadow: 0 4px 10px rgba(11,18,32,.10);
}
.flagIcon svg{ display:block; width:100%; height:100%; }
.routePoint .routeCity{
  font-size: 14px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
}
.routePoint .routeCountry{
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.routePoint[data-current="true"]::after{
  content:"";
  display:block;
  width: 30px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand2));
  box-shadow: 0 4px 12px rgba(22,104,255,.35);
}

.routeLine{
  flex: 1 1 auto;
  position: relative;
  height: 36px;
  margin-top: 18px;
  border-radius: 999px;
  background: rgba(22,104,255,.10);
}
.routeLine::before{
  content:"";
  position:absolute;
  inset: 16px 8px;
  border-top: 2px dashed rgba(22,104,255,.35);
}
.routeProgress{
  position:absolute;
  left:0; top:0; bottom:0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(22,104,255,.18), rgba(54,199,255,.30));
  transition: width .6s ease;
}
.routeProgress::after{
  content:"";
  position:absolute;
  right:0; top: 50%;
  width: 2px; height: 22px;
  transform: translate(0, -50%);
  background: linear-gradient(180deg, var(--brand), var(--brand2));
  border-radius: 2px;
  opacity: .6;
}
.routeLine[data-state="done"] .routeProgress{ width: 100%; background: linear-gradient(90deg, rgba(22,104,255,.32), rgba(54,199,255,.42)); }
.routeLine[data-state="active"] .routeProgress{ width: 50%; }
.routeLine[data-state="active"] .planeIcon{ animation: planeFly 2.4s ease-in-out infinite; }

.planeIcon{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(8deg);
  color: var(--brand);
  background: #fff;
  border: 1px solid rgba(22,104,255,.18);
  border-radius: 999px;
  width: 30px; height: 30px;
  display:flex; align-items:center; justify-content:center;
  box-shadow: 0 6px 14px rgba(22,104,255,.20);
}
.routeLine[data-state="todo"] .planeIcon{ color: var(--muted); background: #f3f5fa; border-color: var(--stroke); box-shadow:none;}
.routeLine[data-state="done"] .planeIcon{ color: var(--ok); border-color: rgba(6,118,71,.22); }

@keyframes planeFly{
  0%   { transform: translate(-90%, -50%) rotate(6deg); }
  50%  { transform: translate(-10%, -65%) rotate(10deg); }
  100% { transform: translate(-90%, -50%) rotate(6deg); }
}

/* ---------- Meta grid ---------- */
.metaGrid{
  margin-top: 16px;
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}
.metaItem{
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fff;
}
.metaLabel{
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  font-weight:600;
}
.metaValue{
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
  color: var(--text);
}

/* ---------- Timeline ---------- */
.timelineHead{
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap:8px;
  margin-top: 20px;
  margin-bottom: 10px;
  flex-wrap:wrap;
}
.lastUpdate{
  font-size: 12.5px;
  color: var(--muted);
}

.timeline{
  list-style:none;
  margin: 0;
  padding: 6px 0 0;
  position:relative;
}
.timeline::before{
  content:"";
  position:absolute;
  top: 8px; bottom: 8px;
  left: 11px;
  width: 2px;
  background: var(--stroke);
  border-radius: 2px;
}
.tlItem{
  position:relative;
  padding: 8px 0 8px 36px;
  display:flex;
  align-items:flex-start;
  gap: 12px;
  flex-wrap:wrap;
}
.tlDot{
  position:absolute;
  left: 4px; top: 12px;
  width: 16px; height: 16px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--stroke);
  box-sizing:border-box;
}
.tlItem[data-state="done"] .tlDot{
  border-color: var(--ok);
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(6,118,71,.12);
}
.tlItem[data-state="active"] .tlDot{
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(22,104,255,.18);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse{
  0%,100%{ box-shadow: 0 0 0 0 rgba(22,104,255,.35); }
  50%{ box-shadow: 0 0 0 8px rgba(22,104,255,0); }
}

.tlMain{ flex: 1 1 240px; min-width: 0; }
.tlTitle{ font-size: 14.5px; font-weight: 700; }
.tlSub{ font-size: 12.5px; color: var(--muted); margin-top: 2px;}
.tlTime{
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  align-self: center;
}
.tlItem[data-state="active"] .tlTitle{ color: var(--brand); }
.tlItem[data-state="todo"] .tlTitle{ color: var(--muted); font-weight: 600; }

/* ---------- Footer / admin link ---------- */
.footer{
  margin-top: 18px;
  padding: 10px 2px 0;
  font-size: 13px;
  display:flex;
  justify-content:flex-end;
}
.adminLink{
  color: var(--muted);
  text-decoration:none;
  border: 1px solid var(--stroke);
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  font-size: 12.5px;
}
.adminLink:hover{ color: var(--brand); border-color: rgba(22,104,255,.30); }

/* ---------- Admin page ---------- */
.adminWrap{ width:min(560px, calc(100% - 32px)); margin: 0 auto; }

.pinCard{
  text-align:center;
  padding: 26px 20px;
}
.pinDots{
  display:flex; gap: 14px; justify-content:center;
  margin: 18px 0 14px;
}
.pinDot{
  width: 16px; height: 16px;
  border-radius: 999px;
  border: 2px solid var(--stroke);
  background: #fff;
}
.pinDot[data-filled="true"]{
  border-color: var(--brand);
  background: var(--brand);
}
.pinDot[data-error="true"]{
  border-color: var(--danger);
  background: var(--danger);
  animation: shake .35s ease;
}
@keyframes shake{
  0%,100%{ transform: translateX(0); }
  20%{ transform: translateX(-4px); }
  40%{ transform: translateX(4px); }
  60%{ transform: translateX(-3px); }
  80%{ transform: translateX(3px); }
}

.pinPad{
  margin: 18px auto 0;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 320px;
}
.pinKey{
  appearance:none;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 16px 0;
  font-size: 22px;
  font-weight: 700;
  cursor:pointer;
  color: var(--text);
  transition: background .12s ease, transform .05s ease;
}
.pinKey:hover{ background: var(--surface2); }
.pinKey:active{ transform: translateY(1px); }
.pinKey[data-action="del"]{ font-size: 18px; color: var(--muted); }
.pinKey[data-action="back"]{ color: var(--muted); }

.adminHead{
  display:flex; justify-content:space-between; align-items:center;
  flex-wrap:wrap; gap: 10px;
}
.adminHead h1{ font-size: 22px; }

.shipmentTag{
  display:inline-flex; gap:8px; align-items:center;
  background: rgba(22,104,255,.08);
  border: 1px solid rgba(22,104,255,.18);
  color: #1654d6;
  padding: 6px 10px;
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
}

.checkList{
  margin: 14px 0 4px;
  padding: 0;
  list-style:none;
  display:flex;
  flex-direction:column;
  gap: 8px;
}
.checkItem{
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--stroke);
  background: #fff;
  border-radius: 14px;
  cursor:pointer;
  user-select:none;
  transition: border-color .15s ease, background .15s ease;
}
.checkItem:hover{ border-color: rgba(22,104,255,.30); }
.checkItem[data-checked="true"]{
  border-color: rgba(22,104,255,.45);
  background: linear-gradient(180deg, rgba(22,104,255,.05), rgba(54,199,255,.05));
}
.checkBox{
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 2px solid var(--stroke);
  display:inline-flex; align-items:center; justify-content:center;
  background:#fff;
  flex-shrink:0;
  color: #fff;
  transition: background .15s ease, border-color .15s ease;
}
.checkItem[data-checked="true"] .checkBox{
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 4px 10px rgba(22,104,255,.30);
}
.checkBox svg{ width: 14px; height: 14px; opacity: 0; transition: opacity .15s ease; }
.checkItem[data-checked="true"] .checkBox svg{ opacity: 1; }
.checkLabel{
  flex: 1 1 auto;
  display:flex; flex-direction:column; gap: 2px;
}
.checkTitle{ font-size: 14.5px; font-weight: 650; }
.checkSub{ font-size: 12.5px; color: var(--muted); }
.checkFlag{
  display:inline-flex; align-items:center; justify-content:center;
  width: 36px; height: 26px;
  border-radius: 6px;
  background:#fff;
  border: 1px solid var(--stroke);
  flex-shrink: 0;
  overflow:hidden;
}
.checkFlag svg{ display:block; }

.adminActions{
  display:flex; gap: 10px; flex-wrap: wrap;
  margin-top: 14px;
}

.toast{
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #0B1220;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(11,18,32,.30);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 50;
}
.toast[data-show="true"]{
  opacity: 1;
  transform: translate(-50%, -4px);
}

/* ---------- Mobile ---------- */
@media (max-width: 640px){
  .container{ padding: 18px 0 32px; }
  .card{ padding: 18px 16px; border-radius: 16px; }
  h1{ font-size: 22px; }
  .fieldRow{ flex-direction:column; }
  .btn{ width:100%; }
  .logoImg{ width: 48px; height: 48px; }

  .resultNumber{ font-size: 18px; }

  .routeMap{
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 14px 12px;
  }
  .routePoint{
    display:flex;
    align-items:center;
    gap: 12px;
    text-align:left;
    padding: 8px 6px;
    min-width: 0;
  }
  .routePoint .flag{ font-size: 24px; }
  .routePoint .routeCity{ margin-top: 0; font-size: 14.5px; }
  .routePoint .routeCountry{ margin-top: 0; }
  .routePoint > div:not(.flag){
    flex: 1 1 auto;
  }
  .routePoint[data-current="true"]::after{
    width: 6px; height: 22px;
    margin: 0 0 0 auto;
  }

  .routeLine{
    width: 4px;
    height: 44px;
    margin: 0 0 0 18px;
    border-radius: 4px;
    background: rgba(22,104,255,.10);
  }
  .routeLine::before{
    inset: 6px 1px;
    border-top: none;
    border-left: 2px dashed rgba(22,104,255,.35);
  }
  .routeProgress{
    width: 100%;
    height: 0%;
    top: 0; bottom: auto;
    transition: height .6s ease;
  }
  .routeLine[data-state="done"] .routeProgress{ height: 100%; width: 100%; }
  .routeLine[data-state="active"] .routeProgress{ height: 50%; width: 100%; }
  .routeProgress::after{ display:none; }
  .planeIcon{ width: 26px; height: 26px; transform: translate(-50%, -50%) rotate(98deg); }
  @keyframes planeFly{
    0%   { transform: translate(-50%, -90%) rotate(96deg); }
    50%  { transform: translate(-50%, -10%) rotate(100deg); }
    100% { transform: translate(-50%, -90%) rotate(96deg); }
  }

  .metaGrid{ grid-template-columns: 1fr; }
}

@media (max-width: 380px){
  .pinPad{ gap: 8px; }
  .pinKey{ font-size: 20px; padding: 14px 0; }
}
