.me-dashboard {
  --me-header: #fc7922;
  --me-green: #3d8b40;
  --me-red: #d9534f;
  --me-action-blue: #4a90e2;
  --me-table-header-top: #5c7eb8;
  --me-table-header-mid: #4a628a;
  --me-table-header-bottom: #3d5280;
  --me-toolbar-bg: #f3f4f6;
  --me-border: #e2e5eb;
  --me-radius: 6px;
  --me-table-max-height: min(52vh, 520px);
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #eef1f5;
  min-height: 100%;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  margin-top: 30px;
}

.me-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--me-header);
  padding: 12px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  min-height: 58px;
  box-sizing: border-box;
}

.me-header-left,
.me-header-right {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
}

.me-header-left {
  justify-content: flex-start;
}

.me-header-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.me-header-logo {
  height: 48px;
  width: auto;
  max-width: 168px;
  object-fit: contain;
  object-position: center;
  display: block;
}

.me-header-right {
  justify-content: flex-end;
  gap: 14px;
}

.me-header-clock {
  font-size: 0.9135rem;
  font-weight: 600;
  color: rgb(255, 255, 255);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.3;
  white-space: nowrap;
}

.me-header-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-width: min(480px, calc(100% - 420px));
  font-size: clamp(1rem, 2.5vw, 1.6rem);
  font-weight: 600;
  color: #fff;
  text-align: center;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.me-header-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.me-header-back:hover {
  background: rgba(255, 255, 255, 0.3);
}

.me-header-back:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.me-header-back-icon {
  font-size: 20px !important;
}

.me-body {
  padding: 2px 8px 8px;
  width: 100%;
  max-width: none;
  margin: 0;
  box-sizing: border-box;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.me-toolbar {
  --me-control-height: 40px;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 16px;
  background: var(--me-toolbar-bg);
  padding: 12px 16px;
  border-radius: var(--me-radius);
  border: 1px solid var(--me-border);
  /* margin-bottom: 2px; */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  min-width: 0;
}

.me-filters {
  display: flex;
  flex: 1 1 0;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 12px;
  min-width: 0;
}

.me-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* Region & Controlling: equal share */
.me-field--region,
.me-field--controlling {
  flex: 2 1 0;
}

/* Branch: wider than region/controlling */
.me-field--branch {
  flex: 3 1 0;
}

/* Customer: widest */
.me-field--customer {
  flex: 5 1 0;
}

.me-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.me-select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  height: var(--me-control-height, 40px);
  min-height: var(--me-control-height, 40px);
  padding: 0 42px 0 12px;
  font-size: 0.875rem;
  line-height: normal;
  border: 1px solid #cfd4dc;
  border-radius: var(--me-radius);
  background-color: #fff;
  color: #111;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='%23475569'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 20px 20px;
  /* Inset from right edge — larger value moves chevron left */
  background-position: right 12px center;
}

.me-select::-ms-expand {
  display: none;
}

.me-select:focus {
  outline: 2px solid rgba(74, 144, 226, 0.45);
  outline-offset: 1px;
}

.me-autocomplete {
  width: 100%;
}

.me-autocomplete .MuiFormControl-root {
  width: 100%;
}

.me-autocomplete .MuiOutlinedInput-root {
  height: var(--me-control-height, 40px);
  min-height: var(--me-control-height, 40px);
  box-sizing: border-box;
  background: #fff;
}

.me-autocomplete .MuiOutlinedInput-input {
  padding: 0 12px !important;
  font-size: 0.7rem;
  line-height: var(--me-control-height, 40px);
}

.me-autocomplete .MuiOutlinedInput-notchedOutline {
  border-color: #cfd4dc;
}

.me-autocomplete .MuiAutocomplete-endAdornment {
  right: 10px !important;
}

.me-autocomplete .MuiAutocomplete-popupIndicator {
  color: #475569;
}

.me-autocomplete .MuiAutocomplete-clearIndicator {
  color: #6b7280;
}

.me-toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: flex-end;
}

.me-toolbar-actions .me-btn {
  flex: 0 0 auto;
  box-sizing: border-box;
  height: var(--me-control-height, 40px);
  min-height: var(--me-control-height, 40px);
  padding: 0 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  gap: 4px;
  white-space: nowrap;
  line-height: 1;
  align-items: center;
  justify-content: center;
}

.me-toolbar-actions .me-btn-icon {
  font-size: 16px !important;
  width: 16px !important;
  height: 16px !important;
}

@media (max-width: 1024px) {
  .me-toolbar {
    flex-wrap: wrap;
  }

  .me-filters {
    flex: 1 1 100%;
  }

  .me-toolbar-actions {
    flex: 1 1 100%;
    justify-content: flex-end;
  }
}

.me-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  border-radius: var(--me-radius);
  cursor: pointer;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.me-btn-icon {
  opacity: 0.95;
}

.me-btn--process {
  background: var(--me-green);
}

.me-btn--process:hover {
  filter: brightness(1.06);
}

.me-btn--clear {
  background: var(--me-red);
}

.me-btn--clear:hover {
  filter: brightness(1.06);
}

.me-cards {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
}

.me-card {
  position: relative;
  background: #fff;
  border-radius: var(--me-radius);
  border: 1px solid var(--me-border);
  padding: 10px 10px 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  flex: 1 1 0;
  min-width: 0;
}

.me-card--clickable {
  cursor: pointer;
}

.me-card--clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.me-card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.me-card-icon-wrap {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.me-card-icon {
  font-size: 22px !important;
}

.me-card--blue .me-card-icon-wrap {
  background: rgba(74, 98, 138, 0.12);
  color: #4a628a;
}

.me-card--lightblue .me-card-icon-wrap {
  background: rgba(74, 144, 226, 0.15);
  color: #3b7ccc;
}

.me-card--teal .me-card-icon-wrap {
  background: rgba(0, 150, 136, 0.12);
  color: #00897b;
}

.me-card--green .me-card-icon-wrap {
  background: rgba(61, 139, 64, 0.14);
  color: #2e7d32;
}

.me-card--orange .me-card-icon-wrap {
  background: rgba(245, 124, 0, 0.14);
  color: #e65100;
}

.me-card--rose .me-card-icon-wrap {
  background: rgba(216, 67, 67, 0.12);
  color: #c62828;
}

.me-card-text {
  min-width: 0;
}

.me-card-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: #5c6578;
  line-height: 1.3;
  margin-bottom: 4px;
}

.me-card-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  color: #1e293b;
}

.me-card-gradient {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  border-radius: 0 0 calc(var(--me-radius) - 1px) calc(var(--me-radius) - 1px);
}

.me-card--blue .me-card-gradient {
  background: linear-gradient(90deg, #5c7aad, #4a628a);
}

.me-card--lightblue .me-card-gradient {
  background: linear-gradient(90deg, #7eb8f7, #4a90e2);
}

.me-card--teal .me-card-gradient {
  background: linear-gradient(90deg, #26a69a, #00897b);
}

.me-card--green .me-card-gradient {
  background: linear-gradient(90deg, #66bb6a, #3d8b40);
}

.me-card--orange .me-card-gradient {
  background: linear-gradient(90deg, #ffb74d, #f57c00);
}

.me-card--rose .me-card-gradient {
  background: linear-gradient(90deg, #ef9a9a, #d9534f);
}

.me-table-panel {
  background: #fff;
  border: 1px solid var(--me-border);
  border-radius: var(--me-radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  /* overflow:hidden on this wrapper breaks position:sticky on tables inside .me-table-scroll */
  overflow: visible;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.me-table-scroll {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  max-height: var(--me-table-max-height);
  -webkit-overflow-scrolling: touch;
  border-radius: var(--me-radius);
  background: #fff;
}

/* Order grid: single scrollport + same visible height as previous inline 500px wrapper */
.me-table-scroll.me-table-scroll--order-grid {
  max-height: min(52vh, 500px);
}

.me-order-grid {
  width: 100%;
  min-height: 0;
}

.me-data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.68rem;
  table-layout: auto;
}

.me-data-table thead th {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(
    180deg,
    var(--me-table-header-top) 0%,
    var(--me-table-header-mid) 45%,
    var(--me-table-header-bottom) 100%
  );
  color: #f8fafc;
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: capitalize; 
  text-align: left;
  padding: 5px 8px;
  white-space: wrap;
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 2px solid rgba(29, 45, 75, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

.me-data-table thead th:last-child {
  border-right: none;
}

.me-data-table tbody td {
  padding: 5px 5px;
  border-bottom: 1px solid #eef0f4;
  vertical-align: middle;
}

.me-data-table tbody tr:hover {
  background: #f9fafb;
}

.me-th-actions {
  text-align: center;
  width: 100px;
}

.me-data-table tbody td:last-child {
  text-align: center;
}

/* Available Vehicle dialog: same shell + scroll as main order grid */
.me-avail-dialog-panel {
  flex: none;
  margin: 0;
}

.me-avail-dialog-scroll {
  max-height: min(55vh, 480px);
}

/* Availability grid matches order table; single-line cells except customer name */
.me-data-table.me-avail-data-table {
  table-layout: auto;
}

/*
 * MUI Dialog is portaled outside .me-dashboard, so --me-table-header-* vars are unset
 * and the default .me-data-table thead gradient becomes invalid. Repeat literal colors here.
 */
.me-data-table.me-avail-data-table thead th {
  background: linear-gradient(
    180deg,
    #5c7eb8 0%,
    #4a628a 45%,
    #3d5280 100%
  );
}

.me-data-table.me-avail-data-table tbody td {
  white-space: nowrap;
}

.me-data-table.me-avail-data-table tbody td.me-td-avail-cust-name {
  white-space: normal;
  line-height: 1.4;
  max-width: 14rem;
}

.me-data-table.me-avail-data-table tbody td:last-child {
  text-align: left;
}

.me-data-table.me-avail-data-table tbody td.me-avail-empty {
  white-space: normal;
  text-align: center !important;
  color: #64748b;
}

.me-avail-empty {
  text-align: center !important;
  color: #64748b;
}

.me-td-multiline {
  max-width: none;
  white-space: normal;
  line-height: 1.4;
}

.me-status-pill {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.56rem;
  font-weight: 700;
  color: #fff;
  background: var(--me-red);
  border-radius: 999px;
}

.me-status-pill--neutral {
  background: #64748b;
}

.me-status-pill--green {
  background: #66bb6a;
  color: #fff;
}

.me-status-pill--orange {
  background: #f7c968;
  color: #070707;
}

.me-cell-input {
  width: 50%;
  min-width: 100px;
  max-width: 100px;
  padding: 8px 10px;
  font-size: 0.8125rem;
  border: 1px solid #cfd4dc;
  border-radius: var(--me-radius);
  background: #fff;
  height: 30px;
}

.me-cell-input:focus {
  outline: 2px solid rgba(74, 144, 226, 0.35);
  outline-offset: 1px;
}

.me-btn-save {
  padding: 8px 16px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
  background: var(--me-action-blue);
  border: none;
  border-radius: var(--me-radius);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.me-btn-save:hover {
  filter: brightness(1.05);
}
