.delivery-content {
  padding-bottom: 48px;
}

.delivery-kpis {
  margin-bottom: 24px;
}

.delivery-kpis .metric-card {
  min-height: 92px;
}

.delivery-focus-card {
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.delivery-focus-card:hover,
.delivery-focus-card:focus-visible,
.delivery-focus-card.is-focus-active {
  border-color: rgba(91, 92, 226, 0.42);
  box-shadow: 0 14px 34px rgba(91, 92, 226, 0.12);
}

.delivery-focus-card:focus-visible {
  outline: 2px solid rgba(91, 92, 226, 0.34);
  outline-offset: 2px;
}

.delivery-focus-card:active {
  transform: translateY(1px);
}

.delivery-grid {
  display: grid;
  grid-template-columns: minmax(0, 650fr) minmax(280px, 340fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
  height: calc(100vh - 250px);
  min-height: 620px;
}

.delivery-card,
.sms-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px;
  overflow: hidden;
}

.delivery-large-card {
  min-height: 320px;
}

.delivery-small-card {
  min-height: 0;
  height: 100%;
  aspect-ratio: auto;
  align-self: stretch;
}

.delivery-card[data-card="all"] {
  grid-column: 1;
  grid-row: 1 / span 2;
  height: 100%;
  min-height: 0;
}

.delivery-card[data-card="building"] {
  grid-column: 2;
  grid-row: 1;
}

.delivery-card[data-card="logs"] {
  grid-column: 2;
  grid-row: 2;
}

.delivery-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 34px;
  margin-bottom: 8px;
}

.delivery-card-head h2,
.card .delivery-card-head h2 {
  position: static;
  left: auto;
  top: auto;
  flex: 0 0 auto;
  margin: 0;
}

.delivery-meta {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.delivery-card-tools {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.delivery-date-menu {
  flex: 0 0 auto;
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  color: #374151;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
}

.delivery-date-menu .lucide-icon {
  width: 14px;
  height: 14px;
}

.delivery-date-menu select {
  width: 104px;
  border: 0;
  outline: 0;
  color: #374151;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
}

.delivery-date-menu.trend-menu select {
  width: 72px;
}

.delivery-list,
.sms-list {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: none;
  overflow-y: auto;
  padding: 1px 3px 1px 1px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.delivery-list::-webkit-scrollbar,
.sms-list::-webkit-scrollbar {
  width: 7px;
}

.delivery-list::-webkit-scrollbar-thumb,
.sms-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.delivery-small-card .delivery-list,
.delivery-small-card .sms-list {
  max-height: none;
}

.delivery-card[data-card="all"] .delivery-list {
  max-height: 100%;
}

.browser-shell.is-sidebar-collapsed .delivery-card[data-card="all"] {
  min-height: 0;
}

.browser-shell.is-sidebar-collapsed .delivery-card[data-card="all"] .delivery-list {
  max-height: 100%;
}

.delivery-order {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(210px, 0.92fr) 112px;
  gap: 14px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.028);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.delivery-order:hover {
  border-color: #d8dce5;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.045);
  transform: translateY(-1px);
}

.delivery-order.has-exception {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fff 0%, #fffafa 100%);
}

.delivery-order.is-non-deliverable {
  border-color: #e2e8f0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.delivery-order.is-focused-order {
  border-color: rgba(91, 92, 226, 0.42);
  background: linear-gradient(180deg, #ffffff 0%, #f7f8ff 100%);
  box-shadow: 0 14px 32px rgba(91, 92, 226, 0.11);
}

.order-main,
.order-side {
  min-width: 0;
}

.order-title-row,
.order-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.order-no {
  color: #111827;
  font-size: 13px;
  font-weight: 560;
  line-height: 1.2;
}

.order-time {
  color: #64748b;
  font-size: 12px;
}

.status-pill {
  height: 21px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 560;
  white-space: nowrap;
}

.status-pending {
  color: #92400e;
  background: #fef3c7;
}

.status-delivered {
  color: #166534;
  background: #dcfce7;
}

.status-sent {
  color: #166534;
  background: #dcfce7;
}

.status-skipped {
  color: #475569;
  background: #e2e8f0;
}

.status-failed {
  color: #991b1b;
  background: #fee2e2;
}

.status-pending-sms {
  color: #4338ca;
  background: #e0e7ff;
}

.status-exception {
  color: #991b1b;
  background: #fee2e2;
}

.order-person {
  margin-top: 9px;
  color: #111827;
  font-size: 13px;
  font-weight: 560;
}

.order-phone,
.order-address,
.order-remark,
.order-items {
  margin-top: 5px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.45;
}

.order-address {
  color: #374151;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.order-items {
  max-height: 38px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.order-amount {
  margin-top: 12px;
  color: #111827;
  font-size: 19px;
  font-weight: 620;
}

.order-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  min-width: 112px;
}

.order-actions button {
  height: 34px;
  padding: 0 12px;
  color: #374151;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 560;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.order-actions button.primary {
  color: #fff;
  background: var(--purple);
  border-color: var(--purple);
}

.order-actions button:not(:disabled):hover {
  color: #111827;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.order-actions button.primary:not(:disabled):hover {
  color: #fff;
  background: #4f50d8;
  border-color: #4f50d8;
}

.order-actions button:not(:disabled):active {
  transform: translateY(1px);
}

.order-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.sms-row {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #374151;
  font-size: 12px;
}

.sms-row strong {
  color: #111827;
  font-size: 13px;
}

.sms-error {
  color: #991b1b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sms-row .sms-extra {
  grid-column: 1 / -1;
  color: #b91c1c;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.building-list,
.operation-log-list {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding: 1px 3px 1px 1px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.building-list::-webkit-scrollbar,
.operation-log-list::-webkit-scrollbar {
  width: 7px;
}

.building-list::-webkit-scrollbar-thumb,
.operation-log-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.building-row {
  width: 100%;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 12px;
  color: inherit;
  font: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.building-row:hover,
.building-row:focus-visible,
.building-row.is-focus-active {
  border-color: rgba(91, 92, 226, 0.42);
  background: #f8f9ff;
  box-shadow: 0 10px 24px rgba(91, 92, 226, 0.1);
}

.building-row:focus-visible {
  outline: 2px solid rgba(91, 92, 226, 0.32);
  outline-offset: 2px;
}

.building-row:active {
  transform: translateY(1px);
}

.building-rank {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--purple);
  background: #eef2ff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 650;
}

.building-main {
  min-width: 0;
}

.building-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #111827;
  font-size: 12px;
}

.building-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 620;
}

.building-title span {
  flex: 0 0 auto;
  color: #64748b;
  font-weight: 560;
}

.building-bar {
  height: 8px;
  overflow: hidden;
  background: #eef2f7;
  border-radius: 999px;
}

.building-bar i {
  display: block;
  height: 100%;
  min-width: 4px;
  background: linear-gradient(90deg, var(--purple), var(--teal));
  border-radius: inherit;
}

.operation-log-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.log-time {
  color: #64748b;
  font-size: 11px;
  font-weight: 560;
}

.log-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.log-main strong {
  color: #111827;
  font-size: 13px;
  font-weight: 620;
}

.log-main span,
.log-main em {
  overflow: hidden;
  color: #64748b;
  font-size: 11px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delivery-trend-summary {
  min-height: 48px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 12px;
}

.delivery-trend-summary strong {
  color: #111827;
  font-size: 26px;
  font-weight: 620;
  line-height: 1;
}

.delivery-trend-summary span {
  color: #64748b;
  font-size: 12px;
  font-weight: 520;
  white-space: nowrap;
}

.delivery-trend-chart {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 2px 2px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.delivery-trend-chart::-webkit-scrollbar {
  height: 7px;
}

.delivery-trend-chart::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.online-trend-bars {
  width: 100%;
  min-width: 100%;
  height: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(22px, 1fr);
  align-items: end;
  gap: 9px;
  padding: 22px 4px 24px;
  background-image: linear-gradient(to bottom, transparent 0, transparent calc(25% - 1px), #eef2f7 calc(25% - 1px), #eef2f7 25%, transparent 25%, transparent calc(50% - 1px), #eef2f7 calc(50% - 1px), #eef2f7 50%, transparent 50%, transparent calc(75% - 1px), #eef2f7 calc(75% - 1px), #eef2f7 75%, transparent 75%);
}

.online-trend-bars.is-hourly {
  width: 880px;
  grid-auto-columns: 26px;
}

.online-trend-bar {
  position: relative;
  height: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.online-trend-bar i {
  width: 100%;
  max-width: 24px;
  height: var(--height);
  min-height: 7px;
  display: block;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #5b5ce2 0%, #27c3c4 100%);
}

.online-trend-bar.is-zero i {
  background: #e5e7eb;
}

.trend-count {
  height: 14px;
  color: #64748b;
  font-size: 10px;
  font-weight: 520;
  line-height: 1;
  white-space: nowrap;
}

.trend-label {
  width: 44px;
  color: #64748b;
  font-size: 10px;
  font-weight: 520;
  text-align: center;
  white-space: nowrap;
}

.trend-empty {
  min-height: 190px;
}

.compact-list .delivery-order {
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
}

.compact-list .order-side {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.compact-list .order-actions {
  flex-direction: row;
  justify-content: flex-start;
}

.empty-state.delivery-empty {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 13px;
  border: 1px dashed #d9dee7;
  border-radius: 10px;
  background: #fbfcfe;
}

@media (max-width: 920px) {
  .delivery-grid {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }

  .delivery-card[data-card="pending"],
  .delivery-card[data-card="sms"],
  .delivery-card[data-card="all"],
  .delivery-card[data-card="building"],
  .delivery-card[data-card="logs"],
  .delivery-card[data-card="online-trend"] {
    grid-column: 1;
    grid-row: auto;
  }

  .delivery-card[data-card="all"] {
    min-height: 420px;
  }

  .delivery-small-card {
    aspect-ratio: auto;
    min-height: 300px;
  }

  .delivery-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .delivery-order {
    grid-template-columns: minmax(0, 1fr);
  }

  .order-actions {
    flex-direction: row;
    justify-content: flex-start;
    flex-wrap: wrap;
    min-width: 0;
  }

  .sms-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .delivery-card {
    padding: 16px;
  }

  .delivery-card-head {
    align-items: flex-start;
  }

  .delivery-date-menu {
    width: 100%;
    justify-content: space-between;
  }

  .delivery-date-menu select {
    width: auto;
    flex: 1 1 auto;
  }

  .order-actions button {
    flex: 1 1 120px;
  }
}
