:root {
  --blue: hsl(211, 45%, 30%);
  --blue-dark: hsl(211, 45%, 20%);
  --dark: hsl(203, 12%, 25%);
  --green: hsl(133, 61%, 40%);
  --red: hsl(354, 70%, 53%);
  --cyan: hsl(188, 77%, 40%);
  --yellow: hsl(45, 95%, 51%);
  --grey: #777;
  --line: #dee2e6;
  --bg: #f4f5f7;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Kanit', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif; font-weight: 300; background: var(--bg); color: #333; font-size: 15px; }
a { color: var(--blue); }
.i { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.125em; }
.text-center, .center { text-align: center; }
.text-right { text-align: right; }
.text-cyan { color: var(--cyan); } .text-red { color: var(--red); } .text-green { color: var(--green); } .text-yellow { color: var(--yellow); }
.hidden { display: none !important; }

/* top bar + side menu */
#topbar { display: flex; align-items: center; background: var(--blue); color: #fff; padding: 10px; font-weight: 300; }
#menu_toggle { background: none; border: 0; color: #fff; font-size: 34px; padding: 0 14px; cursor: pointer; line-height: 1; }
#topbar .right { margin-left: auto; font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
#topbar { position: sticky; top: 0; z-index: 100; }
#sidemenu { position: fixed; z-index: 99; top: var(--topbar-h, 56px); bottom: 0; left: 0; width: 260px; max-width: 85vw; overflow-y: auto; overscroll-behavior: contain; background: var(--blue); color: #fff; box-shadow: 10px 0 10px -2px #888; transform: translateX(-105%); visibility: hidden; transition: transform .2s, visibility .2s; }
#sidemenu.open { transform: none; visibility: visible; }
#sidemenu a.active { background: #444; }
#menu_backdrop { position: fixed; z-index: 98; top: var(--topbar-h, 56px); left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.35); display: none; }
#menu_backdrop.open { display: block; }
#sidemenu a { display: block; color: #fff; text-decoration: none; font-size: 13px; padding: 9px 12px; white-space: nowrap; }
#sidemenu a:hover { background: #444; opacity: .85; }
#sidemenu a .i { margin-right: 6px; }
#sidemenu a.logout { color: var(--yellow); font-weight: 500; }

.badge { display: inline-block; padding: 1px 10px; border-radius: 5px; font-weight: 300; color: #f5f5f5; white-space: nowrap; }
.badge-dark { background: var(--dark); } .badge-green { background: var(--green); } .badge-red { background: var(--red); } .badge-cyan { background: var(--cyan); }

/* layout */
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 12px; }
.container.narrow { max-width: 500px; }
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.col { padding: 0 8px; flex: 1 1 240px; min-width: 0; }
.col-half { padding: 0 8px; flex: 1 1 300px; min-width: 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 4px; margin: 8px 0; }
.card-header { padding: 10px 16px; border-bottom: 1px solid var(--line); background: #f5f5f5; }
.card-header.dark { background: var(--dark); color: #fff; text-align: center; }
.card-header.blue { background: var(--blue); color: #fff; text-align: center; font-size: 20px; }
.card-body { padding: 16px; }
.card-footer { padding: 8px 16px; border-top: 1px solid var(--line); background: #f5f5f5; }
.card-footer.dark { background: var(--dark); color: #fff; text-align: center; }
.card.center { padding: 24px; }

.dropdown { position: relative; display: inline-block; }
.dropdown button { background: none; border: 0; color: #fff; cursor: pointer; font-size: 18px; }
.dropdown .menu { display: none; position: absolute; right: 0; background: #fff; color: #333; border: 1px solid var(--line); border-radius: 4px; min-width: 170px; z-index: 5; text-align: left; font-size: 14px; }
.dropdown.open .menu { display: block; }
.dropdown .menu div { padding: 8px 14px; cursor: pointer; }
.dropdown .menu div:hover { background: #f0f0f0; }

/* forms + buttons */
.form-grid { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.form-grid > div { padding: 8px; flex: 1 1 calc(50% - 16px); min-width: 240px; }
.form-grid > div.full { flex-basis: 100%; }
label, .lbl { display: block; text-align: center; font-size: 14px; color: var(--grey); font-weight: 400; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 6px 10px; border: 1px solid #ced4da; border-radius: 4px; font: inherit; background: #fff;
}
input.bad, select.bad, textarea.bad { background: yellow; }
.btn { display: inline-block; padding: 7px 18px; border: 2px solid var(--blue-dark); background: var(--blue); color: #fff; border-radius: 4px; font: inherit; cursor: pointer; }
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.light { background: #fff; color: var(--blue); }
.alert { padding: 10px 16px; border-radius: 4px; margin: 12px 0; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* login */
body.login { background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 55%, hsl(200, 50%, 38%) 100%); min-height: 100vh; }
.lg { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.lg-card { width: 400px; max-width: 100%; background: #fff; border-radius: 16px; padding: 32px 30px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.28); }
.lg-brand { text-align: center; margin-bottom: 22px; }
.lg-mark { display: inline-flex; align-items: center; justify-content: center; width: 60px; height: 60px; border-radius: 18px; background: var(--blue); color: #fff; font-size: 28px; font-weight: 500; box-shadow: 0 6px 16px rgba(0,0,0,.2); }
.lg-brand h1 { margin: 12px 0 2px; font-size: 22px; font-weight: 500; color: #222; letter-spacing: .5px; }
.lg-brand p { margin: 0; font-size: 14px; color: #888; }
.lg-form label { display: block; margin: 14px 0 6px; font-size: 14px; color: #555; }
.lg-form input[type=text], .lg-form input[type=password] { width: 100%; padding: 11px 14px; border: 1px solid #d5d9e0; border-radius: 10px; font: inherit; font-size: 16px; background: #fafbfc; }
.lg-form input:focus { outline: 0; border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px hsla(211, 45%, 30%, .15); }
.lg-pw { position: relative; }
.lg-pw input { padding-right: 64px !important; }
.lg-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--blue); font: inherit; font-size: 13px; padding: 6px 10px; cursor: pointer; border-radius: 6px; }
.lg-eye:hover { background: #eef1f6; }
.lg-form .check { display: flex; align-items: center; gap: 8px; margin: 14px 0 20px; }
.lg-form .check label { margin: 0; color: #666; }
.lg-submit { width: 100%; padding: 12px 18px; border-radius: 10px; font-size: 16px; font-weight: 400; }
.lg .alert { margin: 0 0 4px; font-size: 14px; }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
table.t th a { color: inherit; text-decoration: none; }
table.t th { background: #fafafa; font-weight: 400; }
table.t td.c, table.t th.c { text-align: center; }
table.t.compact { font-size: 13px; }
table.t.compact th, table.t.compact td { padding: 8px 6px; }
table.t.compact th { line-height: 1.25; }
table.t td.wrap { white-space: normal; min-width: 80px; line-height: 1.3; }
table.t td small { color: #888; font-size: 12px; }
table.t tbody tr:hover td, table.t tr:hover > td { background: #f7f9fc; }
.card-footer.pager { display: flex; justify-content: flex-end; background: #fff; }
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸"; margin-right: 6px; display: inline-block; transition: transform .15s; }
details.card[open] > summary::before { transform: rotate(90deg); }
.pagination { display: flex; list-style: none; margin: 0; padding: 0; gap: 2px; }
.pagination a, .pagination span { display: block; padding: 6px 12px; border: 1px solid var(--line); text-decoration: none; background: #fff; }
.pagination .active span { background: var(--blue); color: #fff; border-color: var(--blue); }
.pagination .disabled span { color: #aaa; }
.search-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 8px; }
.search-bar > div { min-width: 170px; }
.search-bar label { text-align: left; }

/* guide */
.section_partition { padding: 1rem; border: 3px solid #063970; margin-top: 2rem; border-radius: .5rem; }
.section_partition img { max-width: 100%; height: auto; }
.section_partition .detail { padding: 1rem; background: #000; border: 1px solid #999; border-radius: .5rem; margin: 1rem 0; color: greenyellow; }

/* toast */
#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; max-width: 90vw; }
#toast div { font-size: 18px; text-align: center; border-radius: 3px; padding: 10px 18px; margin-bottom: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
#toast .ok { background: #5adda7; color: #333; } #toast .fail { background: #dd5f5a; color: #eee; }

/* shared page theme (.pg) — payment_record, payment_history, contact_us, guide, change_password */
.pg .card { border: 0; border-radius: 12px; box-shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04); margin: 16px 0; overflow: hidden; }
.pg-head { display: flex; align-items: center; gap: 14px; padding: 18px 24px; border-bottom: 1px solid #eef0f3; }
.pg-head h2 { margin: 0; font-size: 18px; font-weight: 500; color: #222; }
.pg-head p { margin: 2px 0 0; font-size: 13px; color: #888; }
.pg-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: hsl(211,45%,94%); color: var(--blue); font-size: 20px; flex: none; }
.pg .card-body { padding: 20px 24px 24px; }
.pg .form-grid { margin: 0 -10px; }
.pg .form-grid > div { padding: 8px 10px; }
.pg label { text-align: left; font-size: 13px; color: #555; margin-bottom: 6px; }
.pg .opt { color: #aaa; font-weight: 300; }
.pg input, .pg select, .pg textarea { border: 1px solid #d5d9e0; border-radius: 8px; padding: 9px 12px; transition: border-color .15s, box-shadow .15s; }
.pg textarea { resize: vertical; }
.pg input:focus, .pg select:focus, .pg textarea:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px hsla(211,45%,30%,.15); }
.pg input.bad, .pg select.bad, .pg textarea.bad { background: #fffbe0; border-color: #e0b400; }
.unit { position: relative; }
.unit input { padding-right: 52px; }
.unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999; font-size: 13px; pointer-events: none; }
.pg-actions { margin-top: 12px; padding: 0 10px; }
.pg-actions .btn { width: 100%; padding: 11px 18px; border-radius: 8px; font-size: 16px; font-weight: 400; }
@media (min-width: 640px) { .pg-actions .btn { width: auto; min-width: 220px; } .pg-actions { text-align: right; } }
.bank-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; padding: 20px 24px 24px; }
.bank { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid #e6e9ee; border-radius: 10px; }
.bank img { border-radius: 10px; flex: none; }
.bank-info { flex: 1; min-width: 0; line-height: 1.35; }
.bank-name { font-size: 13px; color: #888; }
.bank-no { font-size: 18px; font-weight: 500; letter-spacing: .5px; color: #222; }
.bank-owner { font-size: 13px; color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy { border: 1px solid #d5d9e0; background: #fff; color: var(--blue); border-radius: 6px; padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer; flex: none; }
.copy:hover { background: hsl(211,45%,96%); }
.pg .lbl { text-align: left; font-size: 13px; color: #555; margin-bottom: 6px; }
.pg .btn { border-radius: 8px; padding: 9px 22px; font-weight: 400; }
.pg .btn.light { border-color: #d5d9e0; }
.pg .card-footer { background: #fff; border-top: 1px solid #eef0f3; padding: 12px 24px; }
.pg-center { text-align: center; }

/* history */
.pg details.card > summary { padding: 14px 24px; border: 0; background: #fff; color: #555; font-size: 14px; cursor: pointer; }
.pg .search-bar { padding: 4px 24px 20px; gap: 12px; }
.pg .search-bar label { margin-bottom: 4px; }
.pg table.t th { background: #f7f8fa; color: #666; font-size: 12.5px; font-weight: 500; border-bottom: 1px solid #e6e9ee; }
.pg table.t td { border-bottom: 1px solid #f0f2f5; }
.pg table.t tr:last-child td { border-bottom: 0; }
.pg table.t th:first-child, .pg table.t td:first-child { padding-left: 20px; }
.pg table.t th:last-child, .pg table.t td:last-child { padding-right: 20px; }
.pg .pagination { gap: 4px; }
.pg .pagination a, .pg .pagination span { border-radius: 6px; padding: 5px 11px; font-size: 14px; }
.pg .pagination a { color: var(--blue); }
.pg .pagination a:hover { background: hsl(211,45%,96%); }

/* guide */
.pg.guide { display: block; }
.pg .guide-wrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.pg .guide-wrap .card { margin: 0; }
.pg .tabs { flex: 0 0 280px; max-width: 100%; padding: 8px; }
.pg .tabs button { display: block; width: 100%; text-align: left; padding: 10px 14px; margin: 0 0 2px; border: 0; border-radius: 8px; background: transparent; color: #444; font: inherit; font-size: 14px; cursor: pointer; }
.pg .tabs button:hover { background: #f3f5f8; }
.pg .tabs button.active { background: hsl(211,45%,94%); color: var(--blue); font-weight: 500; }
.pg .guide-main { flex: 1 1 400px; min-width: 0; }
.pg .guide-empty { padding: 40px 24px; text-align: center; color: #999; }
.pg .pane { display: none; }
.pg .pane.active { display: block; }
.pg .pane video { width: 100%; display: block; background: #000; }

/* home */
.pg .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 16px 0; }
.pg .stat { margin: 0; padding: 18px 20px; }
.stat-label { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #777; }
.stat-label .pg-ico { width: 32px; height: 32px; font-size: 16px; border-radius: 8px; }
.stat-hint { font-size: 12px; color: #aaa; }
.stat-value { margin-top: 12px; font-size: 22px; font-weight: 500; color: #222; line-height: 1.2; word-break: break-word; }
.stat-sub { font-size: 14px; font-weight: 400; color: #888; margin-left: 6px; }
.stat-sub.text-red { color: var(--red); }
.pg .apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; padding: 20px 24px 24px; }
.app { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 12px 16px; border: 1px solid #e6e9ee; border-radius: 12px; text-decoration: none; color: #333; background: #fff; transition: box-shadow .15s, transform .15s, border-color .15s; }
a.app:hover { border-color: var(--blue); box-shadow: 0 4px 14px rgba(16,24,40,.1); transform: translateY(-2px); }
.app-ico { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 16px; background: hsl(211,45%,95%); color: var(--blue); font-size: 32px; }
.app-ico img { width: 40px; height: 40px; object-fit: contain; }
.app-name { font-size: 14px; text-align: center; }
.app.off { opacity: .45; cursor: not-allowed; }
.pg .gear { border: 1px solid #d5d9e0; background: #fff; color: #555; border-radius: 8px; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }
.pg .gear:hover { background: #f3f5f8; }
.dropdown { position: relative; }
