:root {
  color-scheme: dark;
  --bg: #070707;
  --bg-2: #101217;
  --panel: rgba(19, 20, 24, 0.94);
  --panel-2: rgba(11, 16, 24, 0.96);
  --line: rgba(241, 198, 110, 0.22);
  --line-2: rgba(146, 165, 207, 0.22);
  --gold: #f4c15d;
  --gold-2: #ffdf91;
  --silver: #c9d8f1;
  --blue: #68a7ff;
  --purple: #9a69ff;
  --green: #64d98b;
  --red: #ff6d7a;
  --text: #f6ead4;
  --muted: #9ca3af;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #08090b 0%, #0d1118 55%, #08090b 100%);
  color: var(--text);
  font-family:
    "Microsoft JhengHei",
    "PingFang TC",
    "Noto Sans TC",
    system-ui,
    sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

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

button {
  border: 0;
}

.compact-field {
  display: grid;
  gap: 5px;
  max-width: 260px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.select.compact {
  min-height: 36px;
  padding: 6px 34px 6px 10px;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 12px;
  color: var(--gold-2);
}

.brand-mark {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #fff1b8 0 10%, transparent 11%),
    conic-gradient(from 40deg, #9a620d, #ffe5a2, #d69522, #ffefba, #9a620d);
  box-shadow: 0 0 32px rgba(244, 193, 93, 0.28);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(7, 7, 7, 0.82);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 22px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  color: var(--gold-2);
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.nav-group {
  display: grid;
  gap: 8px;
  min-height: 0;
  padding-bottom: 76px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 193, 93, 0.3) transparent;
}

.nav-section {
  min-width: 0;
}

.nav-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d8d3c9;
  cursor: pointer;
}

.nav-button:hover,
.nav-button.active {
  border-color: rgba(244, 193, 93, 0.42);
  background: linear-gradient(90deg, rgba(244, 193, 93, 0.16), rgba(104, 167, 255, 0.06));
  color: var(--gold-2);
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--gold);
}

.nav-parent .nav-chevron {
  margin-left: auto;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 160ms ease;
}

.nav-section.expanded .nav-chevron {
  transform: rotate(90deg);
  color: var(--gold-2);
}

.nav-children {
  display: grid;
  gap: 2px;
  padding: 3px 4px 7px 40px;
}

.nav-children[hidden] {
  display: none;
}

.nav-child-button {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 0 6px 6px 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.nav-child-button:hover,
.nav-child-button.active {
  border-left-color: var(--gold);
  background: rgba(244, 193, 93, 0.1);
  color: var(--gold-2);
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0 6px;
  border: 1px solid rgba(104, 167, 255, 0.45);
  border-radius: 999px;
  background: rgba(104, 167, 255, 0.12);
  color: #cfe2ff;
  font-size: 11px;
}

.sidebar-foot {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}

.actor-chip {
  min-width: 0;
  flex: 1;
}

.actor-chip span,
.actor-chip strong {
  display: block;
}

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

.actor-chip strong {
  overflow: hidden;
  color: #fff1cf;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
}

.password-control {
  position: relative;
}

.password-control .input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  transform: translateY(-50%);
  border-color: transparent;
  background: transparent;
  color: #d8c294;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  border-color: rgba(244, 193, 93, 0.42);
  background: rgba(244, 193, 93, 0.1);
  color: #fff1cf;
}

.password-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.main {
  min-width: 0;
  padding: 24px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h2 {
  margin: 0;
  color: #fff4d9;
  font-size: 28px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.shared-sandbox-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(87, 156, 255, 0.5);
  border-left: 4px solid #579cff;
  border-radius: 8px;
  background: rgba(20, 46, 82, 0.68);
}

.shared-sandbox-banner div {
  display: grid;
  gap: 4px;
}

.shared-sandbox-banner strong {
  color: #e7f1ff;
}

.shared-sandbox-banner span {
  color: #b8c8dc;
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.select,
.input,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(5, 7, 10, 0.82);
  color: var(--text);
  outline: none;
}

.textarea {
  resize: vertical;
  min-height: 78px;
}

.select:focus,
.input:focus,
.textarea:focus {
  border-color: rgba(244, 193, 93, 0.62);
  box-shadow: 0 0 0 3px rgba(244, 193, 93, 0.1);
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid rgba(244, 193, 93, 0.38);
  background: linear-gradient(180deg, #ffdc83, #c78922);
  color: #171009;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn.compact {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.btn.secondary {
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.btn.danger {
  border-color: rgba(255, 109, 122, 0.45);
  background: rgba(255, 109, 122, 0.13);
  color: #ffd0d5;
}

.btn.blue {
  border-color: rgba(104, 167, 255, 0.48);
  background: rgba(104, 167, 255, 0.15);
  color: #d8e8ff;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid > *,
.panel,
.panel-body {
  min-width: 0;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.quick-workspace-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.quick-workspace-button {
  min-height: 86px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 7px;
  padding: 15px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: rgba(13, 17, 23, 0.78);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.quick-workspace-button:hover,
.quick-workspace-button:focus-visible {
  border-color: rgba(255, 204, 92, 0.68);
  background: rgba(255, 204, 92, 0.08);
  outline: 0;
}

.quick-workspace-button span {
  color: var(--gold-2);
  font-weight: 700;
}

.quick-workspace-button strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 214, 128, 0.07), transparent 34%),
    var(--panel);
  box-shadow: var(--shadow);
}

.dashboard-summary {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

.workspace-stack {
  display: grid;
  gap: 10px;
}

.workspace-group {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.workspace-group > summary {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 15px;
  list-style: none;
  border-left: 3px solid rgba(104, 167, 255, 0.42);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(13, 15, 19, 0.48);
}

.workspace-group[open] > summary {
  background: rgba(19, 22, 28, 0.72);
}

.workspace-group > summary::-webkit-details-marker {
  display: none;
}

.workspace-group > summary::after {
  content: "+";
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  color: var(--gold-2);
}

.workspace-group[open] > summary::after {
  content: "−";
}

.workspace-group > summary > div {
  min-width: 0;
  flex: 1;
}

.workspace-group > summary strong,
.workspace-group > summary small {
  display: block;
}

.workspace-group > summary small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 400;
}

.workspace-group-body {
  padding: 0 0 14px;
  border-top: 0;
}

.workspace-group-body > .panel:first-child,
.workspace-group-body > .section:first-child,
.workspace-group-body > .grid:first-child {
  margin-top: 14px;
}

.workspace-group .panel {
  box-shadow: none;
}

.workspace-page[hidden] {
  display: none !important;
}

.workspace-page-header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 12px 16px;
  border-left: 3px solid rgba(104, 167, 255, 0.55);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(13, 15, 19, 0.52);
}

.workspace-page-header h3,
.workspace-page-header p {
  margin: 0;
}

.workspace-page-header h3 {
  color: var(--gold-2);
  font-size: 17px;
}

.workspace-page-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.workspace-page-body {
  min-width: 0;
}

.profile-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
}

.profile-detail-grid > div {
  min-width: 0;
  padding: 12px;
  background: var(--panel);
}

.profile-detail-grid small,
.profile-detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.profile-detail-grid small {
  margin-bottom: 5px;
  color: var(--muted);
}

.member-relationship-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.member-relationship-summary > div {
  min-width: 0;
}

.member-relationship-summary small,
.member-relationship-summary strong,
.member-relationship-summary span {
  display: block;
  overflow-wrap: anywhere;
}

.member-relationship-summary small,
.member-relationship-summary span {
  color: var(--muted);
}

.member-relationship-summary strong {
  margin: 4px 0;
  color: var(--gold-2);
}

.ledger-limit-note {
  margin: 10px 2px 0;
}

.promotion-benefits {
  padding: 16px;
}

.promotion-benefits.compact {
  margin-top: 16px;
  border-top: 1px solid rgba(244, 193, 93, 0.25);
  border-bottom: 1px solid rgba(104, 167, 255, 0.2);
  background: rgba(13, 15, 19, 0.48);
}

.promotion-benefits-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.promotion-benefits-head h3 {
  margin: 0;
  color: var(--gold-2);
  font-size: 16px;
}

.promotion-benefits-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}

.promotion-benefit-item {
  min-width: 0;
  padding: 4px 14px;
  border-left: 2px solid rgba(244, 193, 93, 0.38);
}

.promotion-benefit-item strong {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.workflow-section {
  margin-top: 14px;
}

.workflow-section + .workflow-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.workflow-section > h3 {
  margin: 0 0 12px;
  color: var(--gold-2);
  font-size: 0.95rem;
  font-weight: 700;
}

.workspace-grid {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.member-create-flow {
  width: 100%;
}

.member-create-submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px;
  border: 1px solid rgba(255, 204, 92, 0.22);
  border-radius: 7px;
  background: rgba(255, 204, 92, 0.05);
}

.member-create-submit > div {
  min-width: 0;
}

.member-create-submit .btn {
  flex: 0 0 auto;
}

.cash-flow-metrics .metric {
  min-height: 92px;
}

.panel.blue-panel {
  border-color: var(--line-2);
  background:
    linear-gradient(145deg, rgba(104, 167, 255, 0.11), transparent 38%),
    var(--panel-2);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 0;
}

.panel-title {
  margin: 0;
  font-size: 17px;
  color: var(--gold-2);
}

.panel-body {
  padding: 16px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 14px;
  align-items: stretch;
}

.profile-block {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.avatar {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 2px solid rgba(244, 193, 93, 0.65);
  background:
    radial-gradient(circle at 50% 30%, #ffe2a1 0 17%, transparent 18%),
    radial-gradient(circle at 50% 72%, #d79a35 0 30%, transparent 31%),
    #1a1a1a;
}

.name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.member-name {
  font-size: 24px;
  font-weight: 900;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid rgba(244, 193, 93, 0.36);
  border-radius: 999px;
  color: var(--gold-2);
  background: rgba(244, 193, 93, 0.09);
  font-size: 13px;
  white-space: nowrap;
}

.pill.blue {
  border-color: rgba(104, 167, 255, 0.42);
  color: #d8e8ff;
  background: rgba(104, 167, 255, 0.11);
}

.pill.green {
  border-color: rgba(100, 217, 139, 0.42);
  color: #c9f6d7;
  background: rgba(100, 217, 139, 0.1);
}

.muted {
  color: var(--muted);
}

.big-number {
  max-width: 100%;
  font-size: 44px;
  line-height: 1;
  color: var(--gold-2);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.big-number small {
  font-size: 15px;
  font-weight: 700;
}

.big-number.compact-number {
  font-size: 36px;
  line-height: 1.18;
}

.big-number.silver {
  color: #d7e6ff;
}

.sub-number {
  color: var(--muted);
  margin-top: 8px;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--blue));
}

.level-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.level-card,
.metric,
.reward-card {
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.24);
}

.metric {
  border: 0;
  border-left: 2px solid rgba(244, 193, 93, 0.42);
  background: transparent;
  box-shadow: none;
}

.level-card.active {
  border-color: rgba(244, 193, 93, 0.72);
  box-shadow: inset 0 0 0 1px rgba(244, 193, 93, 0.16);
}

.level-rate {
  margin: 8px 0 0;
  color: #d7e6ff;
  font-size: 14px;
  font-weight: 800;
}

.level-badge {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 8px;
  border: 1px solid rgba(244, 193, 93, 0.45);
  background: linear-gradient(145deg, rgba(244, 193, 93, 0.2), rgba(104, 167, 255, 0.12));
  color: #fff1ba;
  font-weight: 900;
}

.metric label,
.reward-card label,
.level-card label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.metric strong,
.reward-card strong {
  display: block;
  color: #fff2d0;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.metric .blue-text,
.reward-card .blue-text {
  color: #d7e6ff;
}

.coin-visual {
  position: relative;
  min-height: 116px;
  overflow: hidden;
}

.coin-visual::before,
.coin-visual::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.75), transparent 12%),
    conic-gradient(from 30deg, #9d650e, #ffe29a, #c48520, #fff0be, #9d650e);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0.72;
}

.coin-visual .panel-body {
  position: relative;
  z-index: 1;
  padding-right: 150px;
}

.coin-visual::before {
  right: 32px;
  top: 20px;
  width: 82px;
  height: 82px;
}

.coin-visual::after {
  right: 92px;
  top: 50px;
  width: 56px;
  height: 56px;
}

.silver-visual::before,
.silver-visual::after {
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.8), transparent 12%),
    conic-gradient(from 30deg, #6e7e91, #e8f2ff, #9ba9bd, #ffffff, #6e7e91);
}

.section {
  margin-top: 14px;
}

.table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #e9c987;
  font-size: 13px;
  font-weight: 800;
}

td {
  color: #e9e4dc;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #d8d3c9;
}

.status.pending {
  border-color: rgba(244, 193, 93, 0.4);
  color: #ffe4a8;
}

.status.approved,
.status.settled,
.status.paid,
.status.granted,
.status.applied,
.status.authorized,
.status.executed {
  border-color: rgba(100, 217, 139, 0.42);
  color: #c9f6d7;
}

.status.rejected,
.status.failed_refund,
.status.failed_keep_frozen,
.status.reversed,
.status.reversed_with_shortfall,
.status.reversal_shortfall {
  border-color: rgba(255, 109, 122, 0.45);
  color: #ffd0d5;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sandbox-actions,
.sandbox-control {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
}

.sandbox-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.button-field {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 8px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: #d2c3a3;
  font-size: 13px;
}

.field small,
.member-picker small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.member-picker {
  display: grid;
  gap: 7px;
}

.toolbar .member-picker {
  grid-template-columns: minmax(150px, 0.8fr) minmax(210px, 1fr);
  align-items: center;
  width: min(520px, 45vw);
}

.toolbar .member-picker small {
  display: none;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.field.full {
  grid-column: 1 / -1;
}

.toggle {
  display: flex;
  align-items: center;
  min-height: 40px;
  gap: 8px;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.toggle.full {
  grid-column: 1 / -1;
}

.notice {
  border: 1px solid rgba(104, 167, 255, 0.25);
  border-radius: 8px;
  padding: 12px;
  background: rgba(104, 167, 255, 0.08);
  color: #d8e8ff;
}

.warning {
  border-color: rgba(244, 193, 93, 0.32);
  background: rgba(244, 193, 93, 0.08);
  color: #ffe4a8;
}

.weekly-missing-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.weekly-missing-notice p {
  margin: 4px 0 0;
  color: var(--muted);
}

.weekly-missing-notice .btn {
  flex: 0 0 auto;
}

.record-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.record-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.record-row strong {
  display: block;
  margin-bottom: 4px;
}

.record-row small {
  color: var(--muted);
}

.amount {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.button-row,
.quick-buttons,
.search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(320px, 1.3fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.date-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.search-field {
  grid-column: 1 / -1;
}

.search-row .input {
  flex: 1 1 220px;
}

.field-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.field-alert {
  min-height: 16px;
  margin: -2px 0 6px;
  color: #ff8d98;
  font-size: 12px;
  font-weight: 700;
}

.calculation-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(104, 167, 255, 0.2);
  border-radius: 8px;
  background: rgba(104, 167, 255, 0.06);
}

.calculation-preview .metric {
  min-width: 0;
}

.tree-root,
.referral-node,
.org-node {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.tree-root > summary,
.referral-node > summary,
.org-node > summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.tree-root > summary::-webkit-details-marker,
.referral-node > summary::-webkit-details-marker,
.org-node > summary::-webkit-details-marker {
  display: none;
}

.tree-root > summary::before,
.referral-node > summary::before,
.org-node > summary::before {
  content: "+";
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(244, 193, 93, 0.35);
  border-radius: 6px;
  color: var(--gold-2);
}

.tree-root[open] > summary::before,
.referral-node[open] > summary::before,
.org-node[open] > summary::before {
  content: "−";
}

.tree-root > summary strong,
.referral-node > summary strong {
  margin-left: auto;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
}

.referral-branches,
.source-entries,
.org-children {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px 34px;
}

.source-entries > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-left: 2px solid rgba(104, 167, 255, 0.35);
  color: var(--muted);
}

.source-entries strong {
  color: var(--green);
  white-space: nowrap;
}

.org-tree {
  overflow: hidden;
}

.org-node {
  margin-top: 7px;
}

.org-leaf {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  padding: 9px 12px;
  border-left: 2px solid rgba(104, 167, 255, 0.35);
  background: rgba(0, 0, 0, 0.16);
}

.tree-role {
  min-width: 42px;
  color: var(--gold-2);
  font-size: 12px;
}

.tree-name {
  min-width: 0;
  font-weight: 800;
}

.tree-account {
  color: var(--muted);
  font-size: 13px;
}

.tree-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.report-table {
  min-width: 0;
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.report-head,
.report-row,
.report-total {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(110px, 0.8fr));
  gap: 12px;
  align-items: center;
  padding: 11px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.agent-member-report .report-head,
.agent-member-report .report-row,
.agent-member-report .report-total {
  grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(110px, 0.8fr));
}

.report-head {
  color: #e9c987;
  font-size: 13px;
  font-weight: 800;
}

.report-row span,
.report-total span {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.report-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.report-total {
  color: var(--gold-2);
  font-weight: 900;
  background: rgba(244, 193, 93, 0.06);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 16px;
  border: 1px solid rgba(244, 193, 93, 0.45);
  border-radius: 8px;
  background: rgba(13, 13, 13, 0.96);
  color: var(--gold-2);
  box-shadow: var(--shadow);
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(480px, 100%);
}

.login-brand {
  padding: 0 0 18px;
}

.login-panel h2 {
  margin: 0;
  color: #fff4d9;
  font-size: 28px;
}

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

.green-text {
  color: var(--green);
}

.tab-note {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.wheel-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(250px, 0.54fr);
  align-items: center;
  gap: clamp(24px, 4vw, 56px);
  padding: clamp(22px, 4vw, 48px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 42%, rgba(244, 193, 93, 0.12), transparent 38%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 48%),
    var(--panel);
  overflow: hidden;
}

.wheel-showcase {
  min-width: 0;
  text-align: center;
}

.wheel-stage {
  container-type: inline-size;
  position: relative;
  width: min(100%, 480px);
  aspect-ratio: 1;
  justify-self: center;
  margin: 0 auto;
  padding: clamp(10px, 2.7cqw, 14px);
  border: 1px solid rgba(255, 224, 151, 0.7);
  border-radius: 50%;
  background:
    linear-gradient(135deg, #fff0b0 0%, #8b5c13 22%, #f5cf6d 45%, #573607 67%, #d9a83f 100%);
  box-shadow:
    0 24px 54px rgba(0, 0, 0, 0.56),
    0 0 0 5px rgba(7, 8, 10, 0.92),
    0 0 0 7px rgba(213, 164, 62, 0.38),
    inset 0 0 18px rgba(255, 239, 188, 0.34);
}

.wheel-disc {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: clamp(5px, 1.4cqw, 8px) solid #17120a;
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 2px rgba(255, 236, 175, 0.58),
    inset 0 0 34px rgba(0, 0, 0, 0.44);
  will-change: transform;
}

.wheel-disc::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.22), transparent 29%),
    radial-gradient(circle, transparent 58%, rgba(0, 0, 0, 0.3) 96%);
  pointer-events: none;
}

.wheel-pointer {
  position: absolute;
  z-index: 6;
  top: -15px;
  left: 50%;
  width: clamp(34px, 9cqw, 46px);
  height: clamp(48px, 12cqw, 62px);
  transform: translateX(-50%);
  clip-path: polygon(8% 0, 92% 0, 54% 100%, 46% 100%);
  background: linear-gradient(90deg, #8a5d14, #fff0b1 45%, #d5a13b 62%, #684005);
  filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.72));
}

.wheel-pointer span {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 9px;
  height: 9px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 246, 209, 0.8);
  border-radius: 50%;
  background: #5e3b08;
}

.wheel-hub {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  display: grid;
  width: clamp(58px, 16cqw, 78px);
  aspect-ratio: 1;
  place-items: center;
  transform: translate(-50%, -50%);
  border: clamp(3px, 0.8cqw, 5px) solid #6e4608;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 25%, #fff3be, #e0ad3e 48%, #8a570c 76%, #3e2503);
  box-shadow:
    0 5px 14px rgba(0, 0, 0, 0.58),
    inset 0 0 0 2px rgba(255, 242, 190, 0.58);
  color: #3b2606;
  font-family: "Noto Serif TC", "Microsoft JhengHei", serif;
  font-size: clamp(18px, 5cqw, 25px);
  font-weight: 900;
}

.wheel-hub span {
  transform: translateY(-1px);
}

.wheel-label {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: flex;
  width: 28cqw;
  min-height: 12cqw;
  margin-top: -6cqw;
  margin-left: -14cqw;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: rotate(var(--wheel-angle)) translateY(-31cqw) rotate(calc(-1 * var(--wheel-angle)));
  transform-origin: 50% 50%;
  color: #fff8e7;
  line-height: 1.08;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.82);
}

.wheel-label strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(13px, 4.2cqw, 20px);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wheel-label small {
  display: block;
  margin-top: 4px;
  font-size: clamp(9px, 2.7cqw, 12px);
  font-weight: 800;
  opacity: 0.92;
}

.wheel-label .wheel-label-text {
  font-size: clamp(11px, 3.4cqw, 16px);
  white-space: normal;
}

.wheel-title {
  display: flex;
  margin-top: 22px;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.wheel-title strong {
  color: var(--gold-2);
  font-size: 18px;
}

.wheel-title span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.wheel-result {
  min-width: 0;
  padding: clamp(18px, 3vw, 30px);
  border-left: 1px solid rgba(244, 193, 93, 0.24);
}

.wheel-result h3 {
  margin: 12px 0 6px;
  color: var(--gold-2);
  font-size: 30px;
}

.wheel-result p {
  color: var(--muted);
  line-height: 1.7;
}

.wheel-spin-state {
  display: none;
}

.wheel-result.is-spinning .wheel-final-state {
  display: none;
}

.wheel-result.is-spinning .wheel-spin-state {
  display: block;
}

.wheel-spin-button {
  width: 100%;
  margin-top: 12px;
  min-height: 50px;
}

.wheel-replay-note {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.wheel-admin-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr)) 40px;
  gap: 10px;
  align-items: end;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.wheel-admin-row:last-child {
  border-bottom: 0;
}

.wheel-remove {
  align-self: end;
}

.finance-bill-table .detail-cell {
  min-width: 220px;
  color: var(--muted);
  line-height: 1.6;
}

details > summary {
  cursor: pointer;
  color: var(--gold-2);
  font-weight: 800;
}

@media (max-width: 1100px) {
  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .search-field {
    grid-column: auto;
  }

  .wheel-admin-row {
    grid-template-columns: repeat(3, minmax(0, 1fr)) 40px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 8, 10, 0.96);
    backdrop-filter: none;
  }

  .sidebar-foot {
    position: static;
    width: auto;
    padding: 0;
    border: 0;
    margin: 0;
  }

  .sidebar .brand {
    min-width: 0;
    padding: 0;
  }

  .sidebar .brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
  }

  .sidebar .brand h1 {
    font-size: 15px;
  }

  .sidebar .brand small,
  .actor-chip span {
    display: none;
  }

  .actor-chip strong {
    max-width: 92px;
    font-size: 13px;
  }

  .nav-group {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: flex;
    gap: 0;
    overflow-x: auto;
    padding: 5px 4px max(5px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(7, 8, 10, 0.98);
    scrollbar-width: none;
  }

  .nav-section {
    min-width: 72px;
    flex: 1 0 72px;
  }

  .nav-section > .nav-button {
    min-width: 0;
    width: 100%;
  }

  .nav-parent .nav-chevron {
    display: none;
  }

  .nav-children {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(66px + env(safe-area-inset-bottom));
    z-index: 30;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: min(56vh, 430px);
    gap: 5px;
    padding: 10px;
    overflow-y: auto;
    border: 1px solid rgba(244, 193, 93, 0.35);
    border-radius: 8px;
    background: rgba(12, 14, 18, 0.99);
    box-shadow: 0 -16px 42px rgba(0, 0, 0, 0.48);
  }

  .nav-child-button {
    min-height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
  }

  .nav-child-button:hover,
  .nav-child-button.active {
    border-color: rgba(244, 193, 93, 0.52);
  }

  .nav-group::-webkit-scrollbar {
    display: none;
  }

  .nav-button {
    min-width: 72px;
    min-height: 54px;
    flex: 1 0 72px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 5px 4px;
    font-size: 11px;
  }

  .nav-icon {
    width: 24px;
    height: 24px;
    border: 0;
    font-size: 13px;
  }

  .hero,
  .wheel-layout,
  .grid.two,
  .grid.three,
  .grid.four,
  .form-grid,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .wheel-layout {
    gap: 16px;
  }

  .wheel-result {
    padding: 20px 0 0;
    border-top: 1px solid rgba(244, 193, 93, 0.24);
    border-left: 0;
    text-align: center;
  }

  .field.full {
    grid-column: auto;
  }

  .level-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: 16px 16px calc(78px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 620px) {
  .nav-group.nav-group-multirow {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow-x: hidden;
  }

  .nav-group.nav-group-multirow .nav-button {
    min-width: 0;
    min-height: 50px;
    flex: none;
  }

  .nav-group.nav-group-multirow .nav-section {
    min-width: 0;
    flex: none;
  }

  .nav-group.nav-group-multirow .nav-children {
    bottom: calc(116px + env(safe-area-inset-bottom));
  }

  .app-shell.has-multirow-nav .main {
    padding-bottom: calc(124px + env(safe-area-inset-bottom));
  }

  .weekly-missing-notice {
    align-items: stretch;
    flex-direction: column;
  }

  .main {
    padding: 12px 12px calc(76px + env(safe-area-inset-bottom));
  }

  .wheel-admin-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wheel-label {
    width: 30cqw;
    margin-left: -15cqw;
  }

  .wheel-admin-row .wheel-remove {
    grid-column: 2;
    justify-self: end;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 12px;
  }

  .topbar h2 {
    font-size: 22px;
  }

  .topbar p {
    font-size: 12px;
  }

  .shared-sandbox-banner,
  .sandbox-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .shared-sandbox-banner .btn,
  .sandbox-actions .button-row,
  .sandbox-actions .btn,
  .button-field .btn {
    width: 100%;
  }

  .toolbar {
    width: 100%;
    justify-content: stretch;
  }

  .toolbar > * {
    flex: 1;
  }

  .toolbar .member-picker {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .panel-head,
  .panel-body {
    padding-left: 13px;
    padding-right: 13px;
  }

  .panel-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .profile-block {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 11px;
  }

  .avatar {
    width: 56px;
    height: 56px;
  }

  .member-name {
    width: 100%;
    font-size: 20px;
  }

  .level-strip {
    grid-template-columns: 1fr;
  }

  .calculation-preview {
    grid-template-columns: 1fr;
  }

  .big-number {
    font-size: 32px;
  }

  .big-number.compact-number {
    font-size: 28px;
  }

  .grid.four {
    grid-template-columns: 1fr 1fr;
  }

  .metric strong {
    font-size: 19px;
  }

  .coin-visual .panel-body {
    padding-right: 13px;
  }

  .coin-visual::before,
  .coin-visual::after {
    display: none;
  }

  .date-fields {
    grid-template-columns: 1fr;
  }

  .quick-buttons .btn {
    flex: 1 1 72px;
  }

  .report-head {
    display: none;
  }

  .report-row,
  .report-total {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 12px 8px;
  }

  .report-row > div,
  .report-row > strong,
  .report-total > strong {
    grid-column: 1 / -1;
  }

  .report-row span,
  .report-total span {
    min-width: 0;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .report-row span::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 11px;
  }

  .report-total span {
    color: var(--gold-2);
  }

  .record-row {
    grid-template-columns: 1fr;
  }

  .record-row .button-row {
    justify-content: flex-start;
  }

  .referral-branches,
  .source-entries,
  .org-children {
    padding-left: 14px;
  }

  .tree-root > summary,
  .referral-node > summary,
  .org-node > summary,
  .org-leaf {
    flex-wrap: wrap;
  }

  .tree-count {
    width: 100%;
    margin-left: 32px;
  }

  .tree-root > summary strong,
  .referral-node > summary strong {
    max-width: calc(100% - 42px);
    overflow-wrap: anywhere;
  }

  table {
    min-width: 700px;
  }
}

.document-member-picker {
  width: min(100%, 760px);
  margin-bottom: 18px;
}

.member-document-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.member-document-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(132px, 1fr) auto auto;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: rgba(8, 10, 14, 0.68);
}

.member-document-card > header {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.member-document-card > header strong,
.member-document-card > small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-document-card > small {
  color: var(--muted);
  font-size: 11px;
}

.document-status {
  flex: 0 0 auto;
  color: #8fd9b6;
  font-size: 11px;
}

.document-status.empty {
  color: var(--muted);
}

.document-thumbnail,
.document-placeholder {
  width: 100%;
  min-height: 132px;
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(244, 193, 93, 0.24);
  border-radius: 5px;
  background: #07090c;
  overflow: hidden;
}

.document-thumbnail {
  padding: 0;
  cursor: zoom-in;
}

.document-thumbnail:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.document-thumbnail img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.document-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.document-actions {
  min-height: 34px;
  align-items: center;
}

.document-upload-button {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.document-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

body.viewer-open {
  overflow: hidden;
}

.document-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 18px;
}

.document-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
}

.document-viewer-dialog {
  position: relative;
  width: min(1120px, 100%);
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid rgba(244, 193, 93, 0.46);
  border-radius: 7px;
  background: #101216;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.64);
  overflow: hidden;
}

.document-viewer-dialog > header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
}

.document-viewer-dialog > header div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.document-viewer-dialog > header small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.document-viewer-image {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 12px;
  background: #050608;
}

.document-viewer-image img {
  max-width: 100%;
  max-height: calc(100vh - 118px);
  object-fit: contain;
}

@media (max-width: 1100px) {
  .grid.five,
  .quick-workspace-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .member-document-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .grid.five,
  .quick-workspace-grid {
    grid-template-columns: 1fr;
  }

  .member-create-submit {
    align-items: stretch;
    flex-direction: column;
  }

  .member-create-submit .btn {
    width: 100%;
  }

  .member-document-grid {
    grid-template-columns: 1fr;
  }

  .member-document-card {
    grid-template-rows: auto minmax(150px, 1fr) auto auto;
  }

  .document-viewer {
    padding: 8px;
  }

  .document-viewer-dialog {
    max-height: calc(100vh - 16px);
  }
}

@media (max-width: 380px) {
  .main {
    padding-left: 9px;
    padding-right: 9px;
  }

  .grid.four {
    grid-template-columns: 1fr;
  }

  .actor-chip {
    display: none;
  }

  .nav-button {
    min-width: 68px;
    flex-basis: 68px;
  }
}

.role-profile-list,
.cost-summary-grid,
.note-timeline,
.support-list {
  display: grid;
  gap: 12px;
}

.role-profile-card,
.support-list > details,
.cost-summary-item,
.note-item {
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: rgba(8, 10, 14, 0.58);
}

.role-profile-card > summary,
.support-list > details > summary {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
}

.role-profile-card > summary div,
.support-list > details > summary div,
.masked-profile {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.role-profile-card > summary small,
.support-list > details > summary small,
.masked-profile small {
  color: var(--muted);
}

.capability-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.capability-option {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(156, 163, 175, 0.18);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}

.capability-option input {
  margin-top: 3px;
  accent-color: var(--gold);
}

.capability-option span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.capability-option small {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.cost-summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cost-summary-item {
  padding: 14px;
}

.cost-summary-item > header,
.note-item > header,
.note-item > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.note-item {
  padding: 12px 14px;
}

.note-item.pinned {
  border-color: rgba(244, 193, 93, 0.55);
}

.note-item.archived {
  opacity: 0.58;
}

.note-item p {
  margin: 10px 0;
  color: #ddd7ca;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note-item footer {
  color: var(--muted);
  font-size: 12px;
}

.masked-profile {
  justify-items: end;
  text-align: right;
}

.support-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 0 14px 14px;
  color: var(--muted);
}

.compact-form,
.account-panel {
  width: min(100%, 620px);
}

@media (max-width: 980px) {
  .capability-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cost-summary-grid {
    grid-template-columns: 1fr;
  }

  .promotion-benefits-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 0;
  }
}

@media (max-width: 620px) {
  .profile-detail-grid {
    grid-template-columns: 1fr;
  }

  .capability-grid {
    grid-template-columns: 1fr;
  }

  .role-profile-card > summary,
  .support-list > details > summary,
  .cost-summary-item > header,
  .note-item > header,
  .note-item > footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .masked-profile {
    justify-items: start;
    text-align: left;
  }

  .member-relationship-summary,
  .promotion-benefits-head {
    align-items: stretch;
    flex-direction: column;
  }

  .member-relationship-summary .btn,
  .promotion-benefits-head .btn {
    width: 100%;
  }

  .promotion-benefits-list {
    grid-template-columns: 1fr;
  }
}

.table-member-name {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.weekly-next-period-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.agent-weekly-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: end;
  gap: 12px;
}

.agent-weekly-toolbar .field {
  margin: 0;
}

.segmented-control {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented-control button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  cursor: pointer;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  background: rgba(63, 126, 214, 0.2);
  color: var(--text);
}

.agent-weekly-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(440px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.agent-weekly-tree,
.agent-weekly-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.015);
}

.agent-weekly-node + .agent-weekly-node {
  border-top: 1px solid var(--line);
}

.agent-weekly-agent {
  width: 100%;
  display: grid;
  grid-template-columns: 24px minmax(150px, 1fr) 70px minmax(100px, 0.7fr) minmax(100px, 0.7fr);
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 14px;
  text-align: left;
  cursor: pointer;
}

.agent-weekly-agent > span:not(.tree-chevron):not(.agent-weekly-agent-name),
.agent-weekly-member > span:not(.status) {
  display: grid;
  gap: 3px;
}

.agent-weekly-agent small,
.agent-weekly-member small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.tree-chevron {
  font-size: 1.35rem;
  transform: rotate(0);
  transition: transform 0.18s ease;
}

.agent-weekly-node.expanded .tree-chevron {
  transform: rotate(90deg);
}

.agent-weekly-members {
  border-top: 1px solid var(--line);
  padding: 6px;
}

.agent-weekly-member {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(95px, 0.65fr) minmax(95px, 0.65fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.agent-weekly-member:hover,
.agent-weekly-member.selected {
  border-color: rgba(91, 154, 235, 0.55);
  background: rgba(48, 104, 178, 0.14);
}

.agent-weekly-detail {
  position: sticky;
  top: 16px;
  padding: 16px;
}

.agent-weekly-detail-head,
.agent-weekly-payment-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.agent-weekly-detail-head {
  margin-bottom: 14px;
}

.agent-weekly-detail-head h4,
.agent-weekly-payment-head h4 {
  margin: 4px 0;
}

.agent-weekly-detail-head p {
  margin: 0;
  color: var(--muted);
}

.agent-weekly-breakdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.agent-weekly-breakdown div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.agent-weekly-breakdown span {
  color: var(--muted);
  font-size: 0.8rem;
}

.agent-weekly-payment-head {
  align-items: center;
  margin: 18px 0 8px;
}

.compact-record-list {
  max-height: 340px;
  overflow: auto;
}

.agent-weekly-empty {
  min-height: 240px;
  display: grid;
  place-items: center;
}

@media (max-width: 1100px) {
  .agent-weekly-layout {
    grid-template-columns: 1fr;
  }

  .agent-weekly-detail {
    position: static;
  }
}

@media (max-width: 760px) {
  .agent-weekly-toolbar {
    grid-template-columns: 1fr;
  }

  .segmented-control {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .agent-weekly-agent {
    grid-template-columns: 20px minmax(0, 1fr) minmax(86px, 0.6fr) minmax(86px, 0.6fr);
  }

  .agent-weekly-agent > span:nth-child(3) {
    display: none;
  }

  .agent-weekly-member {
    grid-template-columns: minmax(120px, 1fr) minmax(80px, 0.7fr) minmax(80px, 0.7fr);
  }

  .agent-weekly-member .status {
    display: none;
  }

  .agent-weekly-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .weekly-next-period-notice {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .agent-weekly-agent {
    grid-template-columns: 18px minmax(0, 1fr) minmax(76px, 0.65fr) minmax(76px, 0.65fr);
    gap: 6px;
    padding: 10px 8px;
  }

  .agent-weekly-member {
    grid-template-columns: minmax(100px, 1fr) minmax(72px, 0.65fr) minmax(72px, 0.65fr);
    gap: 6px;
    padding: 9px 7px;
  }

  .agent-weekly-agent strong,
  .agent-weekly-member strong {
    font-size: 0.86rem;
    overflow-wrap: anywhere;
  }

  .agent-weekly-detail {
    padding: 12px;
  }
}
