:root {
  --xr-red: #bf1e2e;
  --xr-black: #171717;
  --xr-white: #fbfbfb;
  --xr-gray: #d9d9d9;
  --xr-border: #c5c5c5;
  --xr-text: #222222;
  --xr-muted: #6b7280;
  --xr-bg: linear-gradient(135deg, #ffffff 0%, #f1f1f1 45%, #e4e4e4 100%);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--xr-text);
  background: var(--xr-bg);
}

body.drawer-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  background: var(--xr-black);
  color: var(--xr-white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
}

.brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 4px;
}

.tagline {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.8rem;
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-chip {
  display: none;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.88rem;
  white-space: nowrap;
}

.menu-button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  padding: 0;
  font-size: 1.2rem;
}

.menu-button.light-icon {
  background: rgba(255, 255, 255, 0.06);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 29;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, calc(100% - 28px));
  height: 100vh;
  background: var(--xr-black);
  color: var(--xr-white);
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 30;
  overflow-y: auto;
  box-shadow: -12px 0 30px rgba(0, 0, 0, 0.24);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.drawer-nav {
  margin-top: 20px;
}

.nav-link {
  display: block;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active,
.nav-link:hover {
  background: var(--xr-red);
}

.drawer-logout {
  margin-top: 12px;
  width: 100%;
}

.main {
  padding: 16px 16px calc(94px + env(safe-area-inset-bottom));
  max-width: 1180px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.page-header p {
  margin: 0;
  color: var(--xr-muted);
}

.button,
button {
  border: 0;
  border-radius: 12px;
  background: var(--xr-red);
  color: white;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
}

.button.secondary,
button.secondary {
  background: var(--xr-black);
}

.button.light,
button.light {
  background: white;
  color: var(--xr-text);
  border: 1px solid var(--xr-border);
}

.cards,
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.card,
.panel,
.stat {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card,
.panel {
  padding: 22px;
}

.stat {
  padding: 18px 20px;
}

.stat strong {
  display: block;
  font-size: 1.9rem;
  margin-top: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--xr-border);
  background: white;
  font: inherit;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.panel h2,
.panel h3,
.card h2,
.card h3 {
  margin-top: 0;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.status {
  margin-top: 14px;
  font-weight: 700;
}

.status.error {
  color: #9b1c1c;
}

.status.success {
  color: #166534;
}

.two-col {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}

.note {
  padding: 14px 16px;
  background: #fff4f5;
  border: 1px solid #f5c2c7;
  border-radius: 8px;
  color: #7f1d1d;
}

.vehicle-type.xrave {
  border-left: 6px solid var(--xr-red);
}

.vehicle-type.repair {
  border-left: 6px solid var(--xr-black);
}

.list {
  display: grid;
  gap: 12px;
}

.list-item {
  padding: 14px 16px;
  border-radius: 8px;
  background: #f8f8f8;
  border: 1px solid #ececec;
}

.qr-box {
  display: grid;
  place-items: center;
  padding: 20px;
  background: white;
  border-radius: 8px;
  border: 2px dashed var(--xr-border);
}

.qr-box img {
  width: 220px;
  height: 220px;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.badge.red {
  background: #fbe5e7;
  color: var(--xr-red);
}

.badge.dark {
  background: #ededed;
  color: var(--xr-black);
}

.chart-row {
  margin-bottom: 16px;
}

.chart-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.bar {
  height: 12px;
  background: #e4e4e4;
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--xr-black), var(--xr-red));
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(480px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 18;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(23, 23, 23, 0.96);
  backdrop-filter: blur(10px);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.18);
}

.bottom-link {
  min-height: 50px;
  border-radius: 8px;
  padding: 8px 6px;
  display: grid;
  place-items: center;
  text-align: center;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.76rem;
  line-height: 1.15;
  background: rgba(255, 255, 255, 0.06);
}

.bottom-link.active {
  background: var(--xr-red);
  color: white;
}

@media (max-width: 960px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 961px) {
  .page-chip {
    display: inline-block;
  }

  .topbar {
    padding: 16px 22px;
  }

  .main {
    padding: 24px 24px 40px;
  }

  .bottom-nav {
    left: 24px;
    right: 24px;
    bottom: 24px;
    max-width: 720px;
    margin: 0 auto;
    border-radius: 8px;
  }
}

@media (max-width: 460px) {
  .topbar {
    align-items: start;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: end;
  }

  .bottom-link {
    font-size: 0.7rem;
    padding: 8px 4px;
  }

  .card,
  .panel {
    padding: 18px;
    border-radius: 8px;
  }
}

/* UI refresh */
:root {
  --xr-red: #c5162f;
  --xr-red-dark: #8f1322;
  --xr-black: #151515;
  --xr-white: #ffffff;
  --xr-gray: #e4e6ea;
  --xr-border: #d8dce2;
  --xr-text: #1f2328;
  --xr-muted: #667085;
  --xr-bg: #f4f6f8;
  --xr-surface: #ffffff;
  --xr-soft: #f9fafb;
  --shadow: 0 16px 40px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 8px 24px rgba(16, 24, 40, 0.06);
}

* {
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  line-height: 1.5;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(244, 246, 248, 0.92)),
    var(--xr-bg);
}

.app-shell {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(197, 22, 47, 0.06), transparent 34%),
    radial-gradient(circle at top right, rgba(21, 21, 21, 0.08), transparent 28%),
    var(--xr-bg);
}

.topbar {
  min-height: 70px;
  padding: 10px 18px;
  background: rgba(21, 21, 21, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
}

.topbar-brand {
  min-width: 0;
}

.brand-lockup,
.public-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-lockup {
  color: var(--xr-white);
}

.brand-logo {
  width: 48px;
  height: 34px;
  padding: 3px;
  object-fit: contain;
  flex: 0 0 auto;
  background: var(--xr-white);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
}

.brand-text {
  display: block;
  overflow-wrap: anywhere;
  color: inherit;
  font-size: 1.08rem;
  line-height: 1;
  font-weight: 800;
}

.brand {
  letter-spacing: 0;
}

.tagline {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.7);
}

.page-chip {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.menu-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  transition: transform 0.16s ease, background 0.16s ease;
}

.menu-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.15);
}

.drawer {
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.drawer-header {
  gap: 12px;
}

.nav-link,
.bottom-link,
.button,
button,
input,
select,
textarea,
.card,
.panel,
.stat,
.list-item,
.note,
.qr-box,
.auth-card {
  border-radius: 8px;
}

.nav-link {
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.16s ease, transform 0.16s ease;
}

.nav-link:hover {
  transform: translateX(-2px);
}

.main {
  width: min(1180px, 100%);
  padding-top: 22px;
}

.page-header {
  align-items: center;
  padding: 20px 0 2px;
  border-bottom: 1px solid rgba(21, 21, 21, 0.08);
}

.page-header h1 {
  margin: 0 0 6px;
  color: #111827;
  font-size: 2rem;
  line-height: 1.15;
}

.page-header p {
  max-width: 760px;
  color: var(--xr-muted);
}

.button,
button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #d41f38, var(--xr-red));
  box-shadow: 0 10px 22px rgba(197, 22, 47, 0.18);
  line-height: 1.2;
  text-align: center;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.button:hover,
button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(197, 22, 47, 0.22);
}

.button.secondary,
button.secondary {
  background: var(--xr-black);
  box-shadow: 0 10px 22px rgba(21, 21, 21, 0.16);
}

.button.light,
button.light {
  background: var(--xr-white);
  color: var(--xr-text);
  border-color: var(--xr-border);
  box-shadow: var(--shadow-soft);
}

.card,
.panel,
.stat {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(16, 24, 40, 0.08);
  box-shadow: var(--shadow-soft);
}

.card,
.panel {
  padding: 22px;
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 18px 20px;
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--xr-red);
}

.stat span {
  color: var(--xr-muted);
}

.stat strong {
  color: #111827;
}

label {
  color: #344054;
}

input,
select,
textarea {
  min-height: 44px;
  border-color: #d0d5dd;
  background: var(--xr-white);
  color: var(--xr-text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--xr-red);
  box-shadow: 0 0 0 4px rgba(197, 22, 47, 0.12);
}

.note {
  background: #fff7f8;
  border-color: #f3b8c1;
}

.list {
  gap: 10px;
}

.list-item {
  background: var(--xr-soft);
  border: 1px solid rgba(16, 24, 40, 0.08);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

a.list-item:hover {
  transform: translateY(-1px);
  border-color: rgba(197, 22, 47, 0.32);
  box-shadow: var(--shadow-soft);
}

.vehicle-type.xrave,
.vehicle-type.repair {
  border-left-width: 5px;
}

.qr-box {
  border-color: #d0d5dd;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(249, 250, 251, 0.94));
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  line-height: 1.1;
  vertical-align: middle;
}

.xrave-inline-brand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  vertical-align: -0.18em;
}

.xrave-inline-brand img {
  width: 24px;
  height: 17px;
  padding: 1px;
  object-fit: contain;
  background: var(--xr-white);
  border: 1px solid rgba(16, 24, 40, 0.12);
  border-radius: 4px;
}

.type-choice-grid {
  display: grid;
  gap: 10px;
}

.type-choice {
  margin: 0;
  cursor: pointer;
}

.type-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.type-choice-content {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: var(--xr-white);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.type-choice input:checked + .type-choice-content {
  border-color: var(--xr-red);
  background: #fff7f8;
  box-shadow: 0 0 0 4px rgba(197, 22, 47, 0.1);
}

.qr-result {
  padding: 18px;
  background: var(--xr-white);
  border: 1px solid rgba(16, 24, 40, 0.08);
  box-shadow: var(--shadow-soft);
}

.qr-print-card {
  background: var(--xr-white);
}

.qr-print-actions {
  align-items: center;
}

.auth-page {
  overflow: hidden;
  background: #151515;
}

.particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.login-shell {
  position: relative;
  z-index: 1;
  padding: 24px;
}

.login-card {
  width: min(520px, 100%);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
}

.login-logo {
  width: 112px;
  height: 78px;
  padding: 6px;
  object-fit: contain;
  flex: 0 0 auto;
  background: var(--xr-white);
  border: 1px solid rgba(16, 24, 40, 0.1);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.login-kicker {
  margin-bottom: 4px;
  color: var(--xr-red);
  font-weight: 800;
}

.login-brand h1 {
  margin: 0;
  color: #111827;
  font-size: 2.2rem;
  line-height: 1;
}

.login-brand p {
  margin: 8px 0 0;
  color: var(--xr-muted);
}

.public-form-page {
  background:
    linear-gradient(90deg, rgba(197, 22, 47, 0.06), transparent 34%),
    var(--xr-bg);
}

.public-form-shell {
  align-items: start;
  padding: 28px 18px;
}

.public-form-card {
  width: min(760px, 100%);
  margin-top: 18px;
}

.public-brand {
  margin-bottom: 18px;
  color: var(--xr-black);
}

.public-brand .brand-logo {
  box-shadow: var(--shadow-soft);
}

.public-brand .brand-text {
  color: var(--xr-black);
}

.bottom-nav {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(21, 21, 21, 0.94);
}

.bottom-link {
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bottom-link.active {
  background: var(--xr-red);
}

@media (min-width: 961px) {
  .topbar {
    padding: 12px 24px;
  }

  .bottom-nav {
    border-radius: 8px;
  }
}

@media (max-width: 720px) {
  .page-header {
    align-items: stretch;
    flex-direction: column;
    padding-top: 12px;
  }

  .page-header h1 {
    font-size: 1.72rem;
  }

  .quick-links,
  .form-actions {
    width: 100%;
  }

  .quick-links .button,
  .form-actions .button,
  .form-actions button {
    flex: 1 1 180px;
  }

  .login-brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-logo {
    width: 96px;
    height: 66px;
  }
}

@media (max-width: 460px) {
  .topbar {
    align-items: center;
  }

  .brand-logo {
    width: 42px;
    height: 30px;
  }

  .brand-text {
    font-size: 0.96rem;
  }

  .tagline {
    font-size: 0.74rem;
  }

  .topbar-actions {
    flex-direction: row;
    align-items: center;
  }

  .main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .card,
  .panel,
  .auth-card {
    padding: 18px;
    border-radius: 8px;
  }

  .login-card {
    padding: 22px;
  }
}

@media print {
  @page {
    margin: 12mm;
  }

  body.qr-print-mode {
    background: white;
  }

  body.qr-print-mode * {
    box-shadow: none !important;
    text-shadow: none !important;
    visibility: hidden !important;
  }

  body.qr-print-mode #qrResult,
  body.qr-print-mode #qrResult .qr-print-card,
  body.qr-print-mode #qrResult .qr-print-card * {
    visibility: visible !important;
  }

  body.qr-print-mode #qrResult {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    max-width: 92mm;
    padding: 0;
    border: 0;
    background: white;
  }

  body.qr-print-mode .qr-print-card {
    display: grid;
    gap: 8mm;
    place-items: center;
    width: 92mm;
    padding: 7mm;
    border: 1.2mm solid #151515;
    border-left: 4mm solid #c5162f;
  }

  body.qr-print-mode .qr-print-card .badge {
    justify-self: start;
    color: #151515 !important;
    background: white !important;
    border: 0.4mm solid #151515;
  }

  body.qr-print-mode .qr-print-card .xrave-inline-brand img {
    border: 0;
  }

  body.qr-print-mode .qr-print-card .qr-box {
    width: 100%;
    padding: 6mm;
    border: 0.6mm dashed #667085;
    background: white;
  }

  body.qr-print-mode .qr-print-card .qr-box img {
    width: 58mm;
    height: 58mm;
  }

  body.qr-print-mode .qr-print-actions {
    display: none !important;
  }
}
