:root {
  --navy: #12305F;
  --orange: #F26B21;
  --bg: #F5F3EC;
  --card: #FFFFFF;
  --line: #E7E2D3;
  --ink: #16233F;
  --muted: #6B6656;
  --green: #1F6F63;
  --red: #B3261E;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  padding-bottom: 32px;
}

.topbar {
  background: var(--navy);
  padding: 16px 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Кенгуру идёт отдельной картинкой без фона, надпись — настоящим текстом:
   так логотип остаётся чётким на любом экране и не выглядит вклейкой */
.mascot {
  height: 54px;
  width: auto;
  flex-shrink: 0;
  /* лёгкий наклон, будто в прыжке */
  transform: rotate(-3deg);
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 0.92;
  letter-spacing: 0.04em;
  font-weight: 800;
  font-size: 21px;
  flex-shrink: 0;
}

.brand-roky { color: var(--orange); }
.brand-cargo { color: #F5F3EC; }

.greeting {
  color: rgba(245, 243, 236, 0.7);
  font-size: 13px;
  font-weight: 500;
  margin-left: auto;
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 10;
}

.tab {
  flex: 0 0 auto;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  background: rgba(245, 243, 236, 0.12);
  color: #F5F3EC;
  cursor: pointer;
  font-family: inherit;
}

.tab.is-active { background: var(--orange); color: #fff; }

main { padding: 14px 12px; }

.section-title { font-size: 16px; margin: 18px 4px 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(22, 35, 63, 0.05);
}

.card h2, .card h3 { margin: 0 0 10px; font-size: 15px; }
.card.warn { background: #FFF8EC; border-color: #F0DCB8; }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 500;
}

label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--ink); }
label.checkbox input { width: auto; margin: 0; }

input, select, textarea {
  width: 100%;
  min-width: 0;
  margin-top: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  /* Ровно 16px: при меньшем шрифте iOS приближает экран на фокусе
     и обратно не отдаляет. */
  font-size: 16px;
  font-family: inherit;
}

textarea { resize: vertical; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.btn-primary {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 13px;
  background: var(--orange);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-ghost {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px;
  background: #fff;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-small {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
}

.calc-out {
  margin-top: 8px;
  padding: 10px;
  background: #EFF4F1;
  border-radius: 10px;
  font-weight: 600;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.parcel { position: relative; }

.parcel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.parcel-no { font-weight: 700; font-size: 15px; letter-spacing: 0.02em; }
.parcel-date { font-size: 12.5px; color: var(--muted); }

.badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.kv { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13.5px; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-variant-numeric: tabular-nums; }

.price { font-weight: 700; color: var(--green); font-size: 16px; }

.divider { border-top: 1px dashed var(--line); margin: 10px 0; }

.copy-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid #F0EDE2;
}

/* Текст адреса можно выделить пальцем и скопировать частями */
.copy-field .cf-value {
  user-select: text;
  -webkit-user-select: text;
}

.copy-field:last-child { border-bottom: none; }
.copy-field .cf-label { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.copy-field .cf-value { font-size: 14.5px; word-break: break-all; }

.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; font-size: 14px; }
.loading {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  font-size: 14px;
}

.loading-mascot {
  height: 68px;
  width: auto;
  opacity: 0.35;
  margin-bottom: 14px;
  animation: hop 1.4s ease-in-out infinite;
}

@keyframes hop {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-9px) rotate(-6deg); }
}

@media (prefers-reduced-motion: reduce) {
  .loading-mascot { animation: none; }
}

.form-msg { margin-top: 10px; font-size: 13.5px; }
.form-msg.ok { color: var(--green); }
.form-msg.err { color: var(--red); }

ul { margin: 6px 0; padding-left: 20px; font-size: 13.5px; line-height: 1.7; }

.addr-item { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.addr-actions { display: flex; gap: 6px; flex-shrink: 0; }
.default-tag {
  font-size: 11px;
  background: #EAF1F8;
  color: #3B6EA5;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}

[hidden] { display: none !important; }

.intro { padding: 0; }

.intro summary {
  padding: 13px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.intro summary::-webkit-details-marker { display: none; }

.intro summary::after {
  content: '▾';
  color: var(--muted);
  font-size: 13px;
  transition: transform 0.15s;
}

.intro[open] summary::after { transform: rotate(180deg); }

.intro .steps {
  margin: 0;
  padding: 0 14px 14px 34px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.intro .steps li { margin-bottom: 2px; }

.item-track { font-weight: 600; font-size: 14px; word-break: break-all; }
.item-desc { font-size: 13px; margin-top: 2px; }
.item-comment {
  margin-top: 8px;
  padding: 8px 10px;
  background: #FBF7EC;
  border-radius: 8px;
  font-size: 12.5px;
  color: #6B5A32;
}

.item-select {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0;
}

.selection-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -4px 16px rgba(22, 35, 63, 0.1);
  z-index: 30;
}

.selection-bar span { font-size: 13.5px; font-weight: 600; flex-shrink: 0; }
.selection-bar .btn-primary { margin: 0; }

.sheet-bg {
  position: fixed;
  inset: 0;
  background: rgba(22, 35, 63, 0.45);
  z-index: 60;
  display: flex;
  align-items: flex-end;
}

.sheet {
  background: #FBFAF6;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px 24px;
}

.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { font-size: 18px; margin: 0; font-weight: 700; }

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}

.upload-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.upload-row input[type=file] { font-size: 12.5px; }

.hint { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); font-weight: 400; }

.calc-note {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.45;
}

.discount { color: var(--green); font-weight: 600; }

.addr-preview {
  margin: -4px 0 12px;
  padding: 10px 12px;
  background: #EFF4F1;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #33574F;
}

.addr-preview:empty { display: none; }

.inline-addr {
  margin-top: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.inline-addr h3 { margin: 0 0 12px; font-size: 15px; }
.inline-addr .row { align-items: flex-end; }

.tg-link {
  color: #3B6EA5;
  font-weight: 600;
  text-decoration: none;
}

.tg-link:hover, .tg-link:focus-visible { text-decoration: underline; }

.review-link {
  display: block;
  margin-top: 10px;
  padding: 11px;
  text-align: center;
  background: #FFF6E8;
  border: 1px solid #F0DCB8;
  border-radius: 10px;
  color: #8A5A00;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}

.review-link:hover, .review-link:focus-visible { background: #FDEFD8; }

/* Выделение текста: по умолчанию оно бледное и на бежевом фоне
   почти не видно — красим в фирменный оранжевый */
::selection {
  background: #F26B21;
  color: #fff;
}

::-moz-selection {
  background: #F26B21;
  color: #fff;
}

.refresh-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: none;
  background: none;
  color: rgba(245, 243, 236, 0.75);
  cursor: pointer;
}

.refresh-btn svg { width: 21px; height: 21px; display: block; }
.refresh-btn:active { color: #F5F3EC; }

.refresh-btn.spinning { animation: spin 0.6s linear; }

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

@media (prefers-reduced-motion: reduce) {
  .refresh-btn.spinning { animation: none; opacity: 0.5; }
}

/* Выделение и внутри полей ввода — там свои правила */
input::selection, textarea::selection {
  background: #F26B21;
  color: #fff;
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.photos-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
  background: #EFEDE4;
}
