/* ============================================
   Rescue Tracking System - Theme CSS
   Color: Navy Blue + White (Modern SaaS)
   ============================================ */

:root {
  --rt-primary: #0b3a82;          /* ฟ้าเข้มหลัก (Navy) */
  --rt-primary-dark: #082a5e;
  --rt-primary-light: #1f5fc7;
  --rt-accent: #0ea5e9;           /* ฟ้าสด */
  --rt-success: #16a34a;
  --rt-warning: #f59e0b;
  --rt-danger:  #dc2626;
  --rt-info:    #0891b2;
  --rt-purple:  #7c3aed;

  --rt-bg:      #f4f6fb;
  --rt-card-bg: #ffffff;
  --rt-text:    #1e293b;
  --rt-muted:   #64748b;
  --rt-border:  #e2e8f0;

  --rt-radius:  14px;
  --rt-radius-sm: 8px;
  --rt-shadow:  0 4px 16px rgba(11, 58, 130, 0.06);
  --rt-shadow-lg: 0 10px 40px rgba(11, 58, 130, 0.12);

  --rt-sidebar-width: 260px;
  --rt-header-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Sarabun', 'Noto Sans Thai', -apple-system, 'Segoe UI', sans-serif;
  background: var(--rt-bg);
  color: var(--rt-text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--rt-primary); text-decoration: none; }
a:hover { color: var(--rt-primary-light); text-decoration: underline; }

/* ===== Auth pages (Login / Register) ===== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0b3a82 0%, #1f5fc7 100%);
  position: relative;
  overflow: hidden;
}
.auth-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.1) 0, transparent 30%),
    radial-gradient(circle at 85% 80%, rgba(14,165,233,0.25) 0, transparent 35%);
}

.auth-card {
  position: relative;
  background: #fff;
  width: 100%;
  max-width: 460px;
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 40px 32px;
  animation: fadeUp 0.5s ease-out;
}
.auth-card.lg { max-width: 720px; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo .logo-circle {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--rt-primary), var(--rt-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 32px;
  box-shadow: var(--rt-shadow-lg);
}
.auth-logo h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--rt-primary);
}
.auth-logo p { margin: 4px 0 0; color: var(--rt-muted); font-size: 14px; }

/* ===== Main layout ===== */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.app-sidebar {
  width: var(--rt-sidebar-width);
  background: linear-gradient(180deg, var(--rt-primary) 0%, var(--rt-primary-dark) 100%);
  color: #fff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand .icon {
  width: 38px; height: 38px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.sidebar-brand .text { font-weight: 700; font-size: 16px; line-height: 1.1; flex: 1; min-width: 0; }
.sidebar-brand .text small { display: block; font-weight: 400; opacity: 0.7; font-size: 11px; }

/* ปุ่มปิด sidebar (เฉพาะมือถือ) */
.sidebar-close {
  display: none;
  position: absolute;
  top: 50%; right: 16px;
  transform: translateY(-50%);
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  border: 0;
  color: #fff;
  font-size: 18px;
  align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.sidebar-close:hover, .sidebar-close:active {
  background: rgba(255,255,255,0.28);
  transform: translateY(-50%) scale(1.05);
}
@media (max-width: 992px) {
  .sidebar-close { display: inline-flex; }
}

.sidebar-user {
  padding: 14px 20px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user .avatar,
.sidebar-user .rt-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  object-fit: cover;
}
.sidebar-user .info { font-size: 13px; line-height: 1.2; flex: 1; min-width: 0; }
.sidebar-user .info .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .info .role { opacity: 0.7; font-size: 11px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-section { padding: 14px 20px 6px; font-size: 11px; opacity: 0.55; text-transform: uppercase; letter-spacing: 1px; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all .15s;
  font-size: 14px;
}
.sidebar-link i { font-size: 18px; width: 22px; text-align: center; }
.sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.sidebar-link.active {
  background: rgba(255,255,255,0.12);
  border-left-color: var(--rt-accent);
  color: #fff;
  font-weight: 600;
}
.sidebar-link-with-badge { justify-content: space-between; }
.sidebar-link .sidebar-live-badge {
  font-size: 12px; font-weight: 700;
  padding: 3px 9px;
  box-shadow: 0 0 0 0 rgba(220,38,38,0.5);
  animation: rtBadgePulse 1.8s infinite;
}
@keyframes rtBadgePulse {
  0%   { box-shadow: 0 0 0 0   rgba(220,38,38,0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0   rgba(220,38,38,0); }
}

/* ===== Live countdown widget (top-right) ===== */
.rt-live-countdown {
  position: fixed !important;
  top: 14px !important;
  right: 14px !important;
  z-index: 1050 !important;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  background: rgba(11, 58, 130, 0.92);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  font-family: 'Sarabun', sans-serif;
  box-shadow: 0 4px 14px rgba(11, 58, 130, 0.25);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: all .15s;
  user-select: none;
}
.rt-live-countdown:hover {
  background: rgba(11, 58, 130, 1);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(11, 58, 130, 0.35);
}
.rt-live-countdown .rt-live-icon {
  font-size: 14px;
  animation: rtSpin 4s linear infinite;
}
@keyframes rtSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.rt-live-countdown.pending {
  background: #ea580c;
  animation: rtPendingPulse 1.2s infinite;
}
.rt-live-countdown.pending .rt-live-icon {
  animation-duration: 1s;
}
@keyframes rtPendingPulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(234, 88, 12, 0.35); }
  50%      { box-shadow: 0 4px 22px rgba(234, 88, 12, 0.65); }
}
.rt-live-countdown.paused {
  background: #64748b;
  cursor: default;
}
.rt-live-countdown.paused:hover {
  transform: none;
  box-shadow: 0 4px 14px rgba(100, 116, 139, 0.25);
}
.rt-live-countdown.paused .rt-live-icon {
  animation: none;
  opacity: 0.6;
}

/* บนมือถือ: ให้อยู่แนวเดียวกับ header (เหมือน desktop) — เล็กลงพอดี */
@media (max-width: 992px) {
  .rt-live-countdown {
    top: 12px !important;
    right: 12px !important;
    font-size: 11px;
    padding: 5px 10px;
    gap: 5px;
  }
  .rt-live-countdown .rt-live-icon { font-size: 12px; }
  /* mobile: widget เล็กลง → padding ลดลงนิด */
  .app-header .header-right { padding-right: 130px; }
  /* h2 ตัดด้วย ellipsis ถ้ายาว — กัน wrap 2 บรรทัด */
  .app-header h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 1;
  }
}
/* จอแคบมาก: ซ่อน header-badge + ปุ่ม "ออนไลน์ขณะนี้" — กันทับกับ countdown widget */
@media (max-width: 600px) {
  .app-header .header-badge { display: none !important; }
  .app-header .header-right { padding-right: 115px; gap: 6px; }
  .rt-live-countdown {
    font-size: 10.5px;
    padding: 4px 8px;
  }
}
/* ซ่อน countdown widget เมื่อเปิด sidebar mobile (กันบัง X) */
body.sidebar-open .rt-live-countdown { display: none !important; }

/* ===== Stale cases alert ===== */
.stale-alert {
  border-left: 4px solid #f59e0b;
  background: linear-gradient(to right, #fef3c7, #fff);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
}
.stale-alert-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  animation: stalePulse 2s infinite;
}
@keyframes stalePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50%     { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
}

/* ============================================================
   Case Card — ใช้ใน cases/index.php, cases/all.php, cases/deferred.php
   ============================================================ */
.case-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--rt-border);
  box-shadow: var(--rt-shadow);
  overflow: hidden;
  transition: all .15s;
  height: 100%;
  color: var(--rt-text);
  display: flex;
  flex-direction: column;
}
.case-card:hover { transform: translateY(-2px); box-shadow: var(--rt-shadow-lg); }
.case-card.case-card-new {
  border-color: #dc2626;
  animation: pulseRed 1.6s infinite;
}
@keyframes pulseRed {
  0%,100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50%    { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}
.case-card-cat {
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
}
.case-card-cat i { font-size: 22px; }
.case-card-body { padding: 14px 16px; flex: 1; }
.case-code { color: var(--rt-primary); font-family: monospace; font-size: 13px; }
.case-desc {
  margin: 8px 0 12px;
  font-size: 13px;
  color: #475569;
  line-height: 1.55;
  min-height: 44px;
}
.case-meta {
  display: flex; flex-wrap: wrap; gap: 12px;
  font-size: 12px; color: var(--rt-muted);
  margin-bottom: 8px;
}
.case-foot {
  border-top: 1px dashed var(--rt-border);
  padding-top: 8px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.case-accept-form { padding: 0 14px 14px; }
.case-card .text-reset { color: inherit !important; display: block; }
.phone-tap { cursor: pointer; color: #0b3a82; font-weight: 600; }
.phone-tap:hover { text-decoration: underline; }

/* Tab font colors (override Bootstrap defaults) */
.rt-pill-tabs .nav-link.text-purple { color: #7c3aed !important; }
.rt-pill-tabs .nav-link.text-amber  { color: #b45309 !important; }
.rt-pill-tabs .nav-link.active      { color: #fff !important; }

/* Pending cancel inline UI */
.case-pending-cancel {
  margin: 0 14px 14px;
  padding: 12px;
  background: #fef3c7;
  border: 2px dashed #f59e0b;
  border-radius: 10px;
}
.case-pending-cancel .pc-meta { color: #92400e; }
.case-pending-cancel .pc-reason {
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.6;
  color: #1f2937;
  white-space: pre-wrap;
  border: 1px solid #fde68a;
}

/* ===== Deferred cases alert (เคสค้างกรอกข้อมูลปิดงาน) ===== */
.deferred-alert {
  border-left: 4px solid var(--rt-info);
  background: linear-gradient(to right, #cffafe, #fff);
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.15);
}
.deferred-alert-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--rt-info);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  animation: deferredPulse 2s infinite;
}
@keyframes deferredPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(8, 145, 178, 0.4); }
  50%     { box-shadow: 0 0 0 8px rgba(8, 145, 178, 0); }
}
.deferred-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none !important;
  font-family: monospace;
  transition: transform .15s, box-shadow .15s;
}
.deferred-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Badge "ค้างกรอกข้อมูล" — ใช้บนการ์ดเคส (cases/index.php, deferred.php, all.php) */
.deferred-badge {
  background: #fee2e2;
  color: #b91c1c;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
  border: 1px solid #fecaca;
  animation: deferredBadgeBlink 2.4s ease-in-out infinite;
}
.deferred-badge i { font-size: 12px; }
@keyframes deferredBadgeBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px; opacity: 0.7;
}

/* Top header */
.app-header {
  position: fixed;
  top: 0; left: var(--rt-sidebar-width); right: 0;
  height: var(--rt-header-height);
  background: #fff;
  border-bottom: 1px solid var(--rt-border);
  display: flex; align-items: center;
  padding: 0 24px;
  z-index: 1030;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.app-header .toggle-sidebar {
  display: none;
  align-items: center; justify-content: center;
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--rt-primary), var(--rt-primary-light));
  border: 0;
  border-radius: 12px;
  color: #fff;
  font-size: 22px;
  margin-right: 12px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(11, 58, 130, 0.3);
  transition: transform .15s, box-shadow .15s;
}
.app-header .toggle-sidebar:hover,
.app-header .toggle-sidebar:focus {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(11, 58, 130, 0.4);
}
.app-header .toggle-sidebar:active { transform: translateY(0); }
.app-header h2 { margin: 0; font-size: 18px; font-weight: 700; color: var(--rt-text); }
.app-header .header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; padding-right: 150px; }

.header-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: #ecfdf5;
  border: 1px solid #d1fae5;
  border-radius: 999px;
  font-size: 12px;
  color: #065f46;
  font-weight: 600;
}
.header-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 0 rgba(16,185,129,.6); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
  70%  { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

/* Main content */
.app-main {
  margin-left: var(--rt-sidebar-width);
  padding-top: var(--rt-header-height);
  flex: 1;
  min-width: 0;
}
.app-main .container-fluid { padding: 24px; }

/* Page header */
.page-header { margin-bottom: 22px; }
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
  display: flex; align-items: center; gap: 10px;
  color: var(--rt-text);
}
.page-header h1 i { color: var(--rt-primary); }
.page-header p { margin: 0; color: var(--rt-muted); font-size: 14px; }

/* Cards */
.rt-card {
  background: var(--rt-card-bg);
  border-radius: var(--rt-radius);
  border: 1px solid var(--rt-border);
  box-shadow: var(--rt-shadow);
  overflow: hidden;
}
.rt-card .rt-card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--rt-border);
  display: flex; align-items: center; gap: 10px;
}
.rt-card .rt-card-head h3 {
  margin: 0; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.rt-card .rt-card-head .ms-auto { margin-left: auto; }
.rt-card .rt-card-body { padding: 20px; }

/* Stat cards */
.stat-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 22px;
}
.stat-card {
  background: #fff;
  border-radius: var(--rt-radius);
  padding: 20px;
  box-shadow: var(--rt-shadow);
  border: 1px solid var(--rt-border);
  display: flex; align-items: center; gap: 14px;
  transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--rt-shadow-lg); }
.stat-card .stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.stat-card .stat-content { min-width: 0; }
.stat-card .stat-label { color: var(--rt-muted); font-size: 13px; margin: 0; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--rt-text); margin: 0; line-height: 1.1; }

.stat-icon.bg-primary-soft { background: #dbeafe; color: var(--rt-primary); }
.stat-icon.bg-success-soft { background: #dcfce7; color: var(--rt-success); }
.stat-icon.bg-warning-soft { background: #fef3c7; color: var(--rt-warning); }
.stat-icon.bg-danger-soft  { background: #fee2e2; color: var(--rt-danger); }
.stat-icon.bg-info-soft    { background: #cffafe; color: var(--rt-info); }
.stat-icon.bg-purple-soft  { background: #ede9fe; color: var(--rt-purple); }

/* Buttons */
.btn { font-weight: 600; border-radius: 10px; padding: 9px 18px; transition: all .15s; }
.btn-primary {
  background: var(--rt-primary);
  border-color: var(--rt-primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--rt-primary-dark);
  border-color: var(--rt-primary-dark);
  box-shadow: 0 4px 14px rgba(11, 58, 130, 0.3);
}
.btn-lg { padding: 12px 24px; font-size: 16px; border-radius: 12px; }
.btn-icon { display: inline-flex; align-items: center; gap: 8px; }

/* Forms */
.form-label { font-weight: 600; font-size: 13px; color: var(--rt-text); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.form-label i { color: var(--rt-primary); }
.form-control, .form-select {
  border-radius: 10px;
  border: 1px solid var(--rt-border);
  padding: 10px 14px;
  font-size: 14px;
  transition: all .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--rt-primary-light);
  box-shadow: 0 0 0 3px rgba(31,95,199,.12);
}
.input-group-text { background: var(--rt-bg); border-color: var(--rt-border); color: var(--rt-primary); }

/* ============================================================
   Tom Select — searchable dropdown global theme
   ============================================================ */
.ts-wrapper.form-select { padding: 0 !important; height: auto !important; background-image: none !important; }
.ts-control {
  border: 1.5px solid var(--rt-border) !important;
  border-radius: 10px !important;
  padding: 8px 14px !important;
  min-height: 44px !important;
  font-family: 'Sarabun', sans-serif !important;
  line-height: 1.6 !important;
  background: #fff !important;
  cursor: pointer !important;
  transition: all .15s !important;
}
.ts-control input {
  font-family: inherit !important;
  font-size: 14px !important;
  color: var(--rt-text) !important;
}
.ts-wrapper:not(.disabled):hover .ts-control {
  border-color: #cbd5e1 !important;
  background: #f8fafc !important;
  box-shadow: 0 2px 8px rgba(11, 58, 130, 0.06);
}
.ts-wrapper.focus .ts-control,
.ts-control:focus-within {
  border-color: var(--rt-primary) !important;
  box-shadow: 0 0 0 4px rgba(11, 58, 130, 0.12) !important;
  background: #fff !important;
}
.ts-wrapper.disabled .ts-control {
  background: #f1f5f9 !important;
  color: var(--rt-muted) !important;
  cursor: not-allowed !important;
  opacity: 0.7 !important;
}
/* Custom arrow (dropdown indicator) */
.ts-wrapper.single .ts-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%230b3a82'%3E%3Cpath d='M3.204 5h9.592L8 10.481zm-.753.659 4.796 5.48a1 1 0 0 0 1.506 0l4.796-5.48c.566-.647.106-1.659-.753-1.659H3.204a1 1 0 0 0-.753 1.659'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 14px 14px !important;
  padding-right: 36px !important;
}
.ts-wrapper.focus.single .ts-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%230b3a82' style='transform:rotate(180deg)'%3E%3Cpath d='M3.204 11h9.592L8 5.519zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659'/%3E%3C/svg%3E") !important;
}
/* Dropdown panel */
.ts-dropdown {
  border-radius: 10px !important;
  box-shadow: 0 12px 40px rgba(11, 58, 130, 0.18) !important;
  border: 1px solid var(--rt-border) !important;
  font-family: 'Sarabun', sans-serif !important;
  z-index: 1080 !important;
  margin-top: 4px !important;
  overflow: hidden !important;
}
.ts-dropdown .option {
  padding: 9px 14px !important;
  line-height: 1.7 !important;
  font-size: 14px !important;
  cursor: pointer !important;
  color: var(--rt-text) !important;
}
.ts-dropdown .option:hover  { background: #f0f7ff !important; color: var(--rt-primary) !important; }
.ts-dropdown .option.active { background: #e0f2fe !important; color: var(--rt-primary) !important; }
.ts-dropdown .option.selected {
  background: var(--rt-primary) !important;
  color: #fff !important;
  font-weight: 600;
}
.ts-dropdown .optgroup-header {
  font-weight: 700; color: var(--rt-primary) !important;
  background: #f8fafc !important; padding: 6px 14px !important; font-size: 12px !important;
}
.ts-dropdown .no-results {
  padding: 14px !important; color: var(--rt-muted) !important; text-align: center; font-size: 14px;
}
/* Multi-select pill */
.ts-wrapper.multi .ts-control > .item {
  background: var(--rt-primary) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 999px !important;
  padding: 3px 10px 3px 12px !important;
  font-size: 13px !important;
  margin: 2px !important;
}
.ts-wrapper.multi .ts-control > .item.active {
  background: var(--rt-primary-dark) !important;
}
/* Mobile-friendly */
@media (max-width: 768px) {
  .ts-control { min-height: 46px !important; font-size: 15px !important; }
  .ts-dropdown .option { padding: 11px 14px !important; font-size: 15px !important; }
}

/* ============================================================
   Form Select — ปรับ native <select> ให้สวยขึ้น (ฟังก์ชันเหมือนเดิม)
   ============================================================ */
.form-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #fff;
  /* ลูกศรลง custom สี navy */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%230b3a82'%3E%3Cpath d='M3.204 5h9.592L8 10.481zm-.753.659 4.796 5.48a1 1 0 0 0 1.506 0l4.796-5.48c.566-.647.106-1.659-.753-1.659H3.204a1 1 0 0 0-.753 1.659'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
  padding-right: 38px;
  cursor: pointer;
  border: 1.5px solid var(--rt-border);
  font-weight: 500;
  color: var(--rt-text);
  background-color: #fff;
}
.form-select:hover:not(:disabled):not(:focus) {
  border-color: #cbd5e1;
  background-color: #f8fafc;
  box-shadow: 0 2px 8px rgba(11, 58, 130, 0.06);
}
.form-select:focus {
  border-color: var(--rt-primary);
  box-shadow: 0 0 0 4px rgba(11, 58, 130, 0.12);
  outline: none;
  background-color: #fff;
}
.form-select:disabled {
  background-color: #f1f5f9;
  color: var(--rt-muted);
  cursor: not-allowed;
  opacity: 0.7;
}
.form-select option {
  padding: 10px 12px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  background-color: #fff;
  color: var(--rt-text);
}
.form-select option:checked,
.form-select option:hover {
  background: linear-gradient(0deg, rgba(11, 58, 130, 0.1) 0%, rgba(11, 58, 130, 0.1) 100%);
  color: var(--rt-primary);
}
.form-select option:disabled { color: #cbd5e1; }
/* Multi-select */
.form-select[multiple] {
  background-image: none;
  padding-right: 14px;
}
.form-select[multiple] option {
  padding: 8px 12px;
  border-radius: 6px;
  margin: 2px 0;
}
/* Size variants */
.form-select-sm {
  padding: 6px 32px 6px 12px;
  font-size: 13px;
  background-size: 12px 12px;
  background-position: right 10px center;
  border-radius: 8px;
}
.form-select-lg {
  padding: 12px 44px 12px 16px;
  font-size: 16px;
  background-size: 16px 16px;
  background-position: right 14px center;
  border-radius: 12px;
}
/* Touch-friendly บนมือถือ (เลือก option ง่ายขึ้น) */
@media (max-width: 768px) {
  .form-select {
    min-height: 46px;
    font-size: 15px;
    padding-top: 11px;
    padding-bottom: 11px;
  }
}

.required::after { content: ' *'; color: var(--rt-danger); }

/* Tables */
.rt-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.rt-table thead th {
  background: #f8fafc;
  color: var(--rt-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rt-border);
  text-align: left;
  white-space: nowrap;
}
.rt-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--rt-border); vertical-align: middle; }
.rt-table tbody tr:last-child td { border-bottom: 0; }
.rt-table tbody tr:hover { background: #f8fafc; }

/* Badges */
.bg-purple { background-color: var(--rt-purple) !important; color: #fff; }

/* Vehicle online card */
.vehicle-card {
  background: #fff;
  border-radius: var(--rt-radius);
  border: 1px solid var(--rt-border);
  padding: 16px;
  box-shadow: var(--rt-shadow);
  transition: all .15s;
}
.vehicle-card:hover { box-shadow: var(--rt-shadow-lg); }
.vehicle-card.vehicle-card-mine {
  border-color: var(--rt-warning);
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 60%);
}
.vehicle-card .v-head { display: flex; align-items: center; gap: 12px; }
.vehicle-card .v-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: #dbeafe;
  color: var(--rt-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.vehicle-card .v-thumb {
  width: 56px; height: 56px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--rt-border);
  background: #f1f5f9;
}
.vehicle-card .v-name { font-weight: 700; font-size: 15px; }
.vehicle-card .v-sub  { color: var(--rt-muted); font-size: 12px; }
.vehicle-card .v-crew {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--rt-border);
  display: flex; flex-wrap: wrap; gap: 6px;
}
.vehicle-card .v-crew .crew-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px;
  padding: 3px 10px 3px 3px;        /* น้อยซ้าย เพราะมี avatar */
  background: #f1f5f9;
  border-radius: 999px;
  line-height: 1.4;
}
.vehicle-card .v-crew .crew-pill .rt-avatar {
  width: 22px; height: 22px;
  font-size: 11px;
}
.vehicle-card .v-crew .crew-pill .crew-pill-text {
  display: inline-flex; align-items: center; gap: 3px;
  white-space: nowrap;
}
.vehicle-card .v-crew .crew-pill-init {
  background: #dcfce7;
  color: #14532d;
  border: 1px solid #86efac;
}
.vehicle-card .v-crew .crew-pill-me {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
  border: 1px solid #fcd34d;
}

/* ========== Pill tabs (online page) ========== */
.rt-pill-tabs { background:#fff; padding:6px; border-radius:14px; box-shadow:var(--rt-shadow); border:1px solid var(--rt-border); }
.rt-pill-tabs .nav-link {
  color: var(--rt-muted);
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 16px;
  display: inline-flex; align-items: center; gap: 8px;
  justify-content: center;
  transition: all .15s;
}
.rt-pill-tabs .nav-link i { font-size: 18px; }
.rt-pill-tabs .nav-link:not(.active):hover { background: #f1f5f9; color: var(--rt-primary); }
.rt-pill-tabs .nav-link.active {
  background: linear-gradient(135deg, var(--rt-primary), var(--rt-primary-light));
  color: #fff;
  box-shadow: 0 4px 14px rgba(11,58,130,.25);
}
.rt-pill-tabs .nav-link.active .badge { background:#fff!important; color: var(--rt-primary)!important; }

/* ========== Volunteer card (online page → tab อาสา) ========== */
.vol-card {
  background:#fff;
  border-radius: var(--rt-radius);
  border: 1px solid var(--rt-border);
  padding: 14px;
  display: flex; gap: 12px; align-items: center;
  box-shadow: var(--rt-shadow);
  transition: all .15s;
  height: 100%;
}
.vol-card:hover { box-shadow: var(--rt-shadow-lg); transform: translateY(-1px); }
.vol-card.vol-card-me { border-color: var(--rt-warning); background: linear-gradient(180deg, #fffbeb 0%, #ffffff 60%); }
/* wrapper รอบ avatar ของ vol-card — รองรับทั้งรูปจริงและอักษรย่อ พร้อม star badge สำหรับ initiator */
.vol-card .vol-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.vol-card .vol-avatar-wrap .rt-avatar {
  display: flex !important; align-items: center !important; justify-content: center !important;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.vol-card .vol-avatar-wrap.is-init::after {
  content: '★';
  position: absolute; bottom: -3px; right: -3px;
  background: #f59e0b; color: #fff;
  width: 20px; height: 20px;
  border-radius: 50%; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  font-weight: 700;
  z-index: 2;
}
.vol-card .vol-info { flex: 1; min-width: 0; }
.vol-card .vol-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vol-card .vol-sub  { color: var(--rt-muted); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.vol-card .vol-meta { color: var(--rt-muted); font-size: 11px; margin-top: 4px; }

/* ========== Filter bar (shift selection) ========== */
.filter-bar {
  background: #f8fafc;
  border: 1px solid var(--rt-border);
  border-radius: 12px;
  padding: 10px;
}
.filter-bar .group-count { font-size: 11px; }

/* Empty state */
.empty-state { text-align: center; padding: 50px 20px; color: var(--rt-muted); }
.empty-state i { font-size: 48px; opacity: 0.4; margin-bottom: 12px; display: block; }
.empty-state p { margin: 0; }

/* Sidebar overlay (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1035;
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .app-header { left: 0; }
  .app-main { margin-left: 0; }
  .app-header .toggle-sidebar { display: inline-flex; }
  .sidebar-backdrop.show { display: block; }

  /* ===== Sidebar mobile mode — grid icon ใหญ่กลางจอ ===== */
  .app-sidebar {
    width: 100%;
    max-width: 100vw;
  }
  .app-sidebar .sidebar-brand {
    padding: 16px 70px 16px 20px;
    position: relative;
  }
  .app-sidebar .sidebar-brand .icon { width: 44px; height: 44px; font-size: 22px; }
  .app-sidebar .sidebar-brand .text { font-size: 17px; }

  .app-sidebar .sidebar-user {
    padding: 16px 20px;
  }
  .app-sidebar .sidebar-user .avatar,
  .app-sidebar .sidebar-user .rt-avatar {
    width: 48px; height: 48px;
  }
  .app-sidebar .sidebar-user .info .name { font-size: 15px; }

  .app-sidebar .sidebar-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 18px 14px;
    align-content: start;
  }
  .app-sidebar .sidebar-section {
    grid-column: 1 / -1;
    padding: 8px 6px 0;
    font-size: 11px;
    letter-spacing: 1.2px;
    margin-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.12);
    padding-top: 12px;
  }
  .app-sidebar .sidebar-section:first-child {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
  }
  .app-sidebar .sidebar-link {
    flex-direction: column;
    text-align: center;
    border-left: 0;
    padding: 16px 8px;
    border-radius: 16px;
    background: rgba(255,255,255,0.08);
    gap: 8px;
    font-size: 12px;
    line-height: 1.25;
    min-height: 96px;
    justify-content: center;
    position: relative;
    word-break: break-word;
  }
  .app-sidebar .sidebar-link i {
    font-size: 32px;
    width: auto;
    line-height: 1;
  }
  .app-sidebar .sidebar-link:hover,
  .app-sidebar .sidebar-link:active {
    background: rgba(255,255,255,0.18);
    transform: translateY(-2px);
  }
  .app-sidebar .sidebar-link.active {
    background: rgba(14,165,233,0.25);
    border: 1px solid var(--rt-accent);
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.25);
  }
  /* badge แทนที่ ms-auto layout เดิม → ลอย top-right */
  .app-sidebar .sidebar-link-with-badge { justify-content: center; }
  .app-sidebar .sidebar-link .sidebar-live-badge {
    position: absolute;
    top: 6px; right: 6px;
    margin: 0 !important;
  }

  .app-sidebar .sidebar-footer {
    padding: 14px 20px env(safe-area-inset-bottom, 14px);
    text-align: center;
  }
}

@media (max-width: 576px) {
  .app-main .container-fluid { padding: 16px; }
  .page-header h1 { font-size: 20px; }
  .stat-card .stat-value { font-size: 22px; }
  .auth-card { padding: 28px 22px; }
  .case-action-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .case-action-grid .action-tile { padding: 18px 10px; }
  .case-action-grid .action-tile .icon-circle { width: 56px; height: 56px; font-size: 28px; }
}

/* ============================================================
   Bottom Nav (Mobile only)
   ============================================================ */
.rt-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: #fff;
  border-top: 1px solid var(--rt-border);
  box-shadow: 0 -2px 12px rgba(11, 58, 130, 0.08);
  z-index: 1045;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.rt-bottom-nav .bn-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--rt-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  position: relative;
  min-height: 48px;
  transition: color .15s;
}
.rt-bottom-nav .bn-item:hover { color: var(--rt-primary); text-decoration: none; }
.rt-bottom-nav .bn-item.active { color: var(--rt-primary); }
.rt-bottom-nav .bn-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  width: 32px; height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--rt-primary);
  transform: translateX(-50%);
}
.rt-bottom-nav .bn-icon-wrap {
  position: relative;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
}
.rt-bottom-nav .bn-icon-wrap i { font-size: 24px; line-height: 1; }
.rt-bottom-nav .bn-label {
  font-size: 11px;
  white-space: nowrap;
  line-height: 1.1;
}
.rt-bottom-nav .bn-badge {
  position: absolute;
  top: -4px; right: -8px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  line-height: 1.2;
  border: 2px solid #fff;
  color: #fff;
}

/* ปุ่มกลาง — แจ้งเหตุใหม่ (FAB-style ยกขึ้น) */
.rt-bottom-nav .bn-center {
  flex: 0 0 auto;
  margin-top: -22px;
}
.rt-bottom-nav .bn-center .bn-icon-wrap {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rt-danger), #ef4444);
  color: #fff;
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.4);
  border: 3px solid #fff;
  transition: transform .15s, box-shadow .15s;
}
.rt-bottom-nav .bn-center:hover .bn-icon-wrap {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 24px rgba(220, 38, 38, 0.5);
}
.rt-bottom-nav .bn-center .bn-icon-wrap i { font-size: 28px; }
.rt-bottom-nav .bn-center.active::before { display: none; }
.rt-bottom-nav .bn-center .bn-label { color: var(--rt-danger); font-weight: 700; }

/* แสดงเฉพาะมือถือ — รวม landscape phone (จอเตี้ย) */
@media (max-width: 768px),
       (orientation: landscape) and (max-height: 500px) {
  .rt-bottom-nav { display: flex; }
  /* ขยับ content ขึ้นเหนือ bottom nav */
  .app-main .container-fluid { padding-bottom: 84px; }
}
/* Landscape phone: ลด height + icon ลงเล็กน้อย เพื่อประหยัดพื้นที่หน้าจอ */
@media (orientation: landscape) and (max-height: 500px) {
  .rt-bottom-nav { height: 54px; }
  .rt-bottom-nav .bn-icon-wrap { width: 24px; height: 24px; }
  .rt-bottom-nav .bn-icon-wrap i { font-size: 20px; }
  .rt-bottom-nav .bn-label { font-size: 10px; }
  .rt-bottom-nav .bn-center { margin-top: -16px; }
  .rt-bottom-nav .bn-center .bn-icon-wrap { width: 46px; height: 46px; }
  .rt-bottom-nav .bn-center .bn-icon-wrap i { font-size: 24px; }
  .app-main .container-fluid { padding-bottom: 70px; }
}

/* ============================================================
   Mobile Case Card (Big Icon Friendly)
   ============================================================ */
@media (max-width: 768px) {
  /* การ์ดเคส — ไอคอน category ใหญ่ขึ้น */
  .case-card-cat {
    padding: 14px 18px;
    font-size: 16px;
  }
  .case-card-cat i { font-size: 28px; }
  .case-card-body { padding: 16px; }
  .case-desc { font-size: 14px; min-height: 48px; }
  .case-meta { font-size: 13px; gap: 10px; }
  .case-accept-form { padding: 0 16px 16px; }
  .case-accept-form .btn {
    padding: 14px 16px;
    font-size: 16px;
    min-height: 52px;
  }
  /* Tab pills แบบ scroll horizontal บนมือถือ */
  .rt-pill-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .rt-pill-tabs::-webkit-scrollbar { display: none; }
  .rt-pill-tabs .nav-item { flex: 0 0 auto; }
  .rt-pill-tabs .nav-link {
    white-space: nowrap;
    padding: 10px 14px;
    font-size: 13px;
  }
  /* page-header ปุ่มสร้างเคส — ซ่อนบนมือถือ (มี FAB กลางแล้ว) */
  .page-header .btn-create-case-mobile-hide { display: none !important; }
}

/* ============================================================
   Mobile Quick Tiles (Dashboard / Hub)
   ============================================================ */
.rt-quick-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.rt-quick-tiles .quick-tile {
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--rt-border);
  padding: 18px 14px;
  text-align: center;
  text-decoration: none;
  color: var(--rt-text);
  transition: all .2s;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  box-shadow: var(--rt-shadow);
  position: relative;
  min-height: 132px;
  justify-content: center;
}
.rt-quick-tiles .quick-tile:hover,
.rt-quick-tiles .quick-tile:active {
  transform: translateY(-2px);
  box-shadow: var(--rt-shadow-lg);
  text-decoration: none;
  color: var(--rt-text);
}
.rt-quick-tiles .quick-tile .qt-icon {
  width: 60px; height: 60px;
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  background: linear-gradient(135deg, var(--rt-primary), var(--rt-accent));
  color: #fff;
  box-shadow: 0 4px 12px rgba(11, 58, 130, 0.2);
}
.rt-quick-tiles .quick-tile.var-danger  .qt-icon { background: linear-gradient(135deg, #dc2626, #f87171); box-shadow: 0 4px 12px rgba(220,38,38,0.25); }
.rt-quick-tiles .quick-tile.var-warning .qt-icon { background: linear-gradient(135deg, #f59e0b, #fbbf24); box-shadow: 0 4px 12px rgba(245,158,11,0.25); }
.rt-quick-tiles .quick-tile.var-success .qt-icon { background: linear-gradient(135deg, #16a34a, #4ade80); box-shadow: 0 4px 12px rgba(22,163,74,0.25); }
.rt-quick-tiles .quick-tile.var-info    .qt-icon { background: linear-gradient(135deg, #0891b2, #06b6d4); box-shadow: 0 4px 12px rgba(8,145,178,0.25); }
.rt-quick-tiles .quick-tile.var-purple  .qt-icon { background: linear-gradient(135deg, #7c3aed, #a78bfa); box-shadow: 0 4px 12px rgba(124,58,237,0.25); }
.rt-quick-tiles .quick-tile .qt-label { font-weight: 700; font-size: 14px; line-height: 1.3; }
.rt-quick-tiles .quick-tile .qt-count {
  font-size: 22px;
  font-weight: 800;
  color: var(--rt-primary);
  line-height: 1;
  margin-top: -2px;
}
.rt-quick-tiles .quick-tile .qt-badge {
  position: absolute;
  top: 10px; right: 10px;
  background: var(--rt-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}

/* แสดงเฉพาะมือถือ */
.rt-quick-tiles { display: none; }
@media (max-width: 768px) {
  .rt-quick-tiles { display: grid; }
}

/* ============================================================
   Touch target safety (≥48px)
   ============================================================ */
@media (max-width: 768px) {
  .btn { min-height: 44px; }
  .btn-lg { min-height: 52px; }
  .form-control, .form-select { min-height: 44px; }
  .nav-link { min-height: 44px; }
}

/* ============================================================
   Modal — Global Enhancement (สวย น่ากด)
   ============================================================ */
.modal-backdrop.show { opacity: 0.55; }
@supports (backdrop-filter: blur(4px)) {
  .modal-backdrop.show { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
}

.modal-content {
  border: 0;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(11, 58, 130, 0.25), 0 8px 20px rgba(0,0,0,0.08);
}
.modal-dialog-centered { padding: 12px; }

/* Header — gradient เป็น default ถ้าไม่ override */
.modal-header {
  border-bottom: 0;
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--rt-primary), var(--rt-primary-light));
  color: #fff;
  position: relative;
}
.modal-header .modal-title {
  font-weight: 700;
  font-size: 17px;
  display: flex; align-items: center; gap: 10px;
}
.modal-header .modal-title i { font-size: 22px; }
.modal-header .btn-close {
  background: rgba(255,255,255,0.2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3E%3Cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3E%3C/svg%3E") center/14px no-repeat;
  border-radius: 10px;
  width: 34px; height: 34px;
  opacity: 1;
  transition: background-color .15s, transform .15s;
  margin: 0;
}
.modal-header .btn-close:hover {
  background-color: rgba(255,255,255,0.32);
  transform: rotate(90deg);
}
.modal-header .btn-close:focus { box-shadow: 0 0 0 3px rgba(255,255,255,0.3); }

/* Header variants — โทนสีตาม semantic */
.modal-header.bg-success,
.modal-content.modal-success .modal-header { background: linear-gradient(135deg, #16a34a, #4ade80); }
.modal-header.bg-warning,
.modal-content.modal-warning .modal-header { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #fff !important; }
.modal-header.bg-danger,
.modal-content.modal-danger  .modal-header { background: linear-gradient(135deg, #dc2626, #f87171); }
.modal-header.bg-info,
.modal-content.modal-info    .modal-header { background: linear-gradient(135deg, #0891b2, #06b6d4); }

.modal-body { padding: 22px; font-size: 14.5px; line-height: 1.6; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-footer {
  border-top: 1px solid var(--rt-border);
  padding: 14px 22px;
  background: #fafbfc;
  gap: 8px;
}
.modal-footer > * { margin: 0 !important; }
.modal-footer .btn { padding: 10px 22px; border-radius: 10px; font-weight: 600; }

/* Animation — scale + fade (smooth) */
.modal.fade .modal-dialog {
  transform: scale(0.92) translateY(18px);
  opacity: 0;
  transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1), opacity .25s;
}
.modal.show .modal-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ============================================================
   Toast — Flash messages (slide from top-right)
   ============================================================ */
.flash-toast-wrap {
  position: fixed;
  top: calc(var(--rt-header-height) + 12px);
  right: 16px;
  z-index: 1080;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
  max-width: 420px;
  width: calc(100% - 32px);
}
.flash-toast-wrap .alert {
  pointer-events: auto;
  margin: 0;
  border-radius: 14px;
  border: 0;
  padding: 14px 44px 14px 18px;
  box-shadow: 0 10px 30px rgba(11, 58, 130, 0.18);
  display: flex; align-items: center; gap: 12px;
  font-size: 14px;
  font-weight: 600;
  position: relative;
  background: #fff;
  color: var(--rt-text);
  border-left: 4px solid var(--rt-primary);
  animation: rtToastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.flash-toast-wrap .alert::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.3;
  border-radius: 0 0 14px 14px;
  animation: rtToastBar 6s linear forwards;
}
.flash-toast-wrap .alert > i:first-child {
  font-size: 22px;
  flex-shrink: 0;
}
.flash-toast-wrap .alert.alert-success { border-left-color: var(--rt-success); }
.flash-toast-wrap .alert.alert-success > i:first-child { color: var(--rt-success); }
.flash-toast-wrap .alert.alert-danger  { border-left-color: var(--rt-danger); }
.flash-toast-wrap .alert.alert-danger  > i:first-child { color: var(--rt-danger); }
.flash-toast-wrap .alert.alert-warning { border-left-color: var(--rt-warning); }
.flash-toast-wrap .alert.alert-warning > i:first-child { color: var(--rt-warning); }
.flash-toast-wrap .alert.alert-info    { border-left-color: var(--rt-info); }
.flash-toast-wrap .alert.alert-info    > i:first-child { color: var(--rt-info); }
.flash-toast-wrap .alert .btn-close {
  position: absolute;
  top: 50%; right: 10px;
  transform: translateY(-50%);
  margin: 0;
  padding: 0;
  width: 26px; height: 26px;
  background-color: transparent;
  opacity: 0.5;
  transition: opacity .15s;
}
.flash-toast-wrap .alert .btn-close:hover { opacity: 1; }
.flash-toast-wrap .alert.fade.hide-out {
  animation: rtToastOut 0.3s ease-in forwards;
}
@keyframes rtToastIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes rtToastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}
@keyframes rtToastBar {
  from { width: 100%; }
  to   { width: 0%; }
}
@media (max-width: 768px) {
  .flash-toast-wrap {
    top: calc(var(--rt-header-height) + 6px);
    left: 12px; right: 12px;
    max-width: none; width: auto;
  }
}

/* ============================================================
   Custom Confirm Dialog (แทน window.confirm)
   ============================================================ */
.rt-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1090;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity .2s;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.rt-confirm-overlay.show { opacity: 1; }
.rt-confirm-card {
  background: #fff;
  border-radius: 22px;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1), opacity .25s;
}
.rt-confirm-overlay.show .rt-confirm-card { transform: scale(1) translateY(0); opacity: 1; }
.rt-confirm-icon {
  display: flex; align-items: center; justify-content: center;
  padding: 26px 20px 6px;
  font-size: 56px;
}
.rt-confirm-icon .icon-circle {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px;
  color: #fff;
  background: linear-gradient(135deg, var(--rt-primary), var(--rt-primary-light));
  box-shadow: 0 6px 16px rgba(11, 58, 130, 0.3);
  animation: rtConfirmPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.rt-confirm-card.var-danger  .icon-circle { background: linear-gradient(135deg, #dc2626, #f87171); box-shadow: 0 6px 16px rgba(220,38,38,0.35); }
.rt-confirm-card.var-warning .icon-circle { background: linear-gradient(135deg, #f59e0b, #fbbf24); box-shadow: 0 6px 16px rgba(245,158,11,0.35); }
.rt-confirm-card.var-success .icon-circle { background: linear-gradient(135deg, #16a34a, #4ade80); box-shadow: 0 6px 16px rgba(22,163,74,0.35); }
@keyframes rtConfirmPop {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.rt-confirm-body {
  padding: 8px 24px 22px;
  text-align: center;
}
.rt-confirm-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--rt-text);
  margin: 0 0 6px;
}
.rt-confirm-msg {
  color: var(--rt-muted);
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-line;
}
.rt-confirm-actions {
  display: flex;
  gap: 10px;
  padding: 0 22px 22px;
}
.rt-confirm-actions .btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  min-height: 48px;
}
.rt-confirm-actions .btn-cancel {
  background: #f1f5f9;
  color: var(--rt-text);
  border: 0;
}
.rt-confirm-actions .btn-cancel:hover { background: #e2e8f0; }
.rt-confirm-actions .btn-ok {
  background: linear-gradient(135deg, var(--rt-primary), var(--rt-primary-light));
  color: #fff;
  border: 0;
  box-shadow: 0 4px 12px rgba(11, 58, 130, 0.3);
}
.rt-confirm-actions .btn-ok:hover { box-shadow: 0 6px 16px rgba(11, 58, 130, 0.4); transform: translateY(-1px); }
.rt-confirm-card.var-danger  .btn-ok { background: linear-gradient(135deg, #dc2626, #f87171); box-shadow: 0 4px 12px rgba(220,38,38,0.35); }
.rt-confirm-card.var-warning .btn-ok { background: linear-gradient(135deg, #f59e0b, #fbbf24); box-shadow: 0 4px 12px rgba(245,158,11,0.35); }
.rt-confirm-card.var-success .btn-ok { background: linear-gradient(135deg, #16a34a, #4ade80); box-shadow: 0 4px 12px rgba(22,163,74,0.35); }

/* ============================================================
   Pull-to-refresh indicator (mobile only)
   ============================================================ */
.rt-ptr-indicator {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #fff;
  color: var(--rt-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 14px rgba(11, 58, 130, 0.25);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  border: 2px solid var(--rt-primary);
}
.rt-ptr-indicator.ready {
  background: var(--rt-primary);
  color: #fff;
  border-color: var(--rt-primary);
  box-shadow: 0 6px 18px rgba(11, 58, 130, 0.4);
}
.rt-ptr-indicator.refreshing {
  background: var(--rt-primary);
  color: #fff;
  border-color: var(--rt-primary);
}
.rt-ptr-indicator.refreshing i {
  animation: rtPtrSpin 0.8s linear infinite;
}
@keyframes rtPtrSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ============================================================
   PWA Install Banner
   ============================================================ */
.rt-pwa-banner {
  position: fixed;
  left: 16px; right: 16px;
  bottom: -100px;
  z-index: 1060;
  background: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 10px 40px rgba(11, 58, 130, 0.25);
  border: 1px solid var(--rt-border);
  transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 480px;
  margin: 0 auto;
}
.rt-pwa-banner.show { bottom: 16px; }
.rt-pwa-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--rt-primary), var(--rt-primary-light));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.rt-pwa-content { flex: 1; min-width: 0; }
.rt-pwa-title { font-weight: 700; font-size: 14px; line-height: 1.3; }
.rt-pwa-sub   { font-size: 12px; color: var(--rt-muted); line-height: 1.5; margin-top: 2px; }
.rt-pwa-install { white-space: nowrap; flex-shrink: 0; font-weight: 700; }
.rt-pwa-dismiss {
  width: 30px; height: 30px;
  border: 0; background: transparent;
  color: var(--rt-muted);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.rt-pwa-dismiss:hover { background: #f1f5f9; color: var(--rt-text); }

/* บนมือถือ: เลื่อนเหนือ bottom-nav */
@media (max-width: 992px) {
  .rt-pwa-banner.show { bottom: 80px; }
}

/* ===== Cancel modal (ใช้ใน cases/view.php + cases/index.php) ===== */
.cancel-modal .modal-content {
  border-radius: 18px;
  border: none;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
}
.cancel-modal .modal-header {
  background: linear-gradient(135deg,#dc2626,#ef4444);
  color: #fff;
  border: 0;
  padding: 18px 22px;
}
.cancel-modal .modal-header .modal-title { font-weight: 700; display:flex; align-items:center; gap:8px; }
.cancel-modal .modal-header .btn-close { filter: invert(1) brightness(2); }
.cancel-modal .modal-body { padding: 22px; }
.cancel-modal .modal-footer { background: #f8fafc; border:0; padding: 14px 22px; }

.reason-tile {
  display: block;
  border: 2px solid var(--rt-border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all .15s;
  background: #fff;
  position: relative;
}
.reason-tile:hover { border-color: #f87171; background: #fef2f2; }
.reason-tile input { display: none; }
.reason-tile:has(input:checked) {
  border-color: #dc2626;
  background: #fef2f2;
  box-shadow: 0 6px 18px rgba(220,38,38,.12);
}
.reason-tile .reason-head {
  display: flex; align-items: center; gap: 12px;
  font-weight: 700; font-size: 15px;
}
.reason-tile .reason-head i {
  font-size: 22px; color: #dc2626;
  width: 36px; height: 36px;
  border-radius: 50%; background: #fee2e2;
  display: inline-flex; align-items: center; justify-content: center;
}
.reason-tile .reason-sub {
  font-size: 12px; color: var(--rt-muted); margin-top: 4px; padding-left: 48px;
}
.reason-tile:has(input:checked) .reason-head i {
  background: #dc2626; color: #fff;
}
.reason-tile-returned input:checked ~ .reason-head { color: #0891b2; }
.reason-tile-returned:has(input:checked) {
  border-color: #0891b2 !important;
  background: linear-gradient(135deg, #ecfeff, #cffafe) !important;
}
.reason-tile-returned:has(input:checked) .reason-head i {
  background: #0891b2 !important;
}

/* Print */
@media print {
  .app-sidebar, .app-header, .rt-bottom-nav, .rt-ptr-indicator, .rt-pwa-banner, .no-print { display: none !important; }
  .app-main { margin-left: 0; padding-top: 0; }
}

/* ========== 📡 Call Sign Badge — รหัส สน./นามเรียกขาน ทั่วระบบ ========== */
.cs-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  color: #b45309;
  border: 1px solid #f59e0b;
  font-weight: 700;
  font-size: 12.5px;
  line-height: 1.4;
  letter-spacing: 0.3px;
  font-family: 'Sarabun', sans-serif;
  white-space: nowrap;
  vertical-align: middle;
  box-shadow: 0 1px 2px rgba(245, 158, 11, 0.18);
}
.cs-badge i {
  font-size: 11px;
  color: #d97706;
}
.cs-badge-sm {
  padding: 1px 7px;
  font-size: 11px;
  border-radius: 5px;
  gap: 3px;
}
.cs-badge-sm i { font-size: 9px; }
.cs-badge-lg {
  padding: 5px 13px;
  font-size: 14px;
  border-radius: 8px;
  gap: 6px;
  box-shadow: 0 2px 5px rgba(245, 158, 11, 0.25);
}
.cs-badge-lg i { font-size: 13px; }
/* compatibility: legacy class .veh-crew-call → upgrade automatic */
.veh-crew-call {
  background: #fef3c7;
  color: #b45309;
  padding: 1px 7px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 11px !important;
  border: 1px solid #fcd34d;
}
