@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap');

/* ===========================
   GLOBAL RESET & BASE
   =========================== */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Kanit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
}


/* ป้องกันหน้า "ล้น" ด้านข้าง */
body, html {
    width: 100%;
    overflow-x: hidden;
}

/* ===========================
   LAYOUT UTILS ใช้ได้ทุกหน้า
   =========================== */

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-main {
    flex: 1;
    padding: 16px;
}

/* container กลางจอ ใช้ครอบเนื้อหาในหลายๆหน้า */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 8px;
}

/* card พื้นฐาน ใช้ซ้ำได้ */
.card {
    background: var(--surface);
    border-radius: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}

/* ปุ่มพื้นฐาน */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 999px;
/* Recent Transactions mobile cards (reuse Transactions look) */
.recent-cards {
    margin-top: 10px;
}
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary1), var(--primary2));
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    text-decoration: none;
    transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* ตารางให้ scroll ได้บนมือถือ */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

/* ===========================
   FORM ทั่วไป
   =========================== */

.form-group {
    margin-bottom: 12px;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: 0.15s ease;
}

input::placeholder,
textarea::placeholder {
    color: #64748b;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.7);
}

/* ===========================
   AUTH PAGE (LOGIN) – prefix: auth-
   =========================== */

.auth-body {
    background: radial-gradient(circle at top left, #0ea5e9, #020617 60%);
}

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.auth-card {
    background: rgba(15, 23, 42, 0.96);
    padding: 24px 20px 20px;
    width: 100%;
    max-width: 380px;
    border-radius: 18px;
    box-shadow:
        0 18px 45px rgba(0,0,0,0.75),
        0 0 0 1px rgba(148,163,184,0.12);
    backdrop-filter: blur(16px);
    animation: auth-pop 0.35s ease-out;
}

@keyframes auth-pop {
    from { opacity:0; transform: translateY(10px) scale(0.98); }
    to   { opacity:1; transform: translateY(0)   scale(1);      }
}

.auth-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.auth-logo-circle {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #020617;
    box-shadow: 0 12px 30px rgba(56,189,248,0.45);
}

.auth-title {
    text-align: center;
    font-size: 1.3rem;
    color: #f8fafc;
    margin-bottom: 4px;
}

.auth-subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 18px;
}

.auth-alert {
    background: rgba(185, 28, 28, 0.9);
    border-radius: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(248, 113, 113, 0.6);
    font-size: 0.8rem;
    color: #fee2e2;
    margin-bottom: 12px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-field label {
    font-size: 0.8rem;
}

.auth-field input {
    font-size: 0.9rem;
}

.auth-button {
    margin-top: 8px;
    width: 100%;
    padding: 9px 12px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    color: #020617;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(56, 189, 248, 0.4);
    transition: 0.15s ease;
}

.auth-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.auth-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 0.78rem;
    color: #64748b;
}

/* ===========================
   DASHBOARD LAYOUT (ใช้ได้หลายหน้า)
   =========================== */

/* top bar ด้านบน */
.top-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.top-bar-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #f9fafb;
    margin-bottom: 2px;
}

.top-bar-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
}

/* ปุ่มด้านขวา */
.top-bar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* grid 2 คอลัมน์ ที่ mobile เป็น 1 คอลัมน์ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

/* ตารางรายการ */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.table th,
.table td {
    padding: 6px 4px;
}

.table thead tr {
    border-bottom: 1px solid var(--border);
    color: var(--muted);
}

.table tbody tr {
    border-bottom: 1px solid #020617;
}

/* quick actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}


/* ===========================
   RESPONSIVE
   =========================== */

/* Tablet ขึ้นไป */
@media (min-width: 640px) {
    .page-main {
        padding: 24px;
    }

    .card {
        padding: 20px;
    }
}

/* Desktop กว้างขึ้น */
@media (min-width: 1024px) {
    .page-main {
        padding: 32px 24px;
    }

    .container {
        padding: 0;
    }
}

@media (min-width: 640px) {
    .top-bar {
        flex-direction: row;
        align-items: center;
    }
}

/* หน้าจอกว้างขึ้น → grid 2 คอลัมน์ */
@media (min-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr 1fr;

/* Dashboard recent transactions: keep table visible on small screens with horizontal scroll */
@media (max-width: 768px) {
    .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 700px; }
    /* Ensure table headers visible on mobile */
    .table thead { display: table-header-group !important; }
    .table tbody { display: table-row-group !important; }
    .table tr { display: table-row !important; }
    .table th, .table td { display: table-cell !important; white-space: nowrap; }
}
    }
}

/* ===========================
   LAYOUT: SIDEBAR + MAIN
   =========================== */

.app-layout {
    min-height: 100vh;
    display: flex;
    background: var(--bg);
}

/* SIDEBAR */
.sidebar {
    width: 230px;
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: fixed;
    inset-block: 0;
    left: 0;
    z-index: 40;
    transform: translateX(0);
    transition: transform 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary1), var(--primary2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--muted);
}

/* เมนูภายใน sidebar */
.sidebar-menu {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: block;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.88rem;
    color: var(--text);
    text-decoration: none;
    border: 1px solid transparent;
    background: transparent;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.1s ease,
        box-shadow 0.15s ease,
        color 0.15s ease;
}

.sidebar-link:hover {
    background: #1d05f1;
    border-color: #1f2937;
    transform: translateX(1px);
}

.sidebar-link--primary {
    background: radial-gradient(circle at top left, #1a76ff, #0ea5e9);
    color: hsl(0, 0%, 100%);
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 10px 24px rgba(56, 189, 248, 0.45);
}

/* Active sidebar link: ทำให้เห็นชัดเจนว่าหน้าไหนกำลังใช้งาน */
.sidebar-link.sidebar-link--primary {
    background: linear-gradient(135deg, rgba(59,130,246,0.18), rgba(59,130,246,0.08));
    border-left: 3px solid #3b82f6;
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

/* เพิ่ม Indicator ด้านซ้ายสำหรับ active item บนอุปกรณ์ที่กว้าง */
@media (min-width: 768px) {
    .sidebar-link.sidebar-link--primary {
        position: relative;
    }
    .sidebar-link.sidebar-link--primary::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #b4fbee;
        box-shadow: 0 0 0 4px rgba(59,130,246,0.18);
    }
}

/* Hover state ยังคงชัด แต่ไม่กลบ active */
.sidebar-link:hover {
    background: rgba(148,163,184,0.12);
}


.sidebar-link--primary:hover {
    filter: brightness(1.05);
}

/* main */
.app-main {
    flex: 1;
    margin-left: 230px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TOPBAR */
.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    position: sticky;
    top: 0;
    z-index: 30;
}

.app-topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f9fafb;
}

.app-topbar-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
}

/* ปุ่ม hamburger สำหรับมือถือ */
.sidebar-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    padding: 6px;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.sidebar-toggle:hover {
    border-color: #38bdf8;
}

.sidebar-toggle-line {
    height: 2px;
    width: 100%;
    border-radius: 999px;
    background: var(--text);
    transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

/* เวลาเปิดเมนู ให้แปลง 3 ขีดเป็นกากบาทนิด ๆ */
body.sidebar-open .sidebar-toggle-line:nth-child(1) {
    transform: translateY(4px) rotate(45deg);
}
body.sidebar-open .sidebar-toggle-line:nth-child(2) {
    opacity: 0;
}
body.sidebar-open .sidebar-toggle-line:nth-child(3) {
    transform: translateY(-4px) rotate(-45deg);
}

/* main content */
.app-content {
    padding: 16px;
}

/* BACKDROP สำหรับมือถือ */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 35;
}

/* ===========================
   RESPONSIVE: SIDEBAR (MOBILE)
   =========================== */

/* มือถือ: ซ่อน sidebar ไว้ด้านซ้าย แล้วใช้ปุ่ม 3 ขีดเปิด */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .app-topbar {
        padding-inline: 12px;
    }

    .sidebar-backdrop {
        display: block;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

/* จอใหญ่: sidebar อยู่ตลอด ไม่ต้องใช้ backdrop และปุ่ม 3 ขีดหายไป */
@media (min-width: 768px) {
    .sidebar-toggle {
        display: none;
    }
    .sidebar-backdrop {
        display: none;
    }
}


/* --- CARD STYLE ปรับให้เด่น --- */
.wallet-card {
    background: #0f172a; /* น้ำเงินเข้ม */
    border: 1px solid #1e293b;
    padding: 20px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}

/* หัวข้อใหญ่ */
.card-title {
    color: var(--primary1);
    font-size: 1.1rem;
    margin-bottom: 12px;
    font-weight: 700;
}

/* ข้อความทั่วไป */
.wallet-text {
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 4px;
}

.wallet-text .label {
    color: var(--muted);
}

/* --- ส่วนยอดเงิน --- */
.wallet-balance-row {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #1e293b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.wallet-balance-label {
    font-size: 0.9rem;
    color: var(--muted);
}

.wallet-balance-amount {
    font-size: 1.8rem;
    font-weight: 700;
    color: #4fd1c5; /* เขียวฟ้าแบบ Neon */
    margin-top: 4px;
    text-shadow: 0 0 8px rgba(79, 209, 197, 0.4);
}

.wallet-balance-amount.loading {
    opacity: 0.4;
    transition: 0.3s;
}

.wallet-loading-text {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 3px;
}


/* --- ปุ่มรีเฟรช --- */
.btn-refresh {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #0ea5e9, #38bdf8);
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    color: #fff;
}

.btn-refresh:hover {
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
    transform: translateY(-1px);
}

/* ไอคอนหมุน */
.refresh-icon {
    width:16px;
    height:16px;
    border:3px solid rgba(255,255,255,0.6);
    border-radius:50%;
    border-right-color:transparent;
    display:inline-block;
    transition: 0.3s;
}

/* ข้อความ error */
.wallet-error {
    color: #f87171;
    font-size: 0.9rem;
    margin-top: 10px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

/* ซ่อนกล่อง error อัตโนมัติเมื่อยังไม่มีข้อความ */
.wallet-error:empty {
    display: none;
}

/* Wallet identity emphasis (ชื่อ/เบอร์) */
.wallet-identity .wallet-text .label { display: none; }
.wallet-identity .wallet-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}
.wallet-identity .wallet-text:first-of-type {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.2px;
}
.wallet-identity .wallet-text:nth-of-type(2) {
    color: #c7d2fe;
    opacity: 0.95;
}

/* ฟอร์มกรอง */
.filter-form {
    margin-top: 8px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.form-group label {
    display:block;
    font-size:0.9rem;
    color: var(--muted);
    margin-bottom:4px;
}

.form-group input,
.form-group select {
    width:100%;
    padding:8px 10px;
    border-radius:8px;
    border:1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.form-group input:focus,
.form-group select:focus {
    outline:none;
    border-color:#38bdf8;
}

/* ตาราง */
.table-wrapper {
    margin-top:10px;
    overflow-x:auto;
}

.table {
    width:100%;
    border-collapse: collapse;
    font-size:0.9rem;
}

.table thead {
    background: var(--surface-2);
}

.table th,
.table td {
    padding:8px 10px;
    border-bottom:1px solid #1f2937;
    text-align:left;
    white-space:nowrap;
}

.table th {
    font-weight:600;
    color: var(--muted);
}

.table tr:hover {
    background: var(--surface-2);
}

.table-link {
    color:#38bdf8;
    text-decoration:none;
    font-size:0.85rem;
}

.table-link:hover {
    text-decoration:underline;
}

/* JSON detail */
.detail-json {
    margin-top:10px;
    background: var(--surface);
    padding:12px;
    border-radius:10px;
    max-height:300px;
    overflow:auto;
    font-size:0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
    .filter-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .filter-grid {
        grid-template-columns: 1fr;
    }
}


/* ====== Transaction Detail Card ====== */

.detail-header {
    margin-top: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid #1f2937;
    padding-bottom: 10px;
}

.detail-main-amount {
    font-size: 1.4rem;
    font-weight: 700;
    color: #facc15; /* เหลืองเด่น ๆ */
}

.detail-main-meta {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.detail-main-date {
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--muted);
}

/* badge เล็ก ๆ สำหรับแสดง type / action */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
}

.badge-secondary {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
}

/* รายการรายละเอียด */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin-top: 4px;
}

.detail-row {
    display: flex;
    flex-direction: column;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    background: rgba(30, 41, 59, 0.5);
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-label {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 0.9rem;
    color: var(--text);
    word-break: break-word;
    font-weight: 500;
}

.detail-row:has(.detail-label:contains("จำนวนเงิน")) .detail-value,
.detail-row:nth-child(2) .detail-value {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
    letter-spacing: 0.5px;
}

.btn-link-open {
    display: inline-block;
    padding: 8px 14px;
    background: linear-gradient(135deg, #00b2ff, #0090d8);
    color: #fff !important;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: 0.25s;
    box-shadow: 0 3px 8px rgba(0, 150, 255, 0.25);
}

.btn-link-open:hover {
    background: linear-gradient(135deg, #27c2ff, #00a0e8);
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(0, 150, 255, 0.35);
}

.btn-link-open:active {
    transform: translateY(0px);
    box-shadow: 0 3px 10px rgba(0, 150, 255, 0.25);
}

/* ปุ่มดูรายละเอียดในตาราง */
.btn-detail {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, var(--primary1), var(--primary2));
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn-detail:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    transform: translateY(-2px);
}

.btn-detail:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* header การ์ดรายละเอียด + ปุ่มปิด */
.detail-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.btn-close-detail {
    border: none;
    background: transparent;
    color: #6b7280;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease,
                transform 0.15s ease;
}

.btn-close-detail:hover {
    background: rgba(248, 113, 113, 0.16);
    color: #fecaca;
    transform: rotate(90deg);
}



@media (max-width: 640px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}


/* ===========================
   MOBILE TABLE → CARD VIEW
   ใช้ร่วมกับ data-label ใน <td>
   =========================== */
@media (max-width: 768px) {
    /* ซ่อนหัวตาราง */
    .table thead {
        display: none;
    }

    /* แต่ละแถวเป็นการ์ด */
    .table tbody tr {
        display: block;
        margin-bottom: 10px;
        padding: 10px 12px;
        border-radius: 12px;
        border: 1px solid var(--border);
        background: var(--surface);
        box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    }

    /* แถวกำลังโหลด ให้แสดงกะทัดรัดและจัดกึ่งกลาง */
    .table tbody tr.loading-row {
        padding: 8px 10px;
        background: #0b1220;
    }
    .table tbody tr.loading-row td {
        display: block;
        text-align: center;
        padding: 2px 0;
    }

    /* cell แต่ละตัวเป็นแถว ๆ พร้อม label */
    .table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border-bottom: 0;
        white-space: normal;      /* ให้ตัดบรรทัดได้ */
    }

    .table tbody td::before {
        content: attr(data-label);
        font-size: 0.8rem;
        color: var(--muted);
        margin-right: 10px;
    }

    /* ช่องปุ่ม “ดูรายละเอียด” จัดให้ไปทางขวา */
    .table tbody td.tx-actions {
        justify-content: flex-end;
    }
    .table tbody td.tx-actions::before {
        content: '';
        margin-right: 0;
    }
}

/* ซองอั่งเปา */
.voucher-filter-select {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
}

.voucher-filter-select:focus {
    outline: none;
    border-color: #38bdf8;
}

/* badge เพิ่มสีใช้ร่วมกับหน้าอื่นได้ */
.badge-success {
    background: rgba(52, 211, 153, 0.18);
    color: #4ade80;
}

.badge-warning {
    background: rgba(250, 204, 21, 0.18);
    color: #fde047;
}

.badge-danger {
    background: rgba(248, 113, 113, 0.18);
    color: #fca5a5;
}


/* ===== MODAL OVERLAY ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-box {
    background: linear-gradient(135deg, #0f172a 0%, #1a2841 100%);
    border: 2px solid #1e293b;
    padding: 28px;
    width: 90%;
    max-width: 420px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.1);
    text-align: center;
    box-shadow: 0 0 20px #000;
    animation: modalFade .2s ease-out;
}

@keyframes modalFade {
    from { opacity: 0; transform: scale(.9); }
    to   { opacity: 1; transform: scale(1); }
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
    text-align: center;
}

.modal-msg {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Disable button style */
.btn.disabled,
button:disabled {
    opacity: .5;
    pointer-events: none;
}

.highlight-amount {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
    letter-spacing: 0.5px;
}

.modal-msg { font-size: 16px; line-height: 1.6; }
		.confirm-highlights { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
		.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-weight: 600; border: 1px solid transparent; }
		.pill-amount { background: linear-gradient(135deg, #8b5cf6, #6366f1); color: #fff; }
		.pill-bank { background: rgba(99,102,241,0.18); color: #dbe4ff; border-color: rgba(139,92,246,0.35); }
		.pill-ac { background: rgba(99,102,241,0.12); color: #e8eaff; border-color: rgba(139,92,246,0.28); }

/* === THEME OVERRIDES: Indigo/Violet Unified Palette === */
:root {
    --bg: #0b1020;
    --surface: #12172a;
    --surface-2: #0f1426;
    --border: #26304a;
    --text: #e7eaf3;
    --muted: #9aa3b8;
    --primary1: #22c55e; /* green */
    --primary2: #16a34a; /* green dark */
    --primary-contrast: #ffffff;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --overlay: rgba(0,0,0,0.65);
    --pill-bg: rgba(99,102,241,0.12);
    --pill-border: rgba(139,92,246,0.32);
    --pill-text: #e3e7ff;
}

html, body {
    background: var(--bg);
    color: var(--text);
}

/* Cards & Containers */
.card, .wallet-card {
    background: var(--surface);
    border-color: var(--border);
}

/* Sidebar & Topbar */
.sidebar {
    background: var(--surface-2);
    border-right-color: var(--border);
}
.app-topbar {
    background: var(--surface-2);
    border-bottom-color: var(--border);
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, var(--primary1), var(--primary2));
    color: var(--primary-contrast);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}
.btn:hover { filter: brightness(1.05); }
.btn:active { box-shadow: 0 4px 12px rgba(0,0,0,0.25); }

.btn-refresh {
    background: linear-gradient(135deg, var(--primary2), var(--primary1));
    color: var(--primary-contrast);
}

/* Sidebar links */
.sidebar-link:hover {
    background: rgba(99,102,241,0.15);
    border-color: var(--border);
}
.sidebar-link--primary {
    background: linear-gradient(135deg, var(--primary1), var(--primary2));
    color: #fff;
}

/* Wallet balance */
.wallet-balance-label { color: var(--muted); }
.wallet-balance-amount {
    color: #c7d2fe;
    text-shadow: 0 0 10px rgba(99,102,241,0.35);
}

/* Modals */
.modal-overlay { background: var(--overlay); }
.modal-box {
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface) 100%);
    border-color: var(--border);
}

/* Badges */
.badge-success { background: rgba(34,197,94,0.18); color: #86efac; }
.badge-warning { background: rgba(245,158,11,0.18); color: #fcd34d; }
.badge-danger  { background: rgba(239,68,68,0.18);  color: #fca5a5; }

/* Amount highlight to primary */
.highlight-amount {
    background: linear-gradient(135deg, var(--primary1), var(--primary2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 15px rgba(99,102,241,0.35);
}

/* Confirm pills unified */
.confirm-highlights { gap: 8px; }
.pill {
    background: var(--pill-bg);
    border-color: var(--pill-border);
    color: var(--pill-text);
}
.pill-amount {
    background: linear-gradient(135deg, var(--primary1), var(--primary2));
    color: var(--primary-contrast);
    border-color: transparent;
}
.pill-bank { background: rgba(99,102,241,0.18); color: #e6eaff; border-color: rgba(139,92,246,0.35); }
.pill-ac   { background: rgba(99,102,241,0.12); color: #dde3ff; border-color: rgba(139,92,246,0.28); }

/* Lightweight skeleton loader for faster-perceived load */
.skeleton {
    opacity: 0.6;
    animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
    0% { opacity: .5; }
    50% { opacity: 1; }
    100% { opacity: .5; }
}

/* Theme System */
.themes-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 20px;
    max-width: 1400px;
}

.theme-card {
    background: var(--surface);
    border: 3px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.theme-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255,255,255,0.03));
    opacity: 0;
    transition: opacity 0.3s;
}

.theme-card:hover::before {
    opacity: 1;
}

.theme-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    border-color: var(--primary1);
}

.theme-card.active {
    border-color: var(--primary1);
    border-width: 3px;
    box-shadow: 0 0 0 4px rgba(139,92,246,0.3), 0 8px 30px rgba(0,0,0,0.4);
    background: linear-gradient(135deg, var(--surface), rgba(139,92,246,0.08));
}

.theme-preview {
    height: 120px;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    margin-bottom: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 2px solid rgba(255,255,255,0.1);
}

.theme-preview-bg {
    position: absolute;
    inset: 0;
    opacity: 0.5;
}

.theme-preview-surface {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    height: 45px;
    border-radius: 8px;
    border: 2px solid;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.theme-info {
    text-align: center;
}

.theme-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    letter-spacing: 0.3px;
}

.theme-active-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary1), var(--primary2));
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    letter-spacing: 0.5px;
}

/* Theme Selection Mobile Responsive */
@media (max-width: 768px) {
    .themes-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    
    .theme-card {
        padding: 12px;
    }
    
    .theme-preview {
        height: 90px;
    }
    
    .theme-preview-surface {
        height: 35px;
        bottom: 8px;
        left: 8px;
        right: 8px;
    }
    
    .theme-name {
        font-size: 13px;
    }
    
    .theme-active-badge {
        font-size: 11px;
        padding: 5px 12px;
    }
}