/* Orders module — composition only. Every rule composes tokens/utilities from tokens.css, base.css, components.css, rtl.css. Zero new design primitives. */

/* ==========================================================================
   T015 — Layout Frame
   ========================================================================== */

.orders-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-block-size: 0;
}

.orders-toolbar {
  position: sticky;
  top: 64px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-neutral-0);
  border-bottom: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}

@media (max-width: 767.98px) {
  .orders-toolbar {
    top: 56px;
    padding: var(--space-2) var(--space-3);
    border-radius: 0;
    margin-inline: calc(-1 * var(--space-4));
    inline-size: calc(100% + 2 * var(--space-4));
  }
}

.orders-toolbar__search {
  flex: 1;
  min-inline-size: 200px;
  max-inline-size: 360px;
}

.orders-toolbar__controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.orders-filter-chips-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  padding-block: var(--space-2);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.orders-filter-chips-row::-webkit-scrollbar {
  display: none;
}

.orders-saved-views-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  padding-block: var(--space-1);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.orders-saved-views-row::-webkit-scrollbar {
  display: none;
}

/* ==========================================================================
   T016 — Orders Table
   ========================================================================== */

.orders-table-wrap {
  position: relative;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
  background: var(--color-neutral-0);
  overflow: hidden;
}

.orders-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.orders-table {
  inline-size: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--type-body-size);
  line-height: var(--type-body-lh);
}

.orders-table thead {
  background: var(--color-neutral-50);
  border-bottom: 1px solid var(--color-neutral-200);
}

.orders-table thead th {
  padding: var(--space-3) var(--space-4);
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-500);
  text-align: start;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-neutral-50);
}

.orders-table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-neutral-100);
  vertical-align: middle;
}

.orders-table tbody tr:last-child td {
  border-bottom: none;
}

.orders-table tbody tr:hover {
  background: var(--color-neutral-50);
}

.orders-table__row--selected {
  background: var(--color-primary-50) !important;
}

.orders-table__cell--numeric {
  font-variant-numeric: tabular-nums;
  text-align: end;
}

.orders-table__sticky-col {
  position: sticky;
  z-index: 3;
  background: var(--color-neutral-0);
}

.orders-table__sticky-col--start {
  inset-inline-start: 0;
  z-index: 4;
}

.orders-table thead .orders-table__sticky-col {
  background: var(--color-neutral-50);
}

.orders-table__sticky-col::after {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-block-end: 0;
  inset-inline-end: -6px;
  inline-size: 6px;
  background: linear-gradient(to var(--direction, right), rgba(0,0,0,0.04), transparent);
  pointer-events: none;
}

[dir="rtl"] .orders-table__sticky-col::after {
  --direction: left;
  inset-inline-end: auto;
  inset-inline-start: -6px;
}

.orders-table__order-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--color-primary-700);
  font-weight: var(--type-label-weight);
}

.orders-table__order-link:hover {
  color: var(--color-primary-600);
  text-decoration: underline;
}

.orders-table__tracking {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-variant-numeric: tabular-nums;
}

.orders-table__customer,
.orders-table__driver {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.orders-table__row-actions-col {
  inline-size: 44px;
  text-align: center;
}

/* Dense mode */
.orders-table--dense tbody td {
  padding: var(--space-2) var(--space-3);
  font-size: var(--type-small-size);
}

.orders-table--dense thead th {
  padding: var(--space-2) var(--space-3);
}

/* Comfortable mode */
.orders-table--comfortable tbody td {
  padding: var(--space-4) var(--space-5);
}

/* ==========================================================================
   T017 — Status Badge (order-badge)
   ========================================================================== */

.order-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  line-height: var(--type-small-lh);
  white-space: nowrap;
}

.order-badge .status-dot {
  inline-size: 6px;
  block-size: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.order-badge[data-tier="active"] {
  background: var(--color-info-50);
  color: var(--color-info-700);
}

.order-badge[data-tier="active"] .status-dot {
  background: var(--color-info-500);
}

.order-badge[data-tier="passive"] {
  background: var(--color-neutral-100);
  color: var(--color-neutral-600);
}

.order-badge[data-tier="passive"] .status-dot {
  background: var(--color-neutral-400);
}

.order-badge[data-tier="failure"] {
  background: var(--color-danger-50);
  color: var(--color-danger-700);
}

.order-badge[data-tier="failure"] .status-dot {
  background: var(--color-danger-500);
}

.order-badge[data-tier="terminal"] {
  background: var(--color-success-50);
  color: var(--color-success-700);
}

.order-badge[data-tier="terminal"] .status-dot {
  background: var(--color-success-500);
}

/* SLA dot */
.sla-dot {
  display: inline-block;
  inline-size: 8px;
  block-size: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sla-dot--within {
  background: var(--color-success-500);
}

.sla-dot--near {
  background: var(--color-warning-500);
}

.sla-dot--breached {
  background: var(--color-danger-500);
}

/* ==========================================================================
   T018 — Action Sidebar
   ========================================================================== */

.action-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
}

@media (min-width: 1280px) {
  .action-sidebar {
    position: sticky;
    top: 80px;
    max-block-size: calc(100dvh - 96px);
    overflow-y: auto;
  }
}

.action-sidebar__primary {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-neutral-200);
}

.action-sidebar__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.action-sidebar__group-title {
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-400);
  margin-bottom: var(--space-1);
}

.action-sidebar__action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: var(--type-body-size);
  color: var(--color-neutral-700);
  text-align: start;
  inline-size: 100%;
  text-decoration: none;
}

.action-sidebar__action:hover {
  background: var(--color-neutral-50);
}

.action-sidebar__action--primary {
  color: var(--color-primary-700);
  background: var(--color-primary-50);
}

.action-sidebar__action--primary:hover {
  background: var(--color-primary-100);
}

.action-sidebar__action--destructive {
  color: var(--color-danger-700);
}

.action-sidebar__action--destructive:hover {
  background: var(--color-danger-50);
}

.action-sidebar__action--disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Mobile bottom action bar */
.mobile-action-bar {
  display: none;
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 25;
  background: var(--color-neutral-0);
  border-top: 1px solid var(--color-neutral-200);
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  gap: var(--space-2);
  align-items: center;
  box-shadow: 0 -2px 8px rgba(16, 24, 40, 0.06);
}

@media (max-width: 767.98px) {
  .mobile-action-bar {
    display: flex;
  }
  .action-sidebar {
    display: none;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.mobile-action-bar__primary {
  flex: 1;
}

/* ==========================================================================
   T019 — Timeline Rail
   ========================================================================== */

.order-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.order-timeline__entry {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: var(--space-3);
  padding-block: var(--space-3);
  position: relative;
}

.order-timeline__entry:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-block-start: calc(var(--space-3) + 20px);
  inset-block-end: 0;
  inset-inline-start: 15px;
  inline-size: 2px;
  background: var(--color-neutral-200);
}

.order-timeline__dot {
  inline-size: 32px;
  block-size: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--color-neutral-100);
  color: var(--color-neutral-500);
  position: relative;
  z-index: 1;
}

.order-timeline__dot--status {
  background: var(--color-info-50);
  color: var(--color-info-600);
}

.order-timeline__dot--note {
  background: var(--color-neutral-50);
  color: var(--color-neutral-500);
}

.order-timeline__dot--sla {
  background: var(--color-warning-50);
  color: var(--color-warning-600);
}

.order-timeline__dot--cod {
  background: var(--color-success-50);
  color: var(--color-success-600);
}

.order-timeline__dot--accent {
  background: var(--color-primary-50);
  color: var(--color-primary-600);
  box-shadow: 0 0 0 3px var(--color-primary-100);
}

.order-timeline__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-block-size: 0;
  padding-bottom: var(--space-2);
}

.order-timeline__content h3 {
  font-size: var(--type-body-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-800);
  margin: 0;
}

.order-timeline__content p {
  margin: 0;
  font-size: var(--type-small-size);
  color: var(--color-neutral-500);
}

.order-timeline__timestamp {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   T020 — Drawer + Dialog
   ========================================================================== */

.orders-drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.orders-drawer[open] {
  display: flex;
}

.orders-drawer__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.4);
  z-index: 51;
}

.orders-drawer__panel {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: 52;
  inline-size: 420px;
  max-inline-size: 100%;
  background: var(--color-neutral-0);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(0);
  transition: transform var(--motion-base);
}

[dir="rtl"] .orders-drawer__panel {
  inset-inline-end: auto;
  inset-inline-start: 0;
}

.orders-drawer__panel > form {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-block-size: 0;
}

@media (max-width: 767.98px) {
  .orders-drawer--mobile-full .orders-drawer__panel {
    inline-size: 100%;
    inset: 0;
  }
}

.orders-dialog--assign .dialog__panel {
  inline-size: 560px;
  max-inline-size: calc(100vw - 2 * var(--space-4));
}

/* ==========================================================================
   Detail page — shared composition
   ========================================================================== */

.detail-hero {
  padding: var(--space-5);
}

.detail-hero__primary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-4);
}

@media (min-width: 1280px) {
  .detail-hero__primary {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

.detail-hero__identity {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.detail-hero__order-id {
  font-size: var(--type-h2-size);
  font-weight: var(--type-h2-weight);
  color: var(--color-neutral-900);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.detail-hero__tracking {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-variant-numeric: tabular-nums;
}

.detail-hero__status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.detail-hero__quickmeta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--type-small-size);
  color: var(--color-neutral-600);
}

.detail-section {
  padding: var(--space-5);
}

.detail-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.detail-section__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--type-h3-size);
  font-weight: var(--type-h3-weight);
  color: var(--color-neutral-800);
  margin: 0;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3) var(--space-6);
}

.kv-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kv-row dt {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-weight: var(--type-label-weight);
}

.kv-row dd {
  font-size: var(--type-body-size);
  color: var(--color-neutral-800);
  margin: 0;
}

/* ==========================================================================
   Detail page — two-column grid
   ========================================================================== */

.detail-grid {
  display: grid;
  gap: var(--space-5);
}

@media (min-width: 1280px) {
  .detail-grid {
    grid-template-columns: 1fr 300px;
  }
}

/* ==========================================================================
   Bulk actions bar
   ========================================================================== */

.bulk-bar {
  display: none;
  position: sticky;
  bottom: 0;
  z-index: 15;
  background: var(--color-neutral-0);
  border-top: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}

.bulk-bar--visible {
  display: flex;
  animation: bulk-bar-in var(--motion-base);
}

@keyframes bulk-bar-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bulk-bar__summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--type-body-size);
  font-weight: var(--type-label-weight);
}

.bulk-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.orders-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--type-small-size);
  color: var(--color-neutral-600);
  flex-wrap: wrap;
}

.orders-pagination__pages {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  padding: 0;
  margin: 0;
}

.orders-pagination__per-page {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.orders-pagination__ellipsis {
  padding: 0 var(--space-1);
  color: var(--color-neutral-400);
}

/* ==========================================================================
   Notes thread
   ========================================================================== */

.notes-thread {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.note-entry {
  display: flex;
  gap: var(--space-3);
}

.note-entry__avatar {
  flex-shrink: 0;
}

.note-entry__body {
  flex: 1;
  min-inline-size: 0;
}

.note-entry__header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-1);
}

.note-entry__text {
  margin: 0;
  font-size: var(--type-body-size);
  color: var(--color-neutral-700);
  line-height: var(--type-body-lh);
}

.notes-composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-neutral-200);
}

.notes-composer__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   Proof grid
   ========================================================================== */

/* ==========================================================================
   Proof upload zones
   ========================================================================== */

.proof-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  padding: 0 var(--space-5) var(--space-5);
}

@media (max-width: 639.98px) {
  .proof-upload-grid {
    grid-template-columns: 1fr;
  }
}

.proof-upload-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-700);
  margin-bottom: var(--space-2);
}

.proof-upload-zone {
  position: relative;
  border: 2px dashed var(--color-neutral-300);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-4) var(--space-5);
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  transition: border-color var(--motion-fast), background var(--motion-fast);
  min-block-size: 160px;
  justify-content: center;
}

.proof-upload-zone:hover,
.proof-upload-zone--drag {
  border-color: var(--color-primary-400);
  background: var(--color-primary-50);
}

.proof-upload-zone__input {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

.proof-upload-zone__icon {
  color: var(--color-neutral-300);
  transition: color var(--motion-fast);
}

.proof-upload-zone:hover .proof-upload-zone__icon,
.proof-upload-zone--drag .proof-upload-zone__icon {
  color: var(--color-primary-400);
}

.proof-upload-zone__title {
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-600);
  margin: 0;
}

.proof-upload-zone__hint {
  font-size: 11px;
  color: var(--color-neutral-400);
  margin: 0;
}

.proof-upload-zone__preview {
  display: none;
  max-inline-size: 100px;
  max-block-size: 100px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--color-neutral-200);
}

.proof-upload-zone__file-name {
  display: none;
  font-size: var(--type-small-size);
  color: var(--color-primary-700);
  font-weight: var(--type-label-weight);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-inline-size: 180px;
  margin: 0;
}

.proof-upload-zone--has-file {
  border-color: var(--color-success-400);
  background: var(--color-success-50);
}

.proof-upload-zone--has-file .proof-upload-zone__preview {
  display: block;
}

.proof-upload-zone--has-file .proof-upload-zone__file-name {
  display: block;
}

.proof-upload-zone--has-file .proof-upload-zone__icon {
  display: none;
}

.proof-upload-zone--has-file .proof-upload-zone__hint {
  display: none;
}

/* ==========================================================================
   Proof slot grid (detail view)
   ========================================================================== */

.proof-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

@media (max-width: 767.98px) {
  .proof-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 479.98px) {
  .proof-grid {
    grid-template-columns: 1fr;
  }
}

.proof-slot {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
}

.proof-slot--captured {
  border-color: var(--color-success-500);
  background: var(--color-success-50);
}

.proof-slot__thumb {
  inline-size: 48px;
  block-size: 48px;
  border-radius: var(--radius-md);
  background: var(--color-neutral-100);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-neutral-400);
  flex-shrink: 0;
}

.proof-slot__thumb--placeholder {
  background: var(--color-neutral-50);
  border: 1px dashed var(--color-neutral-300);
}

.proof-slot__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-inline-size: 0;
}

.proof-slot__label {
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-700);
}

.proof-slot__timestamp {
  font-size: var(--type-small-size);
}

.proof-slot__status {
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-success-600);
}

.proof-slot--empty .proof-slot__status {
  color: var(--color-neutral-400);
  font-weight: var(--type-body-weight);
}

/* ==========================================================================
   Attempts grid
   ========================================================================== */

.attempts-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.attempt-card {
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.attempt-card--failed {
  border-color: var(--color-danger-500);
  background: var(--color-danger-50);
}

.attempt-card--succeeded {
  border-color: var(--color-success-500);
  background: var(--color-success-50);
}

.attempt-card--deferred {
  border-color: var(--color-warning-500);
  background: var(--color-warning-50);
}

.attempt-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.attempt-card__number {
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-700);
}

/* ==========================================================================
   Create / Edit form
   ========================================================================== */

.create-form__section {
  padding: var(--space-5);
}

.create-form__section-header {
  margin-bottom: var(--space-4);
}

.create-form__section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--type-h3-size);
  font-weight: var(--type-h3-weight);
  color: var(--color-neutral-800);
  margin: 0 0 var(--space-1) 0;
}

.create-form__section-number {
  inline-size: 24px;
  block-size: 24px;
  border-radius: var(--radius-full);
  background: var(--color-primary-50);
  color: var(--color-primary-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  flex-shrink: 0;
}

.create-form__section-subtitle {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  margin: 0;
}

.create-form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}

.create-form__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.create-form__field--autofilled {
  background: var(--color-primary-50);
  border-radius: var(--radius-md);
  padding: var(--space-2);
}

.create-form__field--readonly .input {
  background: var(--color-neutral-50);
  color: var(--color-neutral-400);
  pointer-events: none;
}

.create-form__field--readonly::after {
  content: "لا يمكن التعديل في هذه الحالة";
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
}

@media (max-width: 767.98px) {
  .create-form__grid {
    grid-template-columns: 1fr;
  }
  .create-form__section {
    padding: var(--space-3);
  }
}

.create-form__field--error .input {
  border-color: var(--color-danger-500);
}

.form-field__error {
  font-size: var(--type-small-size);
  color: var(--color-danger-600);
  margin: 0;
}

.form-field__hint {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  margin: 0;
}

.dropdown-menu form {
  display: block;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   Saved views
   ========================================================================== */

.saved-view-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-neutral-200);
  background: var(--color-neutral-0);
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-700);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}

.saved-view-chip:hover {
  background: var(--color-neutral-50);
  border-color: var(--color-neutral-300);
}

.saved-view-chip.is-active {
  background: var(--color-primary-50);
  border-color: var(--color-primary-400);
  color: var(--color-primary-700);
}

.saved-view-chip__count {
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-500);
  background: var(--color-neutral-100);
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
}

.saved-view-chip__count--danger {
  background: var(--color-danger-50);
  color: var(--color-danger-700);
}

.saved-view-chip--ghost {
  border-style: dashed;
  color: var(--color-neutral-400);
}

/* ==========================================================================
   Active filters row
   ========================================================================== */

.active-filters-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) 0;
}

.active-filters-row__label {
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-500);
}

/* ==========================================================================
   Filter group (in drawer)
   ========================================================================== */

.filter-group {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-neutral-100);
}

.filter-group:last-child {
  border-bottom: none;
}

.filter-group__label {
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-700);
  margin-bottom: var(--space-3);
}

.filter-group__controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ==========================================================================
   Assign dialog driver list
   ========================================================================== */

.driver-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-block-size: 360px;
  overflow-y: auto;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
}

.driver-list__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  border-bottom: 1px solid var(--color-neutral-100);
  transition: background var(--motion-fast);
}

.driver-list__item:last-child {
  border-bottom: none;
}

.driver-list__item:hover {
  background: var(--color-neutral-50);
}

.driver-list__item[aria-selected="true"] {
  background: var(--color-primary-50);
  border-inline-start: 3px solid var(--color-primary-500);
}

.driver-list__radio {
  position: absolute;
  opacity: 0;
  inline-size: 0;
  block-size: 0;
  pointer-events: none;
}

.driver-list__avatar {
  flex-shrink: 0;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.driver-list__item[aria-selected="true"] .driver-list__avatar {
  background: var(--color-primary-100);
  color: var(--color-primary-700);
}

.driver-list__meta {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.driver-list__name {
  font-size: var(--type-body-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver-list__sub {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.driver-list__sep {
  color: var(--color-neutral-300);
}

.driver-list__check {
  flex-shrink: 0;
  color: var(--color-primary-600);
  opacity: 0;
  transition: opacity var(--motion-fast);
}

.driver-list__item[aria-selected="true"] .driver-list__check {
  opacity: 1;
}

/* ── Assign page: search input ─────────────────────────────────────────── */

.assign-search-wrap {
  position: relative;
  margin-bottom: var(--space-3);
}

.assign-search__icon {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: var(--space-3);
  transform: translateY(-50%);
  color: var(--color-neutral-400);
  pointer-events: none;
}

.assign-search__input {
  inline-size: 100%;
  padding-inline-start: calc(var(--space-3) + 16px + var(--space-2));
}

/* ── Assign page: empty state ──────────────────────────────────────────── */

.assign-empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.assign-empty-state__icon {
  inline-size: 56px;
  block-size: 56px;
  border-radius: var(--radius-full);
  background: var(--color-neutral-100);
  color: var(--color-neutral-400);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-2);
}

.assign-empty-state__title {
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-700);
  margin: 0;
}

.assign-empty-state__body {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  margin: 0;
  max-inline-size: 280px;
}

/* ==========================================================================
   Mobile order cards
   ========================================================================== */

.orders-card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: none;
  flex-direction: column;
  gap: var(--space-3);
}

@media (max-width: 767.98px) {
  .orders-card-list {
    display: flex;
  }
  .orders-table-wrap {
    display: none;
  }
}

.orders-card {
  padding: var(--space-4);
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
  background: var(--color-neutral-0);
}

.orders-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.orders-card__select {
  flex-shrink: 0;
}

.orders-card__order-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  text-decoration: none;
}

.orders-card__id {
  font-weight: var(--type-label-weight);
  color: var(--color-primary-700);
}

.orders-card__tracking {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
}

.orders-card__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin: 0;
}

.orders-card__meta dt {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
}

.orders-card__meta dd {
  margin: 0;
  font-size: var(--type-small-size);
  color: var(--color-neutral-700);
}

.orders-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-neutral-100);
}

/* ==========================================================================
   Nav sub-items
   ========================================================================== */

.nav-sub-item {
  padding-inline-start: calc(var(--space-8) + var(--space-3)) !important;
  font-size: var(--type-small-size) !important;
}

.nav-sub-item .nav-label {
  font-size: var(--type-small-size);
  color: var(--color-neutral-500);
}

.nav-sub-item:hover .nav-label {
  color: var(--color-neutral-700);
}

.nav-sub-item.is-active .nav-label {
  color: var(--color-primary-700);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--color-primary-50);
  color: var(--color-primary-700);
  font-weight: var(--type-label-weight);
  flex-shrink: 0;
}

.avatar--xs {
  inline-size: 24px;
  block-size: 24px;
  font-size: 11px;
}

.avatar--sm {
  inline-size: 32px;
  block-size: 32px;
  font-size: var(--type-small-size);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-neutral-200);
  background: var(--color-neutral-0);
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-700);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}

.chip:hover {
  background: var(--color-neutral-50);
  border-color: var(--color-neutral-300);
}

.chip--active,
.chip.is-active {
  background: var(--color-primary-50);
  border-color: var(--color-primary-400);
  color: var(--color-primary-700);
}

.chip__count {
  font-size: 11px;
  color: var(--color-neutral-500);
  background: var(--color-neutral-100);
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  margin-inline-start: var(--space-1);
}

.chip__count--danger {
  background: var(--color-danger-50);
  color: var(--color-danger-700);
}

.link-button {
  background: none;
  border: none;
  color: var(--color-primary-600);
  cursor: pointer;
  font-size: var(--type-small-size);
  text-decoration: none;
  padding: 0;
  font-weight: var(--type-label-weight);
}

.link-button:hover {
  text-decoration: underline;
  color: var(--color-primary-700);
}

.status-filter-chips {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  padding-block: var(--space-2);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.status-filter-chips::-webkit-scrollbar {
  display: none;
}

.dropdown-menu {
  position: absolute;
  inset-inline-end: 0;
  inset-block-start: 100%;
  z-index: 40;
  min-inline-size: 220px;
  background: var(--color-neutral-0);
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1) 0;
}

.dropdown-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--type-body-size);
  color: var(--color-neutral-700);
  text-decoration: none;
  cursor: pointer;
  inline-size: 100%;
  text-align: start;
  background: none;
  border: none;
  font-family: inherit;
}

.dropdown-menu__item:hover {
  background: var(--color-neutral-50);
  color: var(--color-neutral-900);
}

.dropdown-menu__item--danger {
  color: var(--color-danger-700);
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-wrap: wrap;
}

.segmented-control__option {
  padding: var(--space-2) var(--space-3);
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-600);
  background: var(--color-neutral-0);
  border: none;
  cursor: pointer;
  border-inline-end: 1px solid var(--color-neutral-200);
  white-space: nowrap;
}

.segmented-control__option:last-child {
  border-inline-end: none;
}

.segmented-control__option.is-active {
  background: var(--color-primary-50);
  color: var(--color-primary-700);
}

.segmented-control__option:hover:not(.is-active) {
  background: var(--color-neutral-50);
}

.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-neutral-200);
  background: var(--color-neutral-0);
  font-size: var(--type-small-size);
  color: var(--color-neutral-700);
  cursor: pointer;
}

.checkbox-chip:hover {
  background: var(--color-neutral-50);
}

.checkbox-chip input[type="checkbox"] {
  accent-color: var(--color-primary-600);
}

.orders-table__sticky-col--offset-1 {
  inset-inline-start: 48px;
}

.orders-table thead .orders-table__sticky-col--offset-1 {
  inset-inline-start: 48px;
  background: var(--color-neutral-50);
}

@media (max-width: 1023.98px) {
  .orders-table__sticky-col--offset-1 {
    position: static;
    z-index: auto;
  }
  .orders-table__sticky-col--offset-1::after {
    display: none;
  }
  .orders-table__sticky-col {
    position: static;
    z-index: auto;
  }
  .orders-table__sticky-col::after {
    display: none;
  }
}

.btn-block {
  inline-size: 100%;
}

.saved-views__more {
  flex-shrink: 0;
}

.adv-filters-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.adv-filters-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-top: 1px solid var(--color-neutral-200);
  gap: var(--space-3);
}

.assign-dialog-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  max-block-size: 60vh;
  overflow-y: auto;
}

.assign-dialog__reason-other {
  margin-block-start: var(--space-2);
}

/* ==========================================================================
   Detail hero — redesigned
   ========================================================================== */

.detail-hero[data-status-tier="active"] {
  border-inline-start: 4px solid var(--color-info-500);
}

.detail-hero[data-status-tier="passive"] {
  border-inline-start: 4px solid var(--color-neutral-300);
}

.detail-hero[data-status-tier="failure"] {
  border-inline-start: 4px solid var(--color-danger-500);
}

.detail-hero[data-status-tier="terminal"] {
  border-inline-start: 4px solid var(--color-success-500);
}

.detail-hero__topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.detail-hero__topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.detail-hero__sla-label {
  font-size: var(--type-small-size);
  color: var(--color-neutral-500);
}

.detail-hero__meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.detail-hero__meta-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-2);
  background: var(--color-neutral-50);
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-full);
  font-size: var(--type-small-size);
  color: var(--color-neutral-600);
}

.detail-hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-neutral-100);
}

.detail-hero__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-inline-size: 72px;
}

.detail-hero__stat--highlight .detail-hero__stat-value {
  color: var(--color-success-700);
}

.detail-hero__stat-label {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-weight: var(--type-label-weight);
}

.detail-hero__stat-value {
  font-size: var(--type-body-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-800);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Action sidebar — redesigned
   ========================================================================== */

.action-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-neutral-100);
}

.action-sidebar__title {
  font-size: var(--type-h3-size);
  font-weight: var(--type-h3-weight);
  color: var(--color-neutral-800);
  margin: 0;
}

.action-sidebar__empty {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  padding: var(--space-2) 0;
}

.action-sidebar__actions-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.action-sidebar__tools {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-neutral-100);
}

.action-sidebar__btn-danger {
  color: var(--color-danger-600);
}

.action-sidebar__soon {
  font-size: 10px;
  color: var(--color-neutral-400);
  margin-inline-start: auto;
}

/* ==========================================================================
   Assignment list
   ========================================================================== */

.assignment-list {
  list-style: none;
  padding: var(--space-3) var(--space-4);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.assignment-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-neutral-50);
  border-radius: var(--radius-md);
  font-size: var(--type-small-size);
}

.assignment-item__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-inline-size: 0;
}

.assignment-item__name {
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-700);
}

.assignment-item__time {
  color: var(--color-neutral-400);
  font-variant-numeric: tabular-nums;
}

.assignment-item__badge {
  flex-shrink: 0;
  font-size: 10px;
}

.assignment-item__badge--active {
  background: var(--color-success-50) !important;
  color: var(--color-success-700) !important;
}

/* ==========================================================================
   Section empty state
   ========================================================================== */

.detail-section__empty {
  padding: var(--space-4);
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  text-align: center;
}

/* ==========================================================================
   Timeline entries (matching template classes)
   ========================================================================== */

.timeline {
  list-style: none;
  padding: var(--space-2) var(--space-4);
  margin: 0;
  display: flex;
  flex-direction: column;
}

.timeline-entry {
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--color-neutral-100);
}

.timeline-entry:last-child {
  border-bottom: none;
}

.timeline-entry__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-1);
}

.timeline-entry__actor {
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-700);
}

.timeline-entry__time {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-variant-numeric: tabular-nums;
  margin-inline-start: auto;
}

.timeline-entry__body {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.timeline-entry__type {
  font-size: var(--type-small-size);
  color: var(--color-neutral-600);
}

.timeline-entry__detail {
  font-size: var(--type-small-size);
  color: var(--color-primary-600);
  font-weight: var(--type-label-weight);
}

/* ==========================================================================
   Notes — missing classes
   ========================================================================== */

.note-entry__author {
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-700);
}

.note-entry__time {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-variant-numeric: tabular-nums;
  margin-inline-start: auto;
}

.notes-composer__input {
  inline-size: 100%;
  resize: vertical;
  min-block-size: 80px;
}

.notes-composer__hint {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
}

/* ==========================================================================
   Create form — two-column layout
   ========================================================================== */

.create-form-layout {
  display: grid;
  gap: var(--space-5);
  align-items: start;
}

@media (min-width: 1280px) {
  .create-form-layout {
    grid-template-columns: 1fr 280px;
  }
}

.create-form-layout__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ==========================================================================
   Create form — sidebar
   ========================================================================== */

.create-form-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
}

@media (min-width: 1280px) {
  .create-form-sidebar {
    position: sticky;
    top: 80px;
    max-block-size: calc(100dvh - 96px);
    overflow-y: auto;
  }
}

@media (max-width: 1279.98px) {
  .create-form-sidebar {
    order: -1;
  }
}

.create-form-sidebar__header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-neutral-100);
}

.create-form-sidebar__icon {
  inline-size: 40px;
  block-size: 40px;
  border-radius: var(--radius-md);
  background: var(--color-primary-50);
  color: var(--color-primary-700);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.create-form-sidebar__title {
  font-size: var(--type-h3-size);
  font-weight: var(--type-h3-weight);
  color: var(--color-neutral-800);
  margin: 0 0 2px 0;
}

.create-form-sidebar__subtitle {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  margin: 0;
}

.create-form-sidebar__steps {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.create-form-sidebar__step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-neutral-600);
  font-size: var(--type-small-size);
  transition: background var(--motion-fast), color var(--motion-fast);
}

.create-form-sidebar__step:hover {
  background: var(--color-neutral-50);
  color: var(--color-neutral-800);
}

.create-form-sidebar__step-num {
  inline-size: 20px;
  block-size: 20px;
  border-radius: var(--radius-full);
  background: var(--color-primary-50);
  color: var(--color-primary-600);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: var(--type-label-weight);
  flex-shrink: 0;
}

.create-form-sidebar__step--locked {
  color: var(--color-neutral-300);
  pointer-events: none;
}

.create-form-sidebar__step--locked .create-form-sidebar__step-num {
  background: var(--color-neutral-50);
  color: var(--color-neutral-300);
}

.create-form-sidebar__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-neutral-100);
}

/* ==========================================================================
   Create form — error banner
   ========================================================================== */

.create-form-error-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-warning-50);
  border: 1px solid var(--color-warning-200);
  color: var(--color-warning-700);
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  margin-bottom: var(--space-2);
}

.create-form-error-banner__msg {
  margin: 0;
  font-size: var(--type-small-size);
}

/* ==========================================================================
   Create form — section enhancements
   ========================================================================== */

.create-form__section {
  scroll-margin-top: 80px;
}

.create-form__required {
  color: var(--color-danger-500);
  margin-inline-start: 2px;
}

.create-form__optional {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-weight: var(--type-body-weight);
  margin-inline-start: var(--space-1);
}

/* ==========================================================================
   Create form — autofill block
   ========================================================================== */

.create-form__autofill-block {
  background: var(--color-primary-50);
  border: 1px solid var(--color-primary-100);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.create-form__autofill-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--type-small-size);
  color: var(--color-primary-600);
  font-weight: var(--type-label-weight);
}

.create-form__autofill-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3) var(--space-5);
  margin: 0;
  padding: 0;
}

.create-form__autofill-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.create-form__autofill-row dt {
  font-size: var(--type-small-size);
  color: var(--color-primary-500);
  font-weight: var(--type-label-weight);
}

.create-form__autofill-row dd {
  font-size: var(--type-body-size);
  color: var(--color-neutral-700);
  margin: 0;
}

/* ==========================================================================
   Create form — input helpers
   ========================================================================== */

.create-form__input-with-unit {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.create-form__input-with-unit .form-control {
  flex: 1;
}

.create-form__unit {
  font-size: var(--type-small-size);
  color: var(--color-neutral-500);
  white-space: nowrap;
  flex-shrink: 0;
}

.create-form__dims-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.create-form__dims-row .form-control {
  flex: 1;
  min-inline-size: 0;
}

.create-form__dims-sep,
.create-form__coords-sep {
  color: var(--color-neutral-400);
  flex-shrink: 0;
  font-size: var(--type-small-size);
}

.create-form__coords-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.create-form__coords-row .form-control {
  flex: 1;
  min-inline-size: 0;
}

.create-form__locked-field {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--type-body-size);
  color: var(--color-neutral-500);
  padding: var(--space-2) 0;
}

/* ==========================================================================
   Create form — toggle switch
   ========================================================================== */

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-2) 0;
  user-select: none;
}

.toggle-field__input {
  position: absolute;
  opacity: 0;
  inline-size: 0;
  block-size: 0;
}

.toggle-field__track {
  position: relative;
  inline-size: 36px;
  block-size: 20px;
  background: var(--color-neutral-300);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  transition: background var(--motion-fast);
}

.toggle-field__thumb {
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  inline-size: 16px;
  block-size: 16px;
  border-radius: var(--radius-full);
  background: var(--color-neutral-0);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .15);
  transition: inset-inline-start var(--motion-fast);
}

.toggle-field__input:checked + .toggle-field__track {
  background: var(--color-warning-400);
}

.toggle-field__input:checked + .toggle-field__track .toggle-field__thumb {
  inset-inline-start: calc(100% - 18px);
}

.toggle-field__label {
  font-size: var(--type-body-size);
  color: var(--color-neutral-700);
}

/* ==========================================================================
   Create form — locked section overlay
   ========================================================================== */

.create-form__section--locked {
  position: relative;
  overflow: hidden;
}

.create-form__section--locked > *:not(.create-form__section-lock) {
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
}

.create-form__section-lock {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(2px);
  color: var(--color-neutral-500);
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  z-index: 1;
  border-radius: inherit;
}

/* ==========================================================================
   Create form — mobile sticky footer
   ========================================================================== */

.create-form-mobile-footer {
  display: none;
}

@media (max-width: 1279.98px) {
  .create-form-mobile-footer {
    display: flex;
    position: sticky;
    bottom: 0;
    z-index: 15;
    background: var(--color-neutral-0);
    border-top: 1px solid var(--color-neutral-200);
    padding: var(--space-3) var(--space-4);
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    gap: var(--space-2);
    align-items: center;
    box-shadow: 0 -2px 8px rgba(16, 24, 40, .06);
  }

  .create-form-mobile-footer > .btn-primary {
    flex: 1;
  }

  .create-form-sidebar__steps {
    display: none;
  }
}

/* ==========================================================================
   Confirm modal
   ========================================================================== */

#confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

#confirm-modal[hidden] {
  display: none;
}

.confirm-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  backdrop-filter: blur(2px);
}

.confirm-modal__panel {
  position: relative;
  z-index: 1;
  inline-size: 100%;
  max-inline-size: 420px;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
  animation: modal-in var(--motion-base);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0);    }
}

.confirm-modal__icon {
  inline-size: 56px;
  block-size: 56px;
  border-radius: var(--radius-full);
  background: var(--color-warning-50);
  color: var(--color-warning-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.confirm-modal__title {
  font-size: var(--type-h3-size);
  font-weight: var(--type-h3-weight);
  color: var(--color-neutral-900);
  margin: 0;
}

.confirm-modal__body {
  font-size: var(--type-body-size);
  color: var(--color-neutral-600);
  line-height: var(--type-body-lh);
  margin: 0;
}

.confirm-modal__actions {
  display: flex;
  flex-direction: row-reverse;
  gap: var(--space-2);
  inline-size: 100%;
}

.confirm-modal__actions .btn {
  flex: 1;
}

.btn-danger {
  background: var(--color-danger-600);
  color: var(--color-neutral-0);
  border: 1px solid var(--color-danger-600);
}

.btn-danger:hover {
  background: var(--color-danger-700);
  border-color: var(--color-danger-700);
}

/* ==========================================================================
   Action form layout (attempt / proof pages)
   ========================================================================== */

.action-form-layout {
  display: grid;
  gap: var(--space-5);
  align-items: start;
}

@media (min-width: 1280px) {
  .action-form-layout {
    grid-template-columns: 1fr 280px;
  }
}

.action-form-layout__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ==========================================================================
   Action form — sidebar
   ========================================================================== */

.action-form-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
}

@media (min-width: 1280px) {
  .action-form-sidebar {
    position: sticky;
    top: 80px;
    max-block-size: calc(100dvh - 96px);
    overflow-y: auto;
  }
}

@media (max-width: 1279.98px) {
  .action-form-sidebar {
    order: -1;
  }
}

.action-form-sidebar__order {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-neutral-100);
}

.action-form-sidebar__order-icon {
  inline-size: 40px;
  block-size: 40px;
  border-radius: var(--radius-md);
  background: var(--color-primary-50);
  color: var(--color-primary-700);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-form-sidebar__order-ref {
  font-size: var(--type-body-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-800);
  margin: 0 0 2px 0;
  font-variant-numeric: tabular-nums;
}

.action-form-sidebar__order-meta {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  margin: 0;
}

.action-form-sidebar__kv {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
}

.action-form-sidebar__kv-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.action-form-sidebar__kv-row dt {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-weight: var(--type-label-weight);
}

.action-form-sidebar__kv-row dd {
  font-size: var(--type-body-size);
  color: var(--color-neutral-700);
  margin: 0;
}

.action-form-sidebar__notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-primary-50);
  border-radius: var(--radius-md);
  font-size: var(--type-small-size);
  color: var(--color-primary-700);
  line-height: 1.5;
}

.action-form-sidebar__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-neutral-100);
}

/* ==========================================================================
   Action form — blocked / ineligible state
   ========================================================================== */

.action-form-blocked {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-6);
  text-align: center;
}

.action-form-blocked__icon {
  inline-size: 64px;
  block-size: 64px;
  border-radius: var(--radius-full);
  background: var(--color-danger-50);
  color: var(--color-danger-500);
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-form-blocked__title {
  font-size: var(--type-h2-size);
  font-weight: var(--type-h2-weight);
  color: var(--color-neutral-800);
  margin: 0;
}

.action-form-blocked__body {
  font-size: var(--type-body-size);
  color: var(--color-neutral-600);
  max-inline-size: 480px;
  line-height: var(--type-body-lh);
  margin: 0;
}

/* ==========================================================================
   Attempt result cards
   ========================================================================== */

.attempt-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.attempt-result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  border: 2px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
  background: var(--color-neutral-0);
  cursor: pointer;
  transition: border-color var(--motion-fast), background var(--motion-fast);
  text-align: center;
  user-select: none;
}

.attempt-result-card:hover {
  border-color: var(--color-primary-300);
  background: var(--color-primary-50);
}

.attempt-result-card__input {
  position: absolute;
  opacity: 0;
  inline-size: 0;
  block-size: 0;
}

.attempt-result-card__icon {
  color: var(--color-neutral-400);
  transition: color var(--motion-fast);
}

.attempt-result-card__label {
  font-size: var(--type-small-size);
  font-weight: var(--type-label-weight);
  color: var(--color-neutral-600);
  transition: color var(--motion-fast);
}

.attempt-result-card--selected {
  border-color: var(--color-primary-500);
  background: var(--color-primary-50);
}

.attempt-result-card--selected .attempt-result-card__icon {
  color: var(--color-primary-600);
}

.attempt-result-card--selected .attempt-result-card__label {
  color: var(--color-primary-700);
}

/* Per-result colour variants when selected */
.attempt-result-card:has([value="succeeded"]:checked),
.attempt-result-card--selected:has([value="succeeded"]) {
  border-color: var(--color-success-500);
  background: var(--color-success-50);
}

.attempt-result-card:has([value="succeeded"]:checked) .attempt-result-card__icon,
.attempt-result-card--selected:has([value="succeeded"]) .attempt-result-card__icon {
  color: var(--color-success-600);
}

.attempt-result-card:has([value="succeeded"]:checked) .attempt-result-card__label,
.attempt-result-card--selected:has([value="succeeded"]) .attempt-result-card__label {
  color: var(--color-success-700);
}

.attempt-result-card:has([value="failed"]:checked),
.attempt-result-card--selected:has([value="failed"]) {
  border-color: var(--color-danger-500);
  background: var(--color-danger-50);
}

.attempt-result-card:has([value="failed"]:checked) .attempt-result-card__icon,
.attempt-result-card--selected:has([value="failed"]) .attempt-result-card__icon {
  color: var(--color-danger-600);
}

.attempt-result-card:has([value="failed"]:checked) .attempt-result-card__label,
.attempt-result-card--selected:has([value="failed"]) .attempt-result-card__label {
  color: var(--color-danger-700);
}

.attempt-result-card:has([value="rescheduled"]:checked),
.attempt-result-card--selected:has([value="rescheduled"]) {
  border-color: var(--color-warning-500);
  background: var(--color-warning-50);
}

.attempt-result-card:has([value="rescheduled"]:checked) .attempt-result-card__icon,
.attempt-result-card--selected:has([value="rescheduled"]) .attempt-result-card__icon {
  color: var(--color-warning-600);
}

.attempt-result-card:has([value="rescheduled"]:checked) .attempt-result-card__label,
.attempt-result-card--selected:has([value="rescheduled"]) .attempt-result-card__label {
  color: var(--color-warning-700);
}

/* ==========================================================================
   Timeline — redesigned vertical connector layout
   ========================================================================== */

.tl {
  list-style: none;
  padding: var(--space-4) var(--space-5);
  margin: 0;
  display: flex;
  flex-direction: column;
}

.tl-item {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.tl-item__dot-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.tl-item__dot {
  inline-size: 28px;
  block-size: 28px;
  border-radius: var(--radius-full);
  background: var(--color-neutral-100);
  color: var(--color-neutral-500);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--color-neutral-0, #fff);
  box-shadow: 0 0 0 1px var(--color-neutral-200);
}

.tl-item__connector {
  flex: 1;
  inline-size: 2px;
  min-block-size: var(--space-4);
  background: var(--color-neutral-200);
  margin-block: 2px;
}

/* event-type dot colors */
.tl-item--created .tl-item__dot {
  background: var(--color-success-50);
  color: var(--color-success-600);
  box-shadow: 0 0 0 1px var(--color-success-200);
}
.tl-item--status_changed .tl-item__dot {
  background: var(--color-primary-50);
  color: var(--color-primary-600);
  box-shadow: 0 0 0 1px var(--color-primary-200);
}
.tl-item--assigned .tl-item__dot {
  background: var(--color-primary-50);
  color: var(--color-primary-600);
  box-shadow: 0 0 0 1px var(--color-primary-200);
}
.tl-item--attempt_registered .tl-item__dot {
  background: var(--color-warning-50);
  color: var(--color-warning-600);
  box-shadow: 0 0 0 1px var(--color-warning-200);
}
.tl-item--proof_attached .tl-item__dot {
  background: var(--color-success-50);
  color: var(--color-success-600);
  box-shadow: 0 0 0 1px var(--color-success-200);
}

.tl-item__content {
  flex: 1;
  min-inline-size: 0;
  padding-block-end: var(--space-4);
}

.tl-item:last-child .tl-item__content {
  padding-block-end: 0;
}

.tl-item__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-1);
  padding-block-start: var(--space-1);
}

.tl-item__type {
  font-size: var(--type-small-size);
  font-weight: 600;
  color: var(--color-neutral-800);
  background: var(--color-neutral-100);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}

.tl-item--created .tl-item__type {
  background: var(--color-success-50);
  color: var(--color-success-700);
}
.tl-item--status_changed .tl-item__type,
.tl-item--assigned .tl-item__type {
  background: var(--color-primary-50);
  color: var(--color-primary-700);
}
.tl-item--attempt_registered .tl-item__type {
  background: var(--color-warning-50);
  color: var(--color-warning-700);
}
.tl-item--proof_attached .tl-item__type {
  background: var(--color-success-50);
  color: var(--color-success-700);
}

.tl-item__arrow {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
}

.tl-item__detail {
  font-size: var(--type-small-size);
  color: var(--color-primary-600);
  font-weight: 500;
}

.tl-item__detail--preview {
  color: var(--color-neutral-500);
  font-weight: 400;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-inline-size: 200px;
}

.tl-item__time {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-variant-numeric: tabular-nums;
  margin-inline-start: auto;
  white-space: nowrap;
}

.tl-item__actor {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.tl-item__actor-name {
  font-size: var(--type-small-size);
  color: var(--color-neutral-500);
}

.tl-item__actor-name--system {
  color: var(--color-neutral-400);
  font-style: italic;
}

/* ==========================================================================
   Notes — redesigned composer + bubble thread
   ========================================================================== */

.note-composer {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--color-neutral-50);
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.note-composer__input-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.note-composer__avatar {
  flex-shrink: 0;
  margin-block-start: 2px;
  background: var(--color-neutral-100);
  color: var(--color-neutral-500);
}

.note-composer__textarea {
  flex: 1;
  resize: vertical;
  min-block-size: 72px;
}

.note-composer__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline-start: calc(32px + var(--space-3));
}

.note-composer__char-count {
  font-size: var(--type-small-size);
  color: var(--color-neutral-400);
  font-variant-numeric: tabular-nums;
}

/* override old notes-thread/note-entry rules with improved versions */
.notes-thread {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.note-entry {
  display: flex;
  gap: var(--space-3);
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--color-neutral-100);
}

.note-entry:last-child {
  border-bottom: none;
  padding-block-end: 0;
}

.note-entry .avatar {
  flex-shrink: 0;
  margin-block-start: 2px;
}

.note-entry__bubble {
  flex: 1;
  min-inline-size: 0;
  background: var(--color-neutral-50);
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
  border-start-start-radius: 0;
  padding: var(--space-3) var(--space-4);
}

.note-entry__header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.note-entry__text {
  margin: 0;
  font-size: var(--type-body-size);
  color: var(--color-neutral-700);
  line-height: var(--type-body-lh);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
