/* ==========================================================================
   VDS Dashboard

   Skinned to match the EZ-Agent customer portal. Tokens below are taken
   from the live site, not approximated:

     portal shell   https://my.validateddeliverysolutions.com/  (inline <style>)
     order entry    /css/ship_responsive.css

   --navy, --red, --border, --bg-section, --label-color and the font stack
   are the portal's own values. Keep them in sync if the portal changes;
   everything else here derives from them.
   ========================================================================== */

:root {
  /* ---- Portal brand tokens (verbatim from the portal) ------------------ */
  --navy:          #000053;
  --navy-hover:    #00007a;
  --navy-light:    #e8e8f5;
  --red:           #cc0033;
  --red-hover:     #a80028;
  --border:        #c8c8d8;
  --border-light:  #e0e0ea;
  --bg-section:    #fafafa;
  --bg-section-alt:#f4f4fb;
  --bg-sidebar:    #f0f0f5;
  --label-color:   #065B9B;
  --input-border:  #aaaacc;
  --accent-alt:    #004488;   /* portal's pickup/delivery panel accent */

  --font: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;

  /* ---- Dashboard-only ------------------------------------------------- */
  --paper:   #fff;
  --surface: #fff;
  --text:    #111;
  --muted:   #666;

  /* Deadline signal. Overdue reuses the portal red so urgency reads as part
     of the brand; the other two are deliberately NOT navy, since navy is
     structural here and would not register as a status. */
  --late:       var(--red);
  --late-wash:  #fdecf0;
  --soon:       #9a5700;
  --soon-wash:  #fdf4e6;
  --clear:      #1f7a52;
  --clear-wash: #eef6f2;
  --unknown:    #8a8aa0;
  /* Delivered. Deliberately not --clear: a finished shipment and one that is
     merely on schedule must not read as the same state at a glance. Slate
     reads as "settled, no action" rather than "good". */
  --done:       #5a6b86;
  --done-wash:  #f2f4f8;

  --radius: 3px;              /* the portal's radius, not a rounder one */
  --shadow-sm: 0 1px 2px rgba(0, 0, 83, .06);
  --shadow-md: 0 2px 8px rgba(0, 0, 83, .10);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;          /* the portal's base size */
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--navy); color: #fff; padding: 10px 16px;
  border-radius: 0 0 var(--radius) 0; text-decoration: none;
}
.skip:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Top bar

   Mirrors the portal's #site-header: white, 3px navy underline, logo left.
   Deliberately NOT a dark bar - these pages may be loaded inside the
   portal's mainFrame iframe, directly beneath that header, and two heavy
   bars stacked would look like a mistake.
   -------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 0 16px;
  min-height: 72px;            /* the portal's --header-h */
  background: #fff;
  color: var(--navy);
  border-bottom: 3px solid var(--navy);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.topbar__logo { height: 60px; width: auto; flex-shrink: 0; display: block; }

/* Fallback mark, used only when no logo file is configured. */
.mark {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--radius);
  background: var(--navy);
  color: #fff;
  flex: none;
}

.topbar__names { display: flex; flex-direction: column; min-width: 0; }

.topbar__client {
  font-size: 0.72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--label-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.25;
}

.topbar__status { display: flex; align-items: center; gap: 10px; }

.freshness {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-sidebar);
  font-size: 0.78rem;
  color: #444;
  white-space: nowrap;
}

.freshness__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--clear);
  flex: none;
}

.freshness[data-state="live"]  .freshness__dot { animation: pulse 2.4s ease-in-out infinite; }
.freshness[data-state="stale"] .freshness__dot { background: var(--soon); animation: none; }
.freshness[data-state="error"] .freshness__dot { background: var(--red);  animation: none; }
.freshness[data-state="loading"] .freshness__dot { background: var(--unknown); }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(31,122,82,.45); }
  50%      { opacity: .75; box-shadow: 0 0 0 5px rgba(31,122,82,0); }
}

/* Matches the portal's submit button. */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border: none;
  border-radius: 4px;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn:hover  { background: var(--navy-hover); }
.btn:active { transform: scale(.98); }
.btn[data-busy="1"] svg { animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Alert banner
   -------------------------------------------------------------------------- */

.alert {
  padding: 9px 20px;
  font-size: 0.82rem;
  background: var(--soon-wash);
  color: #7a4300;
  border-bottom: 1px solid #efdcbd;
}
.alert[data-tone="error"] {
  background: var(--late-wash);
  color: #8e1030;
  border-bottom-color: #f3cdd8;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.wrap {
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 10px 20px;
}

/* --------------------------------------------------------------------------
   Signal strip

   Built as portal section panels: 3px top accent, pale fill, square corners.
   -------------------------------------------------------------------------- */

.signals {
  display: grid;
  /* Four now: the three deadline states plus Delivered today. */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.signal {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 12px;
  background: var(--bg-section);
  border: 1px solid var(--border-light);
  border-top: 3px solid var(--unknown);
  border-radius: var(--radius);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .12s, box-shadow .12s;
}
.signal:hover { box-shadow: var(--shadow-sm); }
.signal[aria-pressed="true"] { background: var(--navy-light); border-color: var(--navy); }

.signal[data-filter="overdue"]  { border-top-color: var(--late); }
.signal[data-filter="due_soon"] { border-top-color: var(--soon); }
.signal[data-filter="on_track"] { border-top-color: var(--clear); }

.signal__count {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.signal[data-filter="overdue"]  .signal__count { color: var(--late); }
.signal[data-filter="due_soon"] .signal__count { color: var(--soon); }
.signal[data-filter="on_track"] .signal__count { color: var(--clear); }

.signal__label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--navy);
}

/* --------------------------------------------------------------------------
   Toolbar
   -------------------------------------------------------------------------- */

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 8px;
}

.search {
  display: flex; align-items: center; gap: 7px;
  flex: 1 1 300px; max-width: 440px;
  padding: 0 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
}
.search:focus-within {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(0, 0, 83, .15);   /* the portal's focus ring */
}

.search input {
  flex: 1; min-width: 0;
  padding: 5px 0;
  border: 0; background: none;
  font: inherit; font-size: 0.85rem;
  color: var(--text);
}
.search input:focus { outline: none; }

.toolbar__meta { margin: 0; font-size: 0.8rem; color: var(--muted); }

/* --------------------------------------------------------------------------
   Job table
   -------------------------------------------------------------------------- */

.board {
  background: #fff;
  border: 1px solid var(--border-light);
  border-top: 3px solid var(--navy);
  border-radius: var(--radius);
}
.board:focus { outline: none; }

.jobs {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

/* Column headers borrow the portal's .section-title treatment. */
.jobs thead th {
  position: sticky; top: var(--topbar-h, 72px); z-index: 5;
  padding: 7px 10px;
  background: var(--bg-section-alt);
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--navy);
  white-space: nowrap;
}

.jobs th.num, .jobs td.num { text-align: right; }

.jobs th.sortable { cursor: pointer; user-select: none; }
.jobs th.sortable:hover { color: var(--red); }
.jobs th.sortable::after {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  margin-left: 5px;
  vertical-align: middle;
  border: 4px solid transparent;
  opacity: 0;
}
.jobs th.is-sorted { color: var(--red); }
.jobs th.is-sorted::after { opacity: 1; }
.jobs th.is-sorted[aria-sort="ascending"]::after  { border-bottom-color: currentColor; margin-bottom: 3px; }
.jobs th.is-sorted[aria-sort="descending"]::after { border-top-color: currentColor; margin-top: 3px; }

.jobs tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.jobs tbody tr.job { transition: background .12s; }
.jobs tbody tr.job:hover { background: var(--bg-section); }
.jobs tbody tr.job.is-open { background: var(--navy-light); }

/* Status rail on the leading edge of each row - readable across a room. */
.jobs tbody tr.job > td:first-child {
  box-shadow: inset 3px 0 0 var(--rail, var(--unknown));
  padding-left: 13px;
}
.jobs tbody tr.u-overdue  { --rail: var(--late); }
.jobs tbody tr.u-due_soon { --rail: var(--soon); }
.jobs tbody tr.u-on_track { --rail: var(--clear); }
.jobs tbody tr.u-delivered { --rail: var(--done); }

/* Delivered rows are context beneath the live work, so they recede: muted
   text, a faint wash, and no emphasis competing with the rows above that
   still need somebody to act. */
.jobs tbody tr.u-delivered > td { background: var(--done-wash); color: var(--muted); }
.jobs tbody tr.u-delivered .strong-cell { font-weight: 500; }
.jobs tbody tr.u-delivered .deadline__abs { text-decoration: line-through; opacity: .65; }

.jobs tbody tr.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  from { background: #fff6d8; }
  to   { background: transparent; }
}

.jobs tbody tr:last-child td { border-bottom: 0; }

/* Deadline cell ------------------------------------------------------------ */

.deadline { display: flex; flex-direction: column; gap: 1px; min-width: 126px; }

.deadline__remaining {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: -.01em;
}
tr.u-overdue  .deadline__remaining { color: var(--late); }
tr.u-due_soon .deadline__remaining { color: var(--soon); }
tr.u-on_track .deadline__remaining { color: var(--text); }
tr.u-delivered .deadline__remaining { color: var(--done); font-weight: 600; }
tr.u-unknown  .deadline__remaining { color: var(--unknown); font-weight: 500; }

.deadline__abs {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Cell value types --------------------------------------------------------- */

/* Job links use the portal's link red. */
.joblink {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--red);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.joblink:hover { color: var(--red-hover); border-bottom-color: currentColor; }

.mono    { font-family: var(--mono); font-size: 0.78rem; color: var(--text); }
.mono-sm { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }

.strong-cell { font-weight: 600; color: var(--navy); }

.origin__city  { display: block; }
.origin__state { font-size: 0.72rem; color: var(--muted); letter-spacing: .04em; }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-sidebar);
  font-size: 0.72rem;
  color: #444;
  white-space: nowrap;
}

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

/* Detail toggle ------------------------------------------------------------ */

.col-action { width: 38px; }

.disclose {
  display: grid; place-items: center;
  width: 24px; height: 24px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--label-color);
  cursor: pointer;
  transition: transform .18s, color .15s, border-color .15s;
}
.disclose:hover { color: var(--navy); border-color: var(--navy); }
.disclose[aria-expanded="true"] { transform: rotate(180deg); color: var(--navy); border-color: var(--navy); }

/* The expanded panel is a portal section panel. */
tr.detail > td {
  padding: 0 12px 12px;
  background: var(--bg-section-alt);
  border-bottom: 1px solid var(--border-light);
}

.detail__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 20px;
  padding-top: 8px;
}

.detail__group h4 {
  margin: 0 0 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--navy);
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-light);
}

.detail__row { display: flex; gap: 8px; font-size: 0.78rem; padding: 1.5px 0; }
.detail__key { color: var(--label-color); min-width: 80px; flex: none; text-align: right; }
.detail__val { color: var(--text); word-break: break-word; }

.tissue { display: flex; flex-wrap: wrap; gap: 5px; }
.tissue span {
  padding: 1px 8px;
  border: 1px solid var(--accent-alt);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-alt);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: .04em;
}

/* --------------------------------------------------------------------------
   Empty + loading states
   -------------------------------------------------------------------------- */

.empty { padding: 48px 24px; text-align: center; }
.empty__head { margin: 0 0 4px; font-size: 1rem; font-weight: 600; color: var(--navy); }
.empty__sub  { margin: 0; font-size: 0.82rem; color: var(--muted); }

.skeleton { padding: 10px; }
.skeleton span {
  display: block; height: 34px; margin-bottom: 6px; border-radius: var(--radius);
  background: linear-gradient(90deg, #f2f2f8 25%, #e6e6f0 50%, #f2f2f8 75%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.skeleton span:nth-child(2) { animation-delay: .08s; }
.skeleton span:nth-child(3) { animation-delay: .16s; }
.skeleton span:nth-child(4) { animation-delay: .24s; }
.skeleton span:nth-child(5) { animation-delay: .32s; }

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* --------------------------------------------------------------------------
   Footer - matches the portal's .form-footer
   -------------------------------------------------------------------------- */

.footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 10px;
  padding: 8px 0 4px;
  border-top: 1px solid var(--border-light);
  font-size: 0.75rem;
  color: var(--navy);
}
.footer__brand { letter-spacing: .06em; text-transform: uppercase; font-size: 0.7rem; color: var(--muted); }

/* ==========================================================================
   Responsive

   640px matches the order-entry form's breakpoint, so a customer moving
   between the two pages meets the same layout change at the same width.
   Below it the table becomes cards - a wide table in a horizontal scroller
   is not usable on a phone, and this gets read from vehicles.
   ========================================================================== */

@media (max-width: 640px) {

  .wrap { padding: 8px 6px 16px; }

  .topbar { min-height: 60px; padding: 8px 10px; gap: 10px; }
  .topbar__logo { height: 42px; }
  .topbar__title { font-size: 0.92rem; }
  .topbar__status { width: 100%; justify-content: space-between; }

  .signals { grid-template-columns: 1fr; gap: 6px; }
  .signal {
    flex-direction: row; align-items: baseline; gap: 10px;
    border-top-width: 1px;
    border-left: 3px solid var(--unknown);
    padding: 7px 10px;
  }
  .signal[data-filter="overdue"]  { border-left-color: var(--late); border-top-color: var(--border-light); }
  .signal[data-filter="due_soon"] { border-left-color: var(--soon); border-top-color: var(--border-light); }
  .signal[data-filter="on_track"] { border-left-color: var(--clear); border-top-color: var(--border-light); }
  .signal[data-filter="delivered"] { border-left-color: var(--done); border-top-color: var(--border-light); }
  .signal__count { font-size: 1.25rem; }

  .board { background: none; border: 0; border-top: 0; }

  .jobs, .jobs tbody, .jobs tr, .jobs td { display: block; width: 100%; }
  .jobs thead { display: none; }

  .jobs tbody tr.job {
    position: relative;
    margin-bottom: 8px;
    padding: 10px 12px 10px 14px;
    background: var(--bg-section);
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--rail, var(--unknown));
    border-radius: var(--radius);
  }
  .jobs tbody tr.job > td:first-child { box-shadow: none; padding-left: 0; }

  .jobs tbody td {
    padding: 2px 0;
    border: 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
  }
  .jobs tbody tr:last-child td { border-bottom: 0; }

  .jobs tbody td::before {
    content: attr(data-label);
    flex: none;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--label-color);
  }

  .jobs tbody td.cell-deadline,
  .jobs tbody td.cell-job { display: block; }
  .jobs tbody td.cell-deadline::before,
  .jobs tbody td.cell-job::before { display: none; }

  .jobs tbody td.cell-deadline {
    padding-bottom: 5px;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border-light);
  }
  .deadline { flex-direction: row; align-items: baseline; gap: 10px; }
  .deadline__remaining { font-size: 1rem; }

  .jobs tbody td.cell-job { padding-bottom: 5px; }
  .joblink { font-size: 0.95rem; }

  .col-action, .jobs tbody td.cell-action { position: absolute; top: 8px; right: 8px; padding: 0; }
  .jobs tbody td.cell-action::before { display: none; }

  tr.detail { margin: -6px 0 8px; }
  tr.detail > td {
    display: block;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
  }
  tr.detail > td::before { display: none; }
  .detail__grid { grid-template-columns: 1fr; }
  .detail__key { text-align: left; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
  .search input { font-size: 1rem; }   /* 16px minimum stops Android auto-zoom */
}

@media (max-width: 480px) {
  /* The logo alone identifies the app, as on the portal shell. */
  .topbar__names { display: none; }
}

/* --------------------------------------------------------------------------
   Preferences and print
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media print {
  .topbar__status, .toolbar, .disclose, .col-action, .skip, .skeleton { display: none !important; }
  body { background: #fff; font-size: 10pt; }
  .board, .signal { box-shadow: none; }
  .jobs thead th { position: static; background: #fff; }
  .jobs tbody tr.job { break-inside: avoid; }
  tr.detail { display: none; }
}
