.mb-3 { margin-bottom: 1rem !important; }

.case-form .alert {
  border-radius: 12px;
}

.section-title {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 700;
  color: #0b1b44;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.full-span {
  grid-column: 1 / -1;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-label {
  font-weight: 600;
  margin-bottom: 8px;
  color: #334155;
}

.form-control,
.form-select {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 0.2rem rgba(29, 78, 216, 0.10);
  outline: none;
}

textarea.form-control {
  min-height: 96px;
  resize: vertical;
}

.latlng-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.map-card {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.map-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  margin-bottom: 10px;
}

.map-mode-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.search-results {
  max-height: 180px;
  overflow: auto;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: #f8fafc;
}

#supMap {
  height: 380px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.form-actions {
  display: flex;
  gap: 10px;
}

.d-none {
  display: none !important;
}

.result-item {
  width: 100%;
  display: block;
  text-align: left;
  border: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.result-item:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

.policy-inline-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
  align-items: center;
}

.policy-inline-btn {
  height: 44px;
  width: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: #1d4ed8;
  cursor: pointer;
  transition: .15s ease;
}

.policy-inline-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

.policy-inline-btn:focus {
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(29, 78, 216, 0.10);
}

.policy-inline-icon {
  width: 18px;
  height: 18px;
  display: block;
}

body.popup-open {
  overflow: hidden;
}

.pc-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 2000;
  opacity: 0;
  transition: opacity .18s ease;
  overflow-y: auto;
}

.pc-popup-backdrop.show {
  opacity: 1;
}

.pc-popup-card {
  width: min(100%, 420px);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: #fff;
  border-radius: 26px;
  padding: 22px 22px 18px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  transform: translateY(16px) scale(.98);
  transition: transform .2s ease;
}

.pc-popup-card.pc-popup-card-lg {
  width: min(100%, 760px);
  max-height: calc(100vh - 36px);
  background: #fff;
  border-radius: 26px;
  padding: 22px 22px 16px;
  text-align: left;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  overflow: hidden;
}

.pc-popup-backdrop.show .pc-popup-card {
  transform: translateY(0) scale(1);
}

.pc-popup-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  box-shadow: 0 14px 30px rgba(34, 197, 94, 0.35);
}

.pc-popup-icon-search {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  box-shadow: 0 14px 30px rgba(59, 130, 246, 0.28);
}

.popup-search-icon,
.popup-success-icon {
  width: 30px;
  height: 30px;
  display: block;
}

.pc-popup-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
  color: #0f172a;
  text-align: center;
}

.pc-popup-text {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.5;
  color: #64748b;
  text-align: center;
}

.pc-popup-case {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f0fdf4;
  color: #166534;
  font-weight: 700;
  letter-spacing: .2px;
}

.lookup-history,
.lookup-summary {
  margin-top: 16px;
}

.lookup-history-title {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 10px;
}

.lookup-history-list {
  display: grid;
  gap: 10px;
}

.lookup-history-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid #dbe4f0;
  border-radius: 18px;
  padding: 14px 16px;
  background: #fff;
}

.lookup-history-btn {
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: .15s ease;
}

.lookup-history-btn:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.lookup-history-btn.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.lookup-history-main {
  min-width: 0;
  flex: 1;
}

.lookup-history-case {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.lookup-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 14px;
  color: #475569;
  line-height: 1.55;
}

.lookup-history-empty {
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  color: #64748b;
  background: #f8fafc;
}

/* กล่องรายละเอียด */
.policy-summary-box {
  border: 1px solid #dbe4f0;
  border-radius: 18px;
  background: #f8fafc;
  overflow: hidden;
}

.policy-summary-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.policy-summary-table th,
.policy-summary-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
  text-align: left;
}

.policy-summary-table tr:last-child th,
.policy-summary-table tr:last-child td {
  border-bottom: 0;
}

.policy-summary-table th {
  width: 16%;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  background: transparent;
}

.policy-summary-table td {
  width: 34%;
  color: #0f172a;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
  word-break: break-word;
}

/* แยกแถวให้มีจังหวะ */
.policy-summary-table tr:nth-child(even) {
  background: rgba(255,255,255,0.55);
}

.policy-summary-empty {
  padding: 18px;
  text-align: center;
  color: #64748b;
}

/* ปุ่มล่าง */
.pc-popup-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pc-popup-actions .btn {
  min-width: 140px;
  border-radius: 14px;
}

.policy-popup-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, #fff 75%, rgba(255,255,255,0.85) 100%);
  padding-top: 14px;
  margin-top: 16px;
  justify-content: flex-end;
  border-top: 1px solid rgba(226, 232, 240, 0.9);
}

/* popup scrollbar */
.pc-popup-card::-webkit-scrollbar {
  width: 10px;
}

.pc-popup-card::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
  border: 2px solid #fff;
}

.pc-popup-card::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 767.98px) {
  .pc-popup-backdrop {
    padding: 10px;
    align-items: flex-start;
  }

  .pc-popup-card,
  .pc-popup-card.pc-popup-card-lg {
    width: 100%;
    max-height: calc(100vh - 20px);
    border-radius: 18px;
    padding: 18px 16px 14px;
  }

  .pc-popup-icon {
    width: 58px;
    height: 58px;
    margin-bottom: 10px;
  }

  .pc-popup-title {
    font-size: 18px;
  }

  .pc-popup-text {
    font-size: 13px;
    margin-bottom: 14px;
  }

  .lookup-history-row,
  .policy-popup-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .policy-summary-table,
  .policy-summary-table tbody,
  .policy-summary-table tr,
  .policy-summary-table th,
  .policy-summary-table td {
    display: block;
    width: 100%;
  }

  .policy-summary-table tr {
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 0;
  }

  .policy-summary-table tr:last-child {
    border-bottom: 0;
  }

  .policy-summary-table th {
    padding: 12px 16px 4px;
  }

  .policy-summary-table td {
    padding: 0 16px 12px;
    font-size: 14px;
  }
}

.map-notice {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #f5c2c7;
  background: #fff3f4;
  color: #842029;
  font-size: 14px;
}

.map-notice-warning {
  border-color: #ffe69c;
  background: #fff8db;
  color: #7a5b00;
}

.map-notice-danger {
  border-color: #f5c2c7;
  background: #fff3f4;
  color: #842029;
}

@media (max-width: 991.98px) {
  .form-grid-4,
  .form-grid-3,
  .form-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 767.98px) {
  .pc-popup-backdrop {
    padding: 10px;
    align-items: flex-start;
  }

  .pc-popup-card,
  .pc-popup-card.pc-popup-card-lg {
    width: 100%;
    max-height: calc(100vh - 20px);
    border-radius: 18px;
    padding: 18px 16px 14px;
  }

  .pc-popup-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 10px;
  }

  .pc-popup-title {
    font-size: 18px;
  }

  .pc-popup-text {
    font-size: 13px;
  }

  .lookup-history-row,
  .policy-popup-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .policy-summary-table,
  .policy-summary-table tbody,
  .policy-summary-table tr,
  .policy-summary-table th,
  .policy-summary-table td {
    display: block;
    width: 100%;
  }

  .policy-summary-table tr {
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 0;
  }

  .policy-summary-table tr:last-child {
    border-bottom: 0;
  }

  .policy-summary-table th {
    padding: 12px 16px 4px;
    background: transparent;
  }

  .policy-summary-table td {
    padding: 0 16px 12px;
  }
}

@media (max-width: 575.98px) {
  .form-grid-4,
  .form-grid-3,
  .form-grid-2,
  .latlng-grid,
  .map-toolbar,
  .policy-inline-wrap {
    grid-template-columns: 1fr;
  }

  .section-head,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

.required-label {
  font-weight: 600;
}

.required-mark {
  color: #dc2626;
  font-weight: 700;
}

.field-error {
  min-height: 18px;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.35;
  color: #dc2626;
  display: block;
}

.form-control.is-invalid,
.form-select.is-invalid,
textarea.form-control.is-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 0.18rem rgba(220, 38, 38, 0.12);
}

.lookup-history {
  margin-top: 16px;
}

.lookup-history-list {
  display: grid;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
}

.lookup-summary {
  margin-top: 16px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  padding-bottom: 6px;
}

.policy-popup-actions {
  position: static;
  margin-top: 14px;
  padding-top: 14px;
  justify-content: flex-end;
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  background: #fff;
}

.policy-summary-box {
  border: 1px solid #dbe4f0;
  border-radius: 18px;
  background: #f8fafc;
  overflow: hidden;
  width: 100%;
}

.policy-summary-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.pc-popup-card.pc-popup-card-lg::-webkit-scrollbar {
  width: 0;
  height: 0;
}


@media (max-width: 767.98px) {
  .pc-popup-backdrop {
    padding: 10px;
    align-items: flex-start;
  }

  .pc-popup-card,
  .pc-popup-card.pc-popup-card-lg {
    width: 100%;
    max-height: calc(100vh - 20px);
    border-radius: 18px;
    padding: 18px 16px 14px;
  }

  .pc-popup-card.pc-popup-card-lg {
    grid-template-rows: auto auto auto auto 1fr auto;
  }

  .pc-popup-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 10px;
  }

  .pc-popup-title {
    font-size: 18px;
  }

  .pc-popup-text {
    font-size: 13px;
  }

  .lookup-history-list {
    max-height: 180px;
    padding-right: 2px;
  }

  .lookup-summary {
    padding-right: 2px;
  }

  .lookup-history-row,
  .policy-popup-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .policy-summary-table,
  .policy-summary-table tbody,
  .policy-summary-table tr,
  .policy-summary-table th,
  .policy-summary-table td {
    display: block;
    width: 100%;
  }

  .policy-summary-table tr {
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 0;
  }

  .policy-summary-table tr:last-child {
    border-bottom: 0;
  }

  .policy-summary-table th {
    padding: 12px 16px 4px;
    background: transparent;
  }

  .policy-summary-table td {
    padding: 0 16px 12px;
  }
}
