/* admin_postal 组（admin/postal-items / admin/postal-item-edit / admin/postal-orders / admin/postal-order）專屬樣式。
 * 全部用 app.css 的 token；class 用 apt- 前綴。兼容 iOS Safari 14：不用 inset / flex gap / aspect-ratio / :is() / dvh / color-mix。
 */

/* ---------------------------------------------------------------- 篩選：segmented 間距 + 狀態 chips + 篩選提示行 */
.apt-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--sp-2);
}
.apt-top .btn { min-height: var(--tap); }
.apt-kind {
  margin-bottom: var(--sp-3);
}
.apt-filters { margin-bottom: var(--sp-3); }
.apt-filters .seg + .seg { margin-top: var(--sp-3); }

.apt-chips {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 var(--sp-3);
}
.apt-chip {
  min-height: var(--tap);
  margin: 0 var(--sp-2) var(--sp-2) 0;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--fill);
  color: var(--label-2);
  font-size: 13px;
}
.apt-chip.is-selected { background: var(--tint-soft); color: var(--tint); font-weight: 600; }
.apt-chip:active { opacity: 0.7; }

.apt-hint-row {
  display: flex;
  align-items: center;
  margin: 0 0 var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--tint-soft);
}
.apt-hint-row__text {
  flex: 1 1 auto;
  min-width: 0;
  margin-right: var(--sp-2);
  color: var(--tint);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.apt-hint-row .btn { flex: 0 0 auto; min-height: 36px; padding: 0 var(--sp-3); }

/* ---------------------------------------------------------------- 卡片：郵品 / 訂單 */
.apt-card {
  display: block;
  margin-bottom: var(--sp-3);
}
.apt-card.is-pressable { cursor: pointer; }
.apt-card__top {
  display: flex;
  align-items: flex-start;
}
.apt-thumb {
  position: relative;
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  margin-right: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--fill);
  overflow: hidden;
}
.apt-thumb--sm { flex: 0 0 44px; width: 44px; height: 44px; margin-right: var(--sp-2); }
.apt-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.apt-thumb__ph {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--fill);
  color: var(--label-3);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}
.apt-thumb.is-broken img { display: none; }

.apt-card__main {
  flex: 1 1 auto;
  min-width: 0;
}
.apt-card__name {
  margin: 0 0 2px;
  color: var(--label);
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.apt-card__sub {
  margin: 0 0 2px;
  color: var(--label-2);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.apt-card__price {
  color: var(--label);
  font-size: 15px;
  font-weight: 600;
}
.apt-card__tags {
  display: flex;
  flex-wrap: wrap;
  margin: var(--sp-2) 0 0;
}
.apt-card__tags .tag { margin: 0 var(--sp-2) var(--sp-2) 0; }
.apt-card__line {
  margin: var(--sp-1) 0 0;
  color: var(--label-2);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.apt-card__line strong { color: var(--label); font-weight: 600; }
.apt-card__act {
  display: flex;
  margin-top: var(--sp-3);
}
.apt-card__act .btn { flex: 1 1 auto; min-height: var(--tap); margin-right: var(--sp-3); }
.apt-card__act .btn:last-child { margin-right: 0; }
.apt-card__act .btn + .btn { flex: 0 0 auto; }

.apt-list-more { margin-top: var(--sp-3); }

/* ---------------------------------------------------------------- 編輯頁：摘要 / 圖片 / 表單 */
.apt-summary {
  margin-bottom: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--fill);
}
.apt-summary__line {
  margin: 0;
  color: var(--label-2);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.apt-summary__line + .apt-summary__line { margin-top: 2px; }
.apt-summary .btn { margin-top: var(--sp-2); min-height: var(--tap); }

.apt-imgbox {
  margin-bottom: var(--sp-3);
}
.apt-imgbox__row {
  display: flex;
  align-items: flex-start;
}
.apt-imgbox__preview {
  position: relative;
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  margin-right: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--fill);
  overflow: hidden;
}
.apt-imgbox__preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.apt-imgbox__ph {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  color: var(--label-3);
  font-size: 12px;
  line-height: 88px;
  text-align: center;
}
.apt-imgbox__acts {
  flex: 1 1 auto;
  min-width: 0;
}
.apt-imgbox__acts .btn { display: block; width: 100%; min-height: var(--tap); }
.apt-imgbox__acts .btn + .btn { margin-top: var(--sp-2); }
.apt-imgbox.is-broken img { display: none; }

.apt-readonly {
  display: block;
  margin-bottom: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--fill);
  color: var(--label-2);
  font-size: 13px;
}
.apt-delta { display: flex; }
.apt-delta__val {
  flex: 0 0 auto;
  min-width: 0;
  margin-left: var(--sp-3);
  color: var(--label-2);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------------------------------------------------------------- 訂單詳情：分區 / 時間軸 / 警示條 */
.apt-sec {
  margin-bottom: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
.apt-sec__title {
  margin: 0 0 var(--sp-2);
  color: var(--label-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.apt-kv {
  display: flex;
  align-items: flex-start;
  padding: var(--sp-1) 0;
}
.apt-kv__k {
  flex: 0 0 84px;
  color: var(--label-2);
  font-size: 13px;
}
.apt-kv__v {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--label);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.apt-kv__v a { color: var(--tint); }
.apt-card__name a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--tint);
}

.apt-tl { margin: 0; padding: 0; list-style: none; }
.apt-tl__item {
  position: relative;
  padding: 0 0 var(--sp-3) var(--sp-4);
  border-left: 2px solid var(--separator);
}
.apt-tl__item:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}
.apt-tl__dot {
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--label-3);
}
.apt-tl__item.is-done .apt-tl__dot { background: var(--green); }
.apt-tl__item.is-warn .apt-tl__dot { background: var(--orange); }
.apt-tl__item.is-bad .apt-tl__dot { background: var(--red); }
.apt-tl__head {
  display: flex;
  align-items: baseline;
}
.apt-tl__label {
  margin-right: var(--sp-2);
  color: var(--label);
  font-size: 14px;
  font-weight: 600;
}
.apt-tl__time {
  color: var(--label-2);
  font-size: 12px;
}
.apt-tl__extra {
  margin: 2px 0 0;
  color: var(--label-2);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.apt-warn {
  margin-bottom: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: var(--red-ink);
  font-size: 13px;
  line-height: 1.5;
}
.apt-warn--soft {
  background: var(--orange-soft);
  color: var(--orange-ink);
}

.apt-sheet-actions {
  display: flex;
}
.apt-sheet-actions .btn { flex: 1 1 0; min-width: 0; }
.apt-sheet-actions .btn + .btn { margin-left: var(--sp-3); }

/* 固定底欄留位：用 margin-bottom 而不是 padding-bottom。
 * assertActionBarClear 會取「所有非 fixed 元素的下沿」，含 padding 的容器會伸到底欄下面而被誤判；
 * margin 不進 border box，容器下沿正好落在底欄上沿之上。 */
.apt-foot {
  margin-bottom: calc(72px + var(--safe-bottom));
}

/* ---------------------------------------------------------------- 深色模式：只調對比度，不另寫色板 */
@media (prefers-color-scheme: dark) {
  .apt-thumb__ph,
  .apt-imgbox__ph { color: var(--label-3); }
}
