:root {
  --brand: #8a6d1f;
  --brand-deep: #6d5416;
  --brand-soft: rgba(138, 109, 31, 0.1);
  --brand-line: rgba(138, 109, 31, 0.38);
  --ink: #26211a;
  --ink2: #6b6456;
  --ink3: #a59d8a;
  --bg: #f4f1e9;
  --panel: #ffffff;
  --line: rgba(28, 26, 23, 0.16);
  --line2: rgba(28, 26, 23, 0.08);
  --ok: #149a5b;
  --ok-soft: #e2f5eb;
  --err: #d8493f;
  --err-soft: #fdecea;
  --warn: #c07a12;
  --warn-soft: #fdf3e1;
  --amber: #b8860b;
  --shadow: 0 1px 2px rgba(28, 26, 23, .04), 0 10px 30px -14px rgba(138, 109, 31, .18);
  --r: 14px;
}
html.theme-dark, html.studio-theme-dark, html.theme-dark body, html.studio-theme-dark body {
  --brand: #f2e3ad;
  --brand-deep: #dcc899;
  --brand-soft: rgba(242, 227, 173, 0.12);
  --brand-line: rgba(242, 227, 173, 0.35);
  --ink: rgba(242, 241, 234, 0.92);
  --ink2: rgba(242, 241, 234, 0.6);
  --ink3: rgba(242, 241, 234, 0.38);
  --bg: #070708;
  --panel: rgba(255, 255, 255, 0.04);
  --line: rgba(255, 255, 255, 0.11);
  --line2: rgba(255, 255, 255, 0.06);
  --ok: #3dca86;
  --ok-soft: rgba(20, 154, 91, .18);
  --err: #f07167;
  --err-soft: rgba(216, 73, 63, .16);
  --warn: #e8b44a;
  --warn-soft: rgba(192, 122, 18, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 12px 28px -16px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body.tm-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
.mono { font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace; }
.scene { max-width: var(--xc-page-w, 1360px); margin: 0 auto; padding: 18px 20px 48px; }
.track {
  display: flex; gap: 8px; align-items: center; margin-bottom: 12px;
  font-family: ui-monospace, "Consolas", monospace;
  font-size: 9.5px; color: var(--ink3); letter-spacing: .04em;
}
.track .step { color: var(--brand); font-weight: 600; }
.track i { font-style: normal; color: var(--ink3); }

.team-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 18px; box-shadow: var(--shadow);
}
.tlogo {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #eaf7f7, #d3eeee);
  border: 1px solid var(--brand-line);
  display: grid; place-items: center; font-size: 21px;
}
html.theme-dark .tlogo, html.studio-theme-dark .tlogo {
  background: linear-gradient(135deg, #1e3334, #163033);
}
.tinfo { min-width: 0; }
.tinfo .tn { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.tinfo .tn .own {
  font-size: 9px; font-weight: 700; color: var(--amber);
  background: var(--warn-soft); padding: 1px 7px; border-radius: 99px;
}
.tinfo .ts {
  font-size: 11px; color: var(--ink3); margin-top: 2px;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.tinfo .ts .mono { color: var(--brand-deep); }
.avst { display: flex; }
.avst .av { margin-left: -7px; border: 2px solid var(--panel); }
.av {
  width: 27px; height: 27px; border-radius: 50%;
  background: linear-gradient(135deg, #6b5d3f, #c9b88f);
  color: #fff; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700;
}
.av.own { box-shadow: 0 0 0 1.5px var(--amber); }
.av.add { background: transparent; color: var(--ink3); border: 1px dashed var(--line); }
.th-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tm-select {
  border: 1px solid var(--line); background: var(--panel); color: inherit;
  border-radius: 9px; padding: 6px 10px; font-size: 12.5px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 14px; border-radius: 9px; border: 1px solid transparent;
  font-size: 12.5px; font-weight: 600; transition: .15s;
}
.btn:active { transform: translateY(1px); }
.btn-pri { background: var(--brand); color: #fff; box-shadow: 0 4px 12px -4px rgba(14, 143, 154, .55); }
.btn-pri:hover { background: var(--brand-deep); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink2); }
html.theme-dark .btn-ghost, html.studio-theme-dark .btn-ghost { background: var(--panel); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-deep); }
.btn-danger { background: var(--err-soft); color: var(--err); border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 11.5px; border-radius: 8px; }

.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line);
  margin-top: 14px; flex-wrap: wrap;
}
.tab {
  background: none; border: none; border-bottom: 2.5px solid transparent;
  color: var(--ink3); font-size: 12.5px; font-weight: 600;
  padding: 8px 13px 9px; display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--ink2); }
.tab.on { color: var(--brand-deep); border-bottom-color: var(--brand); }
.tab .cnt {
  font-family: ui-monospace, Consolas, monospace; font-size: 9px;
  background: var(--line2); padding: 1px 6px; border-radius: 999px; color: var(--ink2);
}
.tab.on .cnt { background: var(--brand-soft); color: var(--brand-deep); }
.tab .newflag {
  font-size: 8.5px; font-weight: 700; background: var(--err); color: #fff;
  padding: 1px 6px; border-radius: 999px;
}
.tpanel { display: none; padding-top: 14px; animation: up .25s ease; }
.tpanel.on { display: block; }
@keyframes up { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 860px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 13px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .sl { font-size: 11px; color: var(--ink3); display: flex; align-items: center; gap: 6px; }
.stat .sv { font-family: ui-monospace, Consolas, monospace; font-size: 21px; font-weight: 700; margin-top: 6px; }
.stat .sv small { font-size: 11px; color: var(--ink3); font-weight: 500; }
.stat .sx { font-size: 10.5px; color: var(--ink2); margin-top: 3px; }
.stat.warn-t .sv { color: var(--err); }
.stat a { color: var(--brand-deep); font-weight: 600; text-decoration: none; }

.grid2 {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .85fr);
  gap: 14px; margin-top: 14px; align-items: start;
}
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.card .ch { padding: 12px 16px 0; display: flex; align-items: center; gap: 8px; }
.card .ch h3 { font-size: 13px; font-weight: 700; margin: 0; }
.card .ch .cnt {
  font-family: ui-monospace, Consolas, monospace; font-size: 9.5px;
  background: var(--line2); padding: 1px 7px; border-radius: 999px; color: var(--ink2);
}
.card .ch .sp { flex: 1; }
.card .ch a.link, .link { font-size: 11px; color: var(--brand-deep); font-weight: 600; text-decoration: none; cursor: pointer; }
.card .cb { padding: 11px 16px 15px; }

.gcard {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px dashed var(--line2); cursor: pointer;
}
.gcard:last-child { border-bottom: none; }
.gcard .gic {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #e6f5f5, #d3ecec);
  display: grid; place-items: center; font-size: 15px;
  border: 1px solid var(--brand-line);
}
.gcard .gn { font-size: 12.5px; font-weight: 700; }
.gcard .gm { font-size: 10.5px; color: var(--ink3); margin-top: 1px; }
.gcard .sp { flex: 1; }
.gbadge { font-size: 9.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.gb-over { background: var(--err-soft); color: var(--err); }
.gb-ok { background: var(--ok-soft); color: var(--ok); }
.empty-note { text-align: center; color: var(--ink3); font-size: 12px; padding: 26px 0; line-height: 1.8; }

.status-strip {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,.7));
  border: 1px solid var(--brand-line); border-radius: 12px;
  padding: 10px 16px; box-shadow: var(--shadow);
}
html.theme-dark .status-strip, html.studio-theme-dark .status-strip {
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
}
.status-strip .it { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink2); }
.status-strip .it .lab { color: var(--ink3); font-size: 10.5px; }
.status-strip .it b.mono { font-size: 15px; font-weight: 700; color: var(--ink); }
.status-strip .sp { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill.on { background: var(--ok-soft); color: var(--ok); }
.pill.on::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.pill.ro { background: var(--warn-soft); color: var(--warn); }

table.nlist { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.nlist th {
  text-align: left; font-size: 9.5px; letter-spacing: .08em; color: var(--ink3);
  font-weight: 600; padding: 7px 10px; border-bottom: 1px solid var(--line);
  font-family: ui-monospace, Consolas, monospace; white-space: nowrap;
}
.nlist td { padding: 9px 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.nlist tr:last-child td { border-bottom: none; }
.nlist tr:hover td { background: #f8fcfc; }
html.theme-dark .nlist tr:hover td, html.studio-theme-dark .nlist tr:hover td { background: rgba(14, 143, 154, .08); }
.nd { display: flex; gap: 9px; align-items: center; min-width: 160px; }
.nd .ic {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #e6f5f5, #d3ecec);
  display: grid; place-items: center; font-size: 14px; border: 1px solid var(--brand-line);
}
.nd .nm { font-weight: 600; font-size: 12px; }
.nd .meta { font-size: 10px; color: var(--ink3); margin-top: 1px; font-family: ui-monospace, Consolas, monospace; }
.badge { display: inline-flex; font-size: 9px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.cnt-cell { display: flex; align-items: center; gap: 9px; }
.cnt-num { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 12.5px; min-width: 22px; }
.pbar { width: 64px; height: 5px; border-radius: 99px; background: var(--line2); overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #8fd4d8, var(--brand)); }
.pbar i.over { background: linear-gradient(90deg, #f2a06a, var(--err)); }
.pbar i.near { background: linear-gradient(90deg, #f6cd7f, #e8a33d); }
.rowflash { animation: rowflash 1.6s ease 3; }
@keyframes rowflash { 0%, 100% { background: transparent; } 50% { background: var(--err-soft); } }

.rulebox { border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; background: #fbfdfd; }
html.theme-dark .rulebox, html.studio-theme-dark .rulebox { background: #16201e; }
.rulebox .rl { font-size: 11px; font-weight: 700; margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.switch {
  position: relative; width: 30px; height: 17px; background: #cfe0e1;
  border-radius: 99px; border: none; transition: .15s; flex: none;
}
.switch.on { background: var(--brand); }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.switch.on::after { left: 15px; }
.kv {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; padding: 6px 0; color: var(--ink2); border-bottom: 1px dashed var(--line2);
}
.kv:last-child { border-bottom: none; }
.kv .mono, .kv b.mono { color: var(--ink); }
.kv input[type="number"] {
  width: 56px; text-align: center; border: 1px solid var(--line); border-radius: 7px;
  padding: 3px 0; font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  color: var(--ink); background: var(--panel);
}
.feeditem {
  display: flex; gap: 9px; padding: 8px 0; border-bottom: 1px dashed var(--line2);
  font-size: 11px; color: var(--ink2); align-items: flex-start;
}
.feeditem:last-child { border-bottom: none; }
.feeditem .fi { width: 25px; height: 25px; border-radius: 8px; flex: none; display: grid; place-items: center; font-size: 12px; }
.feeditem .fi.a { background: var(--err-soft); }
.feeditem .fi.i { background: var(--brand-soft); }
.feeditem .ft b { color: var(--ink); }
.feeditem .tm { font-family: ui-monospace, Consolas, monospace; font-size: 8.5px; color: var(--ink3); margin-left: auto; white-space: nowrap; }

.invite-box {
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,.7));
  border: 1px solid var(--brand-line); border-radius: 13px;
  padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
html.theme-dark .invite-box, html.studio-theme-dark .invite-box {
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
}
.invite-box .il { font-size: 11px; color: var(--ink3); }
.invite-box .icode {
  font-family: ui-monospace, Consolas, monospace; font-size: 22px; font-weight: 800;
  letter-spacing: .18em; color: var(--brand-deep); margin: 4px 0 8px;
}
.invite-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tm-input {
  border: 1px solid var(--line); background: var(--panel); color: inherit;
  border-radius: 9px; padding: 7px 10px; font-size: 12.5px; min-width: 0;
}

/* 创建 / 加入 分隔线（空态与新建弹窗共用） */
.join-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 0; font-size: 11px; color: var(--ink3);
}
.join-divider::before, .join-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line2);
}

.member-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px dashed var(--line2);
}
.member-row:last-child { border-bottom: none; }
.bulk-quota-actions{display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:12px 0;border-bottom:1px solid var(--line2)}
.bulk-quota-actions[hidden]{display:none}
.bulk-quota-actions label{display:flex;align-items:center;gap:6px}
.bulk-quota-actions input,.member-quota-select{width:16px;height:16px;flex:0 0 16px;accent-color:var(--gold,#b49355)}
.bulk-quota-preview{max-height:180px;overflow:auto;margin:12px 0;line-height:1.8}
.member-row .member-main { min-width: 0; flex: 1; }
.member-row .who { font-weight: 700; font-size: 13px; }
.member-row .meta { font-size: 11px; color: var(--ink3); margin-top: 2px; }
.member-row .acts { margin-left: 0; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.member-list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--ink);
}
.member-list-head b { font-family: ui-monospace, Consolas, monospace; color: var(--brand-deep); }
.member-invite-link {
  border: 0; background: transparent; color: var(--brand-deep);
  font-size: 12px; font-weight: 600; cursor: pointer; padding: 0;
}
.member-invite-link:hover { text-decoration: underline; }
.role-tag {
  flex: 0 0 auto;
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--ink2);
  background: rgba(28, 26, 23, 0.05); border: 1px solid var(--line2);
}
.role-tag.is-owner {
  color: var(--brand-deep);
  background: var(--brand-soft);
  border-color: var(--brand-line);
}
.member-credits {
  min-width: 78px; text-align: right; line-height: 1.2;
}
.member-credits b { display: block; font-size: 15px; font-weight: 700; color: var(--ink); }
.member-credits span { font-size: 10px; color: var(--ink3); }
.member-foot-tip {
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line2);
  font-size: 11px; color: var(--ink3); line-height: 1.5;
}
.more-wrap { position: relative; display: inline-flex; }
.more-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 8;
  min-width: 112px; padding: 6px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.more-menu[hidden] { display: none !important; }
.more-menu button {
  border: 0; background: transparent; text-align: left;
  padding: 7px 10px; border-radius: 8px; font-size: 12px; color: var(--ink);
  cursor: pointer;
}
.more-menu button:hover { background: var(--brand-soft); }
.more-menu button.danger { color: var(--err); }
.invite-box.is-open { animation: inviteReveal .18s ease; }
@keyframes inviteReveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.share-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px dashed var(--line2);
}
.share-row:last-child { border-bottom: none; }
.share-row .sn { font-weight: 700; }
.share-row .sm { font-size: 11px; color: var(--ink3); margin-top: 2px; font-family: ui-monospace, Consolas, monospace; }

.delta-pos { color: var(--ok); font-weight: 700; }
.delta-neg { color: var(--err); font-weight: 700; }

.tm-create {
  max-width: 440px; margin: 72px auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 26px; box-shadow: var(--shadow);
}
.tm-create .kicker {
  font-family: ui-monospace, Consolas, monospace; font-size: 10px;
  letter-spacing: .22em; color: var(--brand); font-weight: 600;
}
.tm-create h2 { margin: 6px 0 8px; font-size: 20px; }
.tm-create p { margin: 0 0 16px; color: var(--ink2); font-size: 13px; line-height: 1.6; }
.tm-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 10px;
  font-size: 12.5px; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transform: translateY(8px); transition: .2s;
}
.toast.on { opacity: 1; transform: none; }
.mask {
  position: fixed; inset: 0; background: rgba(18, 54, 60, .28);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.mask.on { display: flex; }
.dialog {
  width: min(420px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 18px 16px; box-shadow: var(--shadow);
}
.dialog h3 { margin: 0 0 8px; font-size: 15px; }
.dialog p { margin: 0 0 12px; color: var(--ink2); font-size: 12.5px; line-height: 1.6; }
.dialog .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* legacy aliases used by invite.html */
.tm-btn { background: var(--brand); color: #fff; border: 0; border-radius: 9px; padding: 8px 14px; font-weight: 600; }
.tm-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink2); border-radius: 9px; padding: 8px 14px; }
.tm-danger { background: var(--err-soft); color: var(--err); border: 0; border-radius: 9px; padding: 6px 10px; }
.tm-muted { color: var(--ink3); }
.tm-empty { padding: 36px 12px; text-align: center; color: var(--ink3); }
.usage-proj {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.usage-proj:last-child { border-bottom: 0; }
.usage-proj .up-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
}
.usage-proj .sn { font-size: 13px; font-weight: 700; }
.usage-proj .sm { font-size: 11px; color: var(--ink3); margin-top: 3px; }
.usage-proj .up-kpi { text-align: right; font-size: 11px; color: var(--ink2); }
.usage-proj .up-kpi b { display: block; font-size: 16px; color: var(--ink); }
.usage-proj .up-kpi span { display: block; margin-top: 3px; }
.usage-proj .up-members { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.usage-proj .up-chip {
  font-size: 11px; padding: 4px 8px; border-radius: 8px;
  background: var(--glass, rgba(255,255,255,.04)); border: 1px solid var(--line);
}
.usage-proj .up-models { margin-top: 10px; }
.usage-share {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  vertical-align: middle;
}
.usage-share i {
  display: block;
  height: 8px;
  min-width: 0;
  max-width: 88px;
  flex: 1 1 auto;
  border-radius: 999px;
  background: linear-gradient(90deg, #5eead4, #38bdf8);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.usage-share em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink3);
  min-width: 34px;
  text-align: right;
}

#ledgerRows tr[data-ld-idx] { cursor: pointer; }
#ledgerRows tr.is-on td { background: rgba(14, 143, 154, .12); }
#ledgerRows tr.ledger-params-row { cursor: default; }
#ledgerRows tr.ledger-params-row td { background: rgba(14, 143, 154, .06); vertical-align: top; }
.ledger-params-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.ledger-params {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink2);
}
