/* SMS Credit Portal — design tokens with automatic dark mode. No external fonts or requests. */

/*
 * Chinese characters and punctuation always use a Simplified Chinese font.
 * Otherwise the browser picks its fallback from the OS language order (e.g.
 * English → Chinese → Japanese) and may draw Simplified text with Japanese or
 * Traditional glyph shapes. local() matches installed fonts by PostScript or
 * full name (no download); unicode-range keeps Latin text on the system font.
 */
@font-face {
  font-family: "Portal SC";
  font-weight: 100 449;
  src: local("PingFangSC-Regular"), local("HiraginoSansGB-W3"), local("Microsoft YaHei"), local("MicrosoftYaHei"),
       local("NotoSansCJKsc-Regular"), local("Noto Sans CJK SC Regular"), local("SourceHanSansSC-Regular"), local("NotoSansSC-Regular");
  unicode-range: U+2E80-2FDF, U+3000-303F, U+3100-312F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF;
}
@font-face {
  font-family: "Portal SC";
  font-weight: 450 549;
  src: local("PingFangSC-Medium"), local("HiraginoSansGB-W3"), local("Microsoft YaHei"), local("MicrosoftYaHei"),
       local("NotoSansCJKsc-Medium"), local("Noto Sans CJK SC Medium"), local("SourceHanSansSC-Medium"), local("NotoSansSC-Medium");
  unicode-range: U+2E80-2FDF, U+3000-303F, U+3100-312F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF;
}
@font-face {
  font-family: "Portal SC";
  font-weight: 550 1000;
  src: local("PingFangSC-Semibold"), local("HiraginoSansGB-W6"), local("Microsoft YaHei Bold"), local("MicrosoftYaHei-Bold"),
       local("NotoSansCJKsc-Bold"), local("Noto Sans CJK SC Bold"), local("SourceHanSansSC-Bold"), local("NotoSansSC-Bold");
  unicode-range: U+2E80-2FDF, U+3000-303F, U+3100-312F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF;
}

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --raised: #ffffff;       /* selected pill inside a track */
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #667085;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --on-accent: #ffffff;
  --success: #067647; --success-soft: #ecfdf3; --success-border: #abefc6;
  --error: #b42318;   --error-soft: #fef3f2;   --error-border: #fecdca;
  --warning: #b54708; --warning-soft: #fffaeb; --warning-border: #fedf89;
  --reversed: #c4320a; --reversed-soft: #fff6ed; --reversed-border: #f9dbaf;
  --info: #175cd3;    --info-soft: #eff8ff;    --info-border: #b2ddff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.06);
  --shadow: 0 1px 3px rgb(16 24 40 / 0.08), 0 12px 32px -16px rgb(16 24 40 / 0.18);
  --shadow-lg: 0 24px 48px -12px rgb(16 24 40 / 0.28);
  --font: "Portal SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12;
    --surface: #13161d;
    --surface-2: #1b1f29;
    --raised: #2e3443;
    --border: #262b36;
    --border-strong: #363c4a;
    --text: #eceef3;
    --text-2: #b0b7c6;
    --text-3: #8b94a7;
    --accent: #8b93ff;
    --accent-hover: #a5abff;
    --accent-soft: rgb(139 147 255 / 0.14);
    --on-accent: #0b0d12;
    --success: #47cd89; --success-soft: rgb(71 205 137 / 0.1);  --success-border: rgb(71 205 137 / 0.3);
    --error: #f97066;   --error-soft: rgb(249 112 102 / 0.1);   --error-border: rgb(249 112 102 / 0.3);
    --warning: #fdb022; --warning-soft: rgb(253 176 34 / 0.1);  --warning-border: rgb(253 176 34 / 0.3);
    --reversed: #fd853a; --reversed-soft: rgb(253 133 58 / 0.1); --reversed-border: rgb(253 133 58 / 0.3);
    --info: #53b1fd;    --info-soft: rgb(83 177 253 / 0.1);     --info-border: rgb(83 177 253 / 0.3);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 1px 3px rgb(0 0 0 / 0.5), 0 12px 32px -16px rgb(0 0 0 / 0.7);
    --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.7);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
p, h1, h2, dl, dd { margin: 0; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
/* Outline (not box-shadow) so components' own shadows can't hide it and forced-colors mode keeps it. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.icon { flex: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.is-negative { color: var(--error) !important; }

/* ---------- Buttons, chips, pills ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; white-space: nowrap; text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--block { width: 100%; height: 44px; }
.btn .icon { width: 18px; height: 18px; }

.spinner {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.is-loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  cursor: pointer; opacity: .65; transition: opacity .15s, background-color .15s;
}
.icon-btn:hover { opacity: 1; background: rgb(127 127 127 / .14); }
.icon-btn .icon { width: 16px; height: 16px; }

.link-btn {
  border: 0; padding: 0; background: none; font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

.chip {
  height: 26px; padding: 0 10px; flex: none;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 700; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.pill--muted { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }

/* ---------- Language switch ---------- */

.lang-switch {
  display: inline-flex; flex: none; gap: 2px; padding: 3px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
}
.lang-switch a {
  padding: 4px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--text-3); text-decoration: none; white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.lang-switch a:hover { color: var(--text); }
.lang-switch a[aria-current="true"] { background: var(--raised); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Brand and top bar ---------- */

.brand {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0;
  color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -.01em;
}
.brand__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 10px; color: #fff;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  box-shadow: 0 6px 16px -6px rgb(99 102 241 / .7);
}
.brand-mark .icon { width: 18px; height: 18px; }
.brand-mark--lg { width: 48px; height: 48px; border-radius: 14px; }
.brand-mark--lg .icon { width: 24px; height: 24px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1040px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar__actions { display: flex; align-items: center; gap: 6px; }
.inline-form { display: contents; }

/* ---------- Page ---------- */

.page { max-width: 1040px; margin: 0 auto; padding: 28px 20px 64px; display: grid; gap: 20px; }
.page__meta { margin-bottom: -8px; font-size: 13px; color: var(--text-3); text-align: right; }

/* One section per main account: its header card, then its customers. */
.group { display: grid; gap: 12px; }
.group + .group { margin-top: 12px; }

/* ---------- Banners ---------- */

.banner {
  position: relative; overflow: hidden;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 12px 14px 18px;
  border: 1px solid var(--b-border); border-radius: var(--radius);
  background: var(--b-soft);
  animation: banner-in .25s ease-out;
}
.banner::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--b-color); }
.banner__icon { display: flex; padding-top: 1px; color: var(--b-color); }
.banner__body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.banner__title { font-weight: 700; }
.banner__message { color: var(--text-2); }
.banner__ref {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px;
  font-size: 13px; color: var(--text-2);
}
.banner__ref code {
  padding: 2px 8px; border: 1px solid var(--b-border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-family: var(--mono); font-size: 12.5px; user-select: all; word-break: break-all;
}
.banner--success  { --b-color: var(--success);  --b-soft: var(--success-soft);  --b-border: var(--success-border); }
.banner--error    { --b-color: var(--error);    --b-soft: var(--error-soft);    --b-border: var(--error-border); }
.banner--warning  { --b-color: var(--warning);  --b-soft: var(--warning-soft);  --b-border: var(--warning-border); }
.banner--reversed { --b-color: var(--reversed); --b-soft: var(--reversed-soft); --b-border: var(--reversed-border); }
.banner--info     { --b-color: var(--info);     --b-soft: var(--info-soft);     --b-border: var(--info-border); }
@keyframes banner-in { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- Main-account hero ---------- */

.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 24px;
  padding: 28px; border-radius: var(--radius-lg); color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #4f46e5 0%, #4338ca 45%, #6d28d9 100%);
  box-shadow: 0 24px 48px -24px rgb(79 70 229 / .6);
}
.hero::after {
  content: ""; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px;
  border-radius: 50%; background: rgb(255 255 255 / .06); pointer-events: none;
}
.hero__main { position: relative; z-index: 1; min-width: 0; }
.hero__label { font-size: 14px; font-weight: 600; }
.hero__value {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-top: 6px;
  font-size: clamp(36px, 7vw, 54px); font-weight: 750; line-height: 1.05; letter-spacing: -.03em;
}
.hero__unit { font-size: 18px; font-weight: 600; letter-spacing: 0; }
.hero__caption { margin-top: 8px; font-size: 14px; }
.hero__stats { position: relative; z-index: 1; display: flex; gap: 12px; }
.hero__stats > div {
  min-width: 150px; padding: 12px 16px; border-radius: var(--radius);
  background: rgb(0 0 0 / .14); border: 1px solid rgb(255 255 255 / .2);
}
.hero__stats dt { font-size: 12px; font-weight: 600; }
.hero__stats dd { margin-top: 2px; font-size: 20px; font-weight: 700; }
.hero .pill--muted { background: rgb(255 255 255 / .16); color: #fff; border-color: rgb(255 255 255 / .28); }
.hero .is-negative { color: #fecdca !important; }

/* ---------- Customers panel ---------- */

.panel {
  overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow);
}
.panel__head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.panel__title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.panel__hint { margin-top: 2px; font-size: 14px; color: var(--text-3); }
.empty { padding: 48px 24px; text-align: center; color: var(--text-3); }

.customers { margin: 0; padding: 0; list-style: none; }
.customer {
  display: grid; grid-template-columns: minmax(180px, 1fr) auto; align-items: center; gap: 12px 24px;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  transition: background-color .15s;
}
.customer:last-child { border-bottom: 0; }
.customer:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.customer__info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.customer__text { min-width: 0; }
.avatar {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  font-size: 14px; font-weight: 700;
}
.customer__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer__balance { margin-top: 1px; font-size: 14px; color: var(--text-2); }
.customer__balance .num { font-weight: 650; color: var(--text); }

/* ---------- Transfer form ---------- */

.transfer { display: grid; justify-items: end; gap: 6px; }
.transfer__fields {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; margin: 0; padding: 0; border: 0;
}
.transfer__fields:disabled { opacity: .5; }
.transfer__error { font-size: 13px; font-weight: 500; color: var(--error); }

.segmented {
  display: inline-flex; padding: 3px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.segmented__option { position: relative; }
.segmented__option input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segmented__option span {
  display: block; padding: 5px 12px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--text-3);
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.segmented__option input:checked + span { background: var(--raised); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented__option input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.transfer.is-reclaim .segmented__option input:checked + span { color: var(--reversed); }

.amount {
  display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 6px 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.amount:focus-within { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.amount.is-invalid { border-color: var(--error); }
.amount__input {
  width: 110px; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent;
  font-weight: 600; text-align: right;
}
.amount__input:focus-visible { outline: none; }
.amount__input::placeholder { color: var(--text-3); font-weight: 500; }
.amount__unit { font-size: 13px; font-weight: 600; color: var(--text-3); }

.transfer__submit { min-width: 108px; }
.transfer.is-reclaim .transfer__submit {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.transfer.is-reclaim .transfer__submit:hover:not(:disabled) { background: var(--surface-2); }

/* ---------- Confirm dialog ---------- */

.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgb(16 24 40 / .5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.dialog[open] { animation: dialog-in .18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog__body { padding: 24px 24px 8px; }
.dialog__title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.dialog__text { margin-top: 8px; color: var(--text-2); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px 20px; }

/* ---------- Login ---------- */

body.is-auth {
  min-height: 100vh;
  background: radial-gradient(60% 45% at 50% 0%, var(--accent-soft) 0%, transparent 100%), var(--bg);
}
.auth { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; padding: 16px; }
.auth__top { display: flex; justify-content: flex-end; }
.auth__card {
  align-self: center; justify-self: center; width: min(400px, 100%);
  display: grid; gap: 20px; padding: 32px; margin-bottom: 8vh;
  border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow);
}
.auth__title { font-size: 22px; font-weight: 750; letter-spacing: -.02em; }
.auth__subtitle { margin-top: 2px; color: var(--text-3); }
.auth__form { display: grid; gap: 8px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input-wrap {
  display: flex; align-items: center; height: 44px; margin-bottom: 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap:focus-within { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.input { flex: 1; min-width: 0; height: 100%; padding: 0 12px; border: 0; outline: 0; background: transparent; }
.input:focus-visible { outline: none; }
.input-wrap__btn {
  height: 100%; padding: 0 14px; border: 0; background: transparent;
  font-size: 13px; font-weight: 600; color: var(--text-3); cursor: pointer;
}
.input-wrap__btn:hover { color: var(--text); }

/* ---------- Phones ---------- */

@media (max-width: 760px) {
  .topbar__inner { padding: 10px 16px; }
  .hide-sm { display: none; }
  .page { padding: 16px 16px 48px; gap: 16px; }
  .hero { grid-template-columns: 1fr; gap: 18px; padding: 22px; }
  .hero__stats > div { flex: 1; min-width: 0; }
  .panel__head { padding: 16px; }
  .customer { grid-template-columns: 1fr; padding: 16px; }
  .transfer { justify-items: stretch; }
  .transfer__fields { flex-wrap: wrap; }
  .segmented { width: 100%; }
  .segmented__option { flex: 1; text-align: center; }
  .amount { flex: 1; }
  .amount__input { width: 100%; }
  .auth__card { padding: 24px; }
  .lang-switch a { padding: 4px 8px; }
}

@media (max-width: 480px) {
  .topbar .brand__name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
