:root {
  --bg: #f2f5f3;
  --surface: #ffffff;
  --ink: #13241a;
  --muted: #5d6d64;
  --line: #e1e8e3;
  --line-strong: #cfd9d2;
  --primary: #15803d;
  --primary-700: #0f6330;
  --primary-900: #0a3f20;
  --primary-50: #ebf7ef;
  --primary-100: #d3eedb;
  --accent: #d4a12a;
  --accent-50: #fbf4e2;
  --danger: #cc3b3b;
  --danger-50: #fdeeee;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 45, 25, .05), 0 12px 32px -12px rgba(15, 45, 25, .14);
  --ring: 0 0 0 4px rgba(21, 128, 61, .15);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 56px 16px 120px;
  color: #fff;
  text-align: center;
  background:
    radial-gradient(900px 300px at 85% -10%, rgba(212, 161, 42, .35), transparent 60%),
    radial-gradient(700px 320px at 0% 120%, rgba(255, 255, 255, .10), transparent 60%),
    linear-gradient(135deg, var(--primary-900), var(--primary) 70%);
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.035) 0 2px, transparent 2px 22px);
  pointer-events: none;
}
.hero__nav {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 960px; margin: -32px auto 28px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; text-align: left; }
.brand img { border-radius: 10px; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); }
.brand span { font-weight: 800; font-size: 15px; line-height: 1.15; letter-spacing: .01em; }
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: rgba(255, 255, 255, .72); letter-spacing: .02em; }
.nav-login {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .1);
  color: #fff; text-decoration: none;
  font-size: 13.5px; font-weight: 600;
  transition: background .15s;
}
.nav-login:hover { background: rgba(255, 255, 255, .2); }
.hero__inner { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; }
.hero__logo {
  display: block; margin: 0 auto 16px;
  border-radius: 20px;
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .45), 0 0 0 6px rgba(255, 255, 255, .08);
}
.hero h1 {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.hero p { margin-top: 8px; color: rgba(255, 255, 255, .82); font-size: 16px; }

/* ---------- Layout ---------- */
.wrap { max-width: 960px; margin: -84px auto 0; padding: 0 16px 40px; position: relative; z-index: 2; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 18px;
}
.card__head { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.step {
  flex: none;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-weight: 800; font-size: 14px;
  color: var(--primary-700);
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
}
.card h2 { font-size: 17px; font-weight: 700; color: var(--primary-900); }
.card__sub { font-size: 13px; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }

/* MST + nút tra cứu */
.input-group { display: flex; min-width: 0; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.lookup-btn {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 46px; padding: 0 12px;
  border: 1.5px solid var(--primary);
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: 13px; font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s;
}
.lookup-btn:hover:not(:disabled) { background: var(--primary-100); }
.lookup-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.lookup-btn:disabled { cursor: wait; opacity: .8; }
.lookup-btn .spinner { display: none; }
.lookup-btn.is-loading .spinner { display: block; }
.lookup-btn.is-loading .lookup-btn__icon { display: none; }
.field.is-invalid .lookup-btn { border-color: var(--danger); }
.ok { font-size: 12.5px; color: var(--primary-700); font-weight: 500; }
.ok:empty { display: none; }
input.is-filled { animation: filled 1.2s ease-out; }
@keyframes filled { 0% { background: #d9f2e1; } 100% { background: #fbfcfb; } }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.field { margin-bottom: 18px; }
.field label, .field legend { font-size: 14px; font-weight: 600; color: var(--ink); padding: 0; }
.req { color: var(--danger); font-weight: 700; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 4px; }

input[type="text"], input[type="tel"], input[type="email"], input[type="date"], input[type="password"], textarea {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fbfcfb;
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
}
textarea { height: auto; min-height: 92px; padding: 12px 14px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #9aa8a0; }
input:hover, textarea:hover { border-color: #b6c4bb; }
input:focus, textarea:focus { border-color: var(--primary); background: #fff; box-shadow: var(--ring); }

.field.is-invalid input, .field.is-invalid textarea { border-color: var(--danger); background: var(--danger-50); }
.field.is-invalid input:focus { box-shadow: 0 0 0 4px rgba(204, 59, 59, .14); }
.err { min-height: 0; font-size: 12.5px; color: var(--danger); font-weight: 500; }
.err:empty { display: none; }
.err--block { display: block; margin: -4px 0 14px; }

.remember { display: inline-flex; gap: 8px; align-items: center; margin-top: 16px; font-size: 13px; color: var(--muted); cursor: pointer; }
.remember input { width: 16px; height: 16px; accent-color: var(--primary); }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 16px 0 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  font-weight: 500; font-size: 14px;
  transition: all .15s;
  user-select: none;
}
.chip span::before {
  content: "";
  width: 18px; height: 18px; flex: none;
  border-radius: 6px;
  border: 1.5px solid #b6c4bb;
  background: #fff center / 12px no-repeat;
  transition: all .15s;
}
.chip:hover span { border-color: var(--primary); }
.chip input:focus-visible + span { box-shadow: var(--ring); }
.chip input:checked + span {
  border-color: var(--primary);
  background: var(--primary-50);
  color: var(--primary-900);
  font-weight: 600;
}
.chip input:checked + span::before {
  border-color: var(--primary);
  background-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
.field.is-invalid .chip span { border-color: #e8a5a5; }

/* ---------- Vehicle groups ---------- */
.vgroup {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 14px;
  background: linear-gradient(180deg, #fbfdfb, #fff);
}
.vgroup__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.vgroup__title { display: flex; align-items: center; gap: 12px; }
.vgroup__icon {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--accent-50);
  color: #9a6f0c;
}
.vgroup h3 { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.vgroup__desc { font-size: 12.5px; color: var(--muted); }
.counter {
  flex: none;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary-700);
}

.vcols, .vrow {
  display: grid;
  grid-template-columns: 28px 140px minmax(0, 1.1fr) minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: center;
}
.vcols {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted);
  padding-bottom: 8px; margin-bottom: 10px;
  border-bottom: 1px dashed var(--line-strong);
}
.vrow { margin-bottom: 10px; animation: rowIn .2s ease-out; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.vrow__no { font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; }
.vrow input.plate { text-transform: uppercase; font-weight: 600; letter-spacing: .04em; }
.vrow input.plate::placeholder { text-transform: none; font-weight: 400; letter-spacing: 0; }

/* Segmented TQ / VN */
.seg { display: grid; grid-template-columns: 1fr 1fr; height: 46px; padding: 4px; border-radius: 12px; background: #eef2ef; border: 1.5px solid var(--line-strong); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span {
  height: 100%;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all .15s;
}
.seg span i { font-style: normal; font-size: 10px; font-weight: 800; padding: 1px 4px; border-radius: 4px; background: #dfe6e1; color: var(--muted); }
.seg input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg input:checked + span i.cn { background: #de2910; color: #ffde00; }
.seg input:checked + span i.vn { background: #da251d; color: #ffcd00; }
.seg input:focus-visible + span { box-shadow: var(--ring); }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: transparent;
  color: #a0aaa4;
  cursor: pointer;
  transition: all .15s;
}
.icon-btn:hover { background: var(--danger-50); color: var(--danger); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(204, 59, 59, .25); }

.add-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 14px;
  margin-top: 4px;
  border: 1.5px dashed #9fcfb0;
  border-radius: 10px;
  background: transparent;
  color: var(--primary-700);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.add-btn:hover:not(:disabled) { background: var(--primary-50); border-color: var(--primary); }
.add-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Submit bar ---------- */
.submitbar {
  position: sticky; bottom: 12px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 12px 12px 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px -10px rgba(15, 45, 25, .28);
}
.progress { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.progress__track { flex: 1; max-width: 240px; height: 8px; border-radius: 99px; background: #e6ece8; overflow: hidden; }
.progress__bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #34b46a); transition: width .3s ease; }
#progressText { font-size: 13px; color: var(--muted); white-space: nowrap; }

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 24px;
  border: 0; border-radius: 12px;
  font-weight: 700; font-size: 15px;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: linear-gradient(180deg, #1a9149, var(--primary-700)); color: #fff; box-shadow: 0 6px 16px -6px rgba(15, 99, 48, .6); }
.btn--primary:hover { box-shadow: 0 10px 22px -8px rgba(15, 99, 48, .7); }
.btn--primary:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(21, 128, 61, .3); }
.btn--ghost { background: #eef2ef; color: var(--ink); }
.btn--ghost:hover { background: #e2e9e4; }
.spinner {
  display: none;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner--dark { width: 16px; height: 16px; border-color: rgba(15, 99, 48, .25); border-top-color: var(--primary-700); }
.btn.is-loading { pointer-events: none; opacity: .9; }
.btn.is-loading .spinner { display: block; }
.btn.is-loading .btn__icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.foot { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 18px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(10, 30, 18, .5);
  backdrop-filter: blur(4px);
  animation: fade .2s ease-out;
}
.modal[hidden] { display: none; }
.modal__box {
  width: 100%; max-width: 420px;
  padding: 32px 28px 24px;
  text-align: center;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.35);
  animation: pop .25s cubic-bezier(.2, 1.3, .4, 1);
}
.modal__check { width: 72px; height: 72px; margin: 0 auto 16px; }
.modal__check svg { width: 100%; height: 100%; }
.modal__check circle { stroke: var(--primary); stroke-width: 3; fill: var(--primary-50); }
.modal__check path { stroke: var(--primary); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .45s .15s ease-out forwards; }
.modal h3 { font-size: 21px; font-weight: 800; color: var(--primary-900); margin-bottom: 14px; }
.modal p { color: var(--muted); font-size: 14px; }
.code {
  margin: 8px 0 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1.5px dashed var(--accent);
  background: var(--accent-50);
  font-size: 22px; font-weight: 800; letter-spacing: .08em;
  color: #7a5608;
}
.modal__note { font-size: 13px !important; }
.modal__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.modal__actions .btn { height: 44px; padding: 0 12px; font-size: 14px; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.92); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: 20px; z-index: 60;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #1d2a22; color: #fff;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.4);
  transform: translate(-50%, -150%);
  transition: transform .3s cubic-bezier(.2, 1, .3, 1);
}
.toast.is-show { transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 > .field:first-child, .grid--3 > .span-2 { grid-column: 1 / -1; }
  .vcols { display: none; }
  .vrow {
    grid-template-columns: minmax(0, 1fr) 40px;
    grid-template-areas: "seg del" "plate plate" "type type";
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }
  .vrow__no { display: none; }
  .vrow .seg { grid-area: seg; }
  .vrow .plate { grid-area: plate; }
  .vrow .vtype { grid-area: type; }
  .vrow .icon-btn { grid-area: del; }
}
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .hero { padding: 40px 16px 104px; }
  .hero__nav { margin: -24px auto 22px; }
  .brand small { display: none; }
  .nav-login { height: 34px; padding: 0 10px; font-size: 12.5px; }
  .hero__logo { width: 60px; height: 60px; }
  .card { padding: 18px 16px; border-radius: 16px; }
  .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
  .grid--3 > .field:first-child, .grid--3 > .span-2, .span-2 { grid-column: auto; }
  .vgroup { padding: 14px 12px; }
  .chip span { height: 40px; padding: 0 14px 0 10px; font-size: 13.5px; }
  .submitbar { padding: 10px; bottom: 8px; }
  .progress__track { display: none; }
  #progressText { font-size: 12px; }
  .btn { padding: 0 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .modal__check path { stroke-dashoffset: 0; }
}

/* Khung yêu cầu đăng nhập (form nội bộ) */
.gate { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 40px 24px; }
.gate img { border-radius: 16px; }
.gate h2 { font-size: 20px; font-weight: 800; color: var(--primary-900); }
.gate__msg { color: var(--muted); max-width: 420px; }
.gate .btn { text-decoration: none; }
.foot a { color: var(--primary-700); }
