:root {
  --bg: #14110d;
  --bg-2: #1b1611;
  --panel: #221c15;
  --panel-2: #2c241b;
  --border: #3a2f23;
  --border-2: #4a3c2c;
  --text: #ece2d0;
  --muted: #a8977c;
  --gold: #d6c09b;
  --gold-2: #b8924f;
  --gold-3: #8a6d39;
  --teal: #538486;
  --danger: #e07a6b;
  --warn: #e0a85a;
  --ok: #8fce9b;
  --radius: 12px;
  --primary: var(--gold);
  --primary-d: var(--gold-2);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(184,146,79,0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(83,132,134,0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; }
input, textarea, select {
  font: inherit; width: 100%; padding: 10px 12px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--gold-2);
  box-shadow: 0 0 0 3px rgba(184,146,79,0.18);
}

.btn {
  border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text);
  padding: 8px 16px; border-radius: 9px; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--gold-2); color: var(--gold); }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold-2)); border-color: var(--gold-2); color: #2a2113; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); color: #2a2113; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.block { width: 100%; padding: 11px; letter-spacing: 2px; }

.spacer { flex: 1; }
.badge { background: var(--gold-2); color: #2a2113; font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge.muted { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); font-weight: 400; }
.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 2px; }

/* ===================== 登录（分屏） ===================== */
.login-shell { min-height: 100vh; display: flex; }

.login-hero {
  flex: 1.25; position: relative; padding: 48px 52px; color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: transparent; /* 背景图由 JS 应用到整页 .login-shell */
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.login-hero::after { content: none; } /* 去掉原装饰性点阵背景 */
.hero-scrim { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.55), rgba(0,0,0,.12) 55%, transparent); pointer-events: none; }
.hero-content { position: relative; z-index: 1; }
.hero-brand { font-size: 46px; font-weight: 800; letter-spacing: 6px; color: #fff; text-shadow: 0 2px 20px rgba(0,0,0,.7); }
.hero-en { margin-top: 6px; font-size: 15px; letter-spacing: 10px; color: rgba(255,255,255,.85); text-shadow: 0 1px 12px rgba(0,0,0,.6); }
.hero-rule { width: 84px; height: 3px; margin: 22px 0; background: linear-gradient(90deg, rgba(214,192,155,.9), transparent); border-radius: 2px; }
.hero-desc { white-space: pre-line; color: rgba(255,255,255,.85); font-size: 15px; max-width: 360px; line-height: 1.9; text-shadow: 0 1px 10px rgba(0,0,0,.6); }

.login-panel {
  flex: 1; max-width: 460px; padding: 56px 48px; display: flex; flex-direction: column; justify-content: center;
  background: rgba(20,17,13,0.6);
}
.mon {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  font-size: 30px; color: #2a2113; margin-bottom: 18px;
  background: radial-gradient(circle at 35% 30%, var(--gold), var(--gold-2));
  box-shadow: 0 6px 24px rgba(184,146,79,0.35);
}
.login-title { margin: 0 0 6px; font-size: 26px; letter-spacing: 1px; }
.login-sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }

.auth-tabs { display: flex; gap: 8px; margin-bottom: 22px; }
.auth-tabs .tab { flex: 1; text-align: center; padding: 10px; border-radius: 9px; background: var(--panel-2); color: var(--muted); cursor: pointer; border: 1px solid var(--border); transition: .15s; }
.auth-tabs .tab.active { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #2a2113; font-weight: 600; border-color: var(--gold-2); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.error-msg { color: var(--danger); font-size: 14px; min-height: 18px; margin-top: 6px; }

/* ===================== 后台布局：上 - 左 - 右 ===================== */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  height: 56px; flex: none; display: flex; align-items: center; gap: 16px;
  padding: 0 20px; background: linear-gradient(180deg, #221b13, #1a140e);
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--gold); font-size: 16px; letter-spacing: .5px; white-space: nowrap; }
.mon-sm { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; color: #2a2113; background: radial-gradient(circle at 35% 30%, var(--gold), var(--gold-2)); }
.banner { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 10px; }
.top-right select { width: auto; min-width: 160px; padding: 7px 10px; }

.app-body { display: flex; flex: 1; min-height: 0; }

.sidebar { width: 220px; flex: none; background: var(--panel); border-right: 1px solid var(--border); padding: 16px 12px; }
.menu { display: flex; flex-direction: column; gap: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: 9px;
  color: var(--muted); cursor: pointer; border-left: 3px solid transparent; transition: .15s; user-select: none;
}
.menu-item:hover { background: var(--panel-2); color: var(--text); }
.menu-item.active { background: linear-gradient(90deg, rgba(184,146,79,0.18), transparent); color: var(--gold); border-left-color: var(--gold-2); font-weight: 600; }
.menu-icon { width: 18px; text-align: center; }
.menu-item .soon { margin-left: auto; font-size: 11px; color: var(--muted); background: var(--panel-2); padding: 1px 8px; border-radius: 999px; font-weight: 400; }

.content { flex: 1; padding: 24px 28px; overflow: auto; }

/* ===================== 工作台 Dashboard ===================== */
.dash-hero { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 16px; }
.dash-hero h2 { margin: 0 0 6px; color: var(--gold); font-size: 22px; }
.dash-hero p { margin: 0; color: var(--muted); font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-card .num { font-size: 30px; font-weight: 800; color: var(--gold); }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 6px; }

.dash-panel { background: var(--panel); border: 1px dashed var(--border-2); border-radius: var(--radius); padding: 20px 24px; }
.panel-title { color: var(--gold); font-weight: 600; margin-bottom: 10px; }

/* ===================== 页面通用 ===================== */
.section-head { display: flex; align-items: center; margin: 6px 0 16px; }
.section-head h2 { font-size: 19px; margin: 0; }

/* ===================== 游戏人物 ===================== */
.char-group { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.account-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.group-body { padding: 8px 18px 12px; }
.char-row { display: flex; align-items: center; gap: 9px; padding: 10px 0 10px 14px; border-top: 1px dashed var(--border); }
.char-row:first-child { border-top: none; }
.character-name { font-weight: 600; }

.chip { background: var(--panel); color: var(--muted); font-size: 12px; padding: 2px 9px; border-radius: 7px; border: 1px solid var(--border); white-space: nowrap; }
.chip.gold { color: var(--gold); border-color: var(--border-2); }

.row-actions { display: flex; gap: 6px; }

/* ===================== 武士讨伐录 ===================== */
.sub-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.sub-toolbar select { width: auto; min-width: 200px; }
.toolbar-label { font-size: 13px; color: var(--muted); }

.sub-info { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 18px; }
.sub-info-title { font-size: 17px; font-weight: 700; color: var(--gold); margin-bottom: 10px; }
.sub-info-grid { display: flex; gap: 40px; flex-wrap: wrap; }
.sub-info-label { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.sub-info-value { font-size: 14px; }
.sub-info-desc { margin-top: 10px; color: var(--muted); font-size: 13px; }
.sub-info-rewards { margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sub-info-rewards .sub-info-label { margin-bottom: 0; }
.sub-info-rewards .chip { color: var(--gold); border-color: var(--border-2); }

.sub-char-block { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; overflow-x: auto; }
.sub-char-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.sub-char-name { font-weight: 700; }

.badge-table { width: 100%; min-width: 940px; border-collapse: collapse; font-size: 13px; }
.badge-table th, .badge-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: center; }
.badge-table thead th { background: var(--panel-2); color: var(--gold); font-weight: 600; }
.badge-table .badge-type { text-align: left; font-weight: 600; white-space: nowrap; }
.cell-input input { width: 76px; padding: 6px 8px; text-align: center; }
.cell-output { color: var(--muted); }

.sub-calc-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--border); background: rgba(184,146,79,0.06); }
.sub-calc-result { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.calc-time { color: var(--muted); }
.calc-avail { color: var(--muted); }
.calc-boxes { color: var(--gold); font-weight: 700; font-size: 14px; }
.calc-alloc { color: var(--muted); font-size: 12px; width: 100%; }
.calc-error { color: var(--danger); }
.calc-loading { color: var(--muted); }
.cell-calc.cell-warn { background: rgba(224,168,90,0.18); color: var(--warn); font-weight: 600; }

/* ===================== 占位页 ===================== */
.placeholder-card { text-align: center; padding: 80px 20px; background: var(--panel); border: 1px dashed var(--border-2); border-radius: var(--radius); }
.placeholder-icon { font-size: 46px; margin-bottom: 12px; }
.placeholder-card h3 { margin: 0 0 8px; color: var(--gold); }
.placeholder-card p { margin: 0; color: var(--muted); }

/* ===================== 系统配置 ===================== */
.config-form { max-width: 520px; }
.bg-preview {
  height: 220px; border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(150deg, #211a12, #14110d 55%, #0c0a07);
  background-size: cover; background-position: center; background-repeat: no-repeat;
}

/* ===================== 模态框 ===================== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 24px; width: 380px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal h3 { margin: 0 0 14px; color: var(--gold); }
.modal label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
.modal-error { color: var(--danger); font-size: 13px; min-height: 16px; margin-top: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.check-field { display: flex !important; align-items: center; gap: 9px; cursor: pointer; margin-top: 16px !important; }
.check-field input { width: 18px; height: 18px; flex: none; accent-color: var(--gold-2); }

.field-label { font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.radio-group { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-item { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--panel-2); color: var(--text); transition: .15s; }
.radio-item:hover { border-color: var(--gold-2); }
.radio-item input { width: auto; margin: 0; accent-color: var(--gold-2); }
.radio-item:has(input:checked) { border-color: var(--gold-2); color: var(--gold); background: rgba(184,146,79,0.16); font-weight: 600; }

/* ===================== 活动主表编辑（紧凑布局） ===================== */
.modal-wide { width: 640px; max-height: 92vh; overflow: auto; }
.modal-wide .form-row { margin: 14px 0 0; }
.modal-wide .form-row.cols { display: flex; gap: 12px; }
.modal-wide .form-col { flex: 1; min-width: 0; }
.modal-wide .form-row label,
.modal-wide .form-col label,
.modal-wide .form-sub-label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px; }
.modal-wide .form-row input[type=number] { max-width: 180px; }
.loc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.loc-table th, .loc-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.loc-table thead th { background: var(--panel-2); color: var(--gold); font-weight: 600; }
.loc-table .loc-badge { white-space: nowrap; font-weight: 600; width: 130px; }
.loc-table td input { padding: 7px 10px; }

/* ===================== 响应式 ===================== */
@media (max-width: 760px) {
  .login-shell { flex-direction: column; }
  .login-hero { flex: none; padding: 40px 28px; }
  .login-panel { max-width: none; padding: 36px 26px; }
  .hero-brand { font-size: 34px; }
  .banner { display: none; }
  .sidebar { width: 64px; padding: 16px 8px; }
  .menu-item { justify-content: center; padding: 12px 0; }
  .menu-item > span:not(.menu-icon) { display: none; }
  .content { padding: 18px 14px; }
}
