:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #111827;
  --muted: #52627a;
  --line: #d8e1eb;
  --line-strong: #c8d5ea;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --primary: #2451a6;
  --primary-strong: #1d3f82;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #ecfdf5;
  --danger: #b42318;
  --success: #15803d;
  --shadow-soft: 0 14px 34px rgba(22, 42, 58, 0.08);
  --shadow-lift: 0 24px 70px rgba(15, 23, 42, 0.14);
  color: var(--ink);
  background: #e9eef3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12) 0%, rgba(15, 118, 110, 0) 34%),
    linear-gradient(225deg, rgba(245, 158, 11, 0.12) 0%, rgba(245, 158, 11, 0) 38%),
    linear-gradient(180deg, #eef6f8 0%, #f2f5f8 44%, #e8edf3 100%);
}

p,
h1,
h2,
dl,
dd {
  margin: 0;
}

button,
input,
select {
  font: inherit;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease,
    color 140ms ease,
    transform 120ms ease;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(245, 158, 11, 0.34);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 12px 10px 22px;
  background: var(--surface-soft);
}

.auth-shell,
.admin-shell {
  width: min(1120px, 100%);
  padding: 28px;
  background: transparent;
}

.admin-shell {
  width: min(1240px, 100%);
}

.top-bar,
.voice-panel,
.chat-stage,
.trip-card,
.booking-card,
.inline-chat,
.hero,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.hero,
.card {
  box-shadow: var(--shadow-soft);
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 28px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  position: sticky;
  top: 0;
  z-index: 2;
  border-color: rgba(198, 211, 224, 0.78);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 26px rgba(31, 41, 55, 0.08);
  backdrop-filter: blur(14px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: var(--surface);
  font-size: 20px;
  font-weight: 950;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.24);
}

.app-label,
.section-kicker,
.status-label,
.eyebrow {
  color: #23615d;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.eyebrow {
  color: #2451a6;
  font-size: 12px;
}

h1 {
  margin-top: 3px;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0;
}

.hero h1 {
  margin-top: 6px;
  font-size: clamp(34px, 6vw, 56px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-top: 4px;
  color: #111827;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 720px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid #c8d5ea;
  border-radius: 999px;
  background: #f5f8ff;
  color: #2451a6;
  font-weight: 750;
}

.badge-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 5px rgba(22, 163, 74, 0.12);
}

.account-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  color: #42526b;
  font-weight: 750;
}

#accountInfo {
  overflow-wrap: anywhere;
}

.account-panel.compact {
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: 220px;
  font-size: 12px;
  text-align: right;
}

.primary-button,
.secondary-button,
.send-button,
.replay-button,
.table-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 850;
}

.primary-button {
  background: var(--primary);
  color: var(--surface);
  box-shadow: 0 10px 22px rgba(36, 81, 166, 0.24);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--primary);
  box-shadow: none;
}

.send-button {
  min-height: 50px;
  background: var(--primary);
  color: var(--surface);
}

.primary-button:hover,
.send-button:hover {
  background: var(--primary-strong);
  box-shadow: 0 12px 24px rgba(36, 81, 166, 0.28);
}

.secondary-button:hover,
.table-button:hover,
.control-button:hover {
  border-color: #9fb4cd;
  background: #f5f8ff;
  transform: translateY(-1px);
}

.voice-panel,
.chat-stage {
  position: relative;
  display: grid;
  justify-items: stretch;
  gap: 14px;
  padding: 16px;
  border-color: rgba(176, 205, 198, 0.88);
  background: linear-gradient(180deg, #ffffff 0%, #f7fbfa 100%);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.voice-panel > *,
.chat-stage > * {
  position: relative;
  z-index: 1;
}

.chat-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, rgba(15, 118, 110, 0.08), transparent 42%),
    linear-gradient(245deg, rgba(36, 81, 166, 0.08), transparent 46%);
  pointer-events: none;
}

.chat-stage {
  height: calc(100vh - 182px);
  min-height: 560px;
  max-height: 780px;
  grid-template-rows: auto auto minmax(140px, 1fr) auto auto auto;
}

.chat-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.assistant-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #cce3dc;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #16665d;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.assistant-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

.session-toolbar {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #dbe5ee;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.session-toolbar label {
  grid-column: 1 / -1;
  grid-row: 1;
  color: #496174;
  font-size: 12px;
  font-weight: 850;
}

.session-toolbar .secondary-button {
  grid-column: 1;
  grid-row: 2;
  white-space: nowrap;
}

.session-toolbar select {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid #cfdce8;
  border-radius: 8px;
  background:
    linear-gradient(45deg, transparent 50%, #52627a 50%) right 16px top 18px / 6px 6px no-repeat,
    linear-gradient(135deg, #52627a 50%, transparent 50%) right 10px top 18px / 6px 6px no-repeat,
    var(--surface);
  color: #1f2937;
  font-size: 14px;
  font-weight: 750;
  appearance: none;
}

.status-text {
  min-height: 0;
  padding: 10px 12px;
  border: 1px solid #d8e6e2;
  border-radius: 8px;
  background: rgba(248, 251, 250, 0.92);
  color: #24423e;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.4;
}

.admin-shell > .status-text {
  min-height: 0;
  font-size: 16px;
}

.voice-panel h2,
.chat-stage h2 {
  margin-top: 4px;
  font-size: 26px;
  line-height: 1.12;
}

.prompt-copy {
  color: #415168;
  font-size: 16px;
  line-height: 1.45;
}

.prompt-block {
  display: grid;
  gap: 5px;
}

.voice-controls {
  display: grid;
  grid-template-columns: 74px minmax(128px, 1fr) 74px;
  gap: 12px;
  align-items: end;
  justify-items: center;
  padding: 12px 8px 8px;
  border: 1px solid #dbe5ee;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.control-button {
  display: grid;
  place-items: center;
  gap: 4px;
  min-width: 0;
  border: 1px solid #d0dce8;
  border-radius: 8px;
  background: #f7fafc;
  color: #37516f;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
}

.side-control {
  width: 74px;
  min-height: 56px;
  padding: 6px 8px;
}

.control-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 22px;
  border-radius: 999px;
  background: #eef5fb;
  color: var(--primary);
  font-size: 12px;
  font-weight: 950;
}

.control-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #16665d;
}

.mic-button {
  width: 132px;
  min-height: 132px;
  margin: 0;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 16px;
  border-radius: 999px;
  border: 6px solid #e7f7f2;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, transparent 42%),
    var(--accent);
  color: var(--surface);
  box-shadow:
    0 18px 34px rgba(15, 118, 110, 0.28),
    0 0 0 1px rgba(10, 94, 88, 0.12);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.mic-button:active {
  transform: translateY(1px) scale(0.99);
}

.mic-button:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 42%),
    var(--accent-strong);
  box-shadow:
    0 20px 38px rgba(15, 118, 110, 0.32),
    0 0 0 1px rgba(10, 94, 88, 0.14);
}

.mic-button.recording {
  border-color: #fee4e2;
  background: var(--danger);
  box-shadow: 0 14px 26px rgba(180, 35, 24, 0.24);
  animation: micPulse 1.2s ease-in-out infinite;
}

.mic-symbol {
  position: relative;
  width: 26px;
  height: 38px;
  border: 4px solid currentColor;
  border-radius: 20px;
}

.mic-symbol::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -16px;
  width: 42px;
  height: 23px;
  border: 4px solid currentColor;
  border-top: 0;
  border-radius: 0 0 24px 24px;
  transform: translateX(-50%);
}

.mic-symbol::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -29px;
  width: 30px;
  height: 4px;
  border-radius: 99px;
  background: currentColor;
  transform: translateX(-50%);
}

.mic-text {
  margin-top: 24px;
  font-size: 18px;
  font-weight: 850;
}

.chat-label,
dt {
  color: #516176;
  font-size: 14px;
  font-weight: 800;
}

.chat-form {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #d8e4ee;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.chat-form label {
  color: #1f2937;
  font-size: 16px;
  font-weight: 800;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

#chatInput,
.auth-card input {
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #bfccd9;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  font-size: 16px;
}

.auth-card input {
  min-height: 44px;
  border-width: 1px;
  border-radius: 12px;
}

#chatInput:focus,
.auth-card input:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.16);
  outline: none;
}

.trip-card,
.booking-card,
.inline-chat,
.card {
  padding: 16px;
}

.card {
  padding: 20px;
}

.section-heading,
.card-heading {
  display: grid;
  gap: 3px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.state-list,
.booking-details dl {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  border: 0;
}

.state-list div,
.booking-details dl div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid #e0e8ef;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

dd {
  color: #111827;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.state-confirmed {
  color: var(--success);
}

.empty-state {
  margin-top: 14px;
  padding: 14px;
  border: 2px dashed #aebdcb;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  color: #415168;
  font-size: 17px;
  line-height: 1.5;
}

.booking-details {
  margin-top: 14px;
}

.booking-id {
  display: block;
  padding: 14px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: #166534;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}

#chatLog {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  margin-top: 0;
  padding: 14px;
  border: 1px solid #d5e2ed;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 251, 253, 0.96)),
    #f8fbfd;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#chatLog::-webkit-scrollbar {
  width: 10px;
}

#chatLog::-webkit-scrollbar-track {
  background: transparent;
}

#chatLog::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: #bdcddd;
  background-clip: content-box;
}

#chatLog:empty::before {
  content: "Nói nơi bạn muốn đi hoặc bấm Nhập để gõ yêu cầu.";
  align-self: center;
  width: min(100%, 260px);
  margin: auto;
  padding: 16px;
  border: 1px dashed #c6d7e3;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.45;
  text-align: center;
}

.chat-message {
  width: fit-content;
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 16px;
  line-height: 1.45;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.07);
}

.chat-message.user {
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, var(--primary), #1f6ab0);
  color: var(--surface);
}

.chat-message.assistant {
  align-self: flex-start;
  border: 1px solid #d8e1eb;
  border-bottom-left-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.chat-message p {
  overflow-wrap: anywhere;
}

.replay-button {
  display: block;
  min-height: 44px;
  margin-top: 10px;
  border: 1px solid #a7d2ca;
  background: #ecfdf5;
  color: #16665d;
  font-size: 15px;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.auth-card {
  display: grid;
  gap: 14px;
  min-height: 100%;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: #42526b;
  font-weight: 750;
}

.form-status {
  min-height: 22px;
  color: #42526b;
  line-height: 1.45;
}

.page-status {
  min-height: 0;
  padding: 0 4px;
  font-weight: 750;
}

.form-status.success {
  color: var(--success);
}

.form-status.error {
  color: var(--danger);
}

.admin-card {
  display: grid;
  gap: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: #536176;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #f8fafc;
}

tbody tr:hover {
  background: #f9fbff;
}

.table-button {
  min-height: 32px;
  margin: 0 6px 6px 0;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #f5f8ff;
  color: var(--primary);
  box-shadow: none;
  font-size: 13px;
}

.empty-table-cell {
  color: #65748b;
  text-align: center;
}

@keyframes micPulse {
  0%,
  100% {
    box-shadow: 0 14px 26px rgba(180, 35, 24, 0.24);
  }

  50% {
    box-shadow:
      0 14px 26px rgba(180, 35, 24, 0.24),
      0 0 0 10px rgba(180, 35, 24, 0.12);
  }
}

@media (min-width: 430px) {
  .input-row {
    grid-template-columns: 1fr auto;
  }
}

@media (min-width: 760px) {
  body {
    padding: 24px 0;
  }

  .booking-shell {
    min-height: calc(100vh - 48px);
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    box-shadow: var(--shadow-lift);
  }

  .chat-stage {
    grid-template-rows: auto auto minmax(220px, 1fr) auto auto auto;
  }
}

@media (max-width: 759px) {
  .chat-stage:has(#chatForm:not([hidden])) {
    height: auto;
    max-height: none;
  }
}

@media (min-width: 960px) {
  .booking-shell {
    width: min(1180px, calc(100% - 48px));
    grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
    align-items: start;
    padding: 14px;
  }

  .booking-shell .top-bar {
    grid-column: 1 / -1;
  }

  .booking-shell .chat-stage {
    grid-column: 1;
    grid-row: span 2;
    height: calc(100vh - 144px);
    min-height: 620px;
    max-height: 840px;
  }

  .booking-shell .trip-card,
  .booking-shell .booking-card {
    grid-column: 2;
  }
}

@media (max-height: 700px) {
  .chat-stage {
    min-height: 500px;
  }
}

@media (max-width: 900px) {
  .auth-shell,
  .admin-shell {
    padding: 16px;
  }

  .hero,
  .card-heading {
    flex-direction: column;
  }

  .auth-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .top-bar {
    align-items: flex-start;
  }

  .account-panel.compact {
    max-width: 180px;
  }
}

@media (max-width: 430px) {
  .chat-heading {
    flex-direction: column;
  }

  .assistant-pill {
    align-self: flex-start;
  }

  .session-toolbar {
    grid-template-columns: 1fr;
  }

  .session-toolbar label,
  .session-toolbar .secondary-button,
  .session-toolbar select {
    grid-column: 1;
    grid-row: auto;
  }

  .chat-message {
    max-width: 96%;
  }
}

@media (max-width: 380px) {
  .voice-controls {
    grid-template-columns: 66px minmax(116px, 1fr) 66px;
    gap: 9px;
    padding-inline: 6px;
  }

  .side-control {
    width: 66px;
    min-height: 52px;
    font-size: 12px;
  }

  .mic-button {
    width: 118px;
    min-height: 118px;
    padding: 14px;
  }

  .voice-panel h2,
  .chat-stage h2 {
    font-size: 24px;
  }

  .state-list div,
  .booking-details dl div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
