/* ============================================================================
   Shipments — the list of a customer's shipments and one shipment's page
   (pages/shipments.js). The shared vocabulary — .cab-page, .cab-list/.cab-row,
   .cab-pill, .cab-steps, .cab-timeline, .cab-note, .cab-kv — is cabinet.css;
   what is here is only what those two screens add to it. Tokens only, so the
   dark theme needs nothing of its own.

   Phone first: every control a thumb uses is 44px tall below 900px, and the
   search box is 16px text there, because a smaller font makes iOS zoom the
   page in on focus and leave it zoomed.
   ========================================================================== */

/* ── The list: search and filters ──────────────────────────────────────── */

.cab-shipments-tools { display: flex; flex-direction: column; gap: 10px; }

.cab-shipments-search { flex: none; width: 100%; max-width: none; }
.cab-shipments-search svg { left: 13px; }
.cab-shipments-search .input {
  height: 44px; padding-left: 38px; padding-right: 44px;
  font-size: 16px; border-radius: var(--r-md);
}
.cab-shipments-search .search__clear { right: 4px; width: 36px; height: 36px; border-radius: var(--r); }
.cab-shipments-search .search__clear:hover { background: var(--surface-3); }

/* A strip that scrolls sideways on a phone rather than wrapping into two
   ragged rows. It bleeds to the screen's edges (the container's 16px gutter)
   so the last chip visibly runs off — that is what says «there is more». */
.cab-shipments-filters {
  display: flex; gap: 8px;
  margin: 0 -16px; padding: 2px 16px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cab-shipments-filters::-webkit-scrollbar { display: none; }

.cab-shipments-filter {
  flex: 0 0 auto; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: var(--r-full); border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 14px; font-weight: 550; white-space: nowrap;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.cab-shipments-filter:hover { border-color: var(--border-strong); color: var(--text); }
.cab-shipments-filter:focus-visible { outline: none; box-shadow: var(--ring); }
.cab-shipments-filter.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.cab-shipments-filter__count {
  min-width: 22px; padding: 1px 7px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-3);
  font-size: 12px; font-weight: 650; text-align: center;
}
.cab-shipments-filter.is-active .cab-shipments-filter__count {
  background: color-mix(in srgb, #fff 22%, transparent); color: #fff;
}

.cab-shipments-unpaid { display: flex; align-items: center; gap: 8px; }

@media (min-width: 720px) {
  .cab-shipments-tools { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
  .cab-shipments-search { flex: 1 1 300px; max-width: 440px; width: auto; }
  .cab-shipments-filters { margin: 0; padding: 0; overflow: visible; flex-wrap: wrap; }
  .cab-shipments-unpaid { flex-basis: 100%; }
}
@media (min-width: 900px) {
  .cab-shipments-search .input { height: 40px; font-size: 14px; }
  .cab-shipments-filter { min-height: 38px; padding: 0 14px; font-size: 13.5px; }
}

/* ── The list: rows ─────────────────────────────────────────────────────── */

/* On a phone: the number and the total on the first two lines, the status
   under them across the full width, where a long status name has room. From
   720px the three sit side by side.

   The total's column is shared with the eighteen-digit number, so nothing
   else goes in it: «К оплате 1 250 000 сум» under the total widened that
   column to ~155px and cut the number short at 375px. What is owed rides on
   the status line instead — after the date, pushed to the right edge, and
   wrapping onto a line of its own when the pill and a big sum will not share
   one. From 720px it always takes that second line, under the pill, since the
   status column is 250px and right-aligned text in the middle of a row reads
   as belonging to the column beside it. */
.cab-shipments-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "main side" "state state";
  align-items: center; gap: 8px 12px;
  min-height: 64px;
}
.cab-shipments-row > .cab-row__main { grid-area: main; }
.cab-shipments-row > .cab-row__side { grid-area: side; align-self: start; }
.cab-shipments-row .cab-row__title { font-size: 14.5px; letter-spacing: .01em; }

.cab-shipments-row__state {
  grid-area: state; display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px 10px; min-width: 0;
}
.cab-shipments-row__pill { min-width: 0; max-width: 100%; }
.cab-shipments-row__pill-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cab-shipments-row__date { flex: none; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.cab-shipments-row__pay { flex: none; margin-left: auto; }

.cab-shipments-due { font-size: 12.5px; font-weight: 650; color: var(--warning); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cab-shipments-row__hint { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.cab-shipments-row--ghost { cursor: default; }
.cab-shipments-row--ghost:hover { background: none; }
.cab-shipments-row--ghost .cab-row__main { gap: 8px; }

@media (min-width: 720px) {
  .cab-shipments-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 250px) minmax(120px, auto);
    grid-template-areas: "main state side";
  }
  .cab-shipments-row > .cab-row__side { align-self: center; }
  .cab-shipments-row__pay { flex-basis: 100%; margin-left: 0; }
}

.cab-shipments-tap { min-height: 44px; }

.cab-shipments-more { display: flex; justify-content: center; }
.cab-shipments-more .btn { width: 100%; max-width: 320px; }

/* ── One shipment: the head ─────────────────────────────────────────────── */

.cab-shipments-kicker {
  margin: 0 0 2px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-4);
}
.cab-shipments-number { overflow-wrap: anywhere; }
.cab-shipments-number .copyable { gap: 2px; }
/* The component's copy button is a 17px square — fine beside a table cell,
   too small for a thumb. Grown to 44px, with the margin taken back so the
   title line does not grow with it. */
.cab-shipments-number .copyable__btn {
  width: 44px; height: 44px; margin: -10px -10px -10px -4px;
  border-radius: var(--r); color: var(--text-4);
}
.cab-shipments-number .copyable__btn svg { width: 17px; height: 17px; }

.cab-shipments-headline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; }
.cab-shipments-route { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; font-weight: 600; color: var(--text-2); }
.cab-shipments-route svg { flex: none; color: var(--text-4); }

.cab-shipments-when { margin-top: 8px; font-weight: 550; }
.cab-shipments-when--success { color: var(--success); }
.cab-shipments-when--warning { color: var(--warning); }

.cab-shipments-danger { color: var(--danger); }
.cab-shipments-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* On a phone the buttons are a two-column grid, the document download across
   the top (the one most visits come for — the наклейка before delivery, the
   proof after it) and «Отменить» across the foot, where it is furthest from a
   thumb aimed at anything else. A waybill with no document to offer (a
   cancelled one) leaves the two ordinary buttons side by side. */
@media (max-width: 559px) {
  .cab-shipments-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .cab-shipments-actions > .btn {
    min-height: 44px; padding: 6px 10px;
    white-space: normal; line-height: 1.2; text-align: center;
  }
  .cab-shipments-actions > .cab-shipments-actions__doc,
  .cab-shipments-actions > .cab-shipments-danger { grid-column: 1 / -1; }
}
@media (min-width: 560px) and (max-width: 899px) {
  .cab-shipments-actions > .btn { min-height: 44px; }
}

/* ── One shipment: where it stands ──────────────────────────────────────── */

/* A failed attempt keeps its place on the strip, in the warning colour rather
   than the brand's — the step is where the parcel is, not where it is going. */
.cab-steps__step.cab-shipments-step--problem {
  color: var(--warning); border-color: var(--warning-border); background: var(--warning-soft);
}
.cab-steps__step.cab-shipments-step--problem::before { background: var(--warning); color: var(--surface); }

/* cabinet.css drops the step labels below 560px and leaves the numbers, so
   the current one is said in words underneath instead. */
.cab-shipments-step-caption { display: none; margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
@media (max-width: 560px) { .cab-shipments-step-caption { display: block; } }

/* ── One shipment: the body ─────────────────────────────────────────────── */

.cab-shipments-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.cab-shipments-layout__side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 960px) {
  .cab-shipments-layout { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
}

.cab-shipments-detail .card__header h2 { margin: 0; }
.cab-shipments-header-meta { margin-left: auto; font-size: 13px; }

.cab-shipments-event-note { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }

/* Sender and consignee: side by side where the column is wide enough to hold
   two addresses, stacked where it is not. */
.cab-shipments-parties { display: grid; gap: 10px; }
@media (min-width: 640px) and (max-width: 959px) {
  .cab-shipments-parties { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.cab-shipments-party { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cab-shipments-party__label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.cab-shipments-party__name { font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.cab-shipments-party__phone {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; width: fit-content;
  color: var(--text); font-weight: 600; text-decoration: none;
}
.cab-shipments-party__phone svg { color: var(--brand); }
.cab-shipments-party__phone:hover { text-decoration: underline; }
.cab-shipments-party__line { display: flex; align-items: flex-start; gap: 6px; font-size: 13.5px; color: var(--text-2); overflow-wrap: anywhere; }
.cab-shipments-party__line svg { flex: none; margin-top: 2px; color: var(--text-4); }
.cab-shipments-party__leg { font-weight: 600; }

.cab-shipments-pieces {
  list-style: none; margin: 0; padding: 12px 0 0;
  display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid var(--border);
}
.cab-shipments-piece { display: flex; align-items: flex-start; gap: 10px; }
.cab-shipments-piece > svg { flex: none; margin-top: 2px; color: var(--text-4); }
.cab-shipments-piece__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cab-shipments-piece__title { font-size: 14px; font-weight: 600; }
.cab-shipments-piece__meta { font-size: 12.5px; color: var(--text-3); overflow-wrap: anywhere; }

/* Money: charge lines, then the totals under a rule. */
.cab-shipments-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.cab-shipments-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 14px; }
.cab-shipments-line__label { display: flex; flex-direction: column; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
.cab-shipments-line__note { font-size: 12.5px; color: var(--text-3); }
.cab-shipments-line__amount { flex: none; white-space: nowrap; font-weight: 550; }
.cab-shipments-totals { display: flex; flex-direction: column; gap: 7px; padding-top: 11px; border-top: 1px solid var(--border); }
/* «Оплатить онлайн» under what is owed; the whole width on a phone, where it is
   the thumb's next move after reading the sum. */
.cab-shipments-pay { display: flex; justify-content: flex-end; }
@media (max-width: 600px) { .cab-shipments-pay .btn { flex: 1; justify-content: center; } }
.cab-shipments-line--total { font-size: 15.5px; font-weight: 700; }
.cab-shipments-line--due { font-weight: 700; color: var(--warning); }

.cab-shipments-subhead {
  margin: 4px 0 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3);
}

/* The cancel dialog's quick reasons wrap rather than scroll: there are three
   and the dialog is the one place with room for them. */
.cab-shipments-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.cab-shipments-presets .cab-shipments-filter { white-space: normal; text-align: left; line-height: 1.25; padding: 8px 14px; }
