:root {
  --paper: #f4efe4;
  --paper-deep: #ece4d5;
  --panel: #fffdf8;
  --ink: #26322a;
  --ink-soft: #4b564d;
  --muted: #7a8177;
  --line: #e4ddcf;
  --line-strong: #d5cbb9;
  --green: #2f4a3a;
  --green-deep: #243a2d;
  --green-soft: #e8ede2;
  --rust: #b44b33;
  --rust-deep: #963b27;
  --rust-soft: #f6e6dd;
  --gold: #b68a43;
  --shadow: 0 18px 50px rgba(55, 45, 30, 0.08);
  --radius: 22px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
.display {
  font-family: "Songti SC", "STSong", "SimSun", Georgia, serif;
  font-weight: 700;
}

svg {
  display: block;
}

.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;
}

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

.eyebrow,
.kicker {
  color: var(--rust);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  line-height: 1.4;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8f4ea;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-accent {
  border-color: #d8cdbb;
  background: var(--green-soft);
  color: var(--green);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #97b184;
  box-shadow: 0 0 0 3px rgba(151, 177, 132, 0.14);
}

/* Buttons */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:focus-visible,
.segment:focus-visible,
.nav-item:focus-visible,
.member-item:focus-visible,
.logout-button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
}

.btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-primary {
  background: var(--rust);
  border-color: var(--rust);
  color: #fffaf3;
  box-shadow: 0 8px 20px rgba(180, 75, 51, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--rust-deep);
  border-color: var(--rust-deep);
}

.btn-secondary {
  background: var(--green);
  border-color: var(--green);
  color: #fffaf3;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--green-deep);
  border-color: var(--green-deep);
}

.btn-ghost {
  border-color: var(--line-strong);
  background: rgba(255, 253, 248, 0.4);
  color: var(--ink-soft);
}

.btn-ghost:hover:not(:disabled) {
  border-color: #bfb2a0;
  background: var(--panel);
}

.btn-small {
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  min-height: 46px;
}

.btn.is-loading .button-label {
  visibility: hidden;
}

.button-spinner {
  position: absolute;
  display: none;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.btn.is-loading .button-spinner {
  display: block;
}

/* Inputs */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span,
.field > label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.field em {
  color: var(--rust);
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
}

.field input,
.rule-control input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fbf8f1;
  color: var(--ink);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.field input:hover,
.rule-control input:hover {
  border-color: var(--line-strong);
}

.field input:focus,
.rule-control input:focus {
  border-color: var(--rust);
  background: #fffdf8;
  box-shadow: 0 0 0 3px rgba(180, 75, 51, 0.09);
}

.field input[aria-invalid="true"],
.rule-control input[aria-invalid="true"] {
  border-color: var(--rust);
  background: #fff8f4;
}

.field input::placeholder {
  color: #a4a79e;
}

.form-error {
  padding: 10px 12px;
  border: 1px solid #e8c1b3;
  border-radius: 10px;
  background: var(--rust-soft);
  color: #8f3724;
  font-size: 12.5px;
  line-height: 1.55;
}

/* Login */
.login-view {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(400px, 0.88fr);
  min-height: 100vh;
  background: var(--paper);
}

.login-art {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 46px clamp(32px, 6vw, 88px) 38px;
  overflow: hidden;
  background: var(--green);
  color: #f9f3e6;
}

.login-art::before {
  content: "";
  position: absolute;
  top: -26%;
  right: -23%;
  width: 72%;
  aspect-ratio: 1;
  border: 1px solid rgba(243, 234, 215, 0.16);
  border-radius: 50%;
  box-shadow: 0 0 0 80px rgba(243, 234, 215, 0.025), 0 0 0 190px rgba(243, 234, 215, 0.018);
  pointer-events: none;
}

.login-art::after {
  content: "";
  position: absolute;
  right: 12%;
  bottom: 10%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rust);
  box-shadow: -52px -30px 0 rgba(243, 234, 215, 0.22), 34px 44px 0 rgba(243, 234, 215, 0.14);
  pointer-events: none;
}

.login-brand,
.sidebar-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-monogram {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 250, 241, 0.35);
  border-radius: 14px;
  background: var(--rust);
  color: #fffaf3;
  font-family: "Songti SC", "STSong", "SimSun", Georgia, serif;
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
}

.brand-monogram-small {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 21px;
}

.login-brand strong,
.sidebar-brand strong {
  display: block;
  font-family: "Songti SC", "STSong", "SimSun", Georgia, serif;
  font-size: 18px;
  letter-spacing: 0.03em;
  line-height: 1.25;
}

.login-brand span:not(.brand-monogram),
.sidebar-brand span {
  display: block;
  margin-top: 3px;
  color: rgba(249, 243, 230, 0.54);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.22em;
}

.login-copy {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: auto 0;
  padding: 76px 0;
}

.login-copy .kicker {
  color: #d99b79;
}

.login-copy h1 {
  margin: 20px 0 22px;
  font-size: clamp(46px, 5.2vw, 76px);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 1.04;
}

.login-intro {
  max-width: 350px;
  color: rgba(249, 243, 230, 0.64);
  font-size: 14px;
  line-height: 1.8;
}

.login-art-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(249, 243, 230, 0.55);
  font-size: 11px;
}

.login-panel {
  display: grid;
  min-height: 100vh;
  padding: 40px;
  place-items: center;
  background:
    radial-gradient(circle at 76% 18%, rgba(180, 75, 51, 0.075), transparent 26%),
    radial-gradient(circle at 18% 88%, rgba(47, 74, 58, 0.06), transparent 28%),
    var(--paper);
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 17px;
  width: min(100%, 410px);
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin-top: 4px;
  font-size: 31px;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.login-help {
  margin-top: -4px;
  font-size: 12.5px;
  line-height: 1.7;
}

.login-card .btn {
  margin-top: 4px;
}

.login-note {
  color: #969b91;
  font-size: 10.5px;
  line-height: 1.6;
  text-align: center;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 30px 22px 24px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--green);
  color: #f9f3e6;
}

.sidebar::before {
  content: "";
  position: absolute;
  top: 16%;
  right: -125px;
  width: 250px;
  height: 250px;
  border: 1px solid rgba(249, 243, 230, 0.1);
  border-radius: 50%;
  box-shadow: 0 0 0 55px rgba(249, 243, 230, 0.023);
  pointer-events: none;
}

.sidebar-brand {
  padding: 2px 6px 0;
}

.sidebar-label {
  margin: 48px 10px 12px;
  color: rgba(249, 243, 230, 0.35);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.nav {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: rgba(249, 243, 230, 0.6);
  font-size: 13px;
  font-weight: 550;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.nav-item:hover {
  background: rgba(249, 243, 230, 0.06);
  color: rgba(249, 243, 230, 0.92);
}

.nav-item.is-active {
  border-color: rgba(249, 243, 230, 0.08);
  background: rgba(249, 243, 230, 0.1);
  color: #fffaf1;
}

.nav-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-note {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 11px;
  margin-top: auto;
  padding: 17px 13px;
  border-top: 1px solid rgba(249, 243, 230, 0.13);
  border-bottom: 1px solid rgba(249, 243, 230, 0.13);
}

.sidebar-note strong {
  display: block;
  color: rgba(249, 243, 230, 0.78);
  font-size: 11.5px;
  font-weight: 600;
}

.sidebar-note span:not(.status-dot) {
  display: block;
  margin-top: 3px;
  color: rgba(249, 243, 230, 0.38);
  font-size: 10px;
  line-height: 1.55;
}

.sidebar-footer {
  position: relative;
  z-index: 1;
  padding-top: 18px;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #f2dfd2;
  color: var(--rust-deep);
  font-family: "Songti SC", "STSong", "SimSun", Georgia, serif;
  font-size: 16px;
  font-weight: 700;
}

.avatar-large {
  width: 48px;
  height: 48px;
  background: var(--rust-soft);
  font-size: 20px;
}

.account-copy {
  min-width: 0;
}

.account-copy strong {
  display: block;
  overflow: hidden;
  color: #f9f3e6;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: rgba(249, 243, 230, 0.4);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  width: 100%;
  margin-top: 14px;
  padding: 8px 0;
  border: 1px solid rgba(249, 243, 230, 0.18);
  border-radius: 8px;
  background: transparent;
  color: rgba(249, 243, 230, 0.55);
  font-size: 11px;
  transition: border-color 160ms ease, color 160ms ease;
}

.logout-button:hover {
  border-color: rgba(249, 243, 230, 0.35);
  color: #f9f3e6;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 106px;
  padding: 23px 40px;
  border-bottom: 1px solid rgba(213, 203, 185, 0.7);
  background: rgba(244, 239, 228, 0.93);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin-top: 4px;
  font-size: 30px;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.sync-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #89a277;
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #e3bca9;
  border-radius: 999px;
  background: #f8e7db;
  color: #99432d;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.sync-state.is-syncing::before {
  animation: pulse 1.2s ease-in-out infinite;
}

.main-content {
  flex: 1;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 30px 40px 36px;
}

/* Metrics */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  min-height: 122px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--panel);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.metric-value {
  display: block;
  margin: 10px 0 2px;
  color: var(--ink);
  font-family: "Songti SC", "STSong", "SimSun", Georgia, serif;
  font-size: 35px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.metric-note {
  color: #979b91;
  font-size: 10.5px;
}

.metric-accent {
  border-color: var(--green);
  background: var(--green);
}

.metric-accent .metric-label,
.metric-accent .metric-note {
  color: rgba(249, 243, 230, 0.52);
}

.metric-accent .metric-value {
  color: #fffaf1;
}

/* Workspace */
.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 356px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(56, 45, 30, 0.035);
}

.member-panel {
  padding: 21px 19px 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 3px 14px;
}

.panel-head h2 {
  margin-top: 4px;
  font-size: 22px;
  letter-spacing: -0.025em;
}

.search-form {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbf8f1;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-form:focus-within {
  border-color: #c9bda9;
  box-shadow: 0 0 0 3px rgba(47, 74, 58, 0.05);
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: #969b91;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search-form input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 2px 0 24px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.search-form input::placeholder {
  color: #a3a79c;
}

.search-hint {
  padding: 9px 4px 12px;
  color: #949a8e;
  font-size: 10.5px;
  line-height: 1.6;
}

.search-hint.is-error {
  color: var(--rust);
}

.copy-helper {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: calc(100vh - 350px);
  min-height: 150px;
  overflow-y: auto;
  padding-right: 3px;
}

.member-list::-webkit-scrollbar,
.ledger-list::-webkit-scrollbar {
  width: 5px;
}

.member-list::-webkit-scrollbar-thumb,
.ledger-list::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: #ded6c7;
}

.member-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease;
}

.member-item:hover {
  background: #fbf7ef;
}

.member-item.is-selected {
  border-color: #e2c6b7;
  background: #fcf1e8;
}

.member-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--green-soft);
  color: var(--green);
  font-family: "Songti SC", "STSong", "SimSun", Georgia, serif;
  font-size: 15px;
  font-weight: 700;
}

.member-item.is-selected .member-avatar {
  background: #f0d9cb;
  color: var(--rust-deep);
}

.member-copy {
  min-width: 0;
}

.member-name {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  color: #969b90;
  font-size: 9.5px;
}

.member-meta code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 9.5px;
}

.member-game {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--rust);
  font-size: 9.5px;
}

.member-game::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.member-balance {
  color: var(--green);
  font-family: "Songti SC", "STSong", "SimSun", Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.member-balance small {
  margin-left: 2px;
  color: #a0a396;
  font-family: inherit;
  font-size: 9px;
  font-weight: 400;
}

.member-empty,
.ledger-empty {
  padding: 38px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

/* Detail */
.detail-panel {
  min-height: 600px;
  overflow: hidden;
  scroll-margin-top: 92px;
}

.empty-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 600px;
  padding: 60px 40px;
  text-align: center;
}

.empty-mark {
  display: grid;
  width: 56px;
  height: 56px;
  margin-bottom: 21px;
  place-items: center;
  border: 1px solid #ded3c2;
  border-radius: 50%;
  color: var(--rust);
  font-family: Georgia, serif;
  font-size: 24px;
}

.empty-detail h2 {
  font-size: 25px;
  letter-spacing: -0.025em;
}

.empty-detail p {
  max-width: 360px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}

.empty-hint {
  margin-top: 26px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
  color: #a0a397;
  font-size: 10px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 25px 28px 20px;
}

.detail-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.detail-identity h2 {
  overflow: hidden;
  font-size: 26px;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-code {
  display: block;
  max-width: 410px;
  margin-top: 3px;
  overflow: hidden;
  color: #979c91;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 28px 21px;
  padding: 21px 24px;
  border-radius: 17px;
  background: var(--green);
  color: #fffaf1;
}

.balance-hero .metric-label {
  color: rgba(249, 243, 230, 0.5);
}

.balance-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 3px;
}

.balance-value strong {
  font-family: "Songti SC", "STSong", "SimSun", Georgia, serif;
  font-size: 42px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.balance-value span {
  color: rgba(249, 243, 230, 0.56);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 190px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(249, 243, 230, 0.1);
  color: rgba(249, 243, 230, 0.72);
  font-size: 10.5px;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #a9c094;
}

.status-pill.is-busy {
  background: rgba(217, 155, 121, 0.16);
  color: #efd3c1;
}

.status-pill.is-busy::before {
  background: #d99b79;
}

.adjust-card,
.ledger-card {
  margin: 0 28px 21px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fcf9f2;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.card-heading h3 {
  margin-top: 4px;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.card-hint {
  color: #989d91;
  font-size: 10px;
  line-height: 1.5;
  text-align: right;
}

.segmented {
  display: inline-flex;
  gap: 3px;
  margin-bottom: 15px;
  padding: 3px;
  border: 1px solid #e7ded0;
  border-radius: 9px;
  background: #f2ebdf;
}

.segment {
  min-width: 80px;
  padding: 7px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #858b80;
  font-size: 11px;
  font-weight: 600;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.segment:hover {
  color: var(--ink);
}

.segment.is-active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 2px 7px rgba(55, 45, 30, 0.08);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(130px, 0.72fr) minmax(0, 1.28fr);
  gap: 12px;
}

.field-hint {
  margin-top: 8px;
  color: #969b90;
  font-size: 10px;
  line-height: 1.6;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 13px;
}

.inline-warning {
  margin-bottom: 13px;
  padding: 9px 11px;
  border: 1px solid #e8c7b7;
  border-radius: 8px;
  background: #f8e8df;
  color: #92432f;
  font-size: 11px;
  line-height: 1.6;
}

.ledger-card {
  margin-bottom: 27px;
}

.ledger-list {
  max-height: 315px;
  overflow-y: auto;
  border-top: 1px solid #e8e0d3;
}

.ledger-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: start;
  padding: 12px 3px;
  border-bottom: 1px solid #eae3d7;
}

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

.ledger-main {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
}

.ledger-kind {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 4px;
  background: #eee7da;
  color: #7b8074;
  font-size: 9px;
  line-height: 1.55;
}

.ledger-note {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-amount {
  color: var(--ink-soft);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.ledger-amount.is-positive {
  color: #527446;
}

.ledger-amount.is-negative {
  color: var(--rust);
}

.ledger-meta {
  display: flex;
  grid-column: 1 / -1;
  gap: 12px;
  color: #a2a69a;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

/* Rules */
.rules-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 20px;
  padding: 5px 2px 0;
}

.rules-intro h2 {
  margin: 7px 0 5px;
  font-size: 27px;
  letter-spacing: -0.035em;
}

.rules-intro p.muted {
  max-width: 580px;
  font-size: 12px;
  line-height: 1.8;
}

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

.rules-panel {
  padding: 24px;
}

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

.rules-panel-head h2 {
  margin-top: 3px;
  font-size: 23px;
}

.game-glyph {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  font-size: 26px;
  line-height: 1;
}

.dice-glyph {
  background: var(--rust-soft);
  color: var(--rust);
}

.match-glyph {
  background: var(--green-soft);
  color: var(--green);
  font-size: 24px;
}

.rule-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px 14px;
  padding: 14px 0;
  border-top: 1px solid #ece5d9;
}

.rule-name {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.rule-control {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #9a9e92;
  font-size: 10px;
}

.rule-control input {
  width: 90px;
  height: 36px;
  padding: 0 9px;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.rule-field small {
  grid-column: 1 / -1;
  color: #9a9f93;
  font-size: 10px;
  line-height: 1.6;
}

.rules-savebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 18px 21px;
  border: 1px solid #d9d2c2;
  border-radius: 16px;
  background: #ebe6da;
}

.rules-savebar strong {
  display: block;
  color: var(--ink-soft);
  font-size: 12px;
}

.rules-savebar span {
  display: block;
  margin-top: 2px;
  color: #8e9388;
  font-size: 10.5px;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 40px 28px;
  color: #9a9d92;
  font-size: 9.5px;
}

/* Dialog */
.action-dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid #dfd5c3;
  border-radius: 21px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(25, 33, 25, 0.25);
}

.action-dialog::backdrop {
  background: rgba(26, 37, 29, 0.58);
  backdrop-filter: blur(3px);
}

.dialog-inner {
  padding: 27px;
}

.dialog-inner h2 {
  margin: 5px 0 14px;
  font-size: 25px;
  letter-spacing: -0.025em;
}

.dialog-body {
  max-height: 300px;
  overflow-y: auto;
  padding: 15px;
  border: 1px solid #e9e1d5;
  border-radius: 11px;
  background: #faf6ee;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.8;
  white-space: pre-line;
}

.dialog-body + .form-error {
  margin-top: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 21px;
}

/* Toast */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 16px;
  border: 1px solid rgba(255, 250, 241, 0.18);
  border-radius: 10px;
  background: var(--green);
  color: #fffaf1;
  box-shadow: 0 14px 35px rgba(35, 45, 33, 0.2);
  font-size: 12px;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  border-color: rgba(255, 230, 220, 0.2);
  background: #8f3a29;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--paper);
  color: var(--muted);
  font-size: 11px;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.boot-screen.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.boot-line {
  width: 90px;
  height: 1px;
  overflow: hidden;
  background: var(--line);
}

.boot-line::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  background: var(--rust);
  animation: boot-slide 1.1s ease-in-out infinite;
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes boot-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(260%); }
}

@media (max-width: 1180px) {
  .topbar {
    padding-inline: 28px;
  }

  .main-content {
    padding-inline: 28px;
  }

  .app-footer {
    padding-inline: 28px;
  }

  .workspace {
    grid-template-columns: minmax(290px, 326px) minmax(0, 1fr);
  }

  .member-list {
    max-height: 600px;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    gap: 18px;
    width: 100%;
    height: auto;
    padding: 14px 22px;
  }

  .sidebar::before,
  .sidebar-label,
  .sidebar-note {
    display: none;
  }

  .sidebar-brand {
    padding: 0;
  }

  .nav {
    flex-direction: row;
    gap: 3px;
    margin-left: auto;
  }

  .nav-item {
    width: auto;
    padding: 8px 10px;
    font-size: 12px;
  }

  .sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 4px;
    padding: 0;
    border: 0;
  }

  .account-copy span {
    display: none;
  }

  .logout-button {
    width: auto;
    margin: 0;
    padding: 7px 10px;
    font-size: 10px;
  }

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

  .member-panel {
    position: static;
  }

  .member-list {
    max-height: 380px;
  }

  .detail-panel {
    min-height: 0;
  }

  .empty-detail {
    min-height: 390px;
  }

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

  .topbar {
    top: 0;
  }
}

@media (max-width: 760px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-art {
    min-height: 300px;
    padding: 26px 26px 24px;
  }

  .login-copy {
    padding: 38px 0 18px;
  }

  .login-copy h1 {
    margin: 13px 0 12px;
    font-size: clamp(36px, 10vw, 52px);
  }

  .login-intro,
  .login-art-footer {
    display: none;
  }

  .login-panel {
    min-height: 0;
    padding: 24px 20px 36px;
  }

  .login-card {
    padding: 26px 22px;
    border-radius: 20px;
  }

  .login-card h2 {
    font-size: 27px;
  }

  .sidebar {
    gap: 10px;
    padding: 11px 15px;
  }

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

  .sidebar-brand span:not(.brand-monogram) {
    display: none;
  }

  .nav {
    gap: 1px;
  }

  .nav-item {
    gap: 5px;
    padding: 7px 7px;
    font-size: 10.5px;
  }

  .nav-icon {
    width: 15px;
    height: 15px;
  }

  .account {
    display: none;
  }

  .sidebar-footer {
    margin-left: 0;
  }

  .topbar {
    top: 0;
    min-height: 88px;
    padding: 16px 18px;
  }

  .topbar h1 {
    font-size: 25px;
  }

  .sync-state {
    display: none;
  }

  .main-content {
    padding: 18px 16px 26px;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .metric {
    min-height: 100px;
    padding: 15px;
  }

  .metric-value {
    font-size: 28px;
  }

  .metric-accent {
    grid-column: 1 / -1;
  }

  .member-panel {
    padding: 16px 12px 12px;
  }

  .panel-head {
    padding-inline: 2px;
  }

  .detail-head {
    align-items: flex-start;
    padding: 20px 16px 15px;
  }

  .detail-identity h2 {
    font-size: 22px;
  }

  .member-code {
    max-width: 190px;
  }

  .detail-head > .btn {
    padding-inline: 8px;
  }

  .balance-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin: 0 16px 16px;
    padding: 18px;
  }

  .balance-value strong {
    font-size: 37px;
  }

  .adjust-card,
  .ledger-card {
    margin-inline: 16px;
    padding: 16px;
  }

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

  .form-actions .btn {
    width: 100%;
  }

  .ledger-main {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .ledger-note {
    white-space: normal;
  }

  .rules-intro {
    flex-direction: column;
    gap: 10px;
  }

  .rules-intro h2 {
    font-size: 24px;
  }

  .rules-panel {
    padding: 18px 16px;
  }

  .rules-savebar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .rules-savebar .btn {
    width: 100%;
  }

  .app-footer {
    flex-direction: column;
    gap: 3px;
    padding: 16px 16px 24px;
  }

  .toast {
    right: 16px;
    bottom: 16px;
    left: 16px;
    max-width: none;
  }
}

@media (max-width: 440px) {
  .login-art {
    min-height: 250px;
  }

  .login-copy h1 {
    font-size: 36px;
  }

  .login-panel {
    padding-inline: 13px;
  }

  .login-card {
    padding: 23px 18px;
  }

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

  .metric-accent {
    grid-column: 1 / -1;
  }

  .topbar-actions .btn {
    min-height: 31px;
    padding: 5px 8px;
    font-size: 10.5px;
  }

  .member-code {
    max-width: 145px;
  }

  .status-pill {
    max-width: 100%;
  }
}

@media (max-width: 410px) {
  .sidebar {
    gap: 8px;
    padding-inline: 12px;
  }

  .nav-item {
    padding: 7px 6px;
  }

  .nav-item span {
    font-size: 9.5px;
  }

  .topbar {
    gap: 8px;
    padding-inline: 14px;
  }

  .topbar .eyebrow {
    display: none;
  }

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

  .topbar-actions {
    gap: 7px;
  }

  .demo-badge {
    padding: 3px 6px;
    font-size: 8px;
  }

  .main-content {
    padding-inline: 12px;
  }

  .member-panel {
    padding-inline: 9px;
  }

  .detail-head {
    padding-inline: 13px;
  }

  .balance-hero,
  .adjust-card,
  .ledger-card {
    margin-inline: 13px;
  }

  .app-footer {
    padding-inline: 14px;
  }
}

@media (max-width: 360px) {
  .sidebar-brand strong {
    display: none;
  }
}

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