:root {
  color-scheme: light;
  --bg: #f5f6fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #fff;
  --text: #181a2a;
  --muted: #6c7089;
  --line: #e5e7f0;
  --primary: #5b5ce2;
  --primary-dark: #4849c8;
  --primary-soft: #eeefff;
  --success: #168568;
  --success-soft: #e7f7f1;
  --warning: #a56600;
  --warning-soft: #fff3d6;
  --danger: #c23b4a;
  --danger-soft: #fff0f2;
  --shadow: 0 18px 50px rgba(42, 44, 86, 0.09);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: linear-gradient(160deg, #fafaff 0%, var(--bg) 52%, #f3f7ff 100%); }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.ambient { position: fixed; z-index: -1; border-radius: 999px; filter: blur(1px); pointer-events: none; opacity: 0.5; }
.ambient-one { width: 420px; height: 420px; top: -190px; right: -90px; background: radial-gradient(circle, #d9d9ff 0%, transparent 69%); }
.ambient-two { width: 480px; height: 480px; bottom: -240px; left: -170px; background: radial-gradient(circle, #d4efff 0%, transparent 70%); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-card { width: min(100%, 480px); padding: 42px; border: 1px solid rgba(255,255,255,.8); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(22px); }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 26px; border-radius: 16px; color: #fff; font-size: 23px; font-weight: 800; background: linear-gradient(145deg, #7374ef, #4b4ccd); box-shadow: 0 10px 24px rgba(91,92,226,.28); }
.brand-mark-small { width: 38px; height: 38px; margin: 0; border-radius: 12px; font-size: 17px; }
.eyebrow { margin: 0 0 9px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 5vw, 38px); letter-spacing: -.04em; }
h2 { margin-bottom: 6px; font-size: 21px; letter-spacing: -.02em; }
h3 { margin-bottom: 8px; }
.muted { color: var(--muted); line-height: 1.65; }
.intro { margin-bottom: 28px; }
.login-form { display: grid; gap: 10px; }
.login-form label { font-size: 13px; font-weight: 700; }
.password-row { position: relative; }
.password-row input { width: 100%; height: 50px; padding: 0 72px 0 15px; color: var(--text); border: 1px solid var(--line); border-radius: 13px; outline: none; background: #fff; transition: border-color .18s, box-shadow .18s; }
.password-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(91,92,226,.12); }
.icon-button { position: absolute; top: 7px; right: 7px; height: 36px; padding: 0 10px; border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.form-error { margin: 0; color: var(--danger); font-size: 13px; }
.privacy-note { margin: 22px 0 0; color: #9295a8; font-size: 12px; line-height: 1.55; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 7px; padding: 0 16px; border: 1px solid transparent; border-radius: 12px; font-size: 14px; font-weight: 700; cursor: pointer; transition: transform .15s, background .15s, border-color .15s, opacity .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible { outline: 3px solid rgba(91,92,226,.25); outline-offset: 2px; }
.button:disabled { cursor: wait; opacity: .58; }
.button-primary { color: #fff; background: var(--primary); box-shadow: 0 9px 20px rgba(91,92,226,.18); }
.button-primary:hover:not(:disabled) { background: var(--primary-dark); }
.button-secondary { color: var(--primary); border-color: #dadafb; background: var(--primary-soft); }
.button-ghost { color: var(--muted); border-color: var(--line); background: rgba(255,255,255,.7); }
.button-danger { color: var(--danger); border-color: #f2cdd2; background: var(--danger-soft); }
.button-wide { width: 100%; margin-top: 8px; }
.button-small { min-height: 36px; padding: 0 12px; font-size: 13px; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; height: 72px; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1160px) / 2)); border-bottom: 1px solid rgba(229,231,240,.8); background: rgba(250,250,255,.82); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.schedule-chip { padding: 7px 11px; border: 1px solid #dfe0f7; border-radius: 999px; color: #5557b5; background: #f4f4ff; font-size: 12px; font-weight: 650; }
.schedule-chip::before { content: "●"; margin-right: 6px; color: #44a98b; font-size: 8px; }
.content { width: min(calc(100% - 40px), 1160px); margin: 0 auto; padding: 54px 0 70px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.hero p:last-child { margin-bottom: 0; }
.hero-actions { display: flex; gap: 10px; flex: 0 0 auto; }
.deployment-note { display: flex; align-items: baseline; gap: 12px; margin-bottom: 20px; padding: 13px 17px; border: 1px solid #dfe0f7; border-radius: 13px; color: #4d5274; background: #f3f4ff; font-size: 12px; line-height: 1.6; }
.deployment-note strong { flex: 0 0 auto; color: #5557b5; font-size: 12px; }
.deployment-note p { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 20px; }
.stat-card { display: grid; grid-template-columns: auto 1fr; align-items: baseline; padding: 21px 23px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 8px 26px rgba(50,52,90,.04); }
.stat-card span { grid-column: 1 / -1; margin-bottom: 7px; color: var(--muted); font-size: 13px; }
.stat-card strong { font-size: 30px; letter-spacing: -.04em; }
.stat-card small { margin-left: 5px; color: var(--muted); }
.section-block { margin-top: 20px; padding: 25px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 12px 40px rgba(43,45,78,.045); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-heading p { margin-bottom: 0; font-size: 13px; }
.loading-panel, .empty-panel { min-height: 220px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.empty-panel { flex-direction: column; text-align: center; }
.empty-panel p { margin-bottom: 10px; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; color: var(--primary); background: var(--primary-soft); font-size: 30px; }
.accounts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.account-card { display: grid; grid-template-columns: 50px 1fr; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface-solid); }
.account-avatar { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 15px; color: #fff; background: linear-gradient(145deg, #7a7bf1, #5556cf); font-size: 18px; font-weight: 800; }
.account-avatar-international { background: linear-gradient(145deg, #28a88d, #217a8e); }
.account-main { min-width: 0; }
.account-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.account-title-group { display: flex; min-width: 0; align-items: center; gap: 7px; }
.account-title { overflow: hidden; margin: 1px 0 3px; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.account-version { flex: 0 0 auto; padding: 2px 6px; border: 1px solid #dfe0f2; border-radius: 999px; color: #74778d; background: #f7f7fb; font-size: 9px; font-weight: 800; letter-spacing: .04em; }
.account-version-international { border-color: #cde9e2; color: #287c6d; background: #effaf7; }
.account-subtitle { overflow: hidden; margin: 0; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; flex: 0 0 auto; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-muted { color: var(--muted); background: #f0f1f5; }
.account-status { min-height: 36px; margin: 15px 0 12px; padding: 10px 11px; border-radius: 11px; color: #5c6078; background: #f7f7fa; font-size: 12px; line-height: 1.45; }
.account-credits { display: grid; gap: 4px; margin: 0 0 12px; padding: 11px; border: 1px solid #e9e9f5; border-radius: 11px; background: #fbfbff; }
.account-credits-main { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.account-credits-main span { color: var(--muted); font-size: 12px; font-weight: 650; }
.account-credits-main strong { color: var(--primary); font-size: 19px; letter-spacing: -.02em; }
.account-credits small { overflow-wrap: anywhere; color: var(--muted); font-size: 11px; line-height: 1.45; }
.account-credits-error { border-color: #f2d8dc; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.table-wrap { position: relative; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 12px; color: var(--muted); font-size: 11px; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
td { padding: 13px 12px; border-top: 1px solid var(--line); color: #4d5065; }
.table-empty { padding: 50px 0; color: var(--muted); text-align: center; }

.dialog { width: min(calc(100% - 32px), 440px); padding: 0; border: 1px solid rgba(255,255,255,.8); border-radius: 26px; color: var(--text); background: var(--surface-solid); box-shadow: 0 28px 90px rgba(25,27,55,.28); }
.dialog::backdrop { background: rgba(28,29,48,.46); backdrop-filter: blur(7px); }
.dialog-content { padding: 38px; text-align: center; }
.dialog-close { position: absolute; top: 14px; right: 14px; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px; color: #51556c; background: #f1f2f6; font-size: 22px; cursor: pointer; }
.variant-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 18px 0 4px; padding: 4px; border-radius: 13px; background: #f1f2f7; }
.variant-tab { min-height: 38px; border: 0; border-radius: 10px; color: #62667c; background: transparent; font-size: 13px; font-weight: 750; cursor: pointer; }
.variant-tab.active { color: var(--primary); background: var(--surface-solid); box-shadow: 0 4px 14px rgba(45,47,80,.09); }
.qr-stage { display: grid; place-items: center; width: 280px; height: 280px; margin: 22px auto 17px; border: 1px solid var(--line); border-radius: 20px; background: #fff; overflow: hidden; }
.qr-stage img { width: 250px; height: 250px; }
.oauth-web-stage { display: grid; place-items: center; gap: 7px; min-height: 190px; margin: 22px 0 17px; padding: 28px; border: 1px solid #dfe9e7; border-radius: 20px; background: linear-gradient(145deg, #f7fffd, #f7f8ff); }
.oauth-web-stage[hidden] { display: none; }
.oauth-web-stage small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.oauth-web-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 17px; color: #fff; background: linear-gradient(145deg, #28a88d, #5b5ce2); font-size: 25px; font-weight: 800; }
.qr-status { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 13px; }
.pulse { width: 8px; height: 8px; border-radius: 99px; background: var(--primary); box-shadow: 0 0 0 0 rgba(91,92,226,.4); animation: pulse 1.7s infinite; }
.text-link { display: inline-block; margin-top: 13px; color: var(--primary); font-size: 13px; }
.oauth-actions { display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 13px; }
.oauth-actions .text-link { margin-top: 0; }
.oauth-note { margin: 13px 0 0; padding: 10px 12px; border-radius: 11px; color: #765b20; background: #fff8e8; font-size: 11px; line-height: 1.55; text-align: left; }
.settings-dialog { width: min(calc(100% - 32px), 560px); }
.settings-content { padding: 34px; text-align: left; }
.settings-intro { margin-bottom: 20px; }
.settings-card { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fafaff; }
.settings-card + .settings-card { margin-top: 13px; }
.settings-card h3 { font-size: 15px; }
.settings-card p { margin-bottom: 14px; font-size: 12px; }
.settings-form { display: grid; gap: 8px; }
.settings-form label { color: #55586d; font-size: 12px; font-weight: 700; }
.settings-form input { width: 100%; height: 43px; padding: 0 12px; color: var(--text); border: 1px solid var(--line); border-radius: 11px; outline: none; background: var(--surface-solid); }
.settings-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,92,226,.11); }
.settings-password-field { position: relative; }
.settings-password-field input { padding-right: 45px; }
.password-visibility-button { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 35px; height: 35px; padding: 0; border: 0; border-radius: 9px; background: transparent; cursor: pointer; }
.password-visibility-button:hover { background: var(--primary-soft); }
.password-visibility-button:focus-visible { outline: 3px solid rgba(91,92,226,.25); outline-offset: 1px; }
.password-visibility-button img { width: 19px; height: 19px; opacity: .62; }
.settings-form .button { margin-top: 5px; justify-self: start; }
.settings-form-inline { grid-template-columns: minmax(120px, 1fr) auto; align-items: end; }
.settings-form-inline label { grid-column: 1 / -1; }
.settings-form-inline .button { margin: 0; }
.spinner { width: 18px; height: 18px; border: 2px solid #dedff0; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-large { width: 30px; height: 30px; border-width: 3px; }
.toast { position: fixed; z-index: 30; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 48px)); padding: 13px 17px; border: 1px solid #dfe0e9; border-radius: 13px; color: #fff; background: #2b2d3e; box-shadow: 0 16px 38px rgba(24,25,43,.22); font-size: 13px; }
.toast.error { background: #9f3442; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(91,92,226,0); } 100% { box-shadow: 0 0 0 0 rgba(91,92,226,0); } }

@media (max-width: 760px) {
  .topbar { padding: 0 18px; }
  .schedule-chip { display: none; }
  .content { width: min(calc(100% - 28px), 1160px); padding-top: 35px; }
  .hero { align-items: stretch; flex-direction: column; }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .deployment-note { align-items: flex-start; flex-direction: column; gap: 3px; }
  .stats { grid-template-columns: 1fr; gap: 10px; }
  .accounts-grid { grid-template-columns: 1fr; }
  .section-block { padding: 18px; border-radius: 18px; }
  .table-wrap { margin: 0 -18px -18px; }
  table { min-width: 760px; }
  th:first-child, td:first-child { padding-left: 18px; }
}

@media (max-width: 470px) {
  .login-card { padding: 30px 24px; }
  .brand small { display: none; }
  .hero-actions { grid-template-columns: 1fr; }
  .account-card { grid-template-columns: 42px 1fr; padding: 15px; }
  .account-avatar { width: 42px; height: 42px; }
  .dialog-content { padding: 36px 20px 28px; }
  .settings-content { padding: 32px 18px 22px; }
  .settings-form-inline { grid-template-columns: 1fr; }
  .qr-stage { width: 248px; height: 248px; }
  .qr-stage img { width: 224px; height: 224px; }
}

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

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg: #14151d; --surface: rgba(28,29,40,.9); --surface-solid: #20212c; --text: #f1f2f8; --muted: #a2a5b7; --line: #343643; --primary: #8586ff; --primary-dark: #7475ee; --primary-soft: #2c2d52; --success-soft: #173d35; --warning-soft: #41351b; --danger-soft: #42262c; --shadow: 0 18px 50px rgba(0,0,0,.28); }
  body { background: linear-gradient(160deg, #191a24, var(--bg)); }
  .password-row input, .qr-stage { background: #1c1d27; }
  .topbar { background: rgba(20,21,29,.84); }
  .schedule-chip { border-color: #3d3e60; color: #aaaaff; background: #292a44; }
  .deployment-note { border-color: #3d3e60; color: #b8bbd1; background: #292a44; }
  .deployment-note strong { color: #aaaaff; }
  .button-ghost { background: #22232e; }
  .account-status { color: #b5b7c8; background: #272833; }
  .account-credits { border-color: #353649; background: #242532; }
  .account-version { border-color: #424453; background: #292a35; }
  .account-version-international { border-color: #28594f; color: #7fd2c0; background: #193b35; }
  .variant-tabs { background: #191a23; }
  .variant-tab { color: #b1b4c7; }
  .oauth-web-stage { border-color: #344641; background: linear-gradient(145deg, #1b2928, #222331); }
  .oauth-note { color: #e2c277; background: #3a321f; }
  .settings-card { background: #1c1d27; }
  .settings-form label { color: #c4c6d3; }
  .password-visibility-button img { filter: invert(1); opacity: .72; }
  td { color: #c5c7d4; }
}
