:root {
  --bg: #0e1116;
  --card: #171b22;
  --card-2: #1d222b;
  --line: #2a303a;
  --text: #f2f4f7;
  --muted: #8b93a1;
  --green: #3d9b6e;
  --danger: #d46565;
  --accent: #6ea8ff;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { overflow-x: hidden; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 12px 10px 10px;
  background: rgba(14, 17, 22, 0.92);
  backdrop-filter: blur(10px);
}

.topbar-left {
  display: flex;
  width: 48px;
  flex-shrink: 0;
}

.topbar h1 {
  margin: 0;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1;
  flex-shrink: 0;
}

.topbar-login {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.topbar-user .icon-btn {
  width: 36px;
  height: 36px;
  color: var(--muted);
}

.topbar-user .icon-btn svg {
  display: block;
  width: 20px;
  height: 20px;
  margin: 0 auto;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
}

.icon-btn:active { background: var(--card); }

.burger,
.burger:before,
.burger:after {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text);
  border-radius: 2px;
  position: relative;
  margin: 0 auto;
}

.burger:before,
.burger:after {
  content: "";
  position: absolute;
  left: 0;
}

.burger:before { top: -6px; }
.burger:after { top: 6px; }

main {
  padding: 8px 16px 40px;
}

.total-card,
.wallet-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 18px 16px;
  margin-bottom: 12px;
  user-select: none;
  -webkit-user-select: none;
}

.total-card {
  background: var(--card);
  border-color: #c9a24a;
}

.wallet-name {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
}

.wallet-balance {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.03em;
  font-weight: 650;
}

.wallet-balance.muted { color: var(--muted); font-size: 18px; }

.tx-list {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.tx-row {
  padding: 10px 2px;
  border-radius: 10px;
}

.tx-row:active { background: var(--card-2); }

.tx-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.tx-amount { color: var(--green); font-weight: 600; }
.tx-date { color: var(--muted); font-size: 13px; }

.tx-hash {
  margin-top: 6px;
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.4;
}

.empty, .hint, .error-text {
  color: var(--muted);
  text-align: center;
  padding: 48px 16px;
  line-height: 1.5;
}

.error-text { color: var(--danger); }

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.45);
}

.drawer-panel {
  width: min(86vw, 340px);
  height: 100%;
  background: #12161c;
  border-right: 1px solid var(--line);
  padding: 64px 16px 24px;
  overflow: auto;
  box-shadow: var(--shadow);
}

.menu-action {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  font-size: 16px;
  padding: 12px 8px;
  border-radius: 10px;
  cursor: pointer;
}

.menu-action:active,
.menu-item:active { background: var(--card); }

.menu-section {
  margin-top: 22px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.menu-label {
  margin: 0 0 6px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.menu-payout-total {
  margin: 0 0 8px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.menu-section-title {
  flex: 1;
  min-width: 0;
}

.menu-section-total {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.payout-stats {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 0 0 14px;
}

.payout-stats-total {
  margin: 0 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
}

.payout-day-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.payout-day-row:first-of-type { padding-top: 0; }

.payout-balance {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.payout-add {
  width: 100%;
  margin-bottom: 12px;
}

.payout-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.payout-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment-row {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
  align-items: start;
}

.preset-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini-btn {
  width: 40px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-chip {
  border: 1px solid var(--line);
  background: #12161c;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.payout-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
}

.payout-card .tx-hash { margin-top: 8px; }

.payout-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.payout-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.micro-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.micro-btn svg {
  width: 12px;
  height: 12px;
  display: block;
}

.micro-btn.danger { color: #c57a7a; }
.micro-btn:active { background: var(--card-2); }

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0 12px;
}

.stack-form select,
.stack-form input,
.payout-form input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.stack-form select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.primary-btn, .ghost-btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}

.primary-btn { background: #2a6f4c; color: white; }
.primary-btn.danger-btn { background: #7a3333; }
.ghost-btn { background: var(--card-2); color: var(--text); }

.confirm {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
}

.confirm-box {
  width: min(100%, 320px);
  background: #1b2028;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 16px 14px;
}

.confirm-box p {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.4;
}

.confirm-box input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  margin: 0 0 16px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.password-box {
  width: min(100%, 340px);
}

.password-box .login-field {
  margin-bottom: 8px;
}

.password-box .login-field input {
  margin: 0;
}

.password-box .form-error {
  margin: 0 0 12px;
}

.form-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 13px; }

.hash-hint {
  margin: -2px 0 2px;
  min-height: 1.2em;
  font-size: 12px;
  color: var(--muted);
}

.hash-hint.ok { color: var(--green); }
.hash-hint.error { color: var(--danger); }

.menu-list { margin-top: 6px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 8px 8px;
  border-radius: 10px;
}

.menu-item .menu-section-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item .payout-actions {
  flex: 0 0 auto;
}

.popup {
  position: fixed;
  z-index: 50;
  min-width: 180px;
  background: #1b2028;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
}

.popup button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.popup button.danger { color: var(--danger); }
.popup button:active { background: var(--card-2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #222831;
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 12px;
  z-index: 60;
  font-size: 14px;
}

.hidden { display: none !important; }

.login-body { min-height: 100vh; }

.login-shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px 40px;
}

.login-card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 22px 22px;
  box-shadow: var(--shadow);
}

.login-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-title {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.login-lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.login-field span {
  color: var(--muted);
  font-size: 13px;
}

.login-field input {
  width: 100%;
  background: #12161c;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
}

.login-field input:focus {
  outline: none;
  border-color: #3d5478;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
}

.login-submit:disabled {
  opacity: 0.65;
  cursor: default;
}
