:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --hairline: rgba(0, 0, 0, 0.06);
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

.auth {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
  background: linear-gradient(180deg, #f8f8fa 0%, #eef0f4 100%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 12px;
  padding: 28px 24px 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,.08);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.brand-dot { width: 46px; height: 46px; border-radius: 14px; background: linear-gradient(135deg, #34c759, #30b0c7); }
.brand-name { font-size: 21px; font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.auth-view { display: none; }
.auth-view.active { display: block; }
.auth-title { font-size: 19px; font-weight: 700; margin-bottom: 18px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: #6d6d72; margin-bottom: 8px; }
.field input {
  width: 100%; height: 48px; padding: 0 14px; border: 1px solid #e3e3e8;
  border-radius: 12px; font-size: 16px; background: #fafafa; outline: none;
}
.field input:focus { border-color: var(--blue); background: #fff; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--muted); font-size: 14px; }
.auth-switch a { color: var(--blue); text-decoration: none; }
.auth-note { color: var(--muted); font-size: 12px; margin-top: 14px; text-align: center; }

.app { height: 100%; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; }
.topbar {
  height: 54px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: #fff; border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  height: 34px; padding: 0 14px; border-radius: 9px; border: none; background: #f2f2f7;
  color: var(--blue); font-size: 13px; font-weight: 600;
}
.icon-btn.danger { color: var(--red); }
.install-ico { font-size: 21px; line-height: 1; padding: 0 10px; }
.viewport { flex: 1; overflow-y: auto; padding: 16px 14px 24px; -webkit-overflow-scrolling: touch; }
.view { display: none; }
.view.active { display: block; }
.tabbar {
  height: 62px; flex-shrink: 0; display: flex; background: #fff;
  border-top: 1px solid var(--hairline); padding-bottom: 4px;
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; cursor: pointer; }
.tab-ico { font-size: 20px; line-height: 1; }
.tab.active { color: var(--blue); }

.surface { background: var(--surface); border-radius: 8px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.04); margin-bottom: 12px; }
.section-title { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.page-title { font-size: 24px; font-weight: 700; margin-bottom: 3px; }
.page-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.row { display: flex; align-items: center; min-height: 46px; border-bottom: 1px solid var(--hairline); }
.row:last-child { border-bottom: none; }
.row-label { width: 86px; color: #6d6d72; font-size: 14px; flex-shrink: 0; }
.row input { flex: 1; border: none; outline: none; font-size: 16px; background: transparent; min-width: 0; }
.row input::placeholder { color: #c7c7cc; }
.btn { display: flex; align-items: center; justify-content: center; height: 48px; border-radius: 8px; font-size: 16px; font-weight: 600; border: none; cursor: pointer; width: 100%; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:disabled { background: #9ec5ff; }
.btn-secondary { background: #fff; color: var(--blue); border: 1px solid #d1d1d6; }
.btn-danger { background: #fff; color: var(--red); border: 1px solid #ffd1cf; }
.btn-small { height: 32px; border-radius: 8px; font-size: 13px; padding: 0 12px; width: auto; }
.btn-small { white-space: nowrap; }
.panel-action { padding-top: 12px; display: flex; gap: 10px; }
.panel-action .btn { flex: 1; }
.segment { display: flex; background: #f2f2f7; border-radius: 8px; padding: 3px; flex: 1; min-width: 0; }
.segment-item { flex: 1; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #636366; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.segment-item.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.mode-block { padding: 12px 0 4px; border-bottom: 1px solid var(--hairline); }
.mode-label { font-size: 14px; color: #6d6d72; margin-bottom: 10px; }

.avatar { width: 40px; height: 40px; border-radius: 50%; background: #4fb0b0; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; font-size: 16px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 52px; height: 52px; font-size: 20px; }
.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; line-height: 16px; }
.tag { white-space: nowrap; }
.tag-blue { background: rgba(0,122,255,.12); color: var(--blue); }
.tag-green { background: rgba(52,199,89,.14); color: #248a3d; }
.tag-orange { background: rgba(255,149,0,.14); color: #c93400; }
.tag-gray { background: rgba(142,142,147,.14); color: #636366; }
.muted { color: var(--muted); font-size: 12px; }
.empty { padding: 50px 20px; text-align: center; color: #aeaeb2; font-size: 14px; }

.hello { display: flex; align-items: center; gap: 12px; margin: 6px 0 16px; }
.hello .name { font-size: 20px; font-weight: 700; }
.hello .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.hello .spacer { flex: 1; }
.tip { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; color: var(--blue); font-size: 14px; }
.arrow { color: #c7c7cc; font-size: 19px; }
.back-btn { width: auto; height: 38px; padding: 0 14px; margin-bottom: 12px; font-size: 14px; }
.home-actions { display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.home-action { display: flex; align-items: center; gap: 14px; padding: 16px 12px; border-radius: 8px; cursor: pointer; }
.home-action:hover { background: #f7f7f9; }
.home-action-ico { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; background: var(--blue); flex-shrink: 0; }
.home-action-ico.join { background: linear-gradient(135deg, #34c759, #30b0c7); }
.home-action-title { font-size: 16px; font-weight: 600; }
.continue-card { display: flex; align-items: center; padding: 16px; }
.settle-card { display: flex; align-items: center; padding: 16px; cursor: pointer; }
.continue-code { font-size: 30px; font-weight: 800; color: var(--blue); margin-right: 18px; }
.continue-info { flex: 1; }
.continue-title { font-size: 16px; font-weight: 600; }

.room-head-top { display: flex; align-items: center; justify-content: space-between; }
.room-code { font-size: 36px; font-weight: 800; }
.room-meta { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #3a3a3c; margin-top: 10px; }
.admin-bar { display: flex; gap: 8px; align-items: center; padding: 12px; }
.admin-bar .segment { flex: 1; }
.tabs { display: flex; background: #fff; border-radius: 8px; padding: 3px; margin-bottom: 12px; }
.tab-item { flex: 1; height: 38px; display: flex; align-items: center; justify-content: center; color: #636366; font-size: 14px; border-radius: 7px; cursor: pointer; }
.tab-item.active { background: #fff; font-weight: 600; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.member-row { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--hairline); }
.member-row:last-child { border-bottom: none; }
.member-main { flex: 1; min-width: 0; margin-left: 10px; }
.member-name { font-weight: 600; font-size: 15px; margin-right: 8px; }
.member-score { font-size: 20px; font-weight: 700; margin: 0 10px; }
.member-actions { display: flex; gap: 6px; }
.log-item { padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.log-item:last-child { border-bottom: none; }
.log-detail { font-size: 14px; line-height: 1.5; }
.log-time { margin-top: 5px; font-size: 12px; color: #aeaeb2; }
.load-more { padding: 14px; text-align: center; color: var(--blue); }
.settle-edit { margin-top: 6px; font-size: 12px; color: var(--blue); }
.rank-badge { width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #636366; background: #f2f2f7; margin-right: 10px; flex-shrink: 0; }
.rank-badge.rank-top { background: rgba(255,149,0,.16); color: #c93400; }
.rank-badge.rank-wait { color: #c7c7cc; }
.settle-summary { text-align: center; }
.settle-summary .summary-value { font-size: 34px; font-weight: 800; margin: 6px 0 4px; }
.settle-summary .muted { font-size: 13px; }

.summary { display: flex; flex-wrap: wrap; padding: 8px 0; }
.summary-item { width: 33.33%; text-align: center; padding: 12px 4px; }
.summary-value { font-size: 19px; font-weight: 700; }
.summary-label { color: var(--muted); font-size: 11px; margin-top: 4px; }
.filter { display: flex; flex-direction: column; gap: 10px; }
.filter-row { display: flex; align-items: center; gap: 8px; }
.filter-picker { flex: 1; min-width: 0; height: 38px; line-height: 38px; text-align: center; background: #f2f2f7; border-radius: 8px; font-size: 13px; border: none; }
.filter-clear { align-self: flex-end; white-space: nowrap; }
.history-sort { margin-top: 12px; }
.history-item { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.history-item:last-child { border-bottom: none; }
.history-left { flex: 1; }
.history-code { font-size: 21px; font-weight: 800; }
.history-right { text-align: right; }
.history-profit { font-size: 18px; }
.profit-pos { color: var(--red); }
.profit-neg { color: #248a3d; }

.profile-head { display: flex; flex-direction: column; align-items: center; padding: 14px 0 12px; border-bottom: 1px solid var(--hairline); }
.avatar-btn { width: 70px; height: 70px; border-radius: 50%; background: #4fb0b0; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 600; cursor: pointer; overflow: hidden; }
.avatar-tip { margin-top: 8px; font-size: 12px; color: var(--muted); }
.palette-block { padding: 14px 0 4px; border-bottom: 1px solid var(--hairline); }
.palette { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; flex-shrink: 0; }
.swatch.active { border-color: #1c1c1e; }
.link-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.link-row:last-child { border-bottom: none; }
.link-title { font-weight: 600; font-size: 15px; }
.relation-partner { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.relation-main { flex: 1; }
.relation-name { font-weight: 600; font-size: 15px; }
.search-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.search-input { flex: 1; height: 38px; line-height: 38px; background: #f2f2f7; border-radius: 8px; padding: 0 12px; font-size: 13px; border: none; outline: none; }

.admin-user, .admin-room { padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.admin-user:last-child, .admin-room:last-child { border-bottom: none; }
.admin-user-main, .admin-room { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.admin-room > .tag { margin-left: auto; }
.admin-room > div:first-child { flex: 1; min-width: 0; }
.admin-room .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-room .btn-small { flex-shrink: 0; }
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { font-weight: 600; font-size: 15px; }
.role-actions { display: flex; gap: 8px; margin-top: 8px; padding-left: 50px; }
.admin-user { cursor: pointer; }
.role-actions { flex-wrap: wrap; }
.pending-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.pending-item:last-child { border-bottom: none; }
.pending-info { flex: 1; }
.pending-name { font-weight: 600; font-size: 15px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; }
.sheet { width: 100%; max-width: 520px; margin: 0 auto; background: #fff; border-radius: 18px 18px 0 0; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet-title { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 18px; }
.sheet-tip { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.sheet-input { width: 100%; height: 54px; background: #f2f2f7; border-radius: 10px; padding: 0 16px; font-size: 20px; text-align: center; border: none; outline: none; margin-bottom: 18px; }
.sheet-actions { display: flex; gap: 12px; }
.sheet-actions .btn { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: rgba(28,28,30,.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 60; max-width: 80%; text-align: center; }
