.tracking-widget, .tracking-modal {
  --tw-brand: #1900ac;    /* Deliberry indigo: headings, focus, current step */
  --tw-primary: #fe3135;  /* Deliberry red: buttons */
  --tw-primary-hover: #e0252a;
  --tw-ring: var(--tw-primary);  /* button outline: same red (override to add a different outline colour) */
  --tw-accent: var(--tw-brand);
  --tw-ok: #15803d;
  --tw-line: rgba(128, 128, 128, .3);
  --tw-soft: rgba(128, 128, 128, .08);
}
.tracking-widget {
  max-width: 760px;
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.5;
}
.tracking-widget *, .tracking-widget *::before, .tracking-widget *::after { box-sizing: border-box; }

/* ---- form ---- */
.tracking-widget__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px auto;
  gap: 12px;
  align-items: end;
  margin: 0 0 24px;
}
.tracking-widget__field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tracking-widget__field label { font-size: 14px; font-weight: 600; }
.tracking-widget__field input,
.tracking-widget__field select {
  width: 100%; height: 50px; padding: 0 22px; font: inherit;
  border: 1px solid var(--tw-line); border-radius: 999px; background-color: transparent; color: inherit;
  -webkit-appearance: none; appearance: none;
}
.tracking-widget__field select {
  padding-right: 46px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 18px center; background-size: 16px;
}
.tracking-widget__field input:focus,
.tracking-widget__field select:focus { outline: 2px solid var(--tw-accent); outline-offset: 1px; }
.tracking-widget__button {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 15px;
  height: 50px; padding: 0 7px 0 28px; font: inherit; font-size: 17px; font-weight: 500; letter-spacing: .01em;
  white-space: nowrap; cursor: pointer;
  border: 1px solid var(--tw-ring); border-radius: 999px; background: var(--tw-primary); color: #fff;
}
/* Themes and Elementor style every <button>; these keep the brand red in every state. */
.tracking-widget__button,
.tracking-widget__button:focus,
.tracking-widget__button:active {
  background: var(--tw-primary) !important; color: #fff !important; border-color: var(--tw-ring) !important;
  box-shadow: none !important; text-decoration: none !important;
}
.tracking-widget__button:hover {
  background: var(--tw-primary-hover) !important; color: #fff !important; border-color: var(--tw-primary-hover) !important;
}
.tracking-widget__button::after {
  content: ""; flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fe3135' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7M9 7h8v8'/%3E%3C/svg%3E") center / 20px no-repeat;
}
.tracking-widget__button:focus-visible { outline: 3px solid var(--tw-accent); outline-offset: 2px; }
.tracking-widget__button:disabled { opacity: .6; cursor: progress; }
@media (max-width: 640px) {
  .tracking-widget__form { grid-template-columns: 1fr; }
  .tracking-widget__button { width: 100%; }
}

/* ---- states ---- */
.tracking-widget__loading { display: flex; align-items: center; gap: 12px; margin: 0; padding: 16px 0; }
.tracking-widget__loading::before {
  content: ""; width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid var(--tw-line); border-top-color: var(--tw-accent);
  animation: tracking-spin .8s linear infinite;
}
@keyframes tracking-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tracking-widget__loading::before { animation: none; } }
.tracking-widget__error {
  margin: 0; padding: 14px 16px; border-radius: 10px;
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
}

/* ---- card ---- */
.tracking-widget__card { border: 1px solid var(--tw-line); border-radius: 16px; padding: 24px; }
.tracking-widget__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.tracking-widget__label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .65; }
.tracking-widget__id { font-size: 20px; font-weight: 700; word-break: break-all; color: var(--tw-brand); }

.tracking-widget__pill {
  padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: #e2e8f0; color: #334155;
}
.tracking-widget__pill--booked { background: #e2e8f0; color: #334155; }
.tracking-widget__pill--in_transit { background: #dbeafe; color: #1e40af; }
.tracking-widget__pill--customs { background: #fef3c7; color: #92400e; }
.tracking-widget__pill--out_for_delivery { background: #ede9fe; color: #5b21b6; }
.tracking-widget__pill--delivered { background: #dcfce7; color: #166534; }
.tracking-widget__pill--exception { background: #fee2e2; color: #991b1b; }

.tracking-widget__summary { margin: 20px 0 8px; padding: 16px 18px; border-radius: 12px; background: var(--tw-soft); border-left: 4px solid var(--tw-accent); }
.tracking-widget__summary--delivered { border-left-color: var(--tw-ok); }
.tracking-widget__summary--exception { border-left-color: #b91c1c; }
.tracking-widget__summary--customs { border-left-color: #b45309; }
.tracking-widget__headline { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.3; color: var(--tw-brand); }
.tracking-widget__sub { margin: 4px 0 0; opacity: .8; }

/* ---- progress ---- */
.tracking-widget__steps { display: flex; list-style: none; margin: 24px 0 8px; padding: 0; counter-reset: tw-step; }
.tracking-widget__step {
  flex: 1; position: relative; text-align: center; font-size: 13px; line-height: 1.3;
  padding: 0 2px; opacity: .55; counter-increment: tw-step;
}
.tracking-widget__step::before {
  content: counter(tw-step); position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; margin: 0 auto 8px; border-radius: 50%;
  background: var(--tw-soft); border: 2px solid var(--tw-line); font-weight: 700; font-size: 13px;
}
.tracking-widget__step::after {
  content: ""; position: absolute; top: 14px; left: calc(-50% + 15px); right: calc(50% + 15px);
  height: 3px; background: var(--tw-line);
}
.tracking-widget__step:first-child::after { display: none; }
.tracking-widget__step.is-done, .tracking-widget__step.is-current { opacity: 1; }
.tracking-widget__step.is-done::before { content: "\2713"; background: var(--tw-ok); border-color: var(--tw-ok); color: #fff; }
.tracking-widget__step.is-done::after, .tracking-widget__step.is-current::after { background: var(--tw-ok); }
.tracking-widget__step.is-current::before { background: var(--tw-accent); border-color: var(--tw-accent); color: #fff; box-shadow: 0 0 0 4px rgba(25, 0, 172, .2); }
.tracking-widget__step.is-current { font-weight: 700; }

/* ---- route + details ---- */
.tracking-widget__route {
  display: flex; align-items: center; gap: 16px; margin: 24px 0 0; padding: 16px 0;
  border-top: 1px solid var(--tw-line);
}
.tracking-widget__place { flex: 1; min-width: 0; }
.tracking-widget__place strong { display: block; font-size: 17px; overflow-wrap: anywhere; }
.tracking-widget__arrow { font-size: 22px; opacity: .5; }

.tracking-widget__details {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px;
  margin: 0; padding: 16px 0; border-top: 1px solid var(--tw-line);
}
.tracking-widget__detail dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .65; }
.tracking-widget__detail dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---- history ---- */
.tracking-widget__history { border-top: 1px solid var(--tw-line); padding-top: 16px; }
.tracking-widget__heading { margin: 0 0 4px; font-size: 18px; color: var(--tw-brand); }
.tracking-widget__day { margin: 18px 0 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .7; }
.tracking-widget__events { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--tw-line); }
.tracking-widget__event { position: relative; display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 6px 0 10px; }
.tracking-widget__event::before {
  content: ""; position: absolute; left: -24px; top: 12px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--tw-line);
}
.tracking-widget__event.is-latest::before { background: var(--tw-accent); box-shadow: 0 0 0 4px rgba(25, 0, 172, .2); }
.tracking-widget__time { font-size: 14px; opacity: .65; padding-top: 2px; }
.tracking-widget__what { display: flex; flex-direction: column; min-width: 0; }
.tracking-widget__title { font-weight: 600; overflow-wrap: anywhere; }
.tracking-widget__loc { font-size: 14px; opacity: .7; }
.tracking-widget__event.is-muted .tracking-widget__title { font-weight: 400; opacity: .75; }

@media (max-width: 520px) {
  .tracking-widget__card { padding: 16px; }
  .tracking-widget__step { font-size: 11px; }
  .tracking-widget__route { flex-direction: column; align-items: flex-start; gap: 8px; }
  .tracking-widget__arrow { transform: rotate(90deg); }
  .tracking-widget__event { grid-template-columns: 64px minmax(0, 1fr); gap: 8px; }
}

.tracking-widget__field.is-invalid select { border-color: #b91c1c; box-shadow: 0 0 0 3px rgba(185, 28, 28, .18); }

/* ---- popup ---- */
.tracking-modal {
  position: fixed; inset: 0; z-index: 100000; display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 5vh; overflow: hidden;
}
.tracking-modal[hidden] { display: none !important; }
.tracking-modal__backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .6); }

/* The panel is only as tall as its content, up to ~85% of the screen; the body inside it scrolls. */
.tracking-modal__panel {
  position: relative; display: flex; flex-direction: column; width: 100%; max-width: 760px;
  max-height: calc(100vh - 12vh); max-height: calc(100dvh - 12vh);
  background: #fff; color: #1f2937; border-radius: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); overflow: hidden;
}
.tracking-modal__head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 20px 12px 24px; }
.tracking-modal__title { margin: 0; font-size: 24px; line-height: 1.3; font-weight: 700; color: var(--tw-brand); }
.tracking-modal__body {
  flex: 1 1 auto; min-height: 0; padding: 4px 24px 24px;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.tracking-modal__close {
  flex: none; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-size: 26px; line-height: 1;
}
.tracking-modal .tracking-modal__close,
.tracking-modal .tracking-modal__close:focus {
  padding: 0 !important; border: 0 !important; border-radius: 50% !important; box-shadow: none !important;
  background: rgba(25, 0, 172, .08) !important; color: var(--tw-brand) !important;
}
.tracking-modal .tracking-modal__close:hover {
  background: var(--tw-brand) !important; color: #fff !important;
}
.tracking-modal .tracking-widget__form { margin-bottom: 16px; }
html.tracking-modal-open { overflow: hidden !important; }
.tracking-open { cursor: pointer; }
@media (max-width: 520px) {
  .tracking-modal { padding: 12px; align-items: center; }
  .tracking-modal__panel { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); border-radius: 18px; }
  .tracking-modal__head { padding: 16px 14px 8px 18px; }
  .tracking-modal__title { font-size: 20px; }
  .tracking-modal__body { padding: 4px 16px 18px; }
}
