/* SePay Donate — giao diện chung (sáng/tối tự động) */
:root {
  --brand: #2563eb;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f1f5f9;
  --in: #059669;
  --out: #dc2626;
  --warn-bg: #fffbeb; --warn-line: #fcd34d; --warn-text: #92400e;
  --err-bg: #fef2f2; --err-line: #fca5a5; --err-text: #991b1b;
  --ok-bg: #ecfdf5; --ok-line: #6ee7b7; --ok-text: #065f46;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --card: #111a2e; --text: #e2e8f0; --muted: #94a3b8; --line: #1f2a44; --soft: #17223a;
    --in: #34d399; --out: #f87171;
    --warn-bg: #2a2110; --warn-line: #854d0e; --warn-text: #fcd34d;
    --err-bg: #2a1215; --err-line: #7f1d1d; --err-text: #fca5a5;
    --ok-bg: #0d2a22; --ok-line: #065f46; --ok-text: #6ee7b7;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --card: #111a2e; --text: #e2e8f0; --muted: #94a3b8; --line: #1f2a44; --soft: #17223a;
  --in: #34d399; --out: #f87171; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; } h2, .h2 { font-size: 1.15rem; } h3 { font-size: 1rem; margin-top: 1.4em; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9em; }
code { background: var(--soft); padding: .1em .35em; border-radius: 5px; word-break: break-all; }
small, .small { font-size: .85em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.in { color: var(--in); } .out { color: var(--out); }
[hidden] { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 24px; padding-bottom: 40px; }
.foot { color: var(--muted); font-size: .85rem; padding-bottom: 32px; text-align: center; }

/* Topbar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-in { display: flex; align-items: center; gap: 16px; min-height: 58px; flex-wrap: wrap; }
.logo { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.logo:hover { text-decoration: none; }
.logo-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 20%, transparent); }
.logo-img { width: 28px; height: 28px; border-radius: 8px; object-fit: cover; }
.topnav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.topnav a, .linkbtn { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: .92rem; }
.topnav a:hover, .topnav a.active { background: var(--soft); color: var(--text); text-decoration: none; }
.linkbtn { background: none; border: 0; cursor: pointer; font: inherit; }
.linkbtn:hover { color: var(--text); }
.menu-btn { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 4px 10px; font-size: 1.1rem; }
form.inline { display: inline; margin: 0; }
@media (max-width: 760px) {
  .admin .menu-btn { display: block; }
  .admin .topnav { display: none; width: 100%; margin: 0 0 10px; }
  .admin .topnav.open { display: flex; }
}

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.card-head h1, .card-head h2 { margin: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2col.wide-left { grid-template-columns: 2fr 1fr; }
.grid-2col > .card { margin-bottom: 0; }
.grid-2col + .card, .grid-2col { margin-bottom: 18px; }
@media (max-width: 860px) { .grid-2col, .grid-2col.wide-left { grid-template-columns: 1fr; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: filter .15s, background .15s; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); }
.btn-lg { padding: 12px 20px; font-size: 1rem; }
.btn-sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.btn-xs { padding: 2px 8px; font-size: .75rem; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-google { background: var(--card); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, .filters label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.form small, .filters small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); border-color: var(--brand); }
input[type="color"] { padding: 3px; height: 42px; }
input[type="file"] { padding: 7px; }
input[type="checkbox"], input[type="radio"] { width: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.grid2 > h2 { margin: 6px 0 0; }
.span2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.switch { flex-direction: row !important; align-items: flex-start; gap: 10px !important; font-weight: 600; cursor: pointer; }
.switch input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--brand); }
.switch span { display: flex; flex-direction: column; gap: 2px; }
.input-suffix { position: relative; }
.input-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-suffix input { padding-right: 32px; font-size: 1.05rem; font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { min-width: 130px; }
.filters .grow { flex: 1 1 220px; }
.secret-row, .copy-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.secret-row input { flex: 1 1 200px; }
.copy-row code { flex: 1 1 240px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; }
.blur { filter: blur(5px); user-select: none; }
.form-err { color: var(--err-text); background: var(--err-bg); border: 1px solid var(--err-line); padding: 8px 12px; border-radius: 10px; }
.row-btns { display: flex; gap: 8px; }
.thumb { border-radius: 12px; object-fit: cover; border: 1px solid var(--line); }
.hidden-form { display: none; }
.inline-form { margin: -8px 0 18px; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid; }
.alert-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-text); }
.alert-err { background: var(--err-bg); border-color: var(--err-line); color: var(--err-text); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.callout { background: var(--soft); border-left: 4px solid var(--brand); padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; font-size: .92rem; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .wrapcell { min-width: 200px; max-width: 360px; overflow-wrap: anywhere; }
.table.api td:first-child { width: 60px; }
.table.api td:nth-child(2) { white-space: nowrap; }
.m { font-size: .72rem; font-weight: 800; padding: 2px 6px; border-radius: 5px; }
.m.get { background: color-mix(in srgb, var(--in) 15%, transparent); color: var(--in); }
.m.post { background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--brand); }
.tag { display: inline-block; font-size: .72rem; padding: 1px 6px; border-radius: 5px; background: var(--soft); color: var(--muted); font-weight: 600; }
.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 999px; font-weight: 700; background: var(--soft); color: var(--muted); }
.badge-paid { background: var(--ok-bg); color: var(--ok-text); }
.badge-pending { background: var(--warn-bg); color: var(--warn-text); }
.badge-err { background: var(--err-bg); color: var(--err-text); }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pager a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; }
.pre { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font: .82rem/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; margin: 8px 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.35rem; overflow-wrap: anywhere; }
@media (max-width: 860px) { .stats { grid-template-columns: 1fr 1fr; } }
.kv { list-style: none; padding: 0; margin: 0 0 14px; }
.kv li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.kv li b { text-align: right; overflow-wrap: anywhere; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bar i { display: block; width: 100%; max-width: 28px; min-height: 2px; background: var(--brand); border-radius: 4px 4px 0 0; }
.bar span { font-size: .7rem; color: var(--muted); }
.top { padding-left: 20px; margin: 0; }
.top li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.steps { padding-left: 20px; } .steps li { margin-bottom: 8px; }
.checks { list-style: none; padding: 0; } .checks .ok { color: var(--in); } .checks .bad { color: var(--out); font-weight: 700; }
.qr-preview { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.qr-preview img { border-radius: 12px; border: 1px solid var(--line); background: #fff; }

/* Auth / install */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 760px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-links { display: flex; justify-content: space-between; margin: 10px 0; }
.login-links .linkbtn { padding: 4px 0; color: var(--brand); }

/* Donate page */
.donate-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.donate-layout.is-embed { grid-template-columns: 1fr; }
@media (max-width: 860px) { .donate-layout { grid-template-columns: 1fr; } }
.donate-card h1 { font-size: 1.7rem; }
.amounts { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.amounts legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: block; text-align: center; padding: 10px 6px; border: 1.5px solid var(--line); border-radius: 10px; font-weight: 700; transition: all .15s; }
.chip input:checked + span { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); }
.chip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.qr-box { display: flex; justify-content: center; margin: 12px 0; }
.qr-box img { width: 100%; max-width: 300px; height: auto; aspect-ratio: 1; border-radius: 14px; background: #fff; border: 1px solid var(--line); object-fit: contain; }
.pay-status { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; color: var(--warn-text); background: var(--warn-bg); border-radius: 10px; padding: 10px; }
.spinner { width: 16px; height: 16px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bank-info { margin: 14px 0; display: grid; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.bank-info div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.bank-info div:last-child { border-bottom: 0; }
.bank-info dt { color: var(--muted); font-size: .88rem; }
.bank-info dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.hl { color: var(--brand); font-size: 1.1em; letter-spacing: .04em; }
.thanks { text-align: center; padding: 20px 0; }
.thanks-icon { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-bg); color: var(--in); font-size: 2.2rem; font-weight: 800; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.feed-total { display: flex; flex-direction: column; padding: 14px; border-radius: 12px; background: color-mix(in srgb, var(--brand) 8%, transparent); margin-bottom: 16px; }
.feed-total span { color: var(--muted); font-size: .85rem; }
.feed-total b { font-size: 1.6rem; color: var(--brand); }
.feed { list-style: none; padding: 0; margin: 0; }
.feed-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-head { display: flex; justify-content: space-between; gap: 10px; }
.feed-name { overflow-wrap: anywhere; }
.feed-amount { color: var(--in); font-weight: 800; white-space: nowrap; }
.feed-msg { margin: 4px 0; overflow-wrap: anywhere; }
.new { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--brand) 18%, transparent); } }
.is-test { opacity: .7; }

/* Transactions page */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--in); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--in); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.txlist { list-style: none; padding: 0; margin: 0; }
.tx { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tx-icon { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; }
.tx-in .tx-icon { background: color-mix(in srgb, var(--in) 14%, transparent); color: var(--in); }
.tx-out .tx-icon { background: color-mix(in srgb, var(--out) 14%, transparent); color: var(--out); }
.tx-body { flex: 1; min-width: 0; }
.tx-top { display: flex; justify-content: space-between; gap: 10px; }
.tx-in .tx-amount { color: var(--in); } .tx-out .tx-amount { color: var(--out); }
.tx-content { margin: 2px 0; overflow-wrap: anywhere; }

/* Embed */
body.embed { background: transparent; }
body.embed .main { padding: 0; }
body.embed .card { margin-bottom: 0; }
