:root {
  --bg: #f4f6fa; --panel: #ffffff; --panel-2: #f8fafc; --soft: #eef1f6;
  --text: #0f172a; --text-2: #334155; --muted: #64748b; --faint: #94a3b8;
  --line: #e3e8ef; --line-2: #d1d8e3;
  --brand: #0f766e; --brand-2: #0d5f59; --brand-ink: #ffffff; --brand-soft: #e3f4f1; --brand-text: #0b6b63;
  --green: #15803d; --green-soft: #e7f6ec;
  --amber: #a16207; --amber-soft: #fdf5e1;
  --red: #b91c1c; --red-soft: #fdecec;
  --blue: #1d4ed8; --blue-soft: #e8efff;
  --gray-soft: #eef1f5;
  --side-bg: #0e1726; --side-text: #cbd5e1; --side-muted: #7c8aa3; --side-active: rgba(45, 212, 191, .14); --side-hover: rgba(255, 255, 255, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .04);
  --ring: 0 0 0 3px rgba(15, 118, 110, .2);
  --radius: 12px; --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang HK", "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 14.5px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b111c; --panel: #121a28; --panel-2: #172132; --soft: #1b2638;
    --text: #e6ebf3; --text-2: #c3cad8; --muted: #8d99ae; --faint: #66738a;
    --line: #233046; --line-2: #2e3c55;
    --brand: #2dd4bf; --brand-2: #5eead4; --brand-ink: #062320; --brand-soft: #0f2e2b; --brand-text: #5eead4;
    --green: #4ade80; --green-soft: #12301f;
    --amber: #fbbf24; --amber-soft: #352914;
    --red: #f87171; --red-soft: #3a1a1c;
    --blue: #93b4ff; --blue-soft: #1a2647;
    --gray-soft: #1f2a3c;
    --side-bg: #070c15;
    --shadow: none; --ring: 0 0 0 3px rgba(45, 212, 191, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: 1.5rem; margin: 0; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
h2 { font-size: 1.02rem; margin: 0 0 .8rem; font-weight: 650; display: flex; align-items: center; gap: 8px; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .86em; }
code { background: var(--gray-soft); padding: 1px 6px; border-radius: 5px; overflow-wrap: anywhere; }
svg.i { flex-shrink: 0; vertical-align: -3px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--side-bg); color: var(--side-text); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; padding: 4px 10px 16px; font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand small { display: block; color: var(--side-muted); font-weight: 500; font-size: .74rem; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #14b8a6, #0f766e); display: grid; place-items: center; color: #fff; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: var(--side-hover); text-decoration: none; }
.nav a.active { background: var(--side-active); color: #fff; }
.nav a .count { margin-left: auto; background: #dc2626; color: #fff; font-size: .72rem; padding: 0 7px; border-radius: 99px; font-weight: 650; }
.nav .section { color: var(--side-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 4px; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.07); padding-top: 10px; display: flex; align-items: center; gap: 8px; }
.side-foot .who { flex: 1; min-width: 0; color: var(--side-text); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 8px; }
.side-foot button { background: none; border: 0; color: var(--side-muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.side-foot button:hover { color: #fff; background: var(--side-hover); }
.main { padding: 26px 32px 60px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.mobile-top { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--side-bg); color: #fff; font-weight: 650; position: sticky; top: 0; z-index: 20; }
  .mobile-top button { background: none; border: 0; color: #fff; padding: 4px; }
  .main { padding: 18px 16px 50px; }
}

/* ------------------------------------------------------------ panels & grids */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2 { padding: 16px 20px 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.panel.flush .panel-head { padding: 16px 20px 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1050px) { .grid.two, .grid.side { grid-template-columns: 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { color: var(--muted); font-size: .8rem; font-weight: 550; }
.tile .value { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--muted); font-size: .8rem; }
.empty { color: var(--muted); padding: 22px; text-align: center; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: .8rem; }
tr.dim td { opacity: .55; }

/* ------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: .76rem; font-weight: 600; background: var(--gray-soft); color: var(--text-2); white-space: nowrap; }
.badge.green, .badge.approved, .badge.active, .badge.delivered { background: var(--green-soft); color: var(--green); }
.badge.amber, .badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.red, .badge.reversed, .badge.failed, .badge.paused { background: var(--red-soft); color: var(--red); }
.badge.blue, .badge.paid { background: var(--blue-soft); color: var(--blue); }

/* ------------------------------------------------------------ forms & buttons */
label { display: block; font-weight: 550; font-size: .86rem; margin-bottom: 4px; color: var(--text-2); }
.field { margin-bottom: 12px; min-width: 0; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel); color: var(--text); font: inherit; font-size: .93rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
textarea { min-height: 70px; resize: vertical; }
.inline-form { display: inline; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: .82rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 150px; }
.pic-preview { display: block; width: 100%; max-width: 320px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); margin-bottom: 8px; }
.rate-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rate-form select { width: auto; flex: 1 1 190px; }
.rate-form input[type=text] { width: 100px; flex: none; }

details.more { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--brand-text); }
details.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow); }
details.box > summary { padding: 14px 20px; cursor: pointer; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 8px; }
details.box > summary::-webkit-details-marker { display: none; }
details.box[open] > summary { border-bottom: 1px solid var(--line); }
details.box > .body { padding: 16px 20px; }

/* ------------------------------------------------------------ flashes, reveal, copy */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 500; border: 1px solid transparent; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.error { background: var(--red-soft); color: var(--red); }
.reveal { border: 2px solid var(--brand); background: var(--brand-soft); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.reveal h2 { color: var(--brand-text); }
.copyrow { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.copyrow code, .copyrow .val { flex: 1; min-width: 0; display: block; padding: 7px 10px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-sm); font-family: var(--mono); font-size: .85rem; overflow-x: auto; white-space: nowrap; }
pre { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: .84rem; line-height: 1.55; }
pre code { background: none; padding: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .92rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ chart */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding-top: 6px; }
.bars .day { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; min-width: 0; }
.bars .c { background: var(--brand); opacity: .28; border-radius: 3px 3px 0 0; min-height: 1px; }
.bars .s { background: var(--brand); border-radius: 3px; position: absolute; bottom: 0; left: 25%; right: 25%; min-height: 0; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--brand); margin-right: 5px; vertical-align: -1px; }
.legend i.c { opacity: .28; }

/* ------------------------------------------------------------ docs */
.doc { max-width: 860px; }
.doc h1 { margin: 0 0 12px; }
.doc h2 { margin-top: 1.8rem; font-size: 1.2rem; display: block; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.doc h3 { margin-top: 1.4rem; }
.doc table { margin: 10px 0 16px; }
.doc td, .doc th { border: 1px solid var(--line); }
.doc ul, .doc ol { padding-left: 1.4rem; }
.doc li { margin: 3px 0; }

/* ------------------------------------------------------------ login & portal */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.card h1 { margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }
.portal { max-width: 980px; margin: 0 auto; padding: 28px 20px 60px; }
.portal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.portal-head .brand-mark { width: 40px; height: 40px; }

/* ------------------------------------------------------------ affiliates' side (/join, /partner) */
.partner-top { background: var(--side-bg); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; flex-wrap: wrap; }
.partner-top .brand { padding: 0; }
.partner-top .who { color: var(--side-text); font-size: .86rem; overflow-wrap: anywhere; }
.partner-top .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.25); }
.partner-top .btn:hover { background: var(--side-hover); }
.join { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 28px; align-items: start; }
.join > div > .panel { margin-top: 18px; }
.join .card { max-width: none; }
@media (max-width: 860px) { .join { grid-template-columns: 1fr; } }
.offer { padding: 10px 0; border-top: 1px solid var(--line); }
.offer:first-of-type { border-top: 0; padding-top: 0; }
.steps { padding-left: 1.3rem; color: var(--text-2); }
.steps li { margin: 4px 0; }
.notice { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; background: var(--blue-soft); color: var(--text); border: 1px solid var(--line); }
.notice.amber { background: var(--amber-soft); }
.notice.red { background: var(--red-soft); }
.center-block { display: grid; place-items: center; padding: 30px 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.badge.declined { background: var(--red-soft); color: var(--red); }
.item { padding: 12px 0; border-top: 1px solid var(--line); }
.panel-head + .item { border-top: 0; padding-top: 0; }
.item.dim { opacity: .55; }
.item-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.item-end { margin-left: auto; font-size: .85rem; }
.item-sub { font-size: .82rem; overflow-wrap: anywhere; }
.code-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.code-item code { font-size: 1rem; }

/* ---------- region switch (UK / 香港) on the pages before sign-in; the landing pages have landing.css ---------- */
.region-switch { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.region-switch a { padding: 4px 10px; font-size: .82rem; font-weight: 600; color: var(--text-2); }
.region-switch a + a { border-left: 1px solid var(--line-2); }
.region-switch a:hover { text-decoration: none; background: var(--soft); }
.region-switch a.on { background: var(--brand-soft); color: var(--brand-text); }
.partner-top .region-switch, .partner-top .region-switch a + a { border-color: rgba(255,255,255,.25); }
.partner-top .region-switch a { color: var(--side-text); }
.partner-top .region-switch a:hover { background: var(--side-hover); }
.partner-top .region-switch a.on { background: rgba(255,255,255,.16); color: #fff; }
