:root {
  --brand: #3b82f6;
  --brand-dark: #2563eb;
  --brand-light: #93c5fd;
  --pastel-1: #eff6ff;
  --pastel-2: #dbeafe;
  --pastel-3: #bfdbfe;
  --bg: #f6faff;
  --border-soft: #e3ecfb;
  --text-navy: #1e3a5f;
  --card-radius: 16px;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  font-family: "Prompt", "Segoe UI", "Noto Sans Thai", system-ui, sans-serif;
  color: #334155;
}

/* Topbar (mobile only) */
.app-topbar {
  background: #ffffff;
  color: var(--brand-dark);
  padding: 0.6rem 1rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  border-bottom: 1px solid var(--border-soft);
}
.app-topbar .btn-icon { background: transparent; border: none; color: #64748b; }
.app-topbar span { color: #1e293b; }

.app-wrapper {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background: #ffffff;
  color: #334155;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-soft);
}
.app-sidebar .sidebar-brand { border-bottom: 1px solid var(--border-soft); color: var(--brand-dark); }
.app-sidebar .sidebar-user { border-bottom: 1px solid var(--border-soft); padding-bottom: 1rem; margin-bottom: .5rem; color: #1e293b; }
.app-sidebar .sidebar-user .text-white-50 { color: #94a3b8 !important; }
.app-sidebar .btn-close { filter: none; }
.sidebar-nav .nav-link {
  color: #475569;
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
}
.sidebar-nav .nav-link:hover { background: var(--pastel-1); color: var(--brand-dark); }
.sidebar-nav .nav-link.active { background: var(--pastel-2); color: var(--brand-dark); font-weight: 600; }

/* Content */
.app-content { flex: 1; min-width: 0; }
.content-inner { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

.page-header { margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; color: #1e293b; }
.page-header p { color: #64748b; margin: 0.15rem 0 0; }

.stat-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--card-radius);
  padding: 1.25rem 1.4rem;
  color: #1e293b;
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.08);
}
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; color: var(--text-navy); }
.stat-card .stat-label { font-size: 0.9rem; color: #64748b; }
.stat-card .stat-icon {
  font-size: 1.4rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  flex-shrink: 0;
}
.stat-card.bg-brand-1 .stat-icon { background: var(--pastel-1); color: #3b82f6; }
.stat-card.bg-brand-2 .stat-icon { background: var(--pastel-2); color: #0ea5e9; }
.stat-card.bg-brand-3 .stat-icon { background: var(--pastel-3); color: #2563eb; }
.stat-card.bg-brand-4 .stat-icon { background: #e0e7ff; color: #4f46e5; }

.card {
  border: 1px solid var(--border-soft);
  border-radius: var(--card-radius);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.06);
}
.card-header { background: #ffffff; border-bottom: 1px solid var(--border-soft); border-radius: var(--card-radius) var(--card-radius) 0 0 !important; font-weight: 600; color: #1e293b; }

.table thead th { white-space: nowrap; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.02em; color: #64748b; border-bottom-width: 1px; background: var(--pastel-1); }
.table td, .table th { vertical-align: middle; }
.table-responsive { border-radius: 0 0 var(--card-radius) var(--card-radius); }
.table-hover > tbody > tr:hover > * { background-color: var(--pastel-1); }

.badge-status-ok { background: #10b981; }
.badge-status-pending { background: #f59e0b; }

.attendance-cell.present { color: #10b981; }
.attendance-cell.absent { color: #ef4444; }

.btn-brand { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); border: none; color: #fff; }
.btn-brand:hover { color: #fff; filter: brightness(1.05); }

.btn-outline-primary { --bs-btn-color: var(--brand-dark); --bs-btn-border-color: var(--brand-light); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }

/* ปุ่มไอคอนไม่มีกรอบ (เช่น แก้ไข/ลบ/รีเซ็ตในตาราง) */
.btn-borderless {
  --bs-btn-border-color: transparent;
  --bs-btn-bg: transparent;
  --bs-btn-active-border-color: transparent;
}
.btn-borderless.btn-outline-primary { --bs-btn-hover-bg: var(--pastel-1); --bs-btn-hover-color: var(--brand-dark); --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: var(--pastel-2); }
.btn-borderless.btn-outline-danger { --bs-btn-hover-bg: #fee2e2; --bs-btn-hover-color: #dc2626; --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: #fecaca; }
.btn-borderless.btn-outline-warning { --bs-btn-hover-bg: #fef3c7; --bs-btn-hover-color: #b45309; --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: #fde68a; }
.btn-borderless.btn-outline-secondary { --bs-btn-hover-bg: #f1f5f9; --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: #e2e8f0; }
.btn-borderless:disabled { --bs-btn-disabled-border-color: transparent; --bs-btn-disabled-bg: transparent; }

.progress { background-color: var(--pastel-1); }

/* ฟอร์มโค้งมนแบบทันสมัย */
.form-control,
.form-select {
  border-radius: 50rem;
  border: 1.5px solid var(--border-soft);
  padding: 0.55rem 1.25rem;
  background-color: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control::placeholder { color: #94a3b8; }
.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}
textarea.form-control { border-radius: 20px; }
.form-check-input { border-radius: 6px; border: 1.5px solid var(--brand-light); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); }
.form-label { font-weight: 600; color: #1e293b; font-size: 0.92rem; }
.form-text { font-size: 0.8rem; }

/* ปุ่มโค้งมนแบบ pill ทั้งระบบ (ปุ่มไอคอนสี่เหลี่ยมจัตุรัสจะกลายเป็นวงกลมโดยอัตโนมัติ) */
.btn { border-radius: 50rem; font-weight: 500; }
.modal-footer .btn { padding: 0.55rem 1.75rem; }
.btn-secondary { --bs-btn-bg: #fff; --bs-btn-color: #475569; --bs-btn-border-color: var(--border-soft); --bs-btn-hover-bg: #f1f5f9; --bs-btn-hover-color: #1e293b; --bs-btn-hover-border-color: var(--border-soft); }

/* Popup/Modal แบบทันสมัย: มุมโค้งมาก เงานุ่ม ไม่มีเส้นขอบหนักๆ */
.modal-dialog {
  height: calc(100% - 2rem);
  max-height: calc(100% - 2rem);
  display: flex;
  align-items: center;
}
.modal-content {
  border: none;
  border-radius: 26px;
  box-shadow: 0 24px 60px rgba(30, 58, 95, 0.25);
  width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  border-bottom: none;
  padding: 1.5rem 1.75rem 0.25rem;
}
.modal-title { font-weight: 700; font-size: 1.3rem; color: #1e293b; }
.modal-body {
  padding: 1rem 1.75rem;
  min-height: 0;
  overflow-y: auto;
}
.modal-footer {
  border-top: none;
  padding: 0.75rem 1.75rem 1.75rem;
}
.modal-backdrop.show { opacity: 0.45; }
.btn-close { box-shadow: none !important; opacity: 0.5; }
.btn-close:hover { opacity: 0.8; }

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eff6ff, #bfdbfe);
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  border-radius: 20px;
  padding: 2rem;
  background: #fff;
  box-shadow: 0 12px 32px rgba(59, 130, 246, 0.18);
}

@media (max-width: 991.98px) {
  .app-sidebar { width: 260px; }
  .content-inner { padding: 1rem; }
}

/* จอ >= lg: ปักหมุด sidebar ไว้กับหน้าจอ ไม่ยืดตามความสูงของเนื้อหา
   เพื่อให้เมนู "ออกจากระบบ" ที่อยู่ล่างสุดมองเห็นได้เสมอแม้เนื้อหาหลักจะยาวแค่ไหนก็ตาม */
@media (min-width: 992px) {
  .app-sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
  }
}

/* 2026 visual refresh */
:root {
  --brand: #1677ff;
  --brand-dark: #0757c8;
  --brand-light: #85b8ff;
  --accent: #14b8a6;
  --warning: #f59e0b;
  --bg: #f4f7fb;
  --border-soft: #e5ebf3;
  --text-navy: #102a43;
  --card-radius: 20px;
  --sidebar-width: 276px;
}

html { scroll-behavior: smooth; }

body {
  color: #334e68;
  background:
    radial-gradient(circle at 78% 0%, rgba(22,119,255,.08), transparent 28rem),
    var(--bg);
  line-height: 1.65;
  overflow-x: hidden;
}

a { text-underline-offset: 3px; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 2000;
  padding: .65rem 1rem;
  color: #fff;
  background: #102a43;
  border-radius: 12px;
}
.skip-link:focus { top: 1rem; }

.app-sidebar {
  overflow-x: hidden;
  overflow-y: auto;
  color: #dbeafe;
  background:
    radial-gradient(circle at 20% 0%, rgba(56,189,248,.25), transparent 15rem),
    linear-gradient(180deg, #102d58 0%, #0a1f3e 100%);
  border-right: 0;
  box-shadow: 12px 0 35px rgba(15,42,75,.08);
}

.app-sidebar::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -90px;
  bottom: 4rem;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 50%;
  box-shadow: 0 0 0 32px rgba(255,255,255,.025), 0 0 0 64px rgba(255,255,255,.02);
  pointer-events: none;
}

.app-sidebar .sidebar-brand {
  position: relative;
  z-index: 1;
  min-height: 78px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.app-sidebar .sidebar-brand i {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #0a3c6d;
  background: linear-gradient(135deg, #fff, #bae6fd);
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(2,132,199,.25);
}

.brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(0,0,0,.22));
}

.topbar-logo {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(15,42,75,.18));
}

.app-sidebar .sidebar-user {
  position: relative;
  z-index: 1;
  margin: .75rem .75rem .4rem;
  padding: .9rem 1rem !important;
  color: #fff;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 14px;
}
.app-sidebar .sidebar-user .text-white-50 { color: #a9c7e8 !important; }

.sidebar-nav {
  position: relative;
  z-index: 1;
  padding-top: .4rem;
}

.sidebar-nav .nav-link {
  min-height: 46px;
  padding: .68rem .9rem;
  color: #bad0e8;
  border: 1px solid transparent;
  border-radius: 13px;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.sidebar-nav .nav-link i {
  width: 24px;
  color: #7dd3fc;
  font-size: 1.08rem;
  text-align: center;
}
.sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
  transform: translateX(2px);
}
.sidebar-nav .nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(14,165,233,.95), rgba(37,99,235,.95));
  box-shadow: 0 10px 24px rgba(2,132,199,.25);
}
.sidebar-nav .nav-link.active i { color: #fff; }
.app-sidebar .text-muted { color: #7393b7 !important; }
.app-sidebar .btn-outline-danger {
  position: relative;
  z-index: 1;
  color: #fecaca;
  border-color: rgba(254,202,202,.35);
}
.app-sidebar .btn-outline-danger:hover { color: #fff; background: #dc2626; }

.app-content { min-height: 100vh; }
.content-inner { padding: 2rem clamp(1rem, 2.5vw, 2.5rem); }

.page-header { margin-bottom: 1.15rem; }
.page-header h1 { font-size: clamp(1.35rem, 2vw, 1.75rem); color: var(--text-navy); }
.page-header p { color: #7b8fa6; }
.trip-hero + .page-header { display: none !important; }

.trip-hero {
  position: relative;
  min-height: 330px;
  overflow: hidden;
  color: #fff;
  background-color: #0b69c7;
  background-image:
    linear-gradient(90deg, rgba(6,49,102,.98) 0%, rgba(7,78,148,.88) 34%, rgba(11,105,199,.25) 66%, rgba(11,105,199,.08) 100%),
    url("../images/trip-hero.jpg");
  background-position: center, center;
  background-size: cover;
  border-radius: 28px;
  box-shadow: 0 22px 48px rgba(7,75,146,.2);
}

.trip-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: inherit;
  pointer-events: none;
}

.trip-hero-content {
  position: relative;
  z-index: 1;
  width: min(650px, 68%);
  padding: clamp(2rem, 4vw, 3.3rem);
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .8rem;
  padding: .38rem .75rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.trip-hero h1 {
  max-width: 620px;
  margin: 0 0 .55rem;
  color: #fff;
  font-size: clamp(1.8rem, 3vw, 2.75rem);
  font-weight: 700;
  line-height: 1.25;
  text-shadow: 0 2px 16px rgba(0,32,80,.2);
}
.trip-hero p {
  max-width: 570px;
  margin-bottom: 1.1rem;
  color: #dceeff;
  font-size: .98rem;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}
.hero-meta span {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .42rem .68rem;
  color: #eef8ff;
  font-size: .78rem;
  background: rgba(2,34,75,.3);
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 10px;
}
.hero-actions { display: flex; gap: .65rem; margin-top: 1.25rem; }
.hero-actions .btn { padding: .55rem 1rem; font-size: .88rem; }
.btn-hero-outline {
  color: #fff;
  border: 1px solid rgba(255,255,255,.48);
  background: rgba(255,255,255,.08);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.btn-hero-outline:hover { color: #0b5bb1; background: #fff; }

.trip-hero-progress {
  position: absolute;
  z-index: 2;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 220px;
  padding: .8rem 1rem;
  color: #fff;
  background: rgba(5,38,75,.72);
  border: 1px solid rgba(255,255,255,.17);
  border-radius: 15px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.trip-hero-progress > div:first-child { display: flex; justify-content: space-between; font-size: .78rem; }
.trip-hero-progress .progress { height: 6px; margin-top: .5rem; background: rgba(255,255,255,.2); }
.trip-hero-progress .progress-bar { background: linear-gradient(90deg, #2dd4bf, #a7f3d0); }

.card, .stat-card {
  border-color: rgba(218,228,240,.9);
  box-shadow: 0 10px 28px rgba(30,64,105,.07);
}
.card {
  overflow: hidden;
  background: rgba(255,255,255,.92);
}
.card-header {
  padding: 1rem 1.2rem;
  color: var(--text-navy);
  background: rgba(255,255,255,.96);
}
.card-body { padding: 1.25rem; }

.stat-card {
  position: relative;
  min-height: 136px;
  overflow: hidden;
  padding: 1.25rem;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 15px 34px rgba(30,64,105,.12); }
.stat-card::before {
  content: "";
  position: absolute;
  width: 90px;
  height: 90px;
  right: -34px;
  top: -34px;
  background: currentColor;
  border-radius: 50%;
  opacity: .035;
}
.stat-card .stat-value { font-size: clamp(1.55rem, 2.4vw, 2rem); letter-spacing: -.03em; }
.stat-card .stat-label { max-width: 210px; line-height: 1.5; }
.stat-card .stat-icon { width: 56px; height: 56px; border-radius: 18px; }
.stat-card.bg-brand-1 .stat-icon { color: #1677ff; background: #eaf3ff; }
.stat-card.bg-brand-2 .stat-icon { color: #0891b2; background: #e6faff; }
.stat-card.bg-brand-3 .stat-icon { color: #0f9f87; background: #e7faf6; }
.stat-card.bg-brand-4 .stat-icon { color: #7c3aed; background: #f1ebff; }

.table { --bs-table-color: #334e68; }
.table thead th {
  padding: .9rem .85rem;
  color: #60758d;
  font-size: .78rem;
  background: #f7f9fc;
  border-color: #e7edf5;
}
.table tbody td { padding: .82rem .85rem; border-color: #edf1f6; }
.table-hover > tbody > tr:hover > * { background-color: #f0f7ff; }
.badge { padding: .42em .7em; font-weight: 500; border-radius: 999px; }

.btn { transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-brand { box-shadow: 0 8px 18px rgba(22,119,255,.22); }
.btn-brand:hover { box-shadow: 0 10px 22px rgba(22,119,255,.3); }

.form-control, .form-select {
  min-height: 46px;
  border-color: #dce5ef;
  box-shadow: 0 1px 2px rgba(30,64,105,.03);
}

.login-wrapper {
  position: relative;
  justify-content: flex-end;
  overflow: hidden;
  padding: clamp(1rem, 6vw, 5rem);
  background-color: #0a4a8c;
  background-image:
    linear-gradient(90deg, rgba(5,47,94,.18), rgba(5,47,94,.35) 48%, rgba(5,47,94,.88) 72%),
    url("../images/trip-hero.jpg");
  background-position: center;
  background-size: cover;
}
.login-wrapper::before {
  content: "เรียนรู้ • เดินทาง • เติบโต";
  position: absolute;
  left: clamp(2rem, 7vw, 8rem);
  bottom: clamp(2rem, 7vw, 6rem);
  color: rgba(255,255,255,.9);
  font-size: clamp(1.25rem, 2.5vw, 2.5rem);
  font-weight: 600;
  text-shadow: 0 4px 20px rgba(0,36,80,.35);
}
.login-card {
  position: relative;
  z-index: 1;
  max-width: 430px;
  padding: clamp(1.75rem, 3vw, 2.5rem);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 26px;
  box-shadow: 0 28px 70px rgba(2,28,64,.3) !important;
}
.login-eyebrow {
  width: max-content;
  margin: 0 auto 1.25rem;
  padding: .38rem .72rem;
  color: var(--brand-dark);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  background: #eaf3ff;
  border-radius: 999px;
}
.login-card .bi-signpost-2-fill {
  display: inline-grid;
  width: 60px;
  height: 60px;
  place-items: center;
  color: #fff !important;
  font-size: 1.8rem !important;
  background: linear-gradient(135deg, #14b8a6, #1677ff);
  border-radius: 20px;
  box-shadow: 0 12px 25px rgba(22,119,255,.22);
}

.login-brand-logo {
  display: block;
  width: 92px;
  height: 92px;
  margin: 0 auto .75rem;
  object-fit: contain;
  filter: none;
}

/* Trip tracking */
.tracking-capture-card {
  border: 1px solid rgba(22,119,255,.18);
  background:
    radial-gradient(circle at 100% 0%, rgba(22,119,255,.08), transparent 20rem),
    rgba(255,255,255,.96);
}

.tracking-step {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--brand));
  border-radius: 9px;
}

.btn-location-check {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  color: #0757c8;
  font-weight: 600;
  background: #eaf3ff;
  border: 1.5px dashed #65a5f7;
  box-shadow: none;
}
.btn-location-check:hover {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}
.btn-location-check:disabled { color: #587a9e; background: #eef4fa; }

.gps-status {
  display: flex;
  min-height: 68px;
  align-items: center;
  gap: .8rem;
  padding: .75rem 1rem;
  color: #5f748a;
  background: #f6f8fb;
  border: 1px solid #e4ebf3;
  border-radius: 16px;
}
.gps-status-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  color: #6b8199;
  background: #fff;
  border-radius: 12px;
}
.gps-status strong, .gps-status small { display: block; }
.gps-status strong { color: #263f59; font-size: .88rem; }
.gps-status small { margin-top: .05rem; font-size: .75rem; }
.gps-status.is-success { color: #087b68; background: #ebfbf7; border-color: #b8eee3; }
.gps-status.is-success .gps-status-icon { color: #0f9f87; }
.gps-status.is-error { color: #b42318; background: #fff1f0; border-color: #ffd0cc; }
.gps-status.is-error .gps-status-icon { color: #dc2626; }
.gps-status.is-loading { color: #0757c8; background: #eef6ff; border-color: #c9e0ff; }
.gps-status.is-loading .gps-status-icon { color: var(--brand); }

.gps-spin { animation: gps-spin 1s linear infinite; }
@keyframes gps-spin { to { transform: rotate(360deg); } }

.location-input-group .input-group-text {
  padding-left: 1rem;
  color: var(--brand);
  background: #fff;
  border: 1.5px solid #dce5ef;
  border-right: 0;
  border-radius: 999px 0 0 999px;
}
.location-input-group .form-control {
  border-left: 0;
  border-radius: 0 999px 999px 0;
}
.location-input-group:focus-within .input-group-text {
  border-color: var(--brand);
}

.coordinate-preview {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 38px;
  color: #647b92;
  font-size: .85rem;
}

.tracking-field-col {
  align-self: flex-start;
}

#tripMap {
  width: 100%;
  height: 460px;
  background: #eaf0f6;
  z-index: 1;
}

#tripMap .leaflet-control-layers {
  overflow: hidden;
  font-family: "Prompt", sans-serif;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 5px 18px rgba(15,42,75,.18);
}

#tripMap .leaflet-control-layers-expanded {
  padding: .55rem .75rem;
}

#tripMap .leaflet-control-layers label {
  margin: .15rem 0;
  font-size: .78rem;
}

.trip-marker-wrapper {
  background: transparent;
  border: 0;
}

.trip-marker-pin {
  display: block;
  color: #f97316;
  font-size: 2.35rem;
  line-height: 1;
  text-align: center;
  -webkit-text-stroke: 1.5px #fff;
  filter: drop-shadow(0 4px 5px rgba(124,45,18,.38));
}

.map-popup { min-width: 160px; font-family: "Prompt", sans-serif; }
.map-popup strong, .map-popup span, .map-popup small { display: block; }
.map-popup strong { margin-bottom: .2rem; color: #173c63; }
.map-popup span { color: #61788f; font-size: .78rem; }
.map-popup small { margin-top: .35rem; color: #405c76; }

.map-load-error {
  display: grid;
  height: 100%;
  place-items: center;
  align-content: center;
  gap: .5rem;
  color: #71869c;
}
.map-load-error i { color: var(--warning); font-size: 2rem; }

.btn-coordinate {
  padding: .32rem .65rem;
  color: #0b65c7;
  font-size: .78rem;
  background: #eef6ff;
  border: 1px solid #d3e7ff;
  white-space: nowrap;
}
.btn-coordinate:hover { color: #fff; background: var(--brand); border-color: var(--brand); }

.btn-location-action {
  display: inline-grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 1rem;
  box-shadow: none;
  transition: transform .18s ease, color .18s ease;
}
.btn-location-action + .btn-location-action { margin-left: .3rem; }
.btn-location-action:hover {
  background: transparent;
  transform: translateY(-2px) scale(1.08);
  box-shadow: none;
}
.btn-location-action:active { transform: translateY(0); }
.btn-location-edit {
  color: #0757c8;
  background: transparent;
}
.btn-location-edit:hover {
  color: #1677ff;
  background: transparent;
}
.btn-location-delete {
  color: #dc2626;
  background: transparent;
}
.btn-location-delete:hover {
  color: #ef4444;
  background: transparent;
}

.tracking-table td { min-width: 130px; }
.tracking-table td:nth-child(2) { min-width: 230px; }
.tracking-table td:nth-child(4) { min-width: 180px; }

@media (max-width: 1199.98px) {
  .trip-hero-content { width: 73%; }
  .trip-hero { background-position: center, 58% center; }
}

@media (max-width: 991.98px) {
  .app-wrapper {
    display: block;
    width: 100%;
  }
  .app-content {
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1045;
    height: 100vh;
    margin: 0;
  }
  .app-topbar {
    min-height: 62px;
    padding-inline: 1rem;
    box-shadow: 0 5px 18px rgba(30,64,105,.07);
  }
  .app-sidebar { width: 276px; }
  .content-inner {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
  }
  .trip-hero { min-height: 370px; background-position: center, 62% center; }
  .trip-hero-content { width: 78%; }
  .login-wrapper { justify-content: center; background-position: 62% center; }
  .login-wrapper::before { display: none; }
}

@media (max-width: 767.98px) {
  .modal { padding: .5rem; }
  .modal-dialog {
    width: calc(100% - 1rem);
    max-width: none;
    height: calc(100% - 1rem);
    max-height: calc(100% - 1rem);
    margin: .5rem auto;
  }
  .modal-content {
    max-height: 100%;
    border-radius: 18px;
  }
  .modal-header { padding: 1rem 1.1rem .25rem; }
  .modal-title { font-size: 1.1rem; }
  .modal-body { padding: .85rem 1.1rem; }
  .modal-footer {
    padding: .7rem 1.1rem 1.1rem;
    flex-wrap: wrap;
  }
  .modal-footer .btn { flex: 1 1 140px; padding: .5rem 1rem; }
  .trip-hero {
    min-height: 460px;
    background-image:
      linear-gradient(180deg, rgba(5,47,94,.93) 0%, rgba(7,78,148,.82) 56%, rgba(11,105,199,.2) 100%),
      url("../images/trip-hero.jpg");
    background-position: center, 68% center;
    border-radius: 22px;
  }
  .trip-hero-content { width: 100%; padding: 1.5rem; }
  .trip-hero p { font-size: .9rem; }
  .trip-hero-progress { left: 1.5rem; right: 1.5rem; bottom: 1.25rem; width: auto; }
  .hero-actions { flex-wrap: wrap; }
  .stat-card { min-height: 122px; padding: 1rem; }
  .stat-card .stat-icon { width: 48px; height: 48px; }
  .card-header { padding: .9rem 1rem; }
  .login-wrapper {
    align-items: flex-end;
    padding: 1rem;
    background-image:
      linear-gradient(180deg, rgba(5,47,94,.15), rgba(5,47,94,.78)),
      url("../images/trip-hero.jpg");
  }
  .login-card { max-width: 100%; padding: 1.5rem; border-radius: 22px; }
  #tripMap { height: 360px; }
  .tracking-capture-card .card-body { padding: 1rem; }
  .gps-status { min-height: 62px; padding: .65rem .8rem; }
  .coordinate-preview { width: 100%; }
  #saveLocationBtn { width: 100%; min-height: 48px; }
}

@media (max-width: 575.98px) {
  .trip-hero { min-height: 500px; }
  .trip-hero h1 { font-size: 1.65rem; }
  .hero-meta { gap: .4rem; }
  .hero-meta span { font-size: .72rem; }
  .stat-card .stat-value { font-size: 1.35rem; }
  .stat-card .stat-label { font-size: .78rem; }
  .stat-card .stat-icon { width: 42px; height: 42px; font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* Student trip card preview and print layout */
.student-card-preview-wrap {
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow: auto;
  background: #eaf0f6;
}

.student-id-card {
  position: relative;
  width: min(330px, 100%);
  min-width: 320px;
  aspect-ratio: 11 / 17;
  overflow: hidden;
  color: #09245a;
  background-color: #d9f4ff;
  background-image: url("../images/student-card-background.png");
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border: 1px solid #356579;
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(15,42,75,.24);
  font-family: "Prompt", sans-serif;
  container-type: inline-size;
  isolation: isolate;
}

.student-id-card::after {
  content: none;
  position: absolute;
  z-index: 1;
  right: -22%;
  bottom: -7%;
  width: 78%;
  height: 31%;
  background: linear-gradient(145deg, transparent 0 29%, #f3fbff 30% 37%, #0871d0 38% 56%, #023e8a 57%);
  transform: rotate(-3deg);
}

.student-card-sky,
.student-card-mountains,
.student-card-landscape {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.student-card-cloud {
  position: absolute;
  width: 20cqw;
  height: 5.5cqw;
  background: rgba(255,255,255,.92);
  border-radius: 30px;
}
.student-card-cloud::before,
.student-card-cloud::after {
  content: "";
  position: absolute;
  bottom: 0;
  background: inherit;
  border-radius: 50%;
}
.student-card-cloud::before { left: 3cqw; width: 9cqw; height: 9cqw; }
.student-card-cloud::after { right: 2cqw; width: 7cqw; height: 7cqw; }
.cloud-left { left: -12px; top: 15%; }
.cloud-right { right: -9px; top: 9%; transform: scale(.82); }

.student-card-mountains {
  top: 27%;
  height: 37%;
  opacity: .72;
  background:
    linear-gradient(137deg, transparent 0 25%, #69b9eb 25.5% 34%, transparent 34.5%) 0 0 / 56% 100% no-repeat,
    linear-gradient(223deg, transparent 0 24%, #469ddd 24.5% 39%, transparent 39.5%) 100% 0 / 64% 100% no-repeat;
}

.student-card-heading {
  position: relative;
  z-index: 3;
  padding: 7% 4% 0;
  text-align: center;
  line-height: 1.2;
}
.student-card-school { font-size: 6.2cqw; font-weight: 700; letter-spacing: -.03em; }
.student-card-area { margin-top: 1.2cqw; font-size: 3.15cqw; font-weight: 600; }
.student-card-title { margin-top: 2.2cqw; font-size: 5.5cqw; font-weight: 700; }
.student-card-ribbon {
  width: 90%;
  margin: 1.6cqw auto 0;
  padding: 1.15cqw 3cqw;
  color: #fff;
  font-size: 3.35cqw;
  font-weight: 600;
  background: linear-gradient(90deg, #0753b6, #0a75d3, #0753b6);
  clip-path: polygon(0 0, 10% 50%, 0 100%, 100% 100%, 90% 50%, 100% 0);
}

.student-card-photo {
  position: absolute;
  z-index: 4;
  top: 28%;
  left: 50%;
  display: grid;
  width: 44%;
  height: 34%;
  place-items: center;
  align-content: center;
  gap: 1cqw;
  color: #7792aa;
  background: rgba(255,255,255,.96);
  border: 1.5cqw solid #fff;
  border-radius: 4cqw;
  box-shadow: 0 6px 20px rgba(5,68,126,.18), inset 0 0 0 1px #b8d3e5;
  transform: translateX(-50%);
}
.student-card-photo i { font-size: 13cqw; line-height: 1; }
.student-card-photo span { font-size: 3cqw; font-weight: 500; }

.student-card-landscape { z-index: 2; }
.student-card-landscape .bi-tree-fill { position: absolute; color: #087d45; filter: drop-shadow(0 3px 1px rgba(2,82,48,.25)); }
.tree-one { left: 6%; top: 43%; font-size: 13cqw; }
.tree-two { right: 8%; top: 48%; font-size: 10cqw; }
.student-card-bag { position: absolute; right: 6%; top: 55%; color: #b97628; font-size: 11cqw; transform: rotate(5deg); }

.student-card-details {
  position: absolute;
  z-index: 5;
  right: 6%;
  top: 64%;
  bottom: 4.5%;
  left: 6%;
  margin: 0;
  padding: 3% 5%;
  background: rgba(255,255,255,.96);
  border-radius: 4cqw;
  box-shadow: 0 8px 24px rgba(4,48,99,.2);
}
.student-card-detail-row {
  display: grid;
  grid-template-columns: 52% 48%;
  align-items: center;
  height: 25%;
  min-height: 0;
  border-bottom: 1px solid #9bc7ea;
}
.student-card-detail-row:first-child {
  grid-template-columns: 52% 48%;
  align-items: center;
}
.student-card-detail-last { border-bottom: 0; }
.student-card-detail-row dt,
.student-card-detail-row dd { margin: 0; }
.student-card-detail-row dt {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 1cqw;
  font-size: 4.04cqw;
  font-weight: 600;
  white-space: nowrap;
}
.student-card-detail-row dd {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #082257;
  font-size: 4.04cqw;
  font-weight: 600;
  line-height: 1.3;
}
.student-card-name {
  display: grid;
  gap: .15cqw;
  overflow: hidden;
  font-size: 4.04cqw !important;
  font-weight: 700 !important;
  line-height: 1.15;
  overflow-wrap: normal;
  padding-left: 0;
}
.student-card-name span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
}
.student-card-class {
  overflow: hidden;
  overflow-wrap: normal;
  white-space: nowrap;
}
.student-card-detail-icon {
  display: inline-grid;
  width: 8.5cqw;
  height: 8.5cqw;
  flex: 0 0 8.5cqw;
  place-items: center;
  color: #0877df;
  font-size: 6.8cqw;
  line-height: 1;
  background: transparent;
  border-radius: 0;
  filter: drop-shadow(0 .7cqw .8cqw rgba(6, 78, 148, .2));
}
.student-card-detail-row:nth-child(1) .student-card-detail-icon { color: #0877df; }
.student-card-detail-row:first-child dt {
  gap: .6cqw;
  font-size: 4.04cqw;
}
.student-card-detail-row:first-child .student-card-detail-icon {
  width: 7cqw;
  height: 7cqw;
  flex-basis: 7cqw;
  font-size: 6.2cqw;
}
.student-card-detail-row:nth-child(2) .student-card-detail-icon { color: #7c3aed; }
.student-card-detail-row:nth-child(3) {
  grid-template-columns: minmax(0, 1fr) max-content;
  column-gap: 1cqw;
}
.student-card-detail-row:nth-child(3) .student-card-detail-icon { color: #12a150; }
.student-card-detail-row:nth-child(4) .student-card-detail-icon { color: #f97316; }
.student-card-detail-icon.is-green { color: #12a150; background: transparent; }
.student-card-parent-phones {
  position: relative;
  z-index: 1;
  display: grid;
  gap: .25cqw;
  justify-self: end;
  width: max-content;
  padding-left: 2cqw;
  font-size: 4.04cqw !important;
  line-height: 1.15 !important;
  background: rgba(255,255,255,.96);
}
.student-card-parent-phones span { display: block; white-space: nowrap; }
.student-card-teacher-phone { font-size: 4.04cqw !important; }

.student-card-download-stage {
  position: fixed;
  top: 0;
  left: -10000px;
  width: 55mm;
  height: 85mm;
  overflow: hidden;
  pointer-events: none;
}
.student-id-card-export {
  width: 55mm !important;
  min-width: 55mm !important;
  height: 85mm !important;
  aspect-ratio: auto !important;
  box-shadow: none !important;
}

@media (max-width: 575.98px) {
  .student-card-preview-wrap { padding: .75rem; }
  .student-id-card { min-width: 292px; }
}

@media print {
  @page { size: A4 portrait; margin: 10mm; }

  body { background: #fff !important; }
  body * { visibility: hidden !important; }
  #studentCardModal,
  #studentCardModal .modal-dialog,
  #studentCardModal .modal-content,
  #studentCardModal .modal-body {
    position: static !important;
    overflow: visible !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
  }
  #studentIdCard,
  #studentIdCard * { visibility: visible !important; }
  #studentIdCard {
    position: fixed;
    top: 10mm;
    left: 50%;
    width: 55mm;
    min-width: 55mm;
    height: 85mm;
    aspect-ratio: auto;
    border-radius: 5mm;
    box-shadow: none;
    transform: translateX(-50%);
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

@media (min-width: 992px) {
  .app-sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    flex: 0 0 var(--sidebar-width);
    overflow-x: hidden;
    overflow-y: auto;
  }
}
