/* ============================================================================
   Customer cabinet — the frame and the shared vocabulary
   ============================================================================
   Loaded after /css/app.css, whose tokens (both themes) and controls — .btn,
   .card, .input, .field, .badge, .modal, the toasts, the address form — are
   used as they are. This file is the cabinet's own layout on top of them, and
   the handful of blocks every page shares. A page's own styling goes in its
   own file (css/<page>.css), never here, so pages can change apart.

   Shared blocks a page may use:
     .cab-page / __head / __title / __sub / __actions   page wrapper and heading
     .cab-back                                          «← back» link over a title
     .cab-section                                       vertical rhythm between cards
     .cab-grid-2 / .cab-grid-3                          responsive grids
     .cab-stat / __label / __value / __meta             a figure tile
     .cab-list / .cab-row / __main / __title / __sub / __side / __amount
                                                        tappable rows: waybills, pickups
     .cab-pill (style="--c: <colour>")                  a status with a dot
     .cab-kv (dl)                                       label / value pairs
     .cab-steps / __step (.is-active .is-done)          a numbered stepper
     .cab-timeline / __item (.is-first) / __dot / __body   status history
     .cab-sticky-actions                                a form's buttons, kept in reach on a phone
     .cab-note (.cab-note--warning / --danger / --success)  an inline message
     .cab-muted, .cab-tabular                           small helpers
   ========================================================================== */

.cab-body { background: var(--bg); }

.cab { min-height: 100dvh; display: flex; flex-direction: column; }

.cab-container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.cab-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.cab-header__inner {
  height: 60px;
  display: flex; align-items: center; gap: 20px;
}
.cab-header__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.cab-header__send { display: none; }

.cab-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.cab-brand__mark {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: grid; place-content: center;
  border-radius: var(--r-md);
  background: var(--brand); color: #fff;
  font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.cab-brand__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.cab-brand__name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.cab-brand__sub { font-size: 11.5px; color: var(--text-4); white-space: nowrap; }

.cab-nav { display: none; align-items: center; gap: 2px; }
.cab-nav__link {
  padding: 7px 12px; border-radius: var(--r);
  color: var(--text-3); font-weight: 550; font-size: 14px;
  text-decoration: none; white-space: nowrap;
}
.cab-nav__link:hover { color: var(--text); background: var(--surface-3); }
.cab-nav__link.is-active { color: var(--brand); background: var(--brand-soft); }
[data-theme="dark"] .cab-nav__link.is-active { color: var(--brand-700); }

.cab-account {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: var(--r-full, 999px);
  background: none; color: var(--text); cursor: pointer; font: inherit;
}
.cab-account:hover { background: var(--surface-3); }
.cab-account__avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-content: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px;
}
.cab-account__name { display: none; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.cab-account__head { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 8px; }

/* ── Main, footer ───────────────────────────────────────────────────────── */

.cab-main { flex: 1; padding: 20px 0 calc(92px + env(safe-area-inset-bottom)); }

.cab-footer { border-top: 1px solid var(--border); padding: 18px 0 calc(86px + env(safe-area-inset-bottom)); color: var(--text-4); font-size: 13px; }
.cab-footer__inner { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }

/* ── The thumb bar (phones) ─────────────────────────────────────────────── */

.cab-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  /* Equal shares, except that no place is narrower than its own label: the
     long one takes what it needs and the four short ones split the rest. */
  display: grid; grid-template-columns: repeat(5, minmax(max-content, 1fr));
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-top: 1px solid var(--border);
}
.cab-tabs__item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 2px; border-radius: var(--r);
  color: var(--text-4); text-decoration: none; font-size: 11px; font-weight: 550;
  min-width: 0;
}
.cab-tabs__icon { height: 26px; display: grid; place-content: center; }
/* Five places share 360–375px, and «Отправления» is the longest word among
   them: set a hair tighter than body text so it fits whole rather than as
   «Отправле…», which is the one label a customer most needs to read. */
.cab-tabs__label {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  font-size: 10.5px; letter-spacing: -0.02em;
}
.cab-tabs__item.is-active { color: var(--brand); }
[data-theme="dark"] .cab-tabs__item.is-active { color: var(--brand-700); }
.cab-tabs__item--primary .cab-tabs__icon {
  width: 44px; height: 44px; margin-top: -18px;
  border-radius: 50%; background: var(--brand); color: #fff;
  box-shadow: var(--shadow-md), 0 0 0 4px var(--surface);
}
.cab-tabs__item--primary { color: var(--text-3); }
.cab-tabs__item--primary.is-active .cab-tabs__icon { background: var(--brand-600); }

@media (min-width: 900px) {
  .cab-nav { display: flex; }
  .cab-header__send { display: inline-flex; }
  .cab-account__name { display: inline; }
  .cab-tabs { display: none; }
  .cab-main { padding-bottom: 40px; }
  .cab-footer { padding-bottom: 18px; }
}
@media (max-width: 420px) {
  .cab-brand__sub { display: none; }
}

/* ── Auth frame ─────────────────────────────────────────────────────────── */

.cab-auth { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
.cab-auth__aside { display: none; }
.cab-auth__main {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px 16px calc(24px + env(safe-area-inset-bottom)); gap: 18px;
}
.cab-auth__mobile-brand { align-self: center; }
.cab-auth__panel {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); padding: 26px 22px;
}
.cab-auth__foot { font-size: 13px; color: var(--text-4); }

@media (min-width: 960px) {
  .cab-auth { grid-template-columns: minmax(380px, 44%) 1fr; }
  .cab-auth__aside {
    display: flex; align-items: center;
    background:
      radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, #ffffff 14%, transparent), transparent 60%),
      linear-gradient(160deg, var(--brand) 0%, var(--brand-700) 100%);
    color: #fff; padding: 56px;
  }
  .cab-auth__aside .cab-brand { color: #fff; }
  .cab-auth__aside .cab-brand__mark { background: #fff; color: var(--brand); }
  .cab-auth__aside .cab-brand__sub { color: rgba(255, 255, 255, .72); }
  .cab-auth__aside-inner { max-width: 420px; display: flex; flex-direction: column; gap: 28px; }
  .cab-auth__pitch { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; margin: 0; }
  .cab-auth__points { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; font-size: 15px; color: rgba(255, 255, 255, .9); }
  .cab-auth__points li { display: flex; align-items: center; gap: 12px; }
  .cab-auth__mobile-brand { display: none; }
}

/* ── Shared page vocabulary ─────────────────────────────────────────────── */

.cab-page { display: flex; flex-direction: column; gap: 16px; animation: fadeUp .22s ease both; }
.cab-page__head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.cab-page__heading { flex: 1 1 260px; min-width: 0; }
.cab-page__title { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.cab-page__sub { margin: 4px 0 0; color: var(--text-3); font-size: 14px; }
.cab-page__actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 560px) {
  .cab-page__title { font-size: 21px; }
  .cab-page__actions { width: 100%; }
  .cab-page__actions > .btn { flex: 1 1 auto; justify-content: center; }
}

.cab-back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13.5px; font-weight: 550; text-decoration: none; width: fit-content; }
.cab-back:hover { color: var(--brand); }

.cab-section { display: flex; flex-direction: column; gap: 12px; }

.cab-grid-2, .cab-grid-3 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cab-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 640px) { .cab-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .cab-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.cab-stat { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.cab-stat__label { font-size: 12.5px; font-weight: 600; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.cab-stat__value { font-size: 26px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.cab-stat__meta { font-size: 12.5px; color: var(--text-3); }

.cab-list { display: flex; flex-direction: column; }
.cab-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  color: inherit; text-decoration: none; background: none; width: 100%; text-align: left; font: inherit;
  cursor: pointer;
}
.cab-row:last-child { border-bottom: 0; }
.cab-row:hover { background: var(--surface-2); }
.cab-row:focus-visible { outline: none; box-shadow: inset var(--ring); }
.cab-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cab-row__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab-row__sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab-row__side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; text-align: right; }
.cab-row__amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

.cab-pill {
  --c: var(--text-4);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: color-mix(in srgb, var(--c) 82%, var(--text));
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 26%, transparent);
}
.cab-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

.cab-kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.cab-kv dt { color: var(--text-3); }
.cab-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.cab-steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; counter-reset: step; }
.cab-steps__step {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text-4);
}
.cab-steps__step::before {
  counter-increment: step; content: counter(step);
  width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-content: center; font-size: 12px;
  background: var(--surface-3); color: var(--text-3);
}
.cab-steps__step span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab-steps__step.is-active { color: var(--brand); border-color: var(--brand-border); background: var(--brand-soft); }
.cab-steps__step.is-active::before { background: var(--brand); color: #fff; }
.cab-steps__step.is-done { color: var(--text-2); }
.cab-steps__step.is-done::before { content: '✓'; background: var(--success-soft); color: var(--success); }
@media (max-width: 560px) { .cab-steps__step span { display: none; } .cab-steps__step { justify-content: center; } }

.cab-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.cab-timeline__item { position: relative; display: flex; gap: 12px; padding: 0 0 16px; }
.cab-timeline__item:last-child { padding-bottom: 0; }
.cab-timeline__item::before {
  content: ''; position: absolute; left: 7px; top: 16px; bottom: -2px; width: 2px; background: var(--border);
}
.cab-timeline__item:last-child::before { display: none; }
.cab-timeline__dot {
  width: 16px; height: 16px; flex: 0 0 auto; margin-top: 2px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--border-2); position: relative; z-index: 1;
}
.cab-timeline__item.is-first .cab-timeline__dot { border-color: var(--brand); background: var(--brand-soft); }
.cab-timeline__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cab-timeline__title { font-weight: 600; }
.cab-timeline__meta { font-size: 12.5px; color: var(--text-3); }

.cab-sticky-actions {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
}
@media (max-width: 899px) {
  .cab-sticky-actions {
    position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 5;
    padding: 10px; margin: 0 -6px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  }
  .cab-sticky-actions > .btn { flex: 1 1 auto; justify-content: center; }
}

.cab-note {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: var(--r-md);
  background: var(--info-soft); border: 1px solid var(--info-border); color: var(--text-2); font-size: 13.5px;
}
.cab-note > svg { flex: 0 0 auto; margin-top: 1px; color: var(--info); }
.cab-note--warning { background: var(--warning-soft); border-color: var(--warning-border); }
.cab-note--warning > svg { color: var(--warning); }
.cab-note--danger { background: var(--danger-soft); border-color: var(--danger-border); }
.cab-note--danger > svg { color: var(--danger); }
.cab-note--success { background: var(--success-soft); border-color: var(--success-border); }
.cab-note--success > svg { color: var(--success); }

.cab-muted { color: var(--text-3); }
.cab-tabular { font-variant-numeric: tabular-nums; }
