:root {
  --a82-navy: #0b2b63;
  --a82-blue: #1d4ed8;
  --a82-blue-soft: #eff6ff;
  --a82-gold: #c9a84c;
  --a82-green: #15803d;
  --a82-green-soft: #ecfdf3;
  --a82-orange: #c2410c;
  --a82-orange-soft: #fff7ed;
  --a82-red: #b91c1c;
  --a82-red-soft: #fef2f2;
  --a82-purple: #6d28d9;
  --a82-purple-soft: #f5f3ff;
  --a82-slate: #475569;
  --a82-border: #dbe4f0;
  --a82-surface: #ffffff;
  --a82-bg: #f4f7fb;
}

.a82-page {
  min-height: calc(100vh - 64px);
  padding: 26px 28px 56px;
  background:
    radial-gradient(circle at 96% 0%, rgba(37, 99, 235, .08), transparent 28%),
    var(--a82-bg);
  color: #172033;
  font-family: "Sarabun", "IBM Plex Sans Thai", sans-serif;
}

.a82-wrap {
  width: min(1500px, 100%);
  margin: 0 auto;
}

.a82-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.a82-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--a82-blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.a82-title {
  margin: 0;
  color: var(--a82-navy);
  font-size: clamp(24px, 2.2vw, 34px);
  line-height: 1.22;
  font-weight: 800;
}

.a82-subtitle {
  margin: 8px 0 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.65;
}

.a82-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.a82-btn {
  appearance: none;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: #334155;
  padding: 8px 14px;
  font: 700 12.5px/1.35 "Sarabun", sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.a82-btn:hover {
  transform: translateY(-1px);
  border-color: #93a4bb;
  box-shadow: 0 7px 18px rgba(15, 23, 42, .08);
}

.a82-btn:disabled {
  opacity: .48;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.a82-btn-primary {
  color: #fff;
  border-color: var(--a82-blue);
  background: linear-gradient(135deg, #2563eb, #1744af);
}

.a82-btn-success {
  color: #fff;
  border-color: #15803d;
  background: linear-gradient(135deg, #16a34a, #166534);
}

.a82-btn-danger {
  color: #fff;
  border-color: #dc2626;
  background: linear-gradient(135deg, #dc2626, #991b1b);
}

.a82-btn-warning {
  color: #fff;
  border-color: #ea580c;
  background: linear-gradient(135deg, #f97316, #c2410c);
}

.a82-btn-ghost {
  color: var(--a82-blue);
  border-color: #bfdbfe;
  background: #eff6ff;
}

.a82-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.a82-stats-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.a82-stat {
  position: relative;
  overflow: hidden;
  min-height: 104px;
  padding: 17px 18px;
  border: 1px solid var(--a82-border);
  border-radius: 15px;
  background: var(--a82-surface);
  box-shadow: 0 8px 24px rgba(30, 64, 175, .045);
}

button.a82-stat-filter {
  appearance: none;
  width: 100%;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

button.a82-stat-filter:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--stat-color, #2563eb) 45%, #dbe4f0);
  box-shadow: 0 12px 28px rgba(30, 64, 175, .11);
}

button.a82-stat-filter.active {
  border-color: var(--stat-color, #2563eb);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--stat-color, #2563eb) 13%, transparent), 0 12px 28px rgba(30, 64, 175, .09);
}

button.a82-stat-filter.active::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--stat-color, #2563eb);
}

.a82-stat::after {
  content: "";
  position: absolute;
  right: -26px;
  top: -34px;
  width: 98px;
  height: 98px;
  border-radius: 50%;
  background: var(--stat-color, #2563eb);
  opacity: .075;
}

.a82-stat-label {
  color: #64748b;
  font-size: 11.5px;
  font-weight: 700;
}

.a82-stat-value {
  margin-top: 3px;
  color: var(--stat-color, var(--a82-blue));
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}

.a82-stat-note {
  margin-top: 5px;
  color: #94a3b8;
  font-size: 10.5px;
}

.a82-card {
  border: 1px solid var(--a82-border);
  border-radius: 15px;
  background: var(--a82-surface);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .045);
  overflow: hidden;
}

.a82-card + .a82-card {
  margin-top: 15px;
}

.a82-card-head {
  min-height: 58px;
  padding: 13px 18px;
  border-bottom: 1px solid #e7edf5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.a82-card-title {
  margin: 0;
  color: var(--a82-navy);
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.a82-card-body {
  padding: 18px;
}

.a82-filter {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) repeat(2, minmax(160px, .7fr)) auto;
  gap: 10px;
  align-items: end;
}

.a82-field {
  min-width: 0;
}

.a82-label {
  display: block;
  margin: 0 0 6px;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
}

.a82-required {
  color: #dc2626;
}

.a82-input,
.a82-select,
.a82-textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: #1e293b;
  padding: 9px 11px;
  font: 500 12.5px/1.5 "Sarabun", sans-serif;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}

.a82-input,
.a82-select {
  min-height: 40px;
}

.a82-textarea {
  min-height: 102px;
  resize: vertical;
}

.a82-input:focus,
.a82-select:focus,
.a82-textarea:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.a82-table-wrap {
  overflow: auto;
}

.a82-table {
  width: 100%;
  min-width: 900px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.a82-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 13px;
  color: #475569;
  background: #f6f9fd;
  border-bottom: 1px solid #dbe4f0;
  font-size: 10.5px;
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
}

.a82-table td {
  padding: 13px;
  border-bottom: 1px solid #edf1f6;
  color: #334155;
  vertical-align: top;
}

.a82-table tbody tr {
  transition: background .15s;
}

.a82-table tbody tr:hover {
  background: #f8fbff;
}

.a82-table tbody tr:last-child td {
  border-bottom: 0;
}

.a82-link {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--a82-blue);
  font: 800 12px/1.45 "Sarabun", sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.a82-muted {
  color: #94a3b8;
  font-size: 10.5px;
}

.a82-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 25px;
  padding: 4px 9px;
  border: 1px solid #d8e2ef;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
}

.a82-badge.blue { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.a82-text-blue { color: var(--a82-blue); font-weight: 700; }
.a82-badge.green { color: #166534; background: #ecfdf3; border-color: #bbf7d0; }
.a82-badge.orange { color: #9a3412; background: #fff7ed; border-color: #fed7aa; }
.a82-badge.red { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
.a82-badge.purple { color: #6d28d9; background: #f5f3ff; border-color: #ddd6fe; }
.a82-badge.slate { color: #475569; background: #f8fafc; border-color: #cbd5e1; }
.a82-badge.gold { color: #7c5f17; background: #fffbeb; border-color: #fde68a; }

.a82-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.a82-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.a82-info {
  padding: 13px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  background: #fbfdff;
}

.a82-info-label {
  color: #94a3b8;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.a82-info-value {
  margin-top: 4px;
  color: #1e293b;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.55;
}

.a82-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 11px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
  font-size: 12px;
  line-height: 1.6;
}

.a82-alert.warning { color: #9a3412; border-color: #fed7aa; background: #fff7ed; }
.a82-alert.danger { color: #991b1b; border-color: #fecaca; background: #fef2f2; }
.a82-alert.success { color: #166534; border-color: #bbf7d0; background: #ecfdf3; }

.a82-tabs {
  display: flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--a82-border);
  border-radius: 12px;
  background: #edf2f8;
  overflow-x: auto;
  margin-bottom: 14px;
}

.a82-tab {
  flex: 0 0 auto;
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  padding: 9px 13px;
  font: 700 11.5px/1.2 "Sarabun", sans-serif;
  cursor: pointer;
}

.a82-tab.active {
  color: var(--a82-navy);
  background: #fff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, .08);
}

.a82-stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.a82-step {
  position: relative;
  padding: 12px;
  border: 1px solid #dbe4f0;
  border-radius: 11px;
  background: #f8fafc;
}

.a82-step.done { border-color: #86efac; background: #f0fdf4; }
.a82-step.current { border-color: #93c5fd; background: #eff6ff; box-shadow: inset 0 0 0 1px #bfdbfe; }
.a82-step.returned { border-color: #fdba74; background: #fff7ed; }
.a82-step-no { color: #94a3b8; font-size: 9px; font-weight: 800; }
.a82-step-name { margin-top: 3px; color: #334155; font-size: 10.5px; font-weight: 800; line-height: 1.4; }

.a82-timeline {
  display: grid;
  gap: 0;
}

.a82-timeline-item {
  position: relative;
  padding: 0 0 17px 28px;
}

.a82-timeline-item::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 13px;
  bottom: -2px;
  width: 1px;
  background: #dbe4f0;
}

.a82-timeline-item:last-child::before { display: none; }

.a82-timeline-dot {
  position: absolute;
  left: 0;
  top: 3px;
  width: 15px;
  height: 15px;
  border: 3px solid #dbeafe;
  border-radius: 50%;
  background: #2563eb;
}

.a82-timeline-title { color: #1e293b; font-size: 11.5px; font-weight: 800; }
.a82-timeline-meta { color: #94a3b8; font-size: 9.5px; margin-top: 2px; }
.a82-timeline-text { color: #64748b; font-size: 11px; line-height: 1.55; margin-top: 3px; }

.a82-document {
  min-height: 520px;
  padding: 42px 50px;
  border: 1px solid #d7dee9;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 42px rgba(15, 23, 42, .09);
  color: #111827;
  font-size: 13px;
  line-height: 1.8;
}

.a82-document h2,
.a82-document h3 {
  text-align: center;
  color: #111827;
  font-weight: 700;
}

.a82-document-signature {
  margin-top: 34px;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.a82-document-signature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  justify-content: stretch;
  align-items: stretch;
}

.a82-sign-box {
  min-width: 280px;
  padding: 16px;
  border: 1px dashed #93a4bb;
  border-radius: 10px;
  text-align: center;
  background: #fbfdff;
}

.a82-document-signature-grid .a82-sign-box {
  min-width: 0;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.a82-sign-box.signed {
  border-style: solid;
  border-color: #86efac;
  background: #f8fffb;
}

.a82-sign-box.pending {
  color: #64748b;
  background: #f8fafc;
}

.a82-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 8, 23, .62);
  backdrop-filter: blur(4px);
}

.a82-modal {
  width: min(620px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid #dbe4f0;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(2, 8, 23, .28);
}

.a82-modal.a82-modal-wide {
  width: min(860px, 100%);
}

.a82-signature-selector {
  margin-top: 4px;
}

.a82-signature-heading,
.a82-signature-workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.a82-signature-methods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

/* Used when the "ภาพลายเซ็น" option is hidden (ShowImageMethod="false"),
   e.g. BoardCaseCircularDocumentPage, so the remaining 2 cards fill the row
   evenly instead of leaving an empty third column. */
.a82-signature-methods-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.a82-signature-method {
  min-height: 98px;
  padding: 13px;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  background: #fff;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.a82-signature-method:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.a82-signature-method.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .11);
}

.a82-signature-method input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.a82-signature-method-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #e8f0ff;
  color: #1d4ed8;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.a82-signature-method strong,
.a82-signature-method small {
  display: block;
}

.a82-signature-method strong {
  color: #1e293b;
  font-size: 12px;
}

.a82-signature-method small {
  margin-top: 5px;
  color: #64748b;
  font-size: 10.5px;
  line-height: 1.45;
}

.a82-signature-workspace {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  background: #f8fafc;
}

.a82-signature-canvas {
  display: block;
  width: 100%;
  height: 220px;
  margin-top: 12px;
  border: 1px dashed #93a4bb;
  border-radius: 10px;
  background:
    linear-gradient(transparent calc(100% - 46px), #dbe4f0 calc(100% - 45px), transparent calc(100% - 44px)),
    #fff;
  cursor: crosshair;
  touch-action: none;
}

.a82-signature-preview {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
}

.a82-signature-preview img,
.a82-signed-image {
  display: block;
  max-width: 220px;
  max-height: 90px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.a82-modal-head {
  padding: 17px 20px;
  border-bottom: 1px solid #e7edf5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.a82-modal-body { padding: 20px; }
.a82-modal-foot {
  padding: 14px 20px 19px;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.a82-empty {
  padding: 54px 24px;
  text-align: center;
  color: #94a3b8;
}

.a82-empty i {
  display: block;
  margin-bottom: 10px;
  color: #cbd5e1;
  font-size: 38px;
}

.a82-section-separator {
  height: 1px;
  margin: 18px 0;
  background: #e7edf5;
}

.a82-right {
  text-align: right;
}

.a82-center {
  text-align: center;
}

.a82-nowrap {
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .a82-stats,
  .a82-stats-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .a82-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .a82-stepper { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .a82-page { padding: 18px 14px 42px; }
  .a82-hero { display: block; }
  .a82-actions { justify-content: flex-start; margin-top: 14px; }
  .a82-stats,
  .a82-stats-5,
  .a82-grid-2,
  .a82-grid-3,
  .a82-filter { grid-template-columns: 1fr; }
  .a82-stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .a82-document { padding: 28px 22px; }
  .a82-signature-methods { grid-template-columns: 1fr; }
  .a82-signature-heading,
  .a82-signature-workspace-head { align-items: flex-start; flex-direction: column; }
}
