:root {
  --ink: #172b43;
  --ink-soft: #587089;
  --navy: #112237;
  --navy-2: #1c344d;
  --paper: #f5f3ee;
  --paper-strong: #fffdfa;
  --line: #d8dedc;
  --line-dark: #456079;
  --amber: #c77f2e;
  --amber-dark: #98591f;
  --amber-pale: #f6e8d2;
  --mint: #dceee6;
  --mint-ink: #276653;
  --rose: #f4e1dc;
  --rose-ink: #9a493e;
  --shadow: 0 18px 50px rgba(24, 46, 70, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 0%, rgba(199, 127, 46, .07), transparent 28rem),
    var(--paper);
  font: 15px/1.55 "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid rgba(199,127,46,.52); outline-offset: 3px; }

.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;
}
.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 256px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; z-index: 5;
  display: flex; flex-direction: column; padding: 28px 18px 20px;
  color: #edf3f2; background: var(--navy);
  border-right: 1px solid rgba(255,255,255,.09);
}
.brand { display: inline-flex; align-items: center; gap: 11px; margin: 0 10px 42px; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px;
  color: var(--navy); background: var(--amber); border-radius: 10px;
  font: 700 16px/1 "DM Mono", monospace; letter-spacing: -.14em; padding-right: 3px;
}
.brand-copy { display: grid; line-height: 1.05; }
.brand-name { font-size: 15px; font-weight: 800; letter-spacing: .01em; }
.brand-tag { margin-top: 5px; color: #a8bbc3; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.nav-label { margin: 0 12px 11px; color: #8297a3; font: 500 10px "DM Mono", monospace; letter-spacing: .16em; text-transform: uppercase; }
.nav-list { display: grid; gap: 5px; list-style: none; padding: 0; margin: 0; }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 43px; padding: 0 12px;
  color: #b6c8cb; border: 1px solid transparent; border-radius: 9px;
  font-size: 13px; transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.075); transform: translateX(2px); }
.nav-link.active { color: #fff; background: #27445b; border-color: #38566d; }
.nav-icon { width: 18px; color: #8ea9ae; font: 500 12px "DM Mono", monospace; }
.nav-link.active .nav-icon { color: var(--amber); }
.sidebar-bottom { margin-top: auto; padding: 15px 10px 0; border-top: 1px solid rgba(255,255,255,.1); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-copy { display: grid; flex: 1 1 0; min-width: 0; gap: 2px; }
.avatar {
  display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px;
  color: var(--navy); background: #e1c28f; border-radius: 50%;
  font-weight: 800; font-size: 12px;
}
.user-name { display: block; min-width: 0; overflow: hidden; color: #ecf2ef; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.user-role { display: block; color: #8ea2ac; font-size: 11px; overflow-wrap: anywhere; }
.sidebar-logout { display: block; margin-top: 15px; padding: 0; border: 0; background: none; color: #9eafb4; font-size: 12px; cursor: pointer; text-align: left; }
.sidebar-logout:hover { color: #fff; }

.main-column { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 75px; padding: 0 42px; background: rgba(245,243,238,.82);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(12px);
}
.eyebrow { margin: 0; color: var(--amber-dark); font: 500 11px "DM Mono", monospace; letter-spacing: .14em; text-transform: uppercase; }
.topbar-title { margin: 4px 0 0; font-size: 18px; letter-spacing: -.02em; }
.topbar-meta { display: flex; align-items: center; gap: 12px; color: var(--ink-soft); font-size: 12px; }
.topbar-status { display: inline-flex; align-items: center; gap: 7px; }
.topbar-status::before { content: ""; width: 7px; height: 7px; background: #56a981; border-radius: 50%; }
.mobile-logout-form { display: none; }
.content { width: min(1240px, 100%); margin: 0 auto; padding: 38px 42px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head h1 { margin: 3px 0 0; color: var(--navy); font-size: clamp(25px, 3vw, 34px); line-height: 1.15; letter-spacing: -.045em; }
.page-head p { max-width: 650px; margin: 9px 0 0; color: var(--ink-soft); font-size: 13px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px;
  padding: 0 16px; color: var(--paper-strong); background: var(--amber-dark);
  border: 1px solid var(--amber-dark); border-radius: 8px; font-size: 13px; font-weight: 800;
  transition: background .18s ease, transform .18s ease, border-color .18s ease;
}
.button:hover { background: #7e481b; border-color: #7e481b; transform: translateY(-1px); }
.button-secondary { color: var(--ink); background: var(--paper-strong); border-color: var(--line); }
.button-secondary:hover { color: var(--navy); background: #fff; border-color: #9db0b0; }
.button-quiet { min-height: 36px; padding: 0 11px; color: var(--ink-soft); background: transparent; border-color: transparent; }
.button-danger { color: var(--rose-ink); background: var(--rose); border-color: #ebc6be; }

.card {
  background: rgba(255,253,250,.88); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 4px 15px rgba(25,46,64,.025);
}
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 17px; border-bottom: 1px solid var(--line); }
.card-title { margin: 0; color: var(--navy); font-size: 15px; letter-spacing: -.02em; }
.card-note { margin: 4px 0 0; color: var(--ink-soft); font-size: 12px; }
.card-body { padding: 22px 24px; }
.grid { display: grid; gap: 18px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.earning-limits { margin-bottom: 24px; }
.dashboard-grid .earning-limits { margin-bottom: 0; }
.pv-panel { margin-bottom: 20px; }
.dashboard-grid .pv-panel { margin-bottom: 0; }
.pv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0 0 16px; }
.pv-grid > div { min-width: 0; }
.pv-grid dt { color: var(--ink-soft); font-size: 12px; }
.pv-grid dd { margin: 7px 0 0; overflow-wrap: anywhere; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pv-grid dd span { font-size: 12px; color: var(--ink-soft); }
.pv-warning { margin: 12px 0 0; color: var(--amber-dark); font-size: 12px; }
@media (max-width: 650px) {
  .pv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .pv-grid dd { font-size: 22px; }
}
.stat-card { min-height: 132px; padding: 18px 19px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; width: 90px; height: 90px; right: -38px; bottom: -42px; border: 1px solid rgba(199,127,46,.22); border-radius: 50%; }
.stat-label { display: block; color: var(--ink-soft); font-size: 12px; }
.stat-value { display: block; margin-top: 13px; color: var(--navy); font-size: 27px; font-weight: 800; letter-spacing: -.05em; }
.stat-meta { display: block; margin-top: 5px; color: var(--mint-ink); font-size: 11px; }
.dashboard-grid { grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); align-items: start; }
.dashboard-swipe-hint { display: none; }
.wide { grid-column: 1 / -1; }
.profile-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; }
.profile-item { padding: 13px 0; border-bottom: 1px solid var(--line); }
.profile-item:nth-child(odd) { margin-right: 25px; }
.profile-item dt { color: var(--ink-soft); font-size: 11px; }
.profile-item dd { margin: 3px 0 0; font-weight: 700; }
.mono { font-family: "DM Mono", monospace; font-size: .92em; }
.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; min-width: 620px; border-collapse: collapse; }
.data-table th { padding: 12px 24px; color: var(--ink-soft); background: rgba(220,238,230,.28); font: 500 10px "DM Mono", monospace; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 15px 24px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(246,232,210,.22); }
.amount-positive { color: var(--mint-ink); font-weight: 800; }
.amount-negative { color: var(--rose-ink); font-weight: 800; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-success { color: var(--mint-ink); background: var(--mint); }
.badge-muted { color: var(--ink-soft); background: #e8eceb; }
.badge-amber { color: var(--amber-dark); background: var(--amber-pale); }
.empty-state { padding: 32px 22px; color: var(--ink-soft); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--navy); }
.empty-mark { margin: 0 auto 12px; width: 38px; height: 38px; display: grid; place-items: center; color: var(--amber-dark); border: 1px solid #dfc295; border-radius: 11px; font: 500 15px "DM Mono", monospace; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; }
.field label { color: var(--navy); font-size: 12px; font-weight: 800; }
.field-hint { color: var(--ink-soft); font-size: 11px; font-weight: 400; }
.field input, .field select {
  width: 100%; min-height: 44px; padding: 0 12px; color: var(--ink); background: var(--paper-strong);
  border: 1px solid #bfcac8; border-radius: 7px; outline: none;
}
.field textarea { width: 100%; min-height: 90px; padding: 10px 12px; resize: vertical; color: var(--ink); background: var(--paper-strong); border: 1px solid #bfcac8; border-radius: 7px; outline: none; }
.field input::placeholder, .field textarea::placeholder { color: #91a0a4; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #8ca5a5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--amber-dark); box-shadow: 0 0 0 3px rgba(199,127,46,.14); }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.error-text { margin: 0; color: var(--rose-ink); font-size: 12px; }
.alert { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 18px; padding: 13px 15px; border: 1px solid; border-radius: 8px; font-size: 13px; }
.alert::before { content: "!"; display: grid; place-items: center; width: 18px; height: 18px; flex: 0 0 auto; color: currentColor; border: 1px solid currentColor; border-radius: 50%; font: 700 11px "DM Mono", monospace; }
.alert-success { color: var(--mint-ink); background: var(--mint); border-color: #acd2c1; }
.alert-error, .alert-danger { color: var(--rose-ink); background: var(--rose); border-color: #e5bdb5; }
.alert-info { color: var(--ink); background: #e7edf0; border-color: #c3d0d5; }

.auth-page { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(420px, .98fr); background: var(--paper); }
.auth-aside { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 100%; padding: 47px clamp(32px, 7vw, 100px); color: #edf4f1; background: var(--navy); overflow: hidden; }
.auth-aside::before { content: ""; position: absolute; width: 430px; height: 430px; right: -130px; top: 12%; border: 1px solid rgba(218,184,123,.32); border-radius: 50%; box-shadow: 0 0 0 28px rgba(218,184,123,.05), 0 0 0 58px rgba(218,184,123,.04); }
.auth-aside::after { content: ""; position: absolute; width: 210px; height: 210px; left: -95px; bottom: 15%; border: 1px solid rgba(118,174,150,.35); border-radius: 50%; }
.auth-copy { position: relative; z-index: 1; max-width: 490px; margin: auto 0; }
.auth-kicker { color: #d8b579; font: 500 11px "DM Mono", monospace; letter-spacing: .17em; text-transform: uppercase; }
.auth-copy h1 { max-width: 500px; margin: 17px 0 20px; font-family: Georgia, serif; font-size: clamp(40px, 5vw, 68px); font-weight: 400; line-height: 1.03; letter-spacing: -.055em; }
.auth-copy p { max-width: 430px; margin: 0; color: #adc0c2; font-size: 15px; }
.auth-list { display: grid; gap: 15px; max-width: 410px; margin: 35px 0 0; padding: 0; list-style: none; }
.auth-list li { display: flex; gap: 12px; color: #d3dfdc; font-size: 12px; }
.auth-list li::before { content: ""; width: 8px; height: 8px; flex: 0 0 auto; margin-top: 6px; background: var(--amber); border-radius: 50%; }
.auth-footer { position: relative; z-index: 1; color: #82999f; font-size: 11px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px clamp(24px, 7vw, 100px); }
.auth-box { width: min(440px, 100%); }
.auth-box-head { margin-bottom: 29px; }
.auth-box-head .brand { margin: 0 0 32px; color: var(--navy); }
.auth-box-head h2 { margin: 0; color: var(--navy); font-size: 27px; letter-spacing: -.045em; }
.auth-box-head p { margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }
.auth-form { display: grid; gap: 17px; }
.auth-form .button { width: 100%; margin-top: 6px; }
.contact-card { max-width: 720px; margin: 0 auto; padding: clamp(24px, 4vw, 40px); background: var(--paper-strong); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.contact-card .auth-box-head h1 { margin: 0; color: var(--navy); font-size: 27px; letter-spacing: -.045em; }
.contact-card .auth-form { max-width: 560px; }
.contact-honeypot { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.auth-bottom { margin-top: 24px; color: var(--ink-soft); font-size: 12px; text-align: center; }
.auth-bottom a { color: var(--amber-dark); font-weight: 800; }
.password-note { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.password-note a { color: var(--amber-dark); font-size: 11px; font-weight: 700; }

.tree-layout { display: grid; grid-template-columns: minmax(250px, .68fr) minmax(0, 1.7fr); gap: 18px; align-items: start; }
.tree-summary { display: grid; gap: 14px; }
.sponsor-card { padding: 22px; }
.sponsor-card .avatar { width: 44px; height: 44px; }
.sponsor-card h3 { margin: 16px 0 2px; color: var(--navy); font-size: 17px; }
.sponsor-card p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.tree-key { display: grid; gap: 9px; padding: 18px 22px; }
.tree-key p { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--ink-soft); font-size: 11px; }
.key-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint-ink); }
.key-dot.empty { border: 1px dashed #a2b0ad; background: transparent; }
.tree-canvas { min-width: 0; padding: 26px 22px 30px; overflow-x: auto; }
.tree-root { width: min(270px, 100%); margin: 0 auto 52px; position: relative; }
.tree-root::after { content: ""; position: absolute; width: 1px; height: 32px; left: 50%; top: 100%; background: #b8c6c3; }
.tree-branches { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; min-width: 480px; position: relative; }
.tree-branches::before { content: ""; position: absolute; height: 1px; left: 25%; right: 25%; top: -20px; background: #b8c6c3; }
.tree-branch { position: relative; min-width: 0; }
.tree-branch::before { content: ""; position: absolute; width: 1px; height: 20px; top: -20px; left: 50%; background: #b8c6c3; }
.tree-branch-label { margin-bottom: 9px; color: var(--ink-soft); font: 500 10px "DM Mono", monospace; letter-spacing: .13em; text-align: center; text-transform: uppercase; }
.node { padding: 15px 13px; text-align: center; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-strong); }
.node-root { border-color: #d6b47b; background: #fff9ed; }
.node .avatar { width: 30px; height: 30px; margin: 0 auto 8px; }
.node-name { color: var(--navy); font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-email { color: var(--ink-soft); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-empty { padding: 20px 12px; color: #91a09f; border-style: dashed; background: rgba(245,243,238,.55); }
.node-empty .empty-mark { width: 27px; height: 27px; margin-bottom: 7px; color: #91a09f; border-color: #b6c2bf; font-size: 11px; }
.node-empty p { margin: 0; font-size: 11px; }
.node-link { display: block; text-decoration: none; color: inherit; transition: border-color .18s ease, transform .18s ease; }
.node-link:hover { border-color: #d6b47b; transform: translateY(-2px); }
.node-link:focus-visible { outline: 3px solid #b98536; outline-offset: 3px; }
.tree-branches-nested { margin-top: 34px; min-width: 340px; gap: 16px; }
.tree-branches-nested::before { top: -18px; }
.tree-branches-nested .tree-branch::before { top: -18px; height: 18px; }
.tree-more { display: block; margin-top: 12px; color: var(--navy); font-size: 11px; text-align: center; }

.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; align-items: start; }
.admin-grid .full { grid-column: 1 / -1; }
.admin-user-actions { min-width: 126px; white-space: nowrap; }
.admin-user-actions form { margin: 0; }
.admin-delete-button { min-height: 34px; padding: 0 10px; font-size: 12px; }
.account-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 18px; align-items: start; min-width: 0; }
.account-grid > .card { min-width: 0; }
.account-password-fields { display: grid; gap: 17px; }
.mini-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.mini-list li { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list-main { min-width: 0; }
.mini-list-name { display: block; overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.mini-list-meta { color: var(--ink-soft); font-size: 11px; }
.setting-value { font: 700 18px "DM Mono", monospace; color: var(--navy); }
.section-gap { margin-top: 20px; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 210px 1fr; }
  .topbar { padding: 0 25px; }
  .content { padding: 30px 25px 50px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .tree-layout { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: minmax(0, 1fr); }
  .tree-summary { grid-template-columns: 1fr 1fr; }
  .sponsor-card { height: 100%; }
  .tree-key { align-content: center; }
  .auth-page { grid-template-columns: minmax(0, .85fr) minmax(390px, 1.15fr); }
  .auth-aside { padding-left: 45px; padding-right: 45px; }
}
@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 13px 15px 12px; }
  .sidebar-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
  .brand { margin: 0 4px 14px; }
  .nav-label, .sidebar-bottom { display: none; }
  .nav-list { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-link { min-height: 37px; padding: 0 10px; white-space: nowrap; }
  .nav-icon { display: none; }
  .topbar { min-height: 64px; padding: 0 17px; }
  .topbar-meta { display: none; }
  .bonuses-body .topbar { display: none; }
  .mobile-logout-form { display: block; flex: 0 0 auto; }
  .mobile-logout {
    min-height: 44px; padding: 0 12px; border: 1px solid var(--line-dark);
    border-radius: 8px; color: #edf3f2; background: var(--navy-2); font-size: 13px; font-weight: 700;
  }
  .mobile-logout:hover { background: #27445b; }
  .content { padding: 27px 17px 42px; }
  .page-head { display: block; margin-bottom: 22px; }
  .page-actions { margin-top: 17px; }
  .page-actions .button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 115px; padding: 14px; }
  .stat-value { margin-top: 10px; font-size: 21px; }
  .card-header, .card-body { padding-left: 16px; padding-right: 16px; }
  .profile-list, .form-grid, .admin-grid, .tree-summary { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: minmax(0, 1fr); width: 100%; min-width: 0; }
  .account-grid > .card { max-width: 100%; }
  .admin-grid { grid-template-columns: minmax(0, 1fr); min-width: 0; width: 100%; }
  .admin-grid > .card { min-width: 0; max-width: 100%; }
  .admin-grid .data-table-wrap { width: 100%; min-width: 0; max-width: 100%; }
  .admin-grid .card-header { flex-wrap: wrap; }
  .admin-grid .card-header > div { min-width: 0; }
  .admin-grid .card-header > .badge { max-width: 100%; white-space: normal; }
  .profile-item:nth-child(odd) { margin-right: 0; }
  .form-grid .full, .admin-grid .full { grid-column: auto; }
  .data-table th, .data-table td { padding-left: 15px; padding-right: 15px; }
  .bonuses-body .stat-value { overflow-wrap: anywhere; }
  .bonus-history-card .bonus-table-wrap { width: 100%; min-width: 0; overflow: visible; }
  .bonus-history-table { display: block; width: 100%; min-width: 0; }
  .bonus-history-table thead { display: none; }
  .bonus-history-table tbody { display: grid; gap: 10px; padding: 12px; }
  .bonus-history-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 5px 12px;
    padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-strong);
  }
  .bonus-history-table td { min-width: 0; padding: 0; border: 0; font-size: 12px; overflow-wrap: anywhere; }
  .bonus-history-table td:nth-child(1) { grid-row: 1; grid-column: 1; color: var(--ink-soft); white-space: nowrap; }
  .bonus-history-table td:nth-child(2) { grid-row: 2; grid-column: 1 / -1; padding: 2px 0; font-weight: 700; }
  .bonus-history-table td:nth-child(3) { grid-row: 3; grid-column: 1; color: var(--ink-soft); }
  .bonus-history-table td:nth-child(4) { grid-row: 1; grid-column: 2; font-size: 15px; text-align: right; white-space: nowrap; }
  .bonus-history-table td:nth-child(5) { grid-row: 3; grid-column: 2; justify-self: end; }
  .bonus-history-table tbody tr:hover { background: var(--paper-strong); }
  .tree-canvas { padding-left: 12px; padding-right: 12px; }
  .auth-page { display: block; }
  .auth-aside { min-height: 0; padding: 25px 22px 30px; }
  .auth-copy { margin: 34px 0 0; }
  .auth-copy h1 { margin-top: 13px; font-size: 43px; }
  .auth-copy p, .auth-list, .auth-footer { display: none; }
  .auth-panel { padding: 34px 22px 50px; }
  .auth-box-head .brand { margin-bottom: 27px; }

  .dashboard-body { height: 100dvh; overflow: hidden; }
  .dashboard-body .app-shell { display: flex; flex-direction: column; height: 100dvh; min-height: 0; overflow: hidden; }
  .dashboard-body .sidebar { flex: 0 0 auto; }
  .dashboard-body .main-column { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
  .dashboard-body .topbar { display: none; }
  .dashboard-body .content {
    display: flex; flex: 1 1 auto; flex-direction: column; width: 100%; min-height: 0; margin: 0;
    overflow: hidden; padding: 12px 12px 14px;
  }
  .dashboard-body .content > .alert { flex: 0 0 auto; margin-bottom: 8px; }
  .dashboard-view { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; gap: 8px; }
  .dashboard-view .page-head { flex: 0 0 auto; margin: 0; }
  .dashboard-view .page-head h1 { font-size: clamp(18px, 5.8vw, 23px); line-height: 1.12; }
  .dashboard-view .page-head > div:first-child > p:last-child,
  .dashboard-view .page-actions { display: none; }
  .dashboard-view .stats-grid { flex: 0 0 auto; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
  .dashboard-view .stat-card { min-height: 72px; padding: 9px 11px; }
  .dashboard-view .stat-label { font-size: 10px; line-height: 1.25; }
  .dashboard-view .stat-value { display: block; margin-top: 4px; font-size: 18px; line-height: 1.15; }
  .dashboard-view .stat-meta { display: none; }
  .dashboard-swipe-hint { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; margin: 0; color: var(--ink-soft); font-size: 10px; line-height: 1.3; }
  .dashboard-panels {
    display: flex; flex: 1 1 auto; gap: 10px; min-height: 0; overflow-x: auto; overflow-y: hidden;
    overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: thin;
    scrollbar-color: rgba(88,112,137,.38) transparent; -webkit-overflow-scrolling: touch;
  }
  .dashboard-panel {
    display: flex; flex: 0 0 100%; flex-direction: column; min-width: 0; min-height: 0; max-height: 100%;
    overflow: hidden; scroll-snap-align: start; scroll-snap-stop: always;
  }
  .dashboard-panel .card-header { flex: 0 0 auto; gap: 8px; padding: 12px 13px 10px; }
  .dashboard-panel .card-title { font-size: 14px; }
  .dashboard-panel .card-note { font-size: 10px; }
  .dashboard-panel .button-quiet { min-height: 32px; padding: 0 6px; font-size: 11px; }
  .dashboard-panel .card-body,
  .dashboard-panel-content { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; }
  .dashboard-panel .card-body { padding: 12px 13px; }
  .dashboard-panel .profile-list { grid-template-columns: 1fr; }
  .dashboard-panel .profile-item { padding: 9px 0; }
  .dashboard-panel .profile-item:nth-child(odd) { margin-right: 0; }
  .activity-panel .data-table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .activity-panel .data-table { min-width: 520px; }
  .activity-panel .data-table th,
  .activity-panel .data-table td { padding-top: 10px; padding-bottom: 10px; }
  .dashboard-panel .empty-state { flex: 1 1 auto; overflow-y: auto; }
}
@media (max-width: 390px) {
  .dashboard-view .stat-card { min-height: 68px; padding: 8px 9px; }
  .dashboard-view .stat-value { font-size: 16px; }
  .tree-branches { min-width: 410px; gap: 18px; }
}
@media (max-width: 390px) and (max-height: 650px) {
  .dashboard-view .page-head .eyebrow { display: none; }
  .dashboard-view .stats-grid {
    display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity;
    scrollbar-width: thin; -webkit-overflow-scrolling: touch;
  }
  .dashboard-view .stats-grid .stat-card { flex: 0 0 calc(50% - 4px); scroll-snap-align: start; }
}