/* Trang Tạo đơn: cột form bên trái (cuộn riêng, chân dính), bản đồ lớn bên phải. Mobile: bản đồ trên, form dưới. */
.cr { display: grid; grid-template-columns: 460px minmax(0, 1fr); height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); min-height: 520px; }

/* ---------- cột form ---------- */
.cr-form { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); position: relative; z-index: 1; }
.cr-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 8px; scrollbar-gutter: stable; }
.cr-sec { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.cr-sec:last-child { border-bottom: 0; }
.cr-sec-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.cr-sec-head h2 { font-size: 15px; font-weight: 700; }
.cr-sec-meta { margin-left: auto; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }

/* lộ trình: thẻ điểm nối bằng đường kẻ dọc */
.cr-route { position: relative; display: flex; flex-direction: column; gap: 10px; padding-left: 20px; }
.cr-route::before { content: ""; position: absolute; left: 6px; top: 26px; bottom: 26px; border-left: 2px dashed var(--line-2); }
.cr-stop { position: relative; }
.cr-dot { position: absolute; left: -20px; top: 20px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface);
          border: 3px solid var(--pin-b); box-shadow: 0 0 0 3px var(--surface); }
.cr-stop.is-pickup .cr-dot { border-color: var(--pin-a); }
.cr-stop.active .cr-dot { background: currentColor; }
.cr-stop.is-pickup.active .cr-dot { background: var(--pin-a); }
.cr-stop.is-drop.active .cr-dot { background: var(--pin-b); }
.cr-stop > .pt-card { margin: 0; }

.cr-add { margin: 12px 0 0 20px; width: calc(100% - 20px); height: 42px; display: flex; align-items: center; justify-content: center; gap: 8px;
          border: 1.5px dashed var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--brand);
          font: 600 14px var(--font); cursor: pointer; transition: border-color .15s, background .15s; }
.cr-add:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-50); }
.cr-add:disabled { color: var(--muted); cursor: not-allowed; }

/* dịch vụ thêm (thu gọn được) */
.cr-opts { padding-top: 6px; padding-bottom: 6px; }
.cr-collapse { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 0; border: 0; background: none;
               font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.cr-collapse-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.cr-collapse-text b { font-size: 15px; font-weight: 700; }
.cr-collapse-sum { font-size: 13px; color: var(--brand-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-collapse-sum.muted { color: var(--muted); }
.cr-chevron { color: var(--text-2); display: inline-flex; transition: transform .2s; }
.cr-collapse.open .cr-chevron { transform: rotate(180deg); }
.cr-collapse:hover .cr-chevron { color: var(--text); }
.cr-opts-body { padding: 4px 0 14px; }

/* ---------- chọn đơn vị giao ---------- */
.cr-quotes { display: flex; flex-direction: column; gap: 10px; }
.cr-provs { display: flex; flex-direction: column; gap: 10px; }
.cr-q { border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, box-shadow .15s, background .15s; }
.cr-q:not(.off):not(.is-sk):hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.cr-q.selected { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 3px var(--brand-50); }
.cr-q-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px; cursor: pointer; margin: 0; }
.cr-q.off .cr-q-head, .cr-q.is-sk .cr-q-head { cursor: default; }
.cr-q-head > input[type=radio] { width: 18px; height: 18px; }
.cr-logo { width: 38px; height: 38px; border-radius: 10px; font-size: 14px; flex: none; }
.cr-logo-auto { display: inline-flex; align-items: center; justify-content: center; background: var(--brand); color: #fff; }
.cr-q-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cr-q-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cr-q-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.cr-q-price { font-size: 18px; font-weight: 700; color: var(--text); white-space: nowrap; text-align: right; letter-spacing: -.01em; }
.cr-q.selected .cr-q-price { color: var(--brand-600); }
.cr-price-from { font-size: 12px; font-weight: 500; color: var(--muted); margin-right: 4px; }
.cr-price-na { font-size: 13px; font-weight: 600; color: var(--muted); }
.cr-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
          background: var(--grey-50); color: var(--text-2); }
.cr-tag.best { background: var(--ok-50); color: var(--ok); }
.cr-q.off { background: var(--surface-2); border-style: dashed; }
.cr-q.off .cr-logo, .cr-q.off .cr-q-name { opacity: .55; }
.cr-q.off .cr-q-desc { color: var(--danger); }

.cr-switch { display: inline-block; width: 64px; height: 26px; padding: 0 6px; margin: 0 2px; font-size: 13px; text-align: center;
             border-radius: 6px; vertical-align: baseline; }
.cr-q-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: -4px 0 0; padding: 0 14px 10px 64px;
            font-size: 12.5px; color: var(--text-2); cursor: text; }
.cr-q-order { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 14px 12px 64px; font-size: 12px; }
.cr-q-order:empty { display: none; }
.cr-order-item { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--text-2); }
.cr-order-item .cr-logo { width: 18px; height: 18px; border-radius: 5px; font-size: 9px; }
.cr-arrow { color: var(--muted); }

.cr-q-extra { padding: 0 14px 12px 64px; display: flex; flex-direction: column; gap: 6px; }
.cr-bd summary { font-size: 12.5px; color: var(--text-2); cursor: pointer; width: max-content; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.cr-bd summary::-webkit-details-marker { display: none; }
.cr-bd summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
                        transform: rotate(45deg) translateY(-2px); transition: transform .15s; }
.cr-bd[open] summary::after { transform: rotate(225deg) translateY(-1px); }
.cr-bd summary:hover { color: var(--text); }
.cr-bd[open] { padding-bottom: 2px; }
.cr-bd-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.cr-bd-row:first-of-type { margin-top: 6px; }
.cr-bd-row:last-child { border-bottom: 0; }
.cr-bd-row.sub { padding-left: 12px; color: var(--muted); }
.cr-note { font-size: 12px; color: var(--warn); background: var(--warn-50); border-radius: 6px; padding: 5px 8px; line-height: 1.4; }

.cr-qmsg { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--surface-2);
           border: 1px dashed var(--line-2); color: var(--text-2); font-size: 13px; }
.cr-qmsg.err { background: var(--danger-50); border: 1px solid var(--danger-100); color: var(--danger); }
.cr-qmsg.err span { flex: 1; }

.cr-sk-line { display: block; width: 70%; height: 12px; margin-top: 4px; }
.cr-sk-price { display: inline-block; width: 76px; height: 20px; vertical-align: middle; }
.cr-sk-total { display: inline-block; width: 110px; height: 24px; vertical-align: middle; }

.cr-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--brand);
           display: inline-block; animation: cr-spin .7s linear infinite; flex: none; }
.cr-spin.light { border-color: rgba(255, 255, 255, .4); border-top-color: #fff; width: 16px; height: 16px; margin-right: 4px; }
@keyframes cr-spin { to { transform: rotate(360deg); } }

/* ---------- chân form dính ---------- */
.cr-foot { flex: none; padding: 14px 20px 16px; border-top: 1px solid var(--line); background: var(--surface);
           box-shadow: 0 -6px 16px rgba(16, 24, 40, .06); }
.cr-err { margin-bottom: 10px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--danger-50);
          border: 1px solid var(--danger-100); color: var(--danger); font-size: 13px; line-height: 1.45; }
.cr-foot-row { display: flex; align-items: center; gap: 16px; }
.cr-total { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cr-total-label { font-size: 12px; color: var(--text-2); }
.cr-total-price { font-size: 24px; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; color: var(--text); min-height: 30px; }
.cr-total-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-submit { min-width: 150px; height: 50px; font-size: 16px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0, 135, 90, .25); }
.cr-submit.busy { opacity: .85; }

/* ---------- bản đồ ---------- */
.cr-map { position: relative; min-width: 0; min-height: 0; isolation: isolate; z-index: 0; background: var(--grey-50); }
.cr-map-el { position: absolute; inset: 0; }
.cr-map-hint { position: absolute; top: 16px; left: 16px; z-index: 800; max-width: calc(100% - 32px); display: flex; align-items: center; gap: 10px;
               padding: 8px 14px 8px 8px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-size: 13px; color: var(--text-2);
               pointer-events: none; }
.cr-map-hint:empty { display: none; }
.cr-map-hint .pin { width: 26px; height: 26px; }

/* ---------- màn hình vừa ---------- */
@media (max-width: 1100px) and (min-width: 861px) {
  .cr { grid-template-columns: 400px minmax(0, 1fr); }
}

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .cr { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .cr-map { order: -1; height: 260px; flex: none; }
  .cr-map-hint { top: 10px; left: 10px; font-size: 12px; padding: 6px 12px 6px 6px; }
  .cr-map-hint .pin { width: 22px; height: 22px; }
  .cr-form { border-right: 0; }
  .cr-scroll { overflow: visible; padding-bottom: 0; }
  .cr-sec { padding: 16px; }
  .cr-foot { position: sticky; bottom: calc(62px + env(safe-area-inset-bottom)); padding: 12px 16px; z-index: 5; }
  .cr-total-price { font-size: 21px; }
  .cr-submit { min-width: 128px; height: 48px; }
  .cr-q-order, .cr-q-extra, .cr-q-sub { padding-left: 14px; }
  .cr.typing .cr-foot { position: static; box-shadow: none; }
}

/* ---------- lỗi nhập liệu + cảnh báo báo giá ---------- */
.cr input[aria-invalid=true], .cr select[aria-invalid=true] { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-50) !important; }
.cr .pt-in:has(input[aria-invalid=true]) .pt-in-ic, .cr .pt-addr:has(input[aria-invalid=true]) .pt-addr-ic { color: var(--danger); }
.cr-qmsg.warn { background: var(--warn-50); border: 1px solid var(--warn-100); color: var(--warn); }
.cr-qmsg.warn span { flex: 1; }
