:root {
  --bg: #f3f7f5;
  --surface: #ffffff;
  --sidebar: #123c34;
  --sidebar-soft: #1b4b41;
  --primary: #17806b;
  --primary-dark: #116654;
  --primary-soft: #eaf6f2;
  --text: #17372f;
  --muted: #687d76;
  --line: #dce8e3;
  --danger: #ad4045;
  --shadow: 0 10px 30px rgba(22, 64, 53, .07);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-family: Inter, "Microsoft YaHei", Arial, sans-serif; color: var(--text); background: var(--bg); }
button, textarea, input, select { font: inherit; }
button { min-height: 40px; padding: 0 17px; border: 1px solid var(--primary); border-radius: 8px; color: #fff; background: var(--primary); cursor: pointer; font-size: 14px; font-weight: 700; transition: .18s ease; }
button:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-1px); }
button.secondary { color: var(--primary-dark); background: #f7fbfa; border-color: #cbded7; }
button.secondary:hover { background: var(--primary-soft); }
button.danger { background: var(--danger); border-color: var(--danger); }
h1, h2, p { margin: 0; }
h1 { font-size: 25px; letter-spacing: -.5px; margin-bottom: 5px; }
h2 { font-size: 18px; margin: 3px 0 0; }
p { color: var(--muted); }

.app-layout { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: 230px; display: flex; flex-direction: column; padding: 24px 16px; color: #fff; background: linear-gradient(180deg, #123c34 0%, #0d302a 100%); box-shadow: 8px 0 32px rgba(10, 43, 36, .12); }
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 26px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: #124035; background: #d9f4e9; font-size: 20px; font-weight: 900; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; }
.brand small { margin-top: 3px; color: #9fc4ba; font-size: 12px; }
.side-nav { display: grid; gap: 7px; padding-top: 24px; }
.nav-item { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border: 0; border-radius: 10px; color: #bdd4ce; background: transparent; text-align: left; font-size: 15px; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.08); border-color: transparent; transform: none; }
.nav-item.active { color: #fff; background: var(--sidebar-soft); box-shadow: inset 3px 0 #80dac3; }
.nav-icon { width: 27px; height: 27px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; color: #d9f5ed; background: rgba(255,255,255,.08); font-size: 13px; font-weight: 800; }
.nav-item.active .nav-icon { color: #124035; background: #b9eadc; }
.sidebar-foot { margin-top: auto; padding: 15px 10px 2px; border-top: 1px solid rgba(255,255,255,.1); color: #a9c9c0; font-size: 12px; }
.online-dot { width: 8px; height: 8px; display: inline-block; margin-right: 7px; border-radius: 50%; background: #54d3a6; box-shadow: 0 0 0 4px rgba(84,211,166,.12); }

.shell { width: calc(100% - 230px); max-width: 100%; min-height: 100vh; margin-left: 230px; padding: 24px; overflow-x: hidden; }
.topbar, .panel { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.topbar { min-height: 104px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 24px; margin-bottom: 20px; border-radius: 12px; }
.topbar .actions { flex: 0 0 auto; }
.system-status { margin-top: 8px; color: #88a098; font-size: 12px; }
.page-view { display: none; width: 100%; min-width: 0; animation: page-in .18s ease; }
.page-view.active { display: block; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-grid { display: grid; gap: 18px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { min-width: 0; padding: 20px; margin-bottom: 18px; border-radius: 12px; }
.page-view > .panel { width: 100%; max-width: none; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.danger-text { color: var(--danger); }
.table-note { padding: 5px 9px; border-radius: 999px; color: var(--primary-dark); background: var(--primary-soft); font-size: 12px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 14px; }
.pagination button:disabled { opacity: .45; cursor: not-allowed; }
.failure-message { min-width: 320px; max-width: 620px; white-space: normal; word-break: break-word; color: var(--muted); }
.redeem-panel { width: 100%; min-height: 320px; }
.redeem-lists { margin-top: 16px; }
.empty-list { padding: 24px; border: 1px dashed #cbded7; border-radius: 8px; color: var(--muted); background: #f8fbfa; text-align: center; }
.daily-head { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.connection-panel { border-top: 3px solid #55aa96; }
.connection-fields { grid-template-columns: 1.4fr 1fr 1fr; }
.connection-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.connection-actions .check { margin: 0; }
.setting-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.actions { display: inline-flex; gap: 10px; }
.form-actions { margin-top: 20px; }

textarea, input, select { width: 100%; border: 1px solid #cbdad5; border-radius: 8px; color: var(--text); background: #fbfdfc; outline: none; transition: .16s ease; }
textarea:focus, input:focus, select:focus { border-color: #55aa96; background: #fff; box-shadow: 0 0 0 3px rgba(31,139,113,.1); }
textarea { min-height: 145px; padding: 12px; resize: vertical; line-height: 1.6; margin-bottom: 12px; }
input, select { height: 41px; padding: 0 12px; margin-top: 7px; }
label { display: block; margin-bottom: 13px; color: #36564d; font-size: 14px; font-weight: 700; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.inline-form { display: grid; grid-template-columns: minmax(240px, 520px) auto; align-items: end; gap: 12px; }
.inline-form label { margin-bottom: 0; }
.inline-form button { margin-bottom: 0; }
.three-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.status { margin-top: 10px; line-height: 1.5; color: #276454; }
.hint { margin-bottom: 14px; font-size: 13px; line-height: 1.6; }
.callout { padding: 12px 14px; border-left: 3px solid #6ab7a4; border-radius: 0 8px 8px 0; background: #f2f9f6; }
.token-output { overflow-wrap: anywhere; user-select: all; }

.table-wrap { overflow: auto; max-height: 440px; border: 1px solid #e6eeeb; border-radius: 9px; }
.table-wrap.compact { max-height: 330px; }
.account-table { max-height: 620px; }
.main-task-cell { min-width: 175px; }
.main-step { font-weight: 800; color: var(--primary-dark); }
.main-task-text { margin-left: 7px; color: #48635d; white-space: nowrap; }
.main-task-progress { margin-left: 4px; color: #168268; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 11px; border-bottom: 1px solid #e8efec; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; color: #647a72; background: #f8fbfa; font-size: 13px; white-space: nowrap; }
.sort-button { width: 20px; min-height: 24px; margin: -4px -4px -4px 3px; padding: 0; border: 0; border-radius: 5px; color: #9aaca6; background: transparent; vertical-align: middle; box-shadow: none; }
.sort-button:hover { color: var(--primary); background: #eaf4f0; transform: none; box-shadow: none; }
.sort-caret { display: inline-grid; gap: 0; font-size: 8px; line-height: 7px; }
.sort-caret::before { content: "▲"; }
.sort-caret::after { content: "▼"; }
.sort-button.sort-desc .sort-caret::before, .sort-button.sort-asc .sort-caret::after { color: #b8c5c1; }
.sort-button.sort-desc .sort-caret::after, .sort-button.sort-asc .sort-caret::before { color: var(--primary-dark); }
td { white-space: nowrap; }
.row-number { width: 58px; min-width: 58px; text-align: center; font-variant-numeric: tabular-nums; color: #60756e; }
tbody tr:hover { background: #fbfdfc; }
td small { display: block; color: #71847d; margin-top: 4px; }
.yuanbao-total, .yuanbao-growth { font-variant-numeric: tabular-nums; }
.yuanbao-growth.positive { color: #168268; font-weight: 700; }
.yuanbao-growth.negative { color: #b44848; font-weight: 700; }
.yuanbao-growth.neutral { color: #71847d; }
td .row-actions { display: inline-flex; gap: 7px; }
.row-actions button { min-height: 34px; padding: 0 11px; font-size: 13px; }
.node-executor-editor { display: flex; align-items: center; gap: 6px; min-width: 132px; }
.node-executor-editor input { width: 58px; min-height: 32px; padding: 4px 7px; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 12px; }
.badge.ok { color: #17654f; background: #e6f6ef; }
.badge.bad { color: #9b3030; background: #fdeaea; }
.logs { max-height: 420px; overflow: auto; border-top: 1px solid #e6eeeb; margin-top: 12px; }
.log-row { padding: 10px 0; border-bottom: 1px solid #edf3f0; }
.log-row small { display: block; margin-bottom: 4px; color: #6d8179; }
.code-list { display: grid; gap: 8px; max-height: 280px; overflow: auto; margin-top: 16px; }
.code-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid #dbe7e2; border-radius: 8px; background: #f8fbfa; }
.code-row span { color: #60756e; font-size: 13px; white-space: nowrap; }
.code-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
button.compact { min-height: 32px; padding: 0 12px; font-size: 12px; }

.daily-switches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.daily-switches .check, .setting-checks .check { min-height: 44px; margin: 0; padding: 10px 12px; border: 1px solid #dbe7e2; border-radius: 8px; background: #f9fbfa; }
.daily-group { grid-column: 1 / -1; margin-top: 10px; padding: 0 0 7px; border-bottom: 1px solid var(--line); color: #335e52; font-size: 14px; font-weight: 800; }
.hidden { display: none !important; }

@media (max-width: 1080px) {
  .sidebar { width: 190px; }
  .shell { width: calc(100% - 190px); margin-left: 190px; padding: 18px; }
  .daily-switches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .three-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .sidebar { position: sticky; top: 0; width: 100%; height: auto; padding: 10px 12px; }
  .brand, .sidebar-foot { display: none; }
  .side-nav { display: flex; gap: 6px; padding: 0; overflow-x: auto; }
  .nav-item { width: auto; min-width: max-content; min-height: 42px; padding: 0 11px; }
  .nav-item.active { box-shadow: inset 0 -3px #80dac3; }
  .nav-icon { display: none; }
  .shell { width: 100%; margin: 0; padding: 12px; }
  .topbar { display: grid; min-height: auto; padding: 16px; }
  .topbar .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .two-columns, .two, .three-fields, .daily-switches, .setting-checks, .inline-form { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .daily-head { display: grid; }
  .connection-actions { align-items: stretch; flex-direction: column; }
  .daily-group { grid-column: 1; }
  .code-row, .code-actions { align-items: stretch; flex-direction: column; }
  .code-actions { gap: 8px; }
  .code-row span { white-space: normal; }
}
/* ==================== 游戏配置页（账号级 scriptConfig） ==================== */
.config-layout { display: grid; grid-template-columns: 132px 1fr; gap: 18px; align-items: start; }
.config-nav { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #f9fbfa; }
.config-nav-item { min-height: 38px; padding: 0 12px; border: none; border-left: 3px solid transparent; border-radius: 6px; background: transparent; color: #335e52; font-size: 14px; font-weight: 700; text-align: left; }
.config-nav-item:hover { background: var(--primary-soft); color: var(--primary-dark); transform: none; }
.config-body { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.config-group { padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; scroll-margin-top: 12px; }
.config-group-title { margin: 0 0 10px; padding-bottom: 8px; border-bottom: 2px solid var(--primary-soft); color: var(--primary-dark); font-size: 15px; font-weight: 800; }
.cfg-group-title { margin-top: 12px; padding: 0 0 6px; border-bottom: 1px solid var(--line); color: #335e52; font-size: 13px; font-weight: 800; }
.cfg-row { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 12px; border: 1px solid #e7efec; border-radius: 8px; background: #fbfdfc; font-size: 14px; }
.cfg-row + .cfg-row, .cfg-row + .cfg-help, .cfg-help + .cfg-row { margin-top: 6px; }
.cfg-row input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.cfg-indent { margin-left: 26px; background: #f7faf9; }
.cfg-note { margin: 6px 0; padding: 8px 12px; border-radius: 8px; background: #fff8e6; color: #8a6d1a; font-size: 13px; }
.cfg-help { display: block; margin: 2px 0 6px 26px; color: #7a928a; font-size: 12px; }
.cfg-num { justify-content: space-between; gap: 12px; }
.cfg-num > span:first-child { flex: 1; min-width: 0; }
.cfg-num input, .cfg-num select { width: 130px; min-height: 34px; padding: 4px 10px; border: 1px solid #cbded7; border-radius: 7px; font-size: 14px; }
.cfg-num input[type="text"] { width: 220px; }
.cfg-range { display: inline-flex; align-items: center; gap: 6px; }
.cfg-range input { width: 74px; }
.cfg-qualities { justify-content: space-between; gap: 12px; }
.cfg-chips { display: inline-flex; gap: 6px; }
.cfg-chip { position: relative; }
.cfg-chip input { position: absolute; opacity: 0; pointer-events: none; }
.cfg-chip span { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; min-height: 30px; padding: 0 10px; border: 1px solid #cbded7; border-radius: 7px; background: #fff; color: #335e52; font-size: 13px; font-weight: 700; cursor: pointer; }
.cfg-chip input:checked + span { border-color: var(--primary); background: var(--primary); color: #fff; }
.cfg-json { align-items: flex-start; flex-direction: column; }
.cfg-json textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #cbded7; border-radius: 7px; font-family: Consolas, monospace; font-size: 12px; }
@media (max-width: 760px) {
  .config-layout { grid-template-columns: 1fr; }
  .config-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .config-nav-item { border-left: none; border-bottom: 3px solid transparent; }
}

/* 多用户模式：普通用户不可见批量应用按钮 */
body.user-mode #configApplyAllBtn { display: none; }
