:root {
  --bg: #f4f5f8;
  --panel: #ffffff;
  --ink: #19202c;
  --muted: #5f6878;
  --line: #e5e8ef;
  --primary: #0f2f51;
  --primary-soft: #1f4f82;
  --accent: #c9a76a;
  --success: #16784d;
  --warning: #b98920;
  --danger: #b82e32;
  --shadow-soft: 0 14px 38px rgba(17, 34, 60, 0.08);
  --shadow-deep: 0 22px 50px rgba(5, 16, 30, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "Sarabun", sans-serif;
  background: linear-gradient(180deg, #f7f8fb 0%, #f0f2f7 100%);
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
  font-family: "Kanit", sans-serif;
  letter-spacing: 0.01em;
}

a {
  text-decoration: none;
}

.page-bg-art {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(0.5px);
}

.orb-one {
  width: 380px;
  height: 380px;
  left: -120px;
  top: -120px;
  background: radial-gradient(circle at 30% 30%, rgba(15, 47, 81, 0.18), rgba(15, 47, 81, 0));
}

.orb-two {
  width: 420px;
  height: 420px;
  right: -130px;
  top: 8%;
  background: radial-gradient(circle at 50% 50%, rgba(201, 167, 106, 0.2), rgba(201, 167, 106, 0));
}

.orb-three {
  width: 360px;
  height: 360px;
  right: 15%;
  bottom: -110px;
  background: radial-gradient(circle at 50% 50%, rgba(31, 79, 130, 0.16), rgba(31, 79, 130, 0));
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 290px;
  flex: 0 0 290px;
  color: #fff;
  padding: 1.1rem 0.95rem 0.85rem;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(190deg, #12273f 0%, #0c1d31 52%, #081525 100%);
  box-shadow: var(--shadow-deep);
}

.sidebar-brand {
  padding: 0.4rem 0.5rem 1rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
}

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

.brand-subtitle {
  margin-top: 0.52rem;
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.75);
}

.sidebar-scroll {
  overflow: auto;
  padding-right: 0.2rem;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 8px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.26rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  padding: 0.68rem 0.75rem;
  border-radius: 0.8rem;
  color: rgba(255, 255, 255, 0.88);
  transition: all 0.18s ease;
  font-size: 0.96rem;
  font-weight: 500;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-link.active {
  color: #fff;
  background: linear-gradient(100deg, rgba(31, 79, 130, 0.98), rgba(18, 39, 63, 0.95));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.sidebar-icon {
  width: 1.8rem;
  height: 1.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.97rem;
}

.sidebar-link.active .sidebar-icon {
  background: rgba(255, 255, 255, 0.22);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer .navbar-nav {
  width: 100%;
}

.sidebar-footer .nav-item {
  width: 100%;
}

.sidebar-footer .btn {
  width: 100%;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.main-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 0.95rem;
  background: linear-gradient(100deg, #0e2742, #1d4b79);
  color: #fff;
  box-shadow: 0 5px 20px rgba(9, 19, 36, 0.3);
}

.mobile-title {
  font-weight: 700;
  font-size: 1.08rem;
}

.btn-mobile-menu {
  border: 1px solid rgba(255, 255, 255, 0.46);
  color: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
}

.btn-mobile-menu:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.content-wrapper {
  padding: 1.3rem 1.35rem;
  flex: 1;
}

.footer {
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
}

.mobile-sidebar {
  background: linear-gradient(180deg, #f8f9fc, #f0f3f8);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.05rem;
  box-shadow: var(--shadow-soft);
}

.card-header {
  border-bottom: 1px solid var(--line);
  background: #f7f9fc;
}

.table > :not(caption) > * > * {
  border-bottom-color: #edf1f6;
}

.table thead th {
  color: #3c4a5f;
  font-size: 0.86rem;
  font-weight: 700;
}

.table tbody td {
  font-size: 0.92rem;
}

.btn-primary {
  border: none;
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
}

.btn-primary:hover,
.btn-primary:focus {
  filter: brightness(1.05);
}

.dashboard-hero {
  border: 0;
  overflow: hidden;
  background: linear-gradient(120deg, #102b47, #1f4f82 58%, #2e649d);
  color: #fff;
}

.dashboard-hero .card-body {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.hero-kicker {
  display: inline-block;
  margin-bottom: 0.55rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

.hero-text {
  max-width: 700px;
}

.hero-art {
  width: 170px;
  min-width: 170px;
}

.hero-art img {
  width: 100%;
  height: auto;
  display: block;
}

.hero-filter {
  margin-top: 0.85rem;
}

.hero-filter .form-label {
  color: rgba(255, 255, 255, 0.9);
}

.hero-filter .form-control {
  border: 0;
  border-radius: 0.7rem;
}

.stat-card {
  border: 0;
  color: #fff;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.88);
}

.stat-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 0.62rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
}

.stat-value {
  margin-top: 0.55rem;
  font-family: "Kanit", sans-serif;
  font-size: 2.05rem;
  line-height: 1;
}

.stat-primary {
  background: linear-gradient(145deg, #1b3f66, #275f96);
}

.stat-success {
  background: linear-gradient(145deg, #127a4f, #19a168);
}

.stat-danger {
  background: linear-gradient(145deg, #a73035, #cc4b50);
}

.stat-info {
  background: linear-gradient(145deg, #116a8c, #1f8db8);
}

.stat-secondary {
  background: linear-gradient(145deg, #4b5773, #64759c);
}

.stat-warning {
  background: linear-gradient(145deg, #a47612, #ce9520);
}

.scan-wrapper {
  max-width: 860px;
  margin: 0 auto;
}

.scan-hero {
  background: linear-gradient(120deg, #112c48, #17406a 58%, #23639f);
  color: #fff;
}

.scan-hero .card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.scan-hero-mark {
  width: 68px;
  height: 68px;
  opacity: 0.9;
}

.scan-card {
  border-radius: 1.15rem;
}

.matching-status-card {
  display: flex;
  align-items: flex-start;
  gap: 0.72rem;
  padding: 0.72rem 0.85rem;
  border-radius: 0.82rem;
  border: 1px solid #d6deeb;
  background: #f8fbff;
}

.matching-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  margin-top: 0.3rem;
  background: #8da1b9;
  box-shadow: 0 0 0 5px rgba(141, 161, 185, 0.18);
}

.matching-main {
  font-weight: 700;
  line-height: 1.25;
}

.matching-sub {
  margin-top: 0.18rem;
  font-size: 0.89rem;
  color: #5c6d83;
}

.matching-state-idle {
  border-color: #d6deeb;
  background: #f8fbff;
}

.matching-state-track {
  border-color: #a5c2e1;
  background: #eff6ff;
}

.matching-state-ready {
  border-color: #91dfae;
  background: #ecfff2;
}

.matching-state-capture,
.matching-state-matching {
  border-color: #f2d28b;
  background: #fff9ea;
}

.matching-state-success {
  border-color: #95ddae;
  background: #ebfff2;
}

.matching-state-warn {
  border-color: #f1c77b;
  background: #fff8ea;
}

.matching-state-error {
  border-color: #efabab;
  background: #fff1f1;
}

.matching-state-track .matching-dot {
  background: #2a72b8;
  box-shadow: 0 0 0 5px rgba(42, 114, 184, 0.18);
}

.matching-state-ready .matching-dot,
.matching-state-success .matching-dot {
  background: #1f9d57;
  box-shadow: 0 0 0 5px rgba(31, 157, 87, 0.18);
}

.matching-state-capture .matching-dot,
.matching-state-matching .matching-dot,
.matching-state-warn .matching-dot {
  background: #cc9627;
  box-shadow: 0 0 0 5px rgba(204, 150, 39, 0.18);
}

.matching-state-error .matching-dot {
  background: #cb3d41;
  box-shadow: 0 0 0 5px rgba(203, 61, 65, 0.18);
}

.video-shell {
  background: #0e1826;
  border-radius: 1rem;
  overflow: hidden;
  min-height: 340px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
}

#video {
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: cover;
}

#overlayCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.live-name-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.72rem;
  border-radius: 999px;
  background: rgba(12, 23, 37, 0.82);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
}

.scan-clock {
  font-family: "Kanit", sans-serif;
  font-size: 1.07rem;
}

.scan-actions .btn {
  border-radius: 0.85rem;
  font-weight: 600;
}

.auth-shell {
  max-width: 880px;
  margin: 0 auto;
}

.auth-card {
  border: 0;
  overflow: hidden;
}

.auth-head {
  background: linear-gradient(115deg, #102b47, #1b4a79);
  color: #fff;
  padding: 1.35rem 1.35rem 1rem;
}

.auth-head h3 {
  margin-bottom: 0.35rem;
}

.auth-body {
  padding: 1.2rem 1.3rem 1.3rem;
}

@media (max-width: 1200px) {
  .hero-art {
    width: 145px;
    min-width: 145px;
  }
}

@media (max-width: 991.98px) {
  .content-wrapper {
    padding: 0.9rem 0.8rem;
  }

  .dashboard-hero .card-body {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-art {
    width: 130px;
    min-width: 130px;
  }

  .scan-hero .card-body {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 767px) {
  .scan-wrapper .btn-lg {
    font-size: 1rem;
    padding: 0.78rem 0.4rem;
  }

  .video-shell {
    min-height: 260px;
  }
}
