/* =====================================================================
 * New Vehicle Trip — modern redesign
 * Scoped under .nvt-app to avoid clashing with global/legacy styles.
 * ===================================================================== */

:root {
  --nvt-bg: #eef2f7;
  --nvt-card: #ffffff;
  --nvt-ink: #1e293b;
  --nvt-muted: #64748b;
  --nvt-line: #e2e8f0;
  --nvt-primary: #4f46e5;
  --nvt-primary-2: #6366f1;
  --nvt-green: #16a34a;
  --nvt-green-soft: #ecfdf3;
  --nvt-amber: #d97706;
  --nvt-amber-soft: #fffbeb;
  --nvt-red: #dc2626;
  --nvt-radius: 16px;
  --nvt-radius-sm: 10px;
  --nvt-shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px rgba(16,24,40,.06);
}

.nvt-app,
.nvt-app * {
  box-sizing: border-box;
}

.nvt-app {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--nvt-ink);
  max-width: 1280px;
  margin: 24px auto 60px;
  padding: 0 20px;
}

/* ---------------- Header ---------------- */
.nvt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(120deg, #4f46e5 0%, #6d28d9 55%, #7c3aed 100%);
  color: #fff;
  padding: 20px 26px;
  border-radius: var(--nvt-radius);
  box-shadow: var(--nvt-shadow);
  flex-wrap: wrap;
}
.nvt-header .nvt-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .2px;
}
.nvt-header .nvt-title p {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: .85;
}
.nvt-header .nvt-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---------------- Lock banner (edit page) ---------------- */
.nvt-lock-banner {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}
.nvt-lock-banner .ico { font-size: 16px; }

/* ---------------- Layout ---------------- */
.nvt-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  margin-top: 22px;
  align-items: start;
}
.nvt-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* ---------------- Cards / sections ---------------- */
.nvt-card {
  background: var(--nvt-card);
  border: 1px solid var(--nvt-line);
  border-radius: var(--nvt-radius);
  box-shadow: var(--nvt-shadow);
  overflow: hidden;
}
.nvt-card > .nvt-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--nvt-line);
  background: #fafbfe;
}
.nvt-card-head .nvt-step {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--nvt-primary), var(--nvt-primary-2));
}
.nvt-card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.nvt-card-head p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--nvt-muted);
}
.nvt-card-body {
  padding: 20px;
}

/* ---------------- Fields ---------------- */
.nvt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px 18px;
}
.nvt-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.nvt-field { display: flex; flex-direction: column; min-width: 0; }
.nvt-field.span-2 { grid-column: span 2; }
.nvt-field.full { grid-column: 1 / -1; }

.nvt-field label,
.nvt-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--nvt-muted);
  margin-bottom: 6px;
}
.nvt-field .req { color: var(--nvt-red); margin-left: 2px; }

.nvt-app input[type="text"],
.nvt-app input[type="date"],
.nvt-app textarea,
.nvt-app select {
  width: 100%;
  font-size: 14px;
  color: var(--nvt-ink);
  background: #fff;
  border: 1px solid var(--nvt-line);
  border-radius: var(--nvt-radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.nvt-app textarea { min-height: 78px; resize: vertical; }
.nvt-app input:focus,
.nvt-app textarea:focus,
.nvt-app select:focus {
  border-color: var(--nvt-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.14);
}
.nvt-app input[readonly],
.nvt-app input:disabled {
  background: #f1f5f9;
  color: #475569;
  cursor: not-allowed;
}

/* select2 harmonised with inputs */
.nvt-app .select2-container { width: 100% !important; }
.nvt-app .select2-container--default .select2-selection--single {
  height: 40px;
  border: 1px solid var(--nvt-line);
  border-radius: var(--nvt-radius-sm);
}
.nvt-app .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 38px;
  padding-left: 12px;
  color: var(--nvt-ink);
}
.nvt-app .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 38px;
}
.nvt-app .select2-container--default.select2-container--focus .select2-selection--single,
.nvt-app .select2-container--open .select2-selection--single {
  border-color: var(--nvt-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.14);
}

/* ---------------- Matrix tables (adjustments / advances) ---------------- */
.nvt-matrix { width: 100%; border-collapse: separate; border-spacing: 0; }
.nvt-matrix thead th {
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--nvt-muted);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--nvt-line);
  font-weight: 700;
}
.nvt-matrix tbody td {
  padding: 7px 10px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}
.nvt-matrix tbody tr:last-child td { border-bottom: none; }
.nvt-matrix .row-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}
.nvt-matrix input[type="text"],
.nvt-matrix input[type="date"],
.nvt-matrix select { padding: 8px 10px; font-size: 13px; }
.nvt-matrix input[type="text"] { min-width: 130px; }
.nvt-matrix input[type="date"] { min-width: 150px; }
.nvt-matrix select { min-width: 110px; }
.nvt-matrix .deduction-row td {
  background: #fff5f5;
}
.nvt-matrix .deduction-row .row-label { color: var(--nvt-red); }
.nvt-tablewrap { overflow-x: auto; }

.nvt-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.nvt-refbox { display: flex; align-items: center; gap: 8px; }
.nvt-refbox label { margin: 0; }
.nvt-refbox input { width: 130px; }

/* Two side-by-side matrices */
.nvt-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.nvt-subcard {
  border: 1px solid var(--nvt-line);
  border-radius: var(--nvt-radius-sm);
  overflow: hidden;
}
.nvt-subcard .nvt-subhead {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--nvt-line);
}
.nvt-subcard.adj .nvt-subhead   { background: var(--nvt-green-soft); color: #166534; }
.nvt-subcard.adv .nvt-subhead   { background: var(--nvt-amber-soft); color: #92400e; }
.nvt-subcard .nvt-subbody { padding: 8px 12px 14px; }

.nvt-inline-two { display: flex; gap: 8px; align-items: center; }
.nvt-inline-two .total-box { max-width: 92px; text-align: center; }

/* ---------------- Sticky summary ---------------- */
.nvt-summary { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 18px; }
.nvt-summary .summary-card {
  background: var(--nvt-card);
  border: 1px solid var(--nvt-line);
  border-radius: var(--nvt-radius);
  box-shadow: var(--nvt-shadow);
  overflow: hidden;
}
.summary-card .summary-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--nvt-line);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.summary-block { padding: 14px 18px; }
.summary-block + .summary-block { border-top: 1px dashed var(--nvt-line); }
.summary-block h4 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--nvt-muted);
}
.sum-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  font-size: 13px;
  color: #475569;
}
.sum-line span:last-child { font-weight: 600; color: var(--nvt-ink); font-variant-numeric: tabular-nums; }
.sum-line.subtotal {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--nvt-line);
  font-weight: 700;
  color: var(--nvt-ink);
}
.sum-total {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}
.sum-total .lbl { font-size: 13px; }
.sum-total .val { font-size: 20px; font-variant-numeric: tabular-nums; }
.sum-total.freight { background: var(--nvt-green-soft); color: #166534; }
.sum-total.recv    { background: var(--nvt-amber-soft); color: #92400e; }
.summary-hidden-inputs { display: flex; gap: 10px; margin-top: 12px; }
.summary-hidden-inputs .nvt-field { flex: 1; }

/* ---------------- Buttons ---------------- */
.nvt-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 12px;
  transition: transform .05s, box-shadow .15s, background .15s;
}
.nvt-btn.primary {
  background: #fff;
  color: var(--nvt-primary);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.nvt-btn.primary:hover { background: #f5f3ff; }
.nvt-btn.block { width: 100%; justify-content: center; }
.nvt-btn.green { background: var(--nvt-green); color: #fff; }
.nvt-btn.green:hover { background: #15803d; }
.nvt-btn:active { transform: translateY(1px); }
.nvt-req-note { font-size: 12px; color: var(--nvt-muted); margin-top: 10px; text-align: center; }
.nvt-req-note b { color: var(--nvt-red); }

/* ---------------- Loading overlay ---------------- */
.nvt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.nvt-overlay.show { display: flex; }
.nvt-overlay .box {
  background: #fff;
  border-radius: 14px;
  padding: 22px 30px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 600;
  color: var(--nvt-ink);
  box-shadow: var(--nvt-shadow);
}
.nvt-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--nvt-primary);
  border-radius: 50%;
  animation: nvt-spin .7s linear infinite;
}
@keyframes nvt-spin { to { transform: rotate(360deg); } }

/* ---------------- Responsive ---------------- */
@media (max-width: 1080px) {
  .nvt-layout { grid-template-columns: 1fr; }
  .nvt-summary { position: static; }
}
@media (max-width: 720px) {
  .nvt-split { grid-template-columns: 1fr; }
  .nvt-field.span-2 { grid-column: auto; }
}
