/* ==========================================================================
   Da-Ag app screens (customer + rider): delivery progress, phone navigation, phone tables.
   Pairs with /assets/js/dgl-app.js. Loaded after dgl-ui.css on logged-in pages only.
   ========================================================================== */

:root { --dgl-nav-h: 64px; --dgl-track-line: #dfe7f3; }

/* ---- Delivery progress tracker ------------------------------------------------------ */
.dgl-track {
  margin: 8px 0 12px; padding: 14px 14px 12px; border-radius: 16px;
  background: linear-gradient(180deg, #f5f8ff 0%, #ffffff 100%); border: 1px solid #e3eaf6;
}
.dgl-track-rail { position: relative; display: grid; grid-template-columns: repeat(var(--n, 5), 1fr); }
.dgl-track-rail::before, .dgl-track-fill {
  content: ""; position: absolute; top: 11px; left: calc(50% / var(--n, 5)); height: 4px; border-radius: 4px;
}
.dgl-track-rail::before { right: calc(50% / var(--n, 5)); background: var(--dgl-track-line); }
.dgl-track-fill { width: 0; background: linear-gradient(90deg, var(--dgl-navy, #002868), #1d5fd6); transition: width 1.1s cubic-bezier(.65, 0, .35, 1) .15s; z-index: 1; }
.dgl-track.is-live .dgl-track-fill { background: linear-gradient(90deg, var(--dgl-navy, #002868), #1d5fd6 60%, var(--dgl-red, #bf0a30)); }
.dgl-tn { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; min-width: 0; }
.dgl-tn-dot {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px;
  background: #fff; color: #9db0cc; border: 2px solid var(--dgl-track-line); transition: background .35s, color .35s, border-color .35s, scale .35s var(--dgl-spring, ease);
}
.dgl-tn.is-done .dgl-tn-dot { background: var(--dgl-navy, #002868); border-color: var(--dgl-navy, #002868); color: #fff; }
.dgl-tn.is-now .dgl-tn-dot {
  background: var(--dgl-red, #bf0a30); border-color: #fff; color: #fff; scale: 1.18;
  box-shadow: 0 0 0 3px rgba(191, 10, 48, .22), 0 6px 14px rgba(191, 10, 48, .35); animation: dgl-now 1.9s ease-out infinite;
}
.dgl-track.is-delivered .dgl-tn.is-now .dgl-tn-dot { background: var(--dgl-green, #16a34a); box-shadow: 0 0 0 3px rgba(22, 163, 74, .22), 0 6px 14px rgba(22, 163, 74, .35); animation: none; }
@keyframes dgl-now { 0% { box-shadow: 0 0 0 3px rgba(191, 10, 48, .28), 0 0 0 0 rgba(191, 10, 48, .35); } 70% { box-shadow: 0 0 0 3px rgba(191, 10, 48, .12), 0 0 0 11px rgba(191, 10, 48, 0); } 100% { box-shadow: 0 0 0 3px rgba(191, 10, 48, .12), 0 0 0 0 rgba(191, 10, 48, 0); } }
.dgl-tn-label { font-size: 9.5px; font-weight: 700; letter-spacing: .01em; color: #8a9bb5; line-height: 1.15; }
.dgl-tn.is-done .dgl-tn-label { color: #3d5278; }
.dgl-tn.is-now .dgl-tn-label { color: var(--dgl-navy, #002868); }
.dgl-track-note { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed #dbe4f2; font-size: 12.5px; font-weight: 600; color: #3d5278; line-height: 1.35; }
.dgl-track-note i { color: var(--dgl-red, #bf0a30); flex-shrink: 0; }
.dgl-track.is-delivered .dgl-track-note i { color: var(--dgl-green, #16a34a); }
.dgl-track.is-cancelled { background: #fff6f6; border-color: #f6d4d4; padding: 11px 14px; }
.dgl-track.is-cancelled .dgl-track-rail { display: none; }
.dgl-track.is-cancelled .dgl-track-note { margin: 0; padding: 0; border: 0; color: #b42318; }
.dgl-track.is-cancelled .dgl-track-note i { color: #b42318; }
@media (max-width: 360px) { .dgl-tn-label { font-size: 8.5px; } .dgl-tn-dot { width: 24px; height: 24px; } .dgl-track { padding: 12px 8px 10px; } }

/* ---- Greeting summary chip ---------------------------------------------------------------- */
.dgl-chip-live { display: inline-flex; align-items: center; gap: 6px; }
.dgl-chip-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, .7); animation: dgl-ping 1.8s ease-out infinite; }
@keyframes dgl-ping { 70% { box-shadow: 0 0 0 9px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }

/* ---- Phone navigation bar ------------------------------------------------------------------------ */
.dgl-nav { display: none; }
@media (max-width: 900px) {
  html.dgl-has-nav body { padding-bottom: calc(var(--dgl-nav-h) + 18px + env(safe-area-inset-bottom, 0px)); }
  .dgl-nav {
    display: grid; position: fixed; z-index: 9000; left: 10px; right: 10px; max-width: 640px; margin-inline: auto; bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    height: var(--dgl-nav-h); grid-auto-flow: column; grid-auto-columns: 1fr; align-items: center;
    background: rgba(255, 255, 255, .88); -webkit-backdrop-filter: blur(18px) saturate(180%); backdrop-filter: blur(18px) saturate(180%);
    border: 1px solid rgba(0, 40, 104, .08); border-radius: 22px; box-shadow: 0 14px 40px rgba(0, 28, 80, .22);
    transition: translate .35s var(--dgl-ease, ease), opacity .3s;
  }
  .dgl-nav.is-hidden { translate: 0 calc(100% + 24px); }
  .dgl-ni {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 100%; text-decoration: none; color: #7a8aa3; font: 700 10.5px/1 'Inter', sans-serif; letter-spacing: .01em; min-width: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .dgl-ni i { font-size: 18px; transition: translate .3s var(--dgl-spring, ease), color .2s; }
  .dgl-ni.is-active { color: var(--dgl-navy, #002868); }
  .dgl-ni.is-active i { translate: 0 -2px; }
  .dgl-ni.is-active::after { content: ""; position: absolute; bottom: 7px; width: 18px; height: 3px; border-radius: 3px; background: var(--dgl-red, #bf0a30); animation: dgl-pop .4s var(--dgl-spring, ease) both; }
  .dgl-ni:active i { translate: 0 -4px; scale: .9; }
  .dgl-ni-fab { overflow: visible; }
  .dgl-ni-fab .dgl-fab {
    width: 54px; height: 54px; border-radius: 20px; display: grid; place-items: center; margin-top: -26px;
    background: linear-gradient(135deg, var(--dgl-red, #bf0a30), #e11d48); color: #fff; font-size: 20px;
    box-shadow: 0 12px 26px rgba(191, 10, 48, .45), 0 0 0 5px rgba(255, 255, 255, .9); transition: scale .2s var(--dgl-spring, ease), rotate .35s var(--dgl-spring, ease);
  }
  .dgl-ni-fab:active .dgl-fab { scale: .92; rotate: 90deg; }
  .dgl-ni-fab span { margin-top: 2px; color: var(--dgl-red, #bf0a30); }
  .dgl-ni-fab::after { display: none !important; }
  /* the install banner sits ABOVE the bar instead of covering it */
  html.dgl-has-nav #pwa-install-banner { bottom: calc(var(--dgl-nav-h) + 22px + env(safe-area-inset-bottom, 0px)) !important; left: 10px !important; right: 10px !important; border-radius: 18px !important; }
}

/* ---- Tables become cards on phones (customer pages) ----------------------------------------------------- */
@media (max-width: 640px) {
  table.dgl-cards, table.dgl-cards tbody, table.dgl-cards tr, table.dgl-cards td { display: block; width: 100%; }
  table.dgl-cards { border-collapse: separate; min-width: 0; }
  table.dgl-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.dgl-cards tr {
    margin: 0 0 12px; padding: 14px 14px 10px; background: #fff; border: 1px solid #e6ecf5; border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0, 40, 104, .06); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  }
  table.dgl-cards td { padding: 6px 0 !important; border: 0 !important; background: transparent !important; text-align: left; }
  table.dgl-cards td::before { content: attr(data-label); display: block; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #8a9bb5; margin-bottom: 2px; }
  /* first cell = the headline of the card, status badge sits at its right */
  table.dgl-cards td[data-first] { grid-column: 1; }
  table.dgl-cards td[data-first]::before, table.dgl-cards td[data-action]::before { display: none; }
  table.dgl-cards td[data-status] { grid-column: 2; grid-row: 1; justify-self: end; text-align: right; }
  table.dgl-cards td[data-status]::before { display: none; }
  table.dgl-cards td[data-wide] { grid-column: 1 / -1; }
  table.dgl-cards td[data-action] { grid-column: 1 / -1; padding-top: 10px !important; margin-top: 4px; border-top: 1px dashed #dbe4f2 !important; }
  table.dgl-cards td[data-action]:not([data-multi]) a, table.dgl-cards td[data-action]:not([data-multi]) button { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 11px 14px; border-radius: 12px; background: var(--dgl-navy, #002868); color: #fff !important; font-weight: 800; text-decoration: none; }
}

/* on wide screens the tracker stays compact instead of stretching across the row */
@media (min-width: 900px) { .dgl-track { max-width: 640px; } }

/* admin / multi-button action cells stay a tidy row of the page's own buttons */
@media (max-width: 640px) {
  table.dgl-cards td[data-multi] { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  table.dgl-cards td[data-multi] a, table.dgl-cards td[data-multi] button { min-height: 40px; min-width: 40px; }
  table.dgl-cards tr[data-span] { display: block; padding: 6px; }
  table.dgl-cards tr[data-span] td { display: block; }
  table.dgl-cards tr[data-span] td::before { display: none; }
}

/* ---- Rider: available-job card ---------------------------------------------------------------------------- */
.dgl-route { position: relative; margin: 10px 0 12px; padding: 4px 0 4px 2px; }
.dgl-route-stop { position: relative; display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.dgl-route-stop > div { min-width: 0; }
.dgl-route-stop small { display: block; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #8a9bb5; }
.dgl-route-stop b { display: block; font-size: 13.5px; font-weight: 700; color: #0f1f3d; line-height: 1.35; overflow-wrap: anywhere; }
.dgl-route-dot { flex: 0 0 14px; width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; border: 3px solid #16a34a; background: #fff; z-index: 1; }
.dgl-route-stop.is-to .dgl-route-dot { border-color: var(--dgl-red, #bf0a30); background: var(--dgl-red, #bf0a30); box-shadow: 0 0 0 4px rgba(191, 10, 48, .15); }
.dgl-route-line { position: relative; margin-left: 6px; min-height: 26px; border-left: 2px dashed #cfd9ea; padding: 4px 0 4px 18px; }
.dgl-route-dist { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; background: #eef3ff; color: var(--dgl-navy, #002868); font-size: 11px; font-weight: 800; }
.delivery-item.dgl-job .delivery-amount {
  font-size: 1.05rem; font-weight: 900; color: #0a7a35; background: #e8f8ee; border: 1px solid #c6ecd3; padding: 4px 12px; border-radius: 99px; white-space: nowrap;
}
.delivery-item.dgl-job .btn-accept { min-height: 46px; font-weight: 800; box-shadow: 0 8px 20px rgba(22, 163, 74, .28); }

/* ---- Rider pages (wallet/profile): compact header on phones; the bottom bar replaces the text links ------- */
@media (max-width: 768px) {
  html.dgl-has-nav .rider-header:not(:has(.availability-toggle)) .header-container { flex-direction: row !important; flex-wrap: nowrap !important; align-items: center !important; justify-content: space-between; gap: 8px; padding: 8px 12px !important; }
  html.dgl-has-nav .rider-header:not(:has(.availability-toggle)) .logo-area { flex-wrap: nowrap; }
  html.dgl-has-nav .rider-header:not(:has(.availability-toggle)) .header-right { flex: 1; width: auto; justify-content: flex-end; flex-wrap: nowrap; gap: 8px; }
  html.dgl-has-nav .rider-header:not(:has(.availability-toggle)) .back-btn, html.dgl-has-nav .rider-header:not(:has(.availability-toggle)) .rider-name-display, html.dgl-has-nav .rider-header:not(:has(.availability-toggle)) .rider-tier { display: none; }
  html.dgl-has-nav .rider-header:not(:has(.availability-toggle)) .logout-btn span { display: none; }
}

/* toasts stay visible above the phone navigation bar */
@media (max-width: 768px) {
  html.dgl-has-nav :where(.toast-container, #toastContainer, [class*="toast-wrap"]) { bottom: calc(var(--dgl-nav-h) + 22px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* ---- Booking: option cards feel physical ---- */
.vessel-card { transition: translate .3s var(--dgl-spring, ease), scale .2s var(--dgl-spring, ease), box-shadow .3s, border-color .2s, background .2s; }
.vessel-card:not(.truck-disabled):active { scale: .96; }
.vessel-card.selected { translate: 0 -3px; box-shadow: 0 14px 30px rgba(0, 40, 104, .2); }

/* ---- Big money figures must never run into their icon (admin KPI cards) ---- */
.stat-card .stat-header { gap: 10px; min-width: 0; }
.stat-card .stat-value { min-width: 0; font-size: clamp(1.05rem, 1.45vw, 1.7rem); white-space: nowrap; }
@media (max-width: 640px) { .stat-card .stat-value { font-size: clamp(1.05rem, 5.2vw, 1.45rem); } }

/* ---- Profile completeness ------------------------------------------------------------------------------ */
@property --p { syntax: '<number>'; inherits: false; initial-value: 0; }
.dgl-complete {
  display: flex; gap: 20px; align-items: center; margin: 18px 0; padding: 20px; border-radius: 22px; background: #fff;
  border: 1px solid #e3eaf6; box-shadow: 0 10px 30px rgba(0, 40, 104, .07);
}
.dgl-ring {
  --p: 0; flex: 0 0 84px; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--dgl-red, #bf0a30) calc(var(--p) * 1%), #e6ecf5 0); transition: --p 1s var(--dgl-ease, ease);
}
.dgl-ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff; }
.dgl-ring span { position: relative; font-weight: 800; font-size: 1.1rem; color: var(--dgl-navy, #002868); font-variant-numeric: tabular-nums; }
.dgl-complete.is-complete .dgl-ring { background: conic-gradient(var(--dgl-green, #16a34a) 100%, #e6ecf5 0); }
.dgl-complete.is-complete .dgl-ring span { color: var(--dgl-green, #16a34a); }
.dgl-complete-body { min-width: 0; flex: 1; }
.dgl-complete-body h3 { font-size: 1.05rem; font-weight: 800; color: #0f1f3d; margin: 0 0 3px; }
.dgl-complete-body p { font-size: .84rem; line-height: 1.5; color: #64748b; margin: 0 0 12px; }
.dgl-complete-body p b { color: var(--dgl-navy, #002868); }
.dgl-complete-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.dgl-complete-list li, .dgl-complete-list button {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 99px; font: 700 .78rem 'Inter', sans-serif; border: 1px solid transparent;
}
.dgl-complete-list li.is-done { background: #e8f8ee; color: #0a7a35; border-color: #c6ecd3; }
.dgl-complete-list button { cursor: pointer; background: #fff; color: var(--dgl-navy, #002868); border: 1px dashed #9fb3d6; min-height: 34px; }
.dgl-complete-list button:hover { background: #eef3ff; border-style: solid; }
@media (max-width: 560px) { .dgl-complete { flex-direction: column; align-items: flex-start; padding: 18px 16px; } .dgl-ring { flex-basis: 76px; width: 76px; height: 76px; } }

/* ---- Rider wallet: earned vs withdrawn ---- */
.dgl-wallet-sum { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 4px; }
.dgl-wallet-sum span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 99px; font-size: .8rem; font-weight: 700; }
.dgl-wallet-sum .in { background: #e8f8ee; color: #0a7a35; border: 1px solid #c6ecd3; }
.dgl-wallet-sum .out { background: #fff1f1; color: #b42318; border: 1px solid #f6d4d4; }
.dgl-wallet-sum b { font-variant-numeric: tabular-nums; font-weight: 800; }

/* ---- Admin zones: coverage strip + zones that cannot serve ---- */
.dgl-zone-sum { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.dgl-zone-sum span { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 99px; background: #fff; border: 1px solid #e3eaf6; font-size: .82rem; font-weight: 600; color: #3d5278; box-shadow: 0 4px 12px rgba(0, 40, 104, .05); }
.dgl-zone-sum b { color: #0f1f3d; font-weight: 800; }
.dgl-zone-sum .ok { background: #e8f8ee; border-color: #c6ecd3; color: #0a7a35; }
.dgl-zone-sum .ok b { color: #0a7a35; }
.dgl-zone-sum .warn { background: #fff7e6; border-color: #f6dca7; color: #92580a; }
.dgl-zone-sum .warn b { color: #92580a; }
.zone-card.needs-rider { border-color: #f0c36d !important; box-shadow: 0 0 0 3px rgba(245, 158, 11, .14), 0 6px 18px rgba(0, 40, 104, .06); }
.dgl-need-rider { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; padding: 3px 10px; border-radius: 99px; background: #fff7e6; color: #92580a; border: 1px solid #f6dca7; font-size: 10.5px; font-weight: 800; letter-spacing: .02em; white-space: nowrap; }

/* ---- Admin rider detail: performance card ---- */
.dgl-perf { display: flex; gap: 22px; align-items: center; margin: 4px 0 22px; padding: 18px 20px; border-radius: 18px; background: linear-gradient(135deg, #f5f8ff, #ffffff); border: 1px solid #e3eaf6; }
.dgl-perf .dgl-ring { flex-basis: 78px; width: 78px; height: 78px; background: conic-gradient(var(--dgl-green, #16a34a) calc(var(--p) * 1%), #e6ecf5 0); }
.dgl-perf .dgl-ring span { color: #0a7a35; }
.dgl-perf-body { flex: 1; min-width: 0; }
.dgl-perf-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.dgl-perf-head h4 { margin: 0; font-size: .95rem; font-weight: 800; color: #0f1f3d; }
.dgl-perf-tone { padding: 3px 11px; border-radius: 99px; font-size: .7rem; font-weight: 800; letter-spacing: .03em; }
.dgl-perf-tone.is-good { background: #e8f8ee; color: #0a7a35; border: 1px solid #c6ecd3; }
.dgl-perf-tone.is-ok { background: #e8f0ff; color: #1d4ed8; border: 1px solid #c9dafc; }
.dgl-perf-tone.is-warn { background: #fff7e6; color: #92580a; border: 1px solid #f6dca7; }
.dgl-perf-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.dgl-perf-grid b { display: block; font-size: 1.15rem; font-weight: 800; color: #0f1f3d; font-variant-numeric: tabular-nums; }
.dgl-perf-grid small { display: block; margin-top: 2px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #8a9bb5; }
@media (max-width: 560px) { .dgl-perf { flex-direction: column; align-items: flex-start; } .dgl-perf-grid { grid-template-columns: 1fr 1fr 1fr; gap: 8px; } .dgl-perf-grid b { font-size: 1rem; } }

/* ---- Admin deliveries board ---- */
.status-badge.out_for_delivery { background: #ffedd5; color: #c2410c; }
.status-badge.in_transit { background: #cffafe; color: #0e7490; }
.dgl-board-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.dgl-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; min-height: 38px; border-radius: 99px; background: #fff; border: 1px solid #dfe7f3; color: #3d5278; font: 700 .8rem 'Inter', sans-serif; cursor: pointer; transition: background .2s, border-color .2s, color .2s, scale .15s var(--dgl-spring, ease); }
.dgl-chip b { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 99px; background: #eef3ff; color: var(--dgl-navy, #002868); font-size: .74rem; font-variant-numeric: tabular-nums; }
.dgl-chip:hover { border-color: #9fb3d6; }
.dgl-chip:active { scale: .96; }
.dgl-chip.is-on { background: var(--dgl-navy, #002868); border-color: var(--dgl-navy, #002868); color: #fff; }
.dgl-chip.is-on b { background: rgba(255, 255, 255, .2); color: #fff; }
.dgl-chip.is-warn { background: #fff7e6; border-color: #f0c36d; color: #92580a; }
.dgl-chip.is-warn b { background: #f59e0b; color: #fff; }
.dgl-chip.is-warn.is-on { background: #b45309; border-color: #b45309; color: #fff; }
table[data-board="needs"] tbody tr:not([data-needs-rider]),
table[data-board="pending"] tbody tr:not([data-grp="pending"]),
table[data-board="progress"] tbody tr:not([data-grp="progress"]),
table[data-board="delivered"] tbody tr:not([data-grp="delivered"]),
table[data-board="cancelled"] tbody tr:not([data-grp="cancelled"]) { display: none; }
.dgl-needs { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: #fff7e6; color: #92580a; border: 1px solid #f6dca7; font-size: 11px; font-weight: 800; white-space: nowrap; }
tr[data-needs-rider] > td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
td.action-btns { white-space: nowrap; }
td.action-btns > button { margin-right: 4px; vertical-align: middle; }
@media (max-width: 640px) { table.dgl-cards tr[data-needs-rider] { border-color: #f0c36d; box-shadow: 0 0 0 3px rgba(245, 158, 11, .14), 0 6px 18px rgba(0, 40, 104, .06); } }

/* ---- Tracking: shown in place of the map when Google Maps cannot load ---- */
.dgl-map-off { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 40px 22px; min-height: 240px; height: 100%; border-radius: inherit; background: linear-gradient(160deg, #f3f7ff, #e6edfa); color: #3d5278; }
.dgl-map-off i { font-size: 2.2rem; color: #9fb3d6; }
.dgl-map-off b { font-size: 1.05rem; color: #0f1f3d; }
.dgl-map-off span { font-size: .86rem; max-width: 30ch; line-height: 1.5; }

/* when the map is replaced by the notice, do not keep a tall empty box: let the real tracking details come up the page */
#map:has(.dgl-map-off) { height: auto !important; min-height: 0 !important; }
#map .dgl-map-off { min-height: 170px; padding: 28px 20px; }


/* =====================================================================================================
   TABLET RANGE (601-1100px): iPad portrait/landscape, small laptops
   ===================================================================================================== */

/* wide tables (7+ columns) become cards instead of scrolling sideways */
@media (max-width: 1100px) {
  table.dgl-cards.dgl-wide, table.dgl-cards.dgl-wide tbody, table.dgl-cards.dgl-wide tr, table.dgl-cards.dgl-wide td { display: block; width: 100%; }
  table.dgl-cards.dgl-wide { border-collapse: separate; min-width: 0; }
  table.dgl-cards.dgl-wide thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.dgl-cards.dgl-wide tr {
    margin: 0 0 12px; padding: 14px 14px 10px; background: #fff; border: 1px solid #e6ecf5; border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0, 40, 104, .06); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  }
  table.dgl-cards.dgl-wide td { padding: 6px 0 !important; border: 0 !important; background: transparent !important; text-align: left; }
  table.dgl-cards.dgl-wide td::before { content: attr(data-label); display: block; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #8a9bb5; margin-bottom: 2px; }
  /* first cell = the headline of the card, status badge sits at its right */
  table.dgl-cards.dgl-wide td[data-first] { grid-column: 1; }
  table.dgl-cards.dgl-wide td[data-first]::before, table.dgl-cards.dgl-wide td[data-action]::before { display: none; }
  table.dgl-cards.dgl-wide td[data-status] { grid-column: 2; grid-row: 1; justify-self: end; text-align: right; }
  table.dgl-cards.dgl-wide td[data-status]::before { display: none; }
  table.dgl-cards.dgl-wide td[data-wide] { grid-column: 1 / -1; }
  table.dgl-cards.dgl-wide td[data-action] { grid-column: 1 / -1; padding-top: 10px !important; margin-top: 4px; border-top: 1px dashed #dbe4f2 !important; }
  table.dgl-cards.dgl-wide td[data-action]:not([data-multi]) a, table.dgl-cards.dgl-wide td[data-action]:not([data-multi]) button { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 11px 14px; border-radius: 12px; background: var(--dgl-navy, #002868); color: #fff !important; font-weight: 800; text-decoration: none; }
}
@media (min-width: 641px) and (max-width: 1100px) {
  table.dgl-cards.dgl-wide tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
  table.dgl-cards.dgl-wide tr { margin: 0; }
  table.dgl-cards.dgl-wide tr[data-span] { grid-column: 1 / -1; }
}

/* admin: below 1280px the 260px sidebar becomes a slim top bar that stays in view while the page scrolls (every admin page
   shares this structure). Row 1: logo + sign out. Then every page link: on tablets they wrap onto a second (and, if needed,
   third) line so nothing is hidden; on phones they become one swipeable row so the bar never grows to fill the screen. */
@media (max-width: 1280px) {
  body:has(> aside.sidebar) { flex-direction: column; }
  aside.sidebar {
    width: 100%; height: auto; min-height: 0; position: relative; z-index: 40; overflow: visible; border-right: 0; border-bottom: 1px solid #e3eaf6;
    padding: 8px 18px 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; background: #fff; box-shadow: 0 2px 10px rgba(0, 40, 104, .06);
  }
  aside.sidebar .sidebar-header { order: 1; margin: 0; padding: 0; border: 0; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
  aside.sidebar .sidebar-header .logo-area { justify-content: flex-start; }
  aside.sidebar .sidebar-admin, aside.sidebar .nav-label { display: none; }
  aside.sidebar .sidebar-footer { order: 2; display: block !important; padding: 0; border: 0; margin: 0 0 0 auto; }
  aside.sidebar .sidebar-footer a, aside.sidebar .sidebar-footer button { padding: 8px 12px; font-size: 13px; min-height: 40px; }
  aside.sidebar .sidebar-nav { order: 3; flex: 1 1 100%; min-width: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
  aside.sidebar .sidebar-nav ul { display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 0; list-style: none; }
  aside.sidebar .sidebar-nav ul li { flex: 0 0 auto; }
  aside.sidebar .sidebar-nav ul li a { padding: 9px 13px; font-size: 13px; white-space: nowrap; min-height: 40px; display: flex; align-items: center; }
  .main-content { max-width: 100%; padding: 20px 22px; }
}
/* every small admin button is a comfortable touch target on phones and portrait tablets */
@media (max-width: 900px) { body:has(> aside.sidebar) .btn-sm { min-height: 40px; } }
/* laptops: a little less padding in table cells so the ten-column delivery table fits beside the sidebar without scrolling sideways */
@media (min-width: 1281px) and (max-width: 1500px) { body:has(> aside.sidebar) .table-container th, body:has(> aside.sidebar) .table-container td { padding-left: 10px; padding-right: 10px; } }
@media (max-width: 760px) {
  aside.sidebar { position: sticky; top: 0; padding: 8px 14px 0; } /* pinned on phones only: on a tablet three rows of links would eat the screen */
  aside.sidebar .sidebar-nav {
    margin: 0 -14px; padding: 2px 14px 6px; flex-wrap: nowrap;
    overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    /* a soft fade at the right edge says "there is more to swipe" */
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  }
  aside.sidebar .sidebar-nav::-webkit-scrollbar { display: none; }
  aside.sidebar .sidebar-nav ul { flex-wrap: nowrap; flex: 0 0 auto; }
  aside.sidebar .sidebar-nav ul li { scroll-snap-align: center; }
  .main-content { padding: 16px; }
}
@media (max-width: 380px) { aside.sidebar .sidebar-header .admin-badge { display: none; } }

/* in card mode a "needs a rider" row is outlined as a whole card (the left stripe only suits table rows) */
@media (max-width: 1100px) {
  table.dgl-cards.dgl-wide tr[data-needs-rider] { border-color: #f0c36d; box-shadow: 0 0 0 3px rgba(245, 158, 11, .14), 0 6px 18px rgba(0, 40, 104, .06); }
  table.dgl-cards.dgl-wide tr[data-needs-rider] > td:first-child { box-shadow: none; }
}
@media (max-width: 640px) { table.dgl-cards tr[data-needs-rider] > td:first-child { box-shadow: none; } }

/* booking: the vessel cards share the row evenly instead of leaving an empty fifth column */
@media (min-width: 640px) { .vessel-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); } }

/* ---- Admin Monitoring: use the space well at every width ---- */
.stats-grid:has(> .stat-card.danger) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1280px) { .stats-grid:has(> .stat-card.danger) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .stats-grid:has(> .stat-card.danger) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stats-grid:has(> .stat-card.danger) .stat-card { padding: 12px 14px; }
  .stats-grid:has(> .stat-card.danger) .stat-value { font-size: 1.5rem; }
  .stats-grid:has(> .stat-card.danger) .stat-header i { font-size: 18px; }
  .stats-grid:has(> .stat-card.danger) .stat-label { font-size: 10px; letter-spacing: .06em; }
}
/* filters: a compact grid instead of one field per row */
@media (max-width: 900px) {
  .filters-bar { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: stretch; }
  .filters-bar input[type="text"] { grid-column: 1 / -1; order: 9; }
  .filters-bar .btn { min-height: 42px; justify-content: center; }
}
@media (max-width: 560px) { .filters-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- Shared sheet (cancel delivery): a bottom sheet on phones, a centred card on larger screens ---- */
body.dgl-sheet-open { overflow: hidden; }
.dgl-sheet-overlay { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: flex-end; justify-content: center; background: rgba(6, 20, 54, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: dglFade .2s ease both; }
.dgl-sheet-overlay.is-out { animation: dglFadeOut .2s ease both; }
.dgl-sheet-overlay.is-out .dgl-sheet { animation: dglSheetOut .22s ease both; }
.dgl-sheet { width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 24px 24px 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -20px 60px rgba(0, 20, 60, .35); animation: dglSheetIn .32s cubic-bezier(.22, 1, .36, 1) both; font-family: 'Inter', system-ui, sans-serif; color: #0f1f3d; }
@media (min-width: 640px) { .dgl-sheet-overlay { align-items: center; } .dgl-sheet { border-radius: 24px; padding-bottom: 22px; } .dgl-sheet-grab { display: none; } }
.dgl-sheet-grab { width: 44px; height: 5px; border-radius: 5px; background: #d5deee; margin: 4px auto 14px; }
.dgl-sheet h3 { font-size: 1.25rem; font-weight: 800; margin: 6px 0 2px; letter-spacing: -.01em; }
.dgl-sheet-sub { font-size: .85rem; color: #64748b; margin: 0 0 14px; }
.dgl-sheet-refund { display: grid; gap: 2px; padding: 16px; border-radius: 18px; background: linear-gradient(135deg, #e8f8ee, #f3fbf6); border: 1px solid #c6ecd3; margin-bottom: 12px; }
.dgl-sheet-refund span { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #0a7a35; }
.dgl-sheet-refund b { font-size: 1.9rem; font-weight: 900; color: #0a7a35; font-variant-numeric: tabular-nums; }
.dgl-sheet-refund small { font-size: .78rem; color: #3d6b50; }
.dgl-sheet-refund.is-none { background: #f5f8ff; border-color: #dfe7f3; }
.dgl-sheet-refund.is-none span, .dgl-sheet-refund.is-none b { color: #3d5278; }
.dgl-sheet-refund.is-none small { color: #64748b; }
.dgl-sheet-rows { margin: 0 0 12px; }
.dgl-sheet-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px dashed #e3eaf6; font-size: .88rem; color: #3d5278; }
.dgl-sheet-row b { color: #0f1f3d; font-variant-numeric: tabular-nums; }
.dgl-sheet-note { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; padding: 11px 13px; border-radius: 12px; font-size: .82rem; line-height: 1.45; background: #f5f8ff; color: #3d5278; }
.dgl-sheet-note i { margin-top: 2px; }
.dgl-sheet-note.is-warn { background: #fff7e6; color: #7a4a06; }
.dgl-sheet-note.is-ok { background: #e8f8ee; color: #0a5a28; }
.dgl-sheet-label { display: block; margin: 14px 0 6px; font-size: .78rem; font-weight: 800; color: #3d5278; }
.dgl-sheet-field { width: 100%; padding: 12px 14px; border: 1.5px solid #dfe7f3; border-radius: 12px; font: 600 16px 'Inter', sans-serif; color: #0f1f3d; background: #fff; margin-bottom: 8px; }
.dgl-sheet-field:focus { outline: none; border-color: #002868; box-shadow: 0 0 0 4px rgba(0, 40, 104, .1); }
.dgl-sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.dgl-sheet-actions > button:only-child { grid-column: 1 / -1; }
.dgl-sheet-actions button { min-height: 50px; border-radius: 14px; border: 0; font: 800 .92rem 'Inter', sans-serif; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: scale .15s, filter .2s; }
.dgl-sheet-actions button:active { scale: .97; }
.dgl-btn-solid { background: #002868; color: #fff; }
.dgl-btn-ghost { background: #eef3ff; color: #002868; }
.dgl-btn-danger { background: #fff1f1; color: #b42318; border: 1.5px solid #f6d4d4 !important; }
.dgl-btn-danger:hover { background: #b42318; color: #fff; }
.dgl-btn-danger:disabled { opacity: .7; cursor: wait; }
.dgl-sheet-spin, .dgl-btn-spin { display: inline-block; border: 3px solid #dfe7f3; border-top-color: #002868; border-radius: 50%; animation: dgl-spin .7s linear infinite; }
.dgl-sheet-spin { width: 34px; height: 34px; margin: 18px auto; display: block; }
.dgl-btn-spin { width: 16px; height: 16px; border-width: 2.5px; border-color: rgba(180, 35, 24, .25); border-top-color: #b42318; }
.dgl-sheet-done { text-align: center; padding: 8px 0 2px; }
.dgl-sheet-tick { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #16a34a; color: #fff; font-size: 1.6rem; animation: dgl-pop .45s var(--dgl-spring, ease) both; }
@keyframes dglFade { from { opacity: 0; } }
@keyframes dglFadeOut { to { opacity: 0; } }
@keyframes dglSheetIn { from { transform: translateY(40px); opacity: 0; } }
@keyframes dglSheetOut { to { transform: translateY(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dgl-sheet-overlay, .dgl-sheet, .dgl-sheet-tick { animation: none !important; } }

.dgl-sheet-actions--stack { grid-template-columns: 1fr; }
.dgl-btn-plain { background: transparent; color: #64748b; min-height: 44px !important; }
.dgl-btn-plain:hover { color: #0f1f3d; }
.dgl-check { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.dgl-check li { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; color: #3d5278; }
.dgl-check li i { margin-top: 3px; width: 16px; text-align: center; }
.dgl-check .ok i { color: #16a34a; } .dgl-check .no i { color: #d97706; }
.dgl-check b { color: #0f1f3d; }
/* a note with no icon is ordinary flowing text (the flex layout is only for icon + text rows) */
.dgl-sheet-note:not(:has(> i)) { display: block; }
