/* TMS Paperless Driver Log — Stage 1 styles (namespaced pl-*, additive).
   Mobile-first; reuses the app's dark palette. NOT AN ELD. */

#paperlogRoot { display: block; }

.pl-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  padding: 14px;
  margin: 12px 0;
  box-sizing: border-box;
}
.pl-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.pl-card h4 { margin: 0 0 8px; font-size: 0.95rem; }
.pl-rowhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.pl-muted { color: rgba(255,255,255,0.62); font-size: 0.86rem; line-height: 1.4; margin: 6px 0; }
.pl-small { font-size: 0.78rem; }

.pl-badge {
  display: inline-block; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em;
  color: #ffd7a6; background: rgba(255,150,60,0.14); border: 1px solid rgba(255,150,60,0.4);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}

/* buttons */
.pl-btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600;
  min-height: 42px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.06); color: #fff;
}
.pl-btn:hover { background: rgba(255,255,255,0.12); }
.pl-btn--primary { background: #2f6df0; border-color: #2f6df0; }
.pl-btn--primary:hover { background: #3f7dff; }
.pl-btn--warn { background: #a23b3b; border-color: #a23b3b; }
.pl-btn--ghost { background: transparent; }
.pl-btn--sm { min-height: 34px; padding: 5px 10px; font-size: 0.82rem; }
.pl-btn--big { width: 100%; min-height: 56px; font-size: 1.1rem; letter-spacing: 0.04em; margin-top: 10px; }

.pl-check { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0; font-size: 0.9rem; }
.pl-check input { margin-top: 3px; }

/* prefill */
.pl-prefill { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 8px 0; }
.pl-prefill-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px dashed rgba(255,255,255,0.08); }
.pl-k { color: rgba(255,255,255,0.55); font-size: 0.82rem; }
.pl-v { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
@media (min-width: 640px) { .pl-prefill { grid-template-columns: 1fr 1fr; column-gap: 18px; } }

/* gps panel */
.pl-gps-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pl-gps-state { color: rgba(255,255,255,0.6); font-size: 0.82rem; }
.pl-prompt-slot:empty { display: none; }
.pl-prompt {
  margin-top: 10px; background: rgba(47,109,240,0.10); border: 1px solid rgba(47,109,240,0.45);
  border-radius: 12px; padding: 12px;
}
.pl-prompt-title { font-weight: 700; margin-bottom: 4px; }
.pl-prompt-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pl-time { display: block; margin: 8px 0; font-size: 0.85rem; }
.pl-time input, .pl-inline input {
  min-height: 40px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.25); color: #fff; padding: 6px 10px; box-sizing: border-box;
}
.pl-chiprow { display: flex; flex-wrap: wrap; gap: 8px; }
.pl-chip {
  cursor: pointer; font: inherit; font-weight: 600; min-height: 40px; padding: 7px 12px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.06); color: #fff;
}
.pl-chip:hover { background: rgba(255,255,255,0.14); }

/* duty controls */
.pl-duty-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 560px) { .pl-duty-grid { grid-template-columns: 1fr 1fr 1fr 1fr; } }
.pl-duty-btn {
  cursor: pointer; font: inherit; font-weight: 600; min-height: 58px; padding: 8px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,0.16); background: rgba(255,255,255,0.05); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
}
.pl-duty-btn:hover { background: rgba(255,255,255,0.12); }
.pl-duty-line { font-size: 0.68rem; font-weight: 800; opacity: 0.8; }

/* duty line colors */
.pl-line-OFF { --pl-c: #8a94a6; }
.pl-line-SB  { --pl-c: #6b8cff; }
.pl-line-D   { --pl-c: #2fb673; }
.pl-line-ON  { --pl-c: #e0a13a; }
.pl-duty-btn.pl-line-OFF { border-left: 4px solid #8a94a6; }
.pl-duty-btn.pl-line-SB  { border-left: 4px solid #6b8cff; }
.pl-duty-btn.pl-line-D   { border-left: 4px solid #2fb673; }
.pl-duty-btn.pl-line-ON  { border-left: 4px solid #e0a13a; }

/* grid */
.pl-grid { display: flex; flex-direction: column; gap: 2px; margin: 6px 0; }
.pl-grid-row { display: flex; align-items: stretch; gap: 6px; }
.pl-grid-label { width: 34px; font-size: 0.72rem; font-weight: 700; color: rgba(255,255,255,0.7); display: flex; align-items: center; }
.pl-grid-track { position: relative; flex: 1; height: 22px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 4px; min-width: 0; }
.pl-seg { position: absolute; top: 2px; bottom: 2px; border-radius: 3px; }
.pl-seg.pl-line-OFF { background: #8a94a6; }
.pl-seg.pl-line-SB  { background: #6b8cff; }
.pl-seg.pl-line-D   { background: #2fb673; }
.pl-seg.pl-line-ON  { background: #e0a13a; }
.pl-grid-hours { display: flex; justify-content: space-between; margin-left: 40px; font-size: 0.64rem; color: rgba(255,255,255,0.45); }

/* events */
.pl-events { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.pl-event { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: rgba(255,255,255,0.03); border-radius: 8px; font-size: 0.86rem; }
.pl-ev-time { font-variant-numeric: tabular-nums; color: rgba(255,255,255,0.7); min-width: 62px; }
.pl-ev-line { font-weight: 800; font-size: 0.72rem; padding: 1px 6px; border-radius: 4px; color: #0b1020; background: var(--pl-c, #ccc); }
.pl-ev-act { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pl-x { cursor: pointer; background: transparent; border: none; color: rgba(255,255,255,0.5); font-size: 0.9rem; }
.pl-x:hover { color: #ff8a8a; }

/* totals */
.pl-totals { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .pl-totals { grid-template-columns: repeat(5, 1fr); } }
.pl-total { background: rgba(255,255,255,0.04); border-radius: 8px; padding: 8px; text-align: center; border-top: 3px solid var(--pl-c, #888); }
.pl-total--sum { border-top-color: #fff; }
.pl-total-k { font-size: 0.72rem; color: rgba(255,255,255,0.6); }
.pl-total-v { font-weight: 700; font-variant-numeric: tabular-nums; }

/* inline forms */
.pl-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 8px; }
.pl-inline label { display: flex; flex-direction: column; font-size: 0.78rem; color: rgba(255,255,255,0.65); gap: 3px; }
.pl-inline .grow, .pl-inline input.grow { flex: 1; min-width: 160px; }
.pl-remarks { margin: 6px 0; padding-left: 18px; font-size: 0.86rem; }
.pl-remarks li { margin: 3px 0; }

/* certify */
.pl-eod { border-color: rgba(47,182,115,0.35); }
.pl-certified { border-color: rgba(47,182,115,0.5); background: rgba(47,182,115,0.08); }
.pl-cert-badge { font-weight: 800; color: #7ff0b0; letter-spacing: 0.05em; }

/* archive */
.pl-archive { display: flex; flex-direction: column; gap: 6px; }
.pl-arch-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; background: rgba(255,255,255,0.03); border-radius: 8px; font-size: 0.85rem; flex-wrap: wrap; }
.pl-arch-date { font-weight: 700; min-width: 92px; }
.pl-arch-load { flex: 1; min-width: 0; color: rgba(255,255,255,0.7); }
.pl-arch-state { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; }
.pl-arch-state.is-cert { color: #7ff0b0; background: rgba(47,182,115,0.15); }
.pl-arch-state.is-open { color: #ffd7a6; background: rgba(255,150,60,0.14); }

/* modal */
.pl-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.pl-modal { background: #141a2b; border: 1px solid rgba(255,255,255,0.15); border-radius: 14px; padding: 18px; max-width: 440px; width: 100%; }
.pl-modal .pl-inline { margin: 14px 0; }

/* toast */
.pl-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: all 0.2s ease;
  background: #1e2740; color: #fff; border: 1px solid rgba(255,255,255,0.18); padding: 10px 16px; border-radius: 10px; z-index: 10000; font-size: 0.88rem; }
.pl-toast--in { opacity: 1; transform: translate(-50%, 0); }

/* ── Stage 2: Active Trip panel + stops ── */
.pl-trip { border-color: rgba(107,140,255,0.30); }
.pl-chip-stop { font-size: 0.72rem; font-weight: 700; color: #cfe0ff; background: rgba(107,140,255,0.18); border: 1px solid rgba(107,140,255,0.4); padding: 3px 9px; border-radius: 999px; }
.pl-stops { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.pl-stop-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: rgba(255,255,255,0.03); border-radius: 8px; font-size: 0.85rem; }
.pl-stop-row--cur { background: rgba(107,140,255,0.12); border: 1px solid rgba(107,140,255,0.35); }
.pl-stop-badge { font-size: 0.66rem; font-weight: 800; color: #0b1020; padding: 1px 6px; border-radius: 4px; background: var(--pl-c, #ccc); }
.pl-stop-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pl-stop-phase { font-size: 0.72rem; color: rgba(255,255,255,0.6); text-transform: capitalize; }

/* ── Stage 2C: detention ── */
.pl-detention { border-color: rgba(224,161,58,0.4); background: rgba(224,161,58,0.06); }
.pl-det-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; flex-wrap: wrap; }
.pl-det-label { font-weight: 600; }
.pl-det-min { font-variant-numeric: tabular-nums; color: #ffd7a6; flex: 1; }

/* ── Stage 2B: paperwork reminders ── */
.pl-remind { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; margin: 6px 0; font-size: 0.86rem; background: rgba(255,255,255,0.03); flex-wrap: wrap; }
.pl-remind-text { flex: 1; min-width: 140px; overflow-wrap: anywhere; }
.pl-remind-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pl-remind--required { border-left: 3px solid #e0673a; }
.pl-remind--required .pl-remind-dot { background: #e0673a; }
.pl-remind--advisory { border-left: 3px solid #8a94a6; }
.pl-remind--advisory .pl-remind-dot { background: #8a94a6; }

/* ── Stage 2B: end-of-day checklist ── */
.pl-eodcheck { border-color: rgba(47,182,115,0.3); }
.pl-checklist { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.pl-check-item { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; }
.pl-check-item.is-open { color: #ffd7a6; }
.pl-check-item.is-done { color: rgba(255,255,255,0.7); }
.pl-check-box { font-weight: 800; width: 16px; text-align: center; }

/* ── Start My Day: morning dashboard ── */
.pl-morning { background: linear-gradient(160deg, rgba(47,109,240,0.14), rgba(255,255,255,0.03)); border-color: rgba(107,140,255,0.28); }
.pl-morning-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pl-morning-hi { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; }
.pl-morning-date { color: rgba(255,255,255,0.62); font-size: 0.9rem; margin-top: 2px; }
.pl-morning-trip { margin: 14px 0 6px; padding: 12px; background: rgba(0,0,0,0.22); border-radius: 10px; }
.pl-morning-route { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 700; font-size: 1.05rem; }
.pl-morning-city { overflow-wrap: anywhere; }
.pl-morning-arrow { color: #6b8cff; font-weight: 800; }
.pl-morning-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pl-pill { font-size: 0.74rem; font-weight: 600; color: #cfe0ff; background: rgba(107,140,255,0.16); border: 1px solid rgba(107,140,255,0.32); padding: 3px 9px; border-radius: 999px; }

/* ── Stage 3: Driver Sync Status chip ── */
.pl-header-badges { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-sync-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.7); white-space: nowrap; }
.pl-sync-text { line-height: 1; }
.pl-sync-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pl-sync--synced { color: #7ff0b0; border-color: rgba(47,182,115,0.35); background: rgba(47,182,115,0.10); }
.pl-sync--syncing { color: #cfe0ff; border-color: rgba(107,140,255,0.35); background: rgba(107,140,255,0.10); }
.pl-sync--waiting { color: #cfe0ff; border-color: rgba(107,140,255,0.35); background: rgba(107,140,255,0.10); }
.pl-sync--syncing .pl-sync-dot, .pl-sync--waiting .pl-sync-dot { animation: pl-sync-pulse 1s ease-in-out infinite; }
.pl-sync--offline { color: rgba(255,255,255,0.55); }
.pl-sync--conflict { color: #ffb4b4; border-color: rgba(200,70,70,0.5); background: rgba(200,70,70,0.14); }
@keyframes pl-sync-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Persistent STOP banner (stronger during-stop alert) ──────────────────── */
.pl-stopbanner {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px);
  z-index: 2147481500; width: max-content; max-width: min(94vw, 560px);
  background: #0f172a; color: #fff; border: 2px solid rgba(96,165,250,0.55);
  border-radius: 16px; padding: 15px 16px;
  box-shadow: 0 22px 60px rgba(0,0,0,0.6), 0 0 30px rgba(37,99,235,0.28);
  opacity: 0; pointer-events: none; transition: opacity .26s ease, transform .26s ease;
}
.pl-stopbanner.pl-stopbanner--in { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.pl-stopbanner--urgent { border-color: rgba(248,113,113,0.75); box-shadow: 0 22px 60px rgba(0,0,0,0.6), 0 0 30px rgba(220,38,38,0.4); }
.pl-stopbanner-head { display: flex; gap: 12px; align-items: flex-start; }
.pl-stopbanner-dot { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; background: #60a5fa; margin-top: 4px; }
.pl-stopbanner--urgent .pl-stopbanner-dot { background: #f87171; animation: pl-stop-blink 1s ease-in-out infinite; }
.pl-stopbanner-title { font-weight: 800; font-size: 15.5px; line-height: 1.3; }
.pl-stopbanner-sub { font-size: 13px; color: #cbd5e1; margin-top: 3px; line-height: 1.4; }
.pl-stopbanner-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.pl-stopbanner-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
.pl-stopbanner--pulse { animation: pl-stop-pulse 0.9s ease-in-out 3; }
@keyframes pl-stop-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes pl-stop-pulse {
  0%,100% { box-shadow: 0 22px 60px rgba(0,0,0,0.6), 0 0 0 0 rgba(220,38,38,0); }
  50% { box-shadow: 0 22px 60px rgba(0,0,0,0.6), 0 0 0 8px rgba(220,38,38,0.28); }
}
@media (max-width: 640px) {
  .pl-stopbanner { left: 10px; right: 10px; bottom: 12px; transform: translateY(20px); max-width: none; width: auto; }
  .pl-stopbanner.pl-stopbanner--in { transform: translateY(0); }
}

/* no horizontal overflow guard */
#paperlogRoot * { max-width: 100%; }

/* ── Unresolved-stop protection + Edit Log ─────────────────────────────────── */
.pl-line-UN { --pl-c: #fbbf24; }
.pl-review { border: 1px solid rgba(251,191,36,0.55); background: rgba(251,191,36,0.08); }
.pl-review h4 { color: #fbbf24; }
.pl-review-span { font-weight: 700; font-size: 0.9rem; color: #fde68a; margin: 4px 0; }
.pl-event--review { background: rgba(251,191,36,0.10); border-radius: 6px; }
.pl-ev-corrected { font-size: 0.68rem; padding: 1px 6px; border-radius: 999px; color: #93c5fd; background: rgba(96,165,250,0.15); cursor: help; }
.pl-arch-state.is-review { color: #fde68a; background: rgba(251,191,36,0.16); }
.pl-edit-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 8px 10px; margin: 2px 0 8px; border: 1px dashed rgba(148,163,184,0.4); border-radius: 8px; }
.pl-edit-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: #cbd5e1; }
.pl-edit-field select, .pl-edit-field input { background: #101830; color: #e2e8f0; border: 1px solid rgba(148,163,184,0.35); border-radius: 6px; padding: 5px 8px; font-size: 0.85rem; }
.pl-edit-btn { margin-left: auto; }
