:root {
  --primary: #8a6fdf;
  --primary-soft: rgba(138, 111, 223, 0.16);
  --info: #00cfe8;
  --info-soft: rgba(0, 207, 232, 0.16);
  --text: rgba(28, 28, 30, 0.84);
  --muted: rgba(28, 28, 30, 0.7);
  --faint: rgba(28, 28, 30, 0.45);
  --line: rgba(140, 140, 140, 0.22);
  --page: #f4f6f8;
  --white: #fff;
  --shadow: 0 2px 6px rgba(138, 111, 223, 0.48);
  --sidebar: 260px;
  --nav-h: 64px;
  font-family: "Public Sans", sans-serif, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--white);
  font-size: 15px;
  line-height: 1.45;
}

* { box-sizing: border-box; }

html, body, #app { margin: 0; min-height: 100%; }

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

svg { width: 1.15em; height: 1.15em; display: block; }
button svg, a svg { pointer-events: none; }

.layout {
  min-height: 100vh;
  background: var(--white);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 16px 6px;
}

.menu-anchor { position: relative; }

.topnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 0 12px 8px;
}

.home-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #3a3a3a;
  color: #fff;
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 600;
  flex: none;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  min-height: 38px;
  padding: 6px 12px;
  color: #6e6b7b;
  font-weight: 500;
  white-space: nowrap;
}

.nav-link.is-active {
  background: #7367f0;
  color: #fff;
  box-shadow: 0 2px 6px rgba(115, 103, 240, 0.48);
}

.nav-drop { position: relative; }

.nav-pop {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  min-width: 190px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(28, 28, 30, 0.12);
}

.nav-pop .nav-link { width: 100%; }

.bang {
  margin-left: 4px;
  font-style: normal;
  font-weight: 700;
  color: #ea5455;
}

.nav-link.is-active .bang { color: #fff; }

.content-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.spacer { flex: 1; }

.icon-btn, .user-btn, .refresh, .mini, .pager button {
  border: 0;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #6e6b7b;
}

.balance {
  max-width: min(520px, 46vw);
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: #ece8fb;
  color: #7367f0;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lottery {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  border: 0;
  border-radius: 8px;
  background: #ff9f43;
  color: #fff;
  padding: 8px 14px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(255, 159, 67, 0.45);
}

.user-btn {
  gap: 10px;
  height: auto;
  padding: 2px 2px 2px 8px;
  color: var(--text);
  font-weight: 500;
}

.user-mail { white-space: nowrap; }

.avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ece8fb;
  color: #8a6fdf;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.dot {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #28c76f;
  box-shadow: 0 0 0 2px #fff;
}

.bell-btn { position: relative; }

.bell-badge {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: #ea5455;
  color: #fff;
  font-style: normal;
  font-size: 10px;
  line-height: 16px;
}

.notice, .lang-choice {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: 0;
  border-radius: 6px;
  background: #f8f7fa;
  text-align: left;
  padding: 8px 10px;
}

.notice.is-new { background: rgba(115, 103, 240, 0.12); }

.notice strong, .notice span { display: block; }

.notice span { color: var(--muted); font-size: 12px; }

.notice-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.user-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(28, 28, 30, 0.12);
}

.account-menu {
  width: 300px;
  padding: 0 0 6px;
  overflow: hidden;
}

.account-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.user-email { font-weight: 600; font-size: 15px; }

.role-badge {
  display: inline-block;
  margin-top: 4px;
  background: rgba(255, 159, 67, 0.16);
  color: #ff9f43;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 600;
}

.account-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.account-meta strong { color: var(--text); font-weight: 600; }

.stop-work {
  display: flex;
  width: calc(100% - 24px);
  margin: 12px 12px 4px;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  background: #ea5455;
  color: #fff;
  font-weight: 700;
  line-height: 1.15;
}

.stop-work small { font-weight: 600; font-size: 12px; }

.stop-note { padding: 0 16px 8px; }

.pref-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  font-weight: 500;
  color: var(--text);
}

.pref-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pref-icon, .pref-row > svg, .account-meta > svg { color: #6e6b7b; flex: none; }

.switch-ui {
  width: 36px;
  height: 20px;
  border-radius: 99px;
  background: #d8d6de;
  position: relative;
  flex: none;
}

.switch-ui::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.pref-row:has(input:checked) .switch-ui { background: #28c76f; }

.pref-row:has(input:checked) .switch-ui::after { transform: translateX(16px); }

.lang-menu, .notice-menu { padding: 12px 14px; }

.notice-menu { width: min(320px, 80vw); }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--page);
  margin: 0;
}

.auth-card {
  width: min(420px, calc(100% - 32px));
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px 24px 24px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
}

.auth-card > p {
  margin: 0 0 20px;
  color: var(--muted);
}

.auth-card label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

.auth-card label[hidden] {
  display: none;
}

.password-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.password-field input { flex: 1; }

.password-field button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  padding: 0 4px;
}

.remember {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--text);
}

.remember input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.auth-card input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: var(--white);
}

.auth-card .btn {
  width: 100%;
  justify-content: center;
  height: 42px;
}

.auth-card .btn:disabled { opacity: 0.7; cursor: default; }

.auth-error {
  margin: 0 0 12px;
  color: #ea5455;
  font-size: 14px;
}

.page {
  flex: 1;
  padding: 16px;
}

.sheet {
  background: var(--page);
  border-radius: 6px;
  padding: 8px 8px 12px;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 8px 12px;
  font-size: 18px;
  font-weight: 500;
}

.title-icon {
  color: var(--primary);
  display: inline-flex;
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0 8px 8px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 22px 20px 8px;
}

.panel-head h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
}

.tools {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.updated {
  align-self: center;
  color: var(--faint);
  font-size: 12px;
  white-space: nowrap;
}

.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }

.field select, .input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 0 12px;
  min-width: 120px;
}

.filters-bar {
  margin: 12px 20px 8px;
  width: calc(100% - 40px);
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 6px;
  min-height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 18px;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 4px;
}

.mini {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 500;
}

.chip.info { background: var(--info-soft); color: var(--info); }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 20px 18px;
}

.filter-row[hidden] { display: none; }

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #d8d6de;
  position: relative;
}

.track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  transition: transform 0.15s ease;
}

.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }

.btn {
  height: 40px;
  border-radius: 6px;
  border: 0;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn.tonal { background: rgba(176, 181, 193, 0.2); color: #b0b5c1; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(138, 111, 223, 0.35); }

.refresh {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(138, 111, 223, 0.4);
  flex: 0 0 auto;
}

.refresh.is-busy svg { animation: spin 0.7s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.table-wrap { overflow: auto; border-top: 1px solid var(--line); }

table { width: 100%; border-collapse: collapse; font-size: 13px; color: var(--muted); }

th {
  text-align: left;
  text-transform: uppercase;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  padding: 14px 16px;
  white-space: nowrap;
}

td { padding: 18px 16px; }

.empty { text-align: center; color: var(--faint); }

.table-foot {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 16px;
  color: var(--faint);
  font-size: 13px;
}

.pager { display: flex; gap: 6px; }

.pager button {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: rgba(140, 140, 140, 0.12);
  color: var(--muted);
}

.pager .pager-current {
  width: auto;
  min-width: 34px;
  padding: 0 10px;
  white-space: nowrap;
  background: var(--primary-soft);
  color: var(--primary);
}

.pager button:disabled { cursor: default; }

.footer {
  display: flex;
  justify-content: space-between;
  padding: 12px 24px 16px;
  color: var(--muted);
  font-size: 14px;
}

.version { color: var(--faint); }

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  padding-right: 8px;
}

.lede {
  margin: 0 8px 16px 40px;
  color: var(--muted);
}

.block-title {
  margin: 0 12px 12px;
  font-size: 18px;
  font-weight: 600;
}

.wallet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 18px;
  padding: 0 12px;
}

.wallet-grid.pair { grid-template-columns: 1fr 1fr; margin-top: 16px; }

.wallet-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.wallet-input {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: #6e6b7b;
}

.wallet-input .plain {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text);
}

.copy-btn { width: 32px; height: 32px; color: #6e6b7b; }

.wallet-bottom {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
  align-items: stretch;
  margin: 18px 12px 0;
}

.fees-card {
  background: #fff4e8;
  border-radius: 8px;
  padding: 18px 20px;
}

.fees-card h3 {
  margin: 0 0 12px;
  color: #ff9f43;
  font-size: 16px;
}

.fees-card p { margin: 4px 0; color: var(--text); }

.text-btn {
  margin-top: 12px;
  border: 0;
  background: transparent;
  padding: 0;
  color: #7367f0;
  font-weight: 600;
}

.wallet-buttons { display: grid; gap: 12px; align-content: center; }

.wallet-buttons button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-withdraw { background: #7367f0; box-shadow: 0 2px 6px rgba(115, 103, 240, 0.4); }
.btn-transfer { background: #ff9f43; box-shadow: 0 2px 6px rgba(255, 159, 67, 0.4); }
.btn-profit { background: #28c76f; box-shadow: 0 2px 6px rgba(40, 199, 111, 0.4); }

.wallet-form { margin: 12px; }

@media (max-width: 900px) {
  .wallet-grid, .wallet-grid.pair, .wallet-bottom { grid-template-columns: 1fr; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  padding: 0 8px 8px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 18px 18px;
  min-height: 148px;
}

.stat-top {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 500;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
}

.stat-icon.muted {
  background: rgba(140, 140, 140, 0.12);
  color: var(--muted);
}

.stat-value {
  margin-top: 14px;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.stat-meta { color: var(--muted); font-size: 14px; }

.matrix th, .matrix td { text-align: center; white-space: nowrap; }
.matrix tbody th { text-align: left; font-weight: 500; color: var(--text); }
.matrix-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  font-weight: 600;
}

.matrix-cell.is-empty {
  background: rgba(234, 84, 85, 0.16);
  color: #ea5455;
}

.matrix-cell.is-live {
  background: rgba(40, 199, 111, 0.16);
  color: #28c76f;
}

.btn.danger {
  background: rgba(234, 84, 85, 0.12);
  color: #ea5455;
}

.status-select, .filter-row select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 0 10px;
}

.row-btn {
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: rgba(234, 84, 85, 0.12);
  color: #ea5455;
  padding: 0 10px;
}

.profile-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 8px 14px;
}

.profile-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.profile-tab.is-active {
  background: var(--primary);
  color: #fff;
}

.team-groups {
  display: grid;
  gap: 16px;
  padding: 4px 20px 22px;
}

.team-group {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 88px;
  padding: 16px 18px 20px;
}

.team-group h4 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 500;
}

.team-person {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.team-person svg { color: var(--faint); }

.profile-grid { display: grid; gap: 12px; }

.profile-card { margin-bottom: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 8px 20px 0;
}

.form-grid.single { grid-template-columns: 1fr; }

.form-grid .input, .form-grid select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 0 12px;
}

.form-grid input[readonly] { background: var(--page); }

.copy-line { display: flex; gap: 8px; }

.copy-line .input { flex: 1; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 20px;
}

.hint {
  margin: 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.form-note { margin: 0; font-size: 14px; color: #ea5455; }
.form-note.ok { color: #28c76f; }

@media (max-width: 900px) {
  .user-mail { display: none; }
  .balance { max-width: 34vw; font-size: 12px; padding: 8px 10px; }
  .filter-row .input { flex: 1 1 140px; }
}

html.theme-dark {
  --white: #283046;
  --page: #161d31;
  --text: rgba(234, 234, 255, 0.87);
  --muted: rgba(234, 234, 255, 0.68);
  --faint: rgba(234, 234, 255, 0.45);
  --line: rgba(255, 255, 255, 0.12);
  background: #161d31;
  color: var(--text);
}

html.theme-dark body,
html.theme-dark .layout { background: #161d31; }

html.theme-dark .topbar { background: rgba(40, 48, 70, 0.96); }

html.theme-dark .nav-link,
html.theme-dark .icon-btn,
html.theme-dark .pref-icon,
html.theme-dark .account-meta { color: rgba(234, 234, 255, 0.75); }

html.theme-dark .nav-link.is-active { color: #fff; }

html.theme-dark .dot { box-shadow: 0 0 0 2px #283046; }
