/* Điều hành · Điều phối / Nhân sự / Thông báo / nghỉ phép tài xế. Cards first so the station phone works. */
.workspace-v2:not(.driver-mode) :is(#dispatch-roster-workspace, #dispatch-staff-workspace) { max-width: none; width: 100%; margin: 0 0 20px; padding: 0; border: 0; background: transparent; }
.dispatch-roster { display: grid; gap: 16px; min-width: 0; }
.dispatch-roster > .view-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.dispatch-roster > .view-tabs > button { min-height: 44px; }
.roster-panel { display: grid; gap: 12px; min-width: 0; padding: 16px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); background: var(--ui-surface); }
.roster-panel > h3, .account-leave > h2, .account-leave > h3 { margin: 0; }
.roster-cards { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.roster-card { display: grid; gap: 6px; min-width: 0; padding: 12px; border: 1px solid var(--ui-border); border-radius: 10px; background: var(--ui-surface); }
.roster-card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.roster-position { display: inline-grid; place-items: center; flex: none; min-width: 40px; height: 40px; padding: 0 6px; border-radius: 20px; background: var(--ui-primary); color: var(--ui-on-primary); font-size: 18px; font-weight: 700; }
.roster-driver { font-size: 16px; overflow-wrap: anywhere; }
.roster-line { margin: 0; overflow-wrap: anywhere; }
.roster-status { justify-self: start; padding: 2px 10px; border-radius: 999px; background: var(--ui-surface-muted); color: var(--ui-ink); font-size: 13px; }
.status-ready .roster-status, .leave-approved .roster-status { background: var(--ui-success-surface); color: var(--ui-success-ink); }
:is(.status-on_leave, .status-driver_inactive, .status-vehicle_inactive) .roster-status, .leave-pending .roster-status { background: var(--ui-warning-surface); color: var(--ui-warning-ink); }
:is(.status-on_leave, .status-driver_inactive, .status-vehicle_inactive, .status-removed) .roster-position { background: var(--ui-neutral-solid); }
.status-removed, .leave-rejected { color:var(--ui-muted); }
.roster-actions, .roster-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.roster-actions button, .roster-toolbar button, .roster-inline button { min-height: 44px; }
.roster-actions > button { flex: 1 1 auto; }
.roster-open { display: grid; gap: 4px; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.roster-open:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 4px; border-radius: 6px; }
.roster-day, .roster-inline { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; width: 100%; }
.roster-day .action-label, .roster-inline .action-label { flex: 1 1 200px; min-width: 0; }
.roster-form { max-width: 640px; }
/* Preferred vehicle: one search field and its results, then an explicit save. */
.preferred-vehicle, .preferred-pick { display:grid; gap:8px; min-width:0; }
.preferred-vehicle { margin-top:12px; }
.preferred-vehicle .action-label, .preferred-pick > p { min-width:0; margin:0; }
.workspace-v2 .preferred-pick > .action-buttons { display:grid; grid-template-columns:1.4fr 1fr; gap:8px; }
.workspace-v2 .preferred-pick > .action-buttons > button { min-width:0; width:100%; padding-inline:8px; }
.preferred-results { max-height:260px; overflow-y:auto; }
.dispatch-catalog-facts > .metric-row:last-child { grid-column:1 / -1; }
.dispatch-catalog-facts dd { white-space:pre-wrap; overflow-wrap:anywhere; }
.account-leave { display: grid; gap: 12px; margin-top: 20px; min-width: 0; }
/* Danh mục Xe / Bơm, list box head: no repeated title; the plate search fills the line and the add
   (+) button sits at its right, bottom-aligned and as tall as the search field. Bơm: the button alone. */
#dispatch-catalog-workspace .catalog-list-heading.dispatch-list-head { display: flex; align-items: flex-end; justify-content: flex-end; gap: 8px; flex-wrap: nowrap; }
#dispatch-catalog-workspace .dispatch-list-head > .catalog-search { flex: 1 1 auto; min-width: 0; margin: 0; }
#dispatch-catalog-workspace .dispatch-list-head > .catalog-search :is(.action-label, label) { margin: 0; }
#dispatch-catalog-workspace .dispatch-list-head > button { flex: 0 0 auto; height: var(--ui-control, 44px); min-height: var(--ui-control, 44px); width: var(--ui-control, 44px); margin: 0; }
/* Danh mục Xe / Bơm: the short field (Biển số, Tên loại Bơm) and Ghi chú on one row, 2:3; Ghi chú
   starts as high as a single-line field and grows with its text; status and buttons below. */
.workspace-v2 .master-data-form.dispatch-catalog-form { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.workspace-v2 .master-data-form.dispatch-catalog-form > .action-label:has(textarea) { grid-column: auto; }
.workspace-v2 .master-data-form.dispatch-catalog-form textarea.action-input { min-height: var(--ui-control, 44px); max-height: 240px; field-sizing: content; resize: vertical; }
@media (max-width: 700px) {
  .workspace-v2 .master-data-form.dispatch-catalog-form { grid-template-columns: minmax(0, 1fr); }
}
/* Nhân sự: thống kê, danh sách tài xế, Thông báo */
.staff-stats { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); }
.staff-stat { display: grid; gap: 2px; min-height: 64px; padding: 10px 12px; border: 1px solid var(--ui-border); border-radius: 10px; background: var(--ui-surface); color: var(--ui-ink); font: inherit; text-align: left; cursor: pointer; }
.staff-stat[aria-pressed="true"] { border-color: var(--ui-accent); box-shadow: inset 0 0 0 1px var(--ui-accent); }
.staff-stat-label { font-size: 13px; }
.staff-stat-value { font-size: 22px; }
/* The list gets the wider half; five columns only when there is room, else a two-line row. */
@media (min-width: 721px) { .workspace-v2:not(.driver-mode) .master-data-grid.staff-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
/* One column set for the header and every row (px, not em: the header text is smaller), and the
   same 1px border on both so the cells line up. */
.staff-row { --staff-cols: 48px minmax(0, 1fr) 112px minmax(0, 150px) 112px; display: grid; grid-template-columns: var(--staff-cols); align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--ui-border); border-radius: 8px; background: var(--ui-surface); color: inherit; font: inherit; text-align: left; }
button.staff-row { cursor: pointer; }
.staff-row[aria-pressed="true"] { border-color: var(--ui-accent); }
.staff-head { border-color: transparent; background: none; color: var(--ui-muted, var(--ui-muted)); font-size: 13px; min-height: 0; padding-block: 0; }
.staff-row > span, .staff-row > strong { min-width: 0; overflow-wrap: anywhere; }
.staff-row > .roster-status { justify-self: start; }
/* Thông báo badge: red while requests wait, neutral at 0. */
.staff-stat-badge { justify-self: start; min-width: 1.8em; padding: 0 8px; border-radius: 999px; background: var(--ui-surface-muted); color: var(--ui-ink); text-align: center; }
.staff-stat-badge.is-alert { background: var(--ui-danger-solid); color: var(--ui-on-primary); }
.status-ready .roster-status { background: var(--ui-success-surface); color: var(--ui-success-ink); }
.status-busy .roster-status { background: var(--ui-info-surface); color: var(--ui-ink); }
.request-kind { justify-self: start; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--ui-muted, var(--ui-muted)); }
.request-focus .roster-card { border-color: var(--ui-accent); box-shadow: inset 0 0 0 1px var(--ui-accent); }
.dispatch-pending > p { margin: 0; }
/* Thẻ thông báo trong web: top of the page, never over the main actions for long. */
.request-notices { position: fixed; top: 8px; left: 50%; z-index: 50; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); transform: translateX(-50%); }
.request-notices:empty { display: none; }
.request-notice { display: flex; align-items: stretch; border: 1px solid var(--ui-accent); border-radius: 10px; background: var(--ui-surface); box-shadow: 0 6px 20px var(--ui-shadow); }
.request-notice-open { flex: 1; min-height: 44px; padding: 10px 12px; border: 0; background: none; color: var(--ui-ink); font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.request-notice-close { flex: none; width: 44px; border: 0; border-left: 1px solid var(--ui-border); background: none; font-size: 20px; cursor: pointer; }
@media (max-width: 1199px) {
  .staff-row { grid-template-columns: 2.5em minmax(0, 1fr) auto; row-gap: 2px; }
  .staff-head { display: none; }
  .staff-row > .staff-index { grid-row: 1 / span 2; }
  .staff-row > .staff-code { grid-column: 2; grid-row: 2; color: var(--ui-muted, var(--ui-muted)); }
  .staff-row > .staff-code::before { content: "Mã "; }
  .staff-row > .staff-plate { grid-column: 3; grid-row: 2; justify-self: end; color: var(--ui-muted, var(--ui-muted)); }
  .staff-row > .staff-plate::before { content: "Xe "; }
}
@media (max-width: 600px) {

  .roster-panel { padding: 12px; }
  .roster-actions > button { flex: 1 1 calc(50% - 8px); }
}
/* ---- Điều phối theo đơn (Brief 3) ---- */
.dispatch-orders .order-row { --order-cols: 132px minmax(0, 1.4fr) 120px 150px minmax(0, 1.4fr) 116px; display: grid; grid-template-columns: var(--order-cols); align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 8px 10px; border: 1px solid var(--ui-border); border-radius: 8px; background: var(--ui-surface); color: inherit; font: inherit; text-align: left; }
.dispatch-orders button.order-row { cursor: pointer; }
.dispatch-orders .order-head { border-color: transparent; background: none; color: var(--ui-muted, var(--ui-muted)); font-size: 13px; min-height: 0; padding-block: 0; }
.dispatch-orders .order-row > * { min-width: 0; overflow-wrap: anywhere; }
.order-schedule { display: grid; gap: 2px; font-size: 13px; }
.stage-waiting { background: var(--ui-warning-surface) !important; color: var(--ui-warning-ink) !important; }
.stage-arranged { background: var(--ui-info-surface) !important; color: var(--ui-ink) !important; }
.stage-in_progress { background: var(--ui-success-surface) !important; color: var(--ui-success-ink) !important; }
.stage-ending { background: var(--ui-warning-surface) !important; color: var(--ui-warning-ink) !important; }
.stage-completed { background: var(--ui-info-surface) !important; color: var(--ui-ink) !important; }
.dispatch-cards { display: flex; flex-wrap: wrap; gap: 8px; }
.dispatch-cards > button { min-height: 44px; }
.dispatch-cards > button[aria-pressed="true"] { border-color: var(--ui-accent); box-shadow: inset 0 0 0 1px var(--ui-accent); }
.dispatch-quantities { margin: 0; font-size: 14px; }
.slot-row { padding: 8px 10px; border: 1px solid var(--ui-border); border-radius: 8px; background: var(--ui-surface); }
.slot-head { border-color: transparent; background: none; color: var(--ui-muted, var(--ui-muted)); font-size: 13px; padding-block: 0; }
.slot-row > * { min-width: 0; overflow-wrap: anywhere; }
.slot-row.status-new { border-style: dashed; }
.slot-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.slot-actions > button { min-height: 40px; padding-inline: 10px; }
.dispatch-chooser { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--ui-border); border-radius: 10px; background: var(--ui-surface); }
.dispatch-choice { min-height: 44px; padding: 8px 10px; border: 1px solid var(--ui-border); border-radius: 8px; background: var(--ui-surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.dispatch-choice[aria-pressed="true"] { border-color: var(--ui-accent); box-shadow: inset 0 0 0 1px var(--ui-accent); }
.dispatch-choice:disabled { opacity: .55; cursor: not-allowed; }
.dispatch-choice small { color: var(--ui-muted, var(--ui-muted)); }
.instruction-card { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--ui-border); border-radius: 10px; }
.instruction-card > button { justify-self: start; min-height: 44px; }
.instruction-preview { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--ui-surface); font-weight: 600; overflow-wrap: anywhere; }
.workspace-v2 .master-data-form.instruction-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.workspace-v2 .master-data-form.instruction-form > .action-label:has(textarea) { grid-column: span 3; }
.workspace-v2 .master-data-form.instruction-form textarea.action-input { min-height: var(--ui-control, 44px); field-sizing: content; }
.dispatch-check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.dispatch-dialog { width: min(1180px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--ui-border); border-radius: 12px; }
.dispatch-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--ui-border); }
.dispatch-dialog-head h3 { margin: 0; font-size: 17px; }
.dispatch-dialog-body { display: grid; gap: 12px; padding: 16px; }
.account-work { display: grid; gap: 12px; margin-top: 20px; min-width: 0; }
.account-work h2, .account-work h3 { margin: 0; }
.account-work .is-unread { border-color: var(--ui-accent); }
.account-work-pending { margin: 0; padding: 10px 12px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); }
@media (max-width: 1199px) {
  .dispatch-orders .order-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .dispatch-orders .order-head { display: none; }
  .dispatch-orders .order-row > .order-code { grid-column: 1; }
  .dispatch-orders .order-row > .roster-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .dispatch-orders .order-row > :not(.order-code):not(.roster-status) { grid-column: 1 / -1; }
  .workspace-v2 .master-data-form.instruction-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-v2 .master-data-form.instruction-form > .action-label:has(textarea) { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .workspace-v2 .master-data-form.instruction-form { grid-template-columns: minmax(0, 1fr); }
}

.slot-icon-action{width:44px;min-height:44px;padding:10px;display:grid;place-items:center}.slot-icon-action svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.7}

/* Thêm tài xế (19/11/2026): several drivers chosen at once; a chosen one is marked, the list of names sits above Thêm. */
.dispatch-choice[aria-pressed="true"] { border-color:var(--ui-accent); background:var(--ui-selected); box-shadow:inset 3px 0 0 var(--ui-accent); }
.dispatch-chooser-actions { display:flex; flex-wrap:wrap; align-items:center; justify-content:flex-start; gap:8px; }
.dispatch-chooser-actions > button { width:auto; flex:0 0 auto; }
.dispatch-chooser-selected { margin:0; color:var(--ui-muted); overflow-wrap:anywhere; }

/* Lệnh sản xuất (22/11/2026): Thêm lệnh mới vừa nội dung, bên trái dưới bảng. */
.workspace-v2 .dispatch-instruction > .instruction-add { justify-self:start; align-self:start; width:auto; max-width:100%; }
.status-support .roster-status { background: var(--ui-hover); color: var(--ui-ink); }
