/* ======= DESIGN TOKENS ======= */
:root {
  --bg-base:       #FAF7FF;
  --surface:       rgba(255,255,255,0.92);
  --surface-2:     rgba(255,255,255,0.75);
  --surface-3:     rgba(247,243,255,0.85);
  --border:        rgba(196,181,253,0.3);
  --border-strong: rgba(109,40,217,0.25);

  --text:          #2e243d;
  --text-sub:      rgba(46,36,61,0.65);
  --text-inv:      #ffffff;

  --blue:          #c4b5fd;      /* Lavender */
  --blue-2:        #6d28d9;      /* Plum */
  --blue-glow:     rgba(196,181,253,0.25);
  --cyan:          #e9d5ff;      /* Soft Purple */
  --cyan-2:        #8b5cf6;      /* Medium Purple */
  --cyan-glow:     rgba(139,92,246,0.22);
  
  /* สีเขียวสำหรับ ID สำเร็จ และ Progress bar (คงเดิม) */
  --green:         #a8e6cf;
  --green-2:       #7dccb1;
  --danger:        #ff8b94;
  --danger-2:      #e06b74;

  --radius-xl:     26px;
  --radius-lg:     18px;
  --radius-md:     13px;
  --radius-sm:     9px;

  --shadow-card:   0 14px 40px rgba(109,40,217,0.08), 0 2px 8px rgba(0,0,0,0.03);
  --shadow-btn:    0 8px 20px rgba(109,40,217,0.25);
  --wave-bg:       rgba(196,181,253,0.15);
}

body.dark {
  --bg-base:       #15111c;
  --surface:       rgba(31,26,43,0.95);
  --surface-2:     rgba(255,255,255,0.06);
  --surface-3:     rgba(255,255,255,0.04);
  --border:        rgba(196,181,253,0.15);
  --border-strong: rgba(196,181,253,0.3);

  --text:          #f6f4fa;
  --text-sub:      rgba(246,244,250,0.65);
  --text-inv:      #ffffff;

  --blue:          #8b5cf6;
  --blue-2:        #c4b5fd;
  --blue-glow:     rgba(196,181,253,0.15);
  --cyan:          #6d28d9;
  --cyan-2:        #e9d5ff;
  --cyan-glow:     rgba(139,92,246,0.15);
  
  /* สีเขียวสำหรับ ID สำเร็จ และ Progress bar (คงเดิม) */
  --green:         #7dccb1;
  --green-2:       #a8e6cf;

  --shadow-card:   0 18px 50px rgba(0,0,0,0.7), 0 2px 10px rgba(0,0,0,0.5);
  --shadow-btn:    0 8px 20px rgba(0,0,0,0.6);
  --wave-bg:       rgba(0,0,0,0.25);
}

/* ======= RESET ======= */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html { scroll-behavior: smooth; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

/* ======= ICONS & SPINNER ======= */
.material-symbols-rounded {
  font-size: 1.2em;
  vertical-align: middle;
}
.css-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  vertical-align: middle;
}

/* ======= AURORA BACKGROUND ======= */
.bg-aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg-base);
  transition: background 0.5s ease;
}

.bg-mesh {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 5% 0%,    rgba(196,181,253,0.45) 0%, transparent 65%),
    radial-gradient(ellipse 55% 50% at 95% 15%,   rgba(233,213,255,0.4) 0%, transparent 60%),
    radial-gradient(ellipse 60% 55% at 10% 55%,   rgba(250,247,255,0.5) 0%, transparent 65%),
    radial-gradient(ellipse 65% 60% at 90% 80%,   rgba(109,40,217,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 50% 45% at 50% 50%,   rgba(167,139,250,0.25) 0%, transparent 70%);
  transition: opacity 0.5s ease;
}
body.dark .bg-mesh {
  background:
    radial-gradient(ellipse 70% 60% at 5% 0%,    rgba(109,40,217,0.25) 0%, transparent 65%),
    radial-gradient(ellipse 55% 50% at 95% 15%,  rgba(139,92,246,0.2) 0%, transparent 60%),
    radial-gradient(ellipse 60% 55% at 10% 55%,  rgba(88,28,135,0.2) 0%, transparent 65%),
    radial-gradient(ellipse 65% 60% at 90% 80%,  rgba(167,139,250,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 50% 45% at 50% 50%,  rgba(76,29,149,0.25) 0%, transparent 70%);
}

.blob { position: absolute; border-radius: 50%; }
.blob-1 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(196,181,253,0.5) 0%, transparent 70%); top: -220px; left: -150px; animation-duration: 20s; animation-delay: 0s; }
.blob-2 { width: 380px; height: 380px; background: radial-gradient(circle, rgba(233,213,255,0.5) 0%, transparent 70%); top: 0%; right: -120px; animation-duration: 16s; animation-delay: -5s; }
.blob-3 { width: 420px; height: 420px; background: radial-gradient(circle, rgba(250,247,255,0.5) 0%, transparent 70%); top: 38%; left: -100px; animation-duration: 24s; animation-delay: -11s; }
.blob-4 { width: 320px; height: 320px; background: radial-gradient(circle, rgba(139,92,246,0.25) 0%, transparent 70%); bottom: 8%; right: -80px; animation-duration: 18s; animation-delay: -8s; }
.blob-5 { width: 260px; height: 260px; background: radial-gradient(circle, rgba(167,139,250,0.3) 0%, transparent 70%); top: 55%; left: 20%; animation-duration: 22s; animation-delay: -14s; }
.blob-6 { width: 220px; height: 220px; background: radial-gradient(circle, rgba(109,40,217,0.2) 0%, transparent 70%); top: 18%; left: 35%; animation-duration: 28s; animation-delay: -6s; }

body.dark .blob-1 { background: radial-gradient(circle, rgba(109,40,217,0.3) 0%, transparent 70%); }
body.dark .blob-2 { background: radial-gradient(circle, rgba(139,92,246,0.25) 0%, transparent 70%); }
body.dark .blob-3 { background: radial-gradient(circle, rgba(88,28,135,0.3) 0%, transparent 70%); }
body.dark .blob-4 { background: radial-gradient(circle, rgba(167,139,250,0.2) 0%, transparent 70%); }
body.dark .blob-5 { background: radial-gradient(circle, rgba(76,29,149,0.25) 0%, transparent 70%); }
body.dark .blob-6 { background: radial-gradient(circle, rgba(124,58,237,0.2) 0%, transparent 70%); }

/* ======= BODY ======= */
body, button, input, textarea, select {
  font-family: 'Kanit', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background: transparent;
  min-height: 100vh;
  color: var(--text);
  padding: 18px 14px 50px;
  overflow-x: hidden;
  transition: color 0.3s ease;
  position: relative;
}

.page-bg-wave {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  z-index: -1;
  line-height: 0;
  pointer-events: none;
}
.page-bg-wave svg { display: block; width: 100%; height: 20vh; min-height: 150px; }
.page-bg-wave path { transition: fill 0.45s ease; }
.page-bg-wave path:nth-child(1) { fill: rgba(196,181,253,0.15); }
.page-bg-wave path:nth-child(2) { fill: rgba(167,139,250,0.15); }
.page-bg-wave path:nth-child(3) { fill: rgba(109,40,217,0.1); }
body.dark .page-bg-wave path:nth-child(1) { fill: rgba(139,92,246,0.06); }
body.dark .page-bg-wave path:nth-child(2) { fill: rgba(109,40,217,0.08); }
body.dark .page-bg-wave path:nth-child(3) { fill: rgba(76,29,149,0.05); }

/* ======= CONTAINER ======= */
.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 22px 20px 28px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeUp 0.5s cubic-bezier(0.16,1,0.3,1) both;
  position: relative;
  overflow: hidden;
}
.container::before {
  content: ''; position: absolute; inset: 0;
  background-color: var(--border-strong);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M14 11v6M11 14h6' stroke='black' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M14 11v6M11 14h6' stroke='black' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
  -webkit-mask-size: 28px 28px;
  mask-size: 28px 28px;
  opacity: 1.0;
  pointer-events: none; 
  z-index: 0;
}
.container > * { position: relative; z-index: 1; }

.wave-wrap { margin: 0px -20px -1px -20px; line-height: 0; overflow: hidden; }
.wave-wrap svg { display: block; width: calc(100% + 1.3px); height: 55px; }
.wave-wrap path { fill: var(--wave-bg); transition: fill 0.3s ease; }
.bottom-section { margin: 0 -20px -28px -20px; padding: 0px 20px 28px 20px; background: var(--wave-bg); transition: background 0.3s ease; }

/* ======= BALANCE CARD ======= */
.balance-card {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #e9d5ff 0%, #c4b5fd 50%, #a78bfa 100%);
  border-radius: var(--radius-lg); padding: 20px 22px 18px; margin-bottom: 22px;
  color: #2e243d; display: flex; justify-content: space-between; align-items: flex-end;
  box-shadow: 0 14px 32px rgba(196,181,253,0.4), inset 0 1px 0 rgba(255,255,255,0.7);
  cursor: pointer; user-select: none; transition: transform 0.22s ease, box-shadow 0.22s ease;
}
body.dark .balance-card {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 50%, #4c1d95 100%);
  color: #fcf6ff; box-shadow: 0 14px 32px rgba(109,40,217,0.4), inset 0 1px 0 rgba(255,255,255,0.15);
}
.balance-card:active { transform: scale(0.97); }
.balance-card::before { content: ''; position: absolute; width: 210px; height: 210px; background: rgba(255,255,255,0.3); border-radius: 50%; top: -110px; right: -70px; }
body.dark .balance-card::before { background: rgba(255,255,255,0.1); }
.balance-card::after { content: ''; position: absolute; width: 130px; height: 130px; background: rgba(255,255,255,0.25); border-radius: 50%; bottom: -70px; left: 20px; }
body.dark .balance-card::after { background: rgba(255,255,255,0.08); }

.bal-left .bal-label { font-size: 11px; font-weight: 700; opacity: 0.9; letter-spacing: 0.2px; margin-bottom: 7px; display: flex; align-items: center; gap: 7px; }
.bal-left .bal-label .rate-pill { background: rgba(61,52,69,0.12); border-radius: 99px; padding: 2px 8px; font-size: 9px; font-weight: 700; letter-spacing: 0.3px; }
body.dark .bal-left .bal-label .rate-pill { background: rgba(255,255,255,0.2); }
.bal-left .amount { font-family: 'Bebas Neue', sans-serif !important; font-size: 42px; font-weight: 400; letter-spacing: -1.8px; line-height: 1; }
.bal-right { text-align: right; }
.bal-right .thb-label { font-size: 10px; font-weight: 700; opacity: 0.8; }
.bal-right .thb-amount { font-family: 'Bebas Neue', sans-serif !important; font-size: 25px; font-weight: 400; letter-spacing: -0.3px; }

/* ======= APP TITLE ======= */
.app-title { font-family: 'Carter One',sans-serif !important; text-align: center; margin: 0 auto 14px auto; font-size: 2rem; font-weight: 700; letter-spacing: -0.5px; width: fit-content; display: block; }
.gradient-text {
  background: linear-gradient(to right, #6d28d9, #8b5cf6, #c4b5fd, #a78bfa, #6d28d9) !important;
  -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; background-clip: text !important;
}
body.dark .gradient-text {
  background: linear-gradient(to right, #c4b5fd, #a78bfa, #8b5cf6, #a78bfa, #c4b5fd) !important;
  -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; background-clip: text !important;
}

.credit-text {
    font-family: 'Kanit',sans-serif !important;
    position: absolute;
    bottom: -8px; 
    right: 15px;   
    white-space: nowrap; 
    font-size: 12px; 
    font-weight: 600;
    letter-spacing: 0;
    color: #778899 !important; 
    -webkit-text-fill-color: #778899 !important; 
}

/* ======= THEME TOGGLE ======= */
.theme-toggle { display: flex; justify-content: center; gap: 12px; margin-bottom: 20px; }
.theme-toggle-btn {
  display: flex; align-items: center; justify-content: center; flex: 1; gap: 6px; border: 1.5px solid var(--border-strong); border-radius: 99px; padding: 10px 16px;
  background: var(--surface-2); color: var(--blue-2); font-weight: 800; font-size: 12px; cursor: pointer; transition: all 0.2s ease; font-family: inherit; letter-spacing: 0.2px;
}
body.dark .theme-toggle-btn { color: var(--cyan-2); }
.theme-toggle-btn:hover { background: var(--blue-glow); }
.theme-toggle-btn:active { transform: scale(0.92); }
.theme-toggle-btn .material-symbols-rounded { font-size: 16px; }

/* ======= SECTION LABEL ======= */
.sec-label { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; margin-top: 20px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.9px; color: var(--blue-2); }
body.dark .sec-label { color: var(--cyan-2); }
.sec-label .material-symbols-rounded { font-size: 16px; }

/* ======= TEXTAREA / INPUT ======= */
textarea, input[type="text"], input[type="number"] {
  width: 100%; border-radius: var(--radius-md); padding: 13px 15px; font-size: 13px; font-weight: 600; outline: none; border: 1.5px solid var(--border-strong);
  background: var(--surface-3); color: var(--text); transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s; font-family: inherit; -webkit-appearance: none; appearance: none;
}
textarea::placeholder, input::placeholder { color: var(--text-sub); font-weight: 600; }
textarea:focus, input:focus { border-color: var(--cyan-2); box-shadow: 0 0 0 3px var(--cyan-glow); transform: translateY(-1px); }
body.dark textarea, body.dark input[type="text"], body.dark input[type="number"] { background: rgba(255,255,255,0.06); }
#serviceId, #serviceRate, [id^="qty_"] { text-align: center; font-weight: 700; }
.link-count { margin-top: 7px; text-align: right; font-size: 11px; font-weight: 700; color: var(--text-sub); }

/* ======= CONFIG CARD ======= */
.config-card { margin-top: 14px; padding: 15px 16px; border-radius: var(--radius-lg); display: flex; gap: 12px; background: var(--surface-2); border: 1.5px solid var(--border-strong); }
.config-field { flex: 1; }
.config-field > .config-label { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.7px; color: var(--blue-2); margin-bottom: 8px; opacity: 0.9; }
body.dark .config-field > .config-label { color: var(--cyan-2); }

/* ======= BUTTONS ======= */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: none; outline: none; border-radius: 16px; padding: 15px; font-size: 16px; font-weight: 800; cursor: pointer; transition: transform 0.2s cubic-bezier(0.175,0.885,0.32,1.275), filter 0.15s, box-shadow 0.2s;
  position: relative; overflow: hidden; color: white; font-family: inherit; letter-spacing: 0.1px;
}
.btn::before { content: ''; position: absolute; inset: 0 0 50% 0; background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, transparent 100%); border-radius: inherit; pointer-events: none; }
@media (hover: hover) { .btn:hover { transform: translateY(-2px); filter: brightness(1.04); } }
.btn:active { transform: scale(0.95) translateY(1px) !important; filter: brightness(1.05); transition: 0.07s !important; }

.btn-blue { margin-top: 14px; background: linear-gradient(145deg, #a78bfa, #6d28d9); box-shadow: 0 8px 22px rgba(109,40,217,0.3); text-shadow: 0 1px 3px rgba(88,28,135,0.4); }
body.dark .btn-blue { background: linear-gradient(145deg, #8b5cf6, #5b21b6); box-shadow: 0 8px 22px rgba(91,33,182,0.4); text-shadow: 0 1px 3px rgba(0,0,0,0.3); }

.btn-cyan { margin-top: 14px; background: linear-gradient(145deg, #e9d5ff, #c4b5fd); box-shadow: 0 8px 22px rgba(196,181,253,0.4); text-shadow: 0 1px 3px rgba(109,40,217,0.2); }
body.dark .btn-cyan { background: linear-gradient(145deg, #a78bfa, #7c3aed); box-shadow: 0 8px 22px rgba(124,58,237,0.3); text-shadow: 0 1px 3px rgba(0,0,0,0.3); }

.btn-danger { background: linear-gradient(145deg, #ffb3ba, #ffdfba); box-shadow: 0 6px 18px rgba(255,179,186,0.4); text-shadow: 0 1px 3px rgba(180,100,100,0.3); }
body.dark .btn-danger { background: linear-gradient(145deg, #c27d83, #c4a785); box-shadow: 0 6px 18px rgba(194,125,131,0.3); text-shadow: 0 1px 3px rgba(0,0,0,0.3); }

/* ======= QUICK FILL ======= */
.quick-fill-card { margin-top: 14px; padding: 14px; border-radius: var(--radius-lg); background: var(--surface-2); border: 1.5px solid var(--border-strong); }
.quick-fill-title { display: flex; justify-content: center; align-items: center; gap: 4px; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.8px; color: var(--blue-2); margin-bottom: 10px; }
body.dark .quick-fill-title { color: var(--cyan-2); }
.quick-fill-group { display: flex; gap: 8px; }
.quick-fill-group + .quick-fill-group { margin-top: 8px; }
.btn-quick { flex: 1; padding: 10px 5px; font-size: 12px; font-weight: 800; border-radius: var(--radius-md); letter-spacing: 0.1px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.18); border: none; cursor: pointer; }
.btn-1600 { background: #d8b4fe; } /* Soft purple */
.btn-1900 { background: #c4b5fd; } /* Lavender */
.btn-2200 { background: #a78bfa; } /* Medium purple */
.btn-1999 { background: #8ce09f; } /* Soft green */
.btn-2222 { background: #7cc6fe; } /* Soft blue */
body.dark .btn-quick { text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
body.dark .btn-1600 { background: #a78bfa; }
body.dark .btn-1900 { background: #8b5cf6; }
body.dark .btn-2200 { background: #7c3aed; }
body.dark .btn-1999 { background: #61a670; }
body.dark .btn-2222 { background: #5c97c4; }

/* ======= TABLE ======= */
.table-container { margin-top: 16px; overflow: hidden; border-radius: var(--radius-lg); border: 1.5px solid var(--border-strong); background: var(--surface); }
body.dark .table-container { background: rgba(255,255,255,0.04); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--blue-glow); }
th { padding: 12px 9px; font-size: 12px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--blue-2); }
body.dark th { color: var(--cyan-2); }
td { padding: 12px 9px; border-bottom: 1px solid var(--border-strong); font-size: 13px; font-weight: 600; text-align: center; vertical-align: middle; }body.dark td { border-bottom-color: rgba(255,255,255,0.08); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: var(--blue-glow); }
.btn-check-all { display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1.5px solid var(--blue-2); border-radius: 8px; padding: 4px 9px; background: transparent; color: var(--blue-2); font-size: 11px; font-weight: 700; cursor: pointer; font-family: inherit; transition: all 0.18s; letter-spacing: 0.2px; }
body.dark .btn-check-all { border-color: var(--cyan-2); color: var(--cyan-2); }
.btn-check-all:hover { background: var(--blue-glow); }
.btn-check-all:active { transform: scale(0.9); }
.btn-check-all .material-symbols-rounded { font-size: 14px; }
.status-box { margin-top: 5px; padding-top: 3px; text-align: left; }
.status-txt { font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.status-txt .material-symbols-rounded { font-size: 13px; }

/* ======= PROGRESS BAR ======= */
/* (คงค่าสีเดิมไว้ตามที่คุณต้องการ) */
.progress-container { width: 100%; background: var(--surface-2); border-radius: 99px; margin-top: 14px; height: 20px; position: relative; overflow: hidden; display: none; border: 1.5px solid var(--border-strong); }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #11998e, #38ef7d); border-radius: 99px; transition: width 0.3s ease; }
.progress-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; color: white; text-shadow: 0 1px 3px rgba(100,100,100,0.5); z-index: 2; }
body.dark .progress-text { text-shadow: 0 1px 3px rgba(0,0,0,0.8); }

/* ======= ACTION BUTTONS ROW ======= */
.action-row { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 14px; }
.btn-retry-sm { width: auto; padding: 10px 24px; font-size: 12px; border-radius: var(--radius-md); margin-top: 0 !important; }

/* ======= SUMMARY CARD ======= */
.summary-card { margin-top: 0px; display: flex; justify-content: space-around; align-items: center; padding: 16px; border-radius: var(--radius-lg); background: var(--surface-2); border: 1.5px solid var(--border-strong); text-align: center; }
body.dark .summary-card { background: rgba(255,255,255,0.04); }
.sum-divider { width: 1px; height: 36px; background: var(--border-strong); border-radius: 99px; flex-shrink: 0; }
.summary-item .s-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--blue-2); margin-bottom: 5px; }
body.dark .summary-item .s-label { color: var(--text-sub); }
.summary-item .s-val { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; color: var(--text); }
.summary-item.accent .s-val { color: var(--cyan-2); }
body.dark .summary-item.accent .s-val { color: var(--cyan-2); }

/* ======= TOAST ======= */
#toast {
  display: flex; align-items: center; gap: 8px;
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(120px); opacity: 0; visibility: hidden;
  background: rgba(46,36,61,0.95); color: white; padding: 12px 22px; border-radius: 14px;
  font-size: 13px; font-weight: 700; z-index: 999;
  transition: all 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.07);
  white-space: nowrap;
}
body:not(.dark) #toast { background: rgba(46,36,61,0.95); }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }

/* ======= ANIMATIONS ======= */
@keyframes fadeUp { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
@keyframes rowSliceIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.animated-row { animation: rowSliceIn 0.32s cubic-bezier(0.16,1,0.3,1) both; }

.container > *:nth-child(1)  { animation: fadeIn 0.4s ease 0.05s backwards; }
.container > *:nth-child(2)  { animation: fadeIn 0.4s ease 0.10s backwards; }
.container > *:nth-child(3)  { animation: fadeIn 0.4s ease 0.15s backwards; }
.container > *:nth-child(4)  { animation: fadeIn 0.4s ease 0.20s backwards; }
.container > *:nth-child(5)  { animation: fadeIn 0.4s ease 0.25s backwards; }
.container > *:nth-child(6)  { animation: fadeIn 0.4s ease 0.28s backwards; }
.container > *:nth-child(7)  { animation: fadeIn 0.4s ease 0.31s backwards; }
.container > *:nth-child(8)  { animation: fadeIn 0.4s ease 0.34s backwards; }
.container > *:nth-child(9)  { animation: fadeIn 0.4s ease 0.37s backwards; }
.container > *:nth-child(10) { animation: fadeIn 0.4s ease 0.40s backwards; }

@keyframes flashPulse { 0% { box-shadow: 0 0 0 4px rgba(196,181,253,0.5); background: rgba(196,181,253,0.25); } 100% { box-shadow: none; } }
.flash-pulse { animation: flashPulse 0.5s ease-out; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ======= HISTORY MODAL ======= */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px);
  z-index: 1000; display: none; justify-content: center; align-items: center;
  opacity: 0; transition: opacity 0.3s ease; padding: 20px;
}
.modal-overlay.show { display: flex; opacity: 1; }
.history-modal {
  background: var(--surface); border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xl); width: 100%; max-width: 500px; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-card); transform: translateY(20px); transition: transform 0.3s ease;
}
.modal-overlay.show .history-modal { transform: translateY(0); }
.history-header {
  padding: 16px 20px; border-bottom: 1.5px solid var(--border-strong);
  display: flex; justify-content: space-between; align-items: center; background: var(--surface-2);
}
.history-header h3 { font-size: 16px; font-weight: 700; color: var(--blue-2); margin: 0; }
.btn-close {
  background: transparent; border: none; color: var(--text-sub); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: color 0.2s;
  width: 40px; 
  height: 40px;
}
.btn-close .material-symbols-rounded {
  font-size: 28px !important; 
}
.btn-close:hover { color: var(--danger); }
.history-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.batch-card {
  background: var(--surface-3); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); padding: 12px; margin-bottom: 12px;
}
.batch-header {
  display: flex; justify-content: space-between; font-size: 11px; font-weight: 700;
  color: var(--text); margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px dashed var(--border-strong);
}
.batch-item { font-size: 11px; color: var(--text-sub); display: flex; justify-content: space-between; margin-bottom: 4px; }
.batch-item a { color: inherit; text-decoration: underline; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* (สีของ .batch-id คงเดิมตามที่คุณขอ) */
.batch-id { color: var(--green-2); font-weight: 700; }

.btn-history-toggle {
  display: flex; align-items: center; justify-content: center; flex: 1; gap: 6px;
  background: var(--surface-2); border: 1.5px solid var(--border-strong); border-radius: 99px;
  padding: 10px 16px; color: var(--blue-2); font-weight: 700; font-size: 12px; cursor: pointer;
  margin: 0; transition: all 0.2s;
}
.btn-history-toggle:hover { background: var(--blue-glow); }