/* ============================================================
   深矿探采 · 管理后台
   视觉方向：矿洞账房 —— 深色矿洞底、台账式表格、琥珀金仅用于
   关键数值 / 主操作 / 当前态；数字一律等宽表格数字。
   ============================================================ */

:root {
  /* 色彩角色 */
  --bg: #14121C;
  --bg-raise: #181523;
  --surface: #1E1A2B;
  --surface-2: #262134;
  --line: #37304C;
  --line-soft: #292238;
  --text: #ECE7F6;
  --muted: #A79EC0;
  --faint: #786E94;
  --amber: #FFC85C;
  --amber-strong: #FFDD9A;
  --amber-ink: #241B08;
  --amber-dim: rgba(255, 200, 92, 0.12);
  --amber-line: rgba(255, 200, 92, 0.38);
  --ok: #7CD992;
  --ok-dim: rgba(124, 217, 146, 0.12);
  --info: #8FB8F6;
  --info-dim: rgba(143, 184, 246, 0.12);
  --danger: #FF8080;
  --danger-dim: rgba(255, 128, 128, 0.12);
  --warn: #FFB35C;
  --warn-dim: rgba(255, 179, 92, 0.12);

  /* 形状与节奏 */
  --radius: 10px;
  --radius-s: 7px;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --speed: 140ms;

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
}

.hidden { display: none !important; }

::selection { background: var(--amber-line); color: var(--amber-ink); }

/* ---------------- 登录 ---------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  background:
    radial-gradient(560px 320px at 50% 12%, rgba(255, 200, 92, 0.07), transparent 70%),
    var(--bg);
}

.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 34px 30px 28px;
  box-shadow: var(--shadow);
}

.login-brand { text-align: center; margin-bottom: 26px; }

.gem {
  color: var(--amber);
  font-size: 20px;
  line-height: 1;
}

.login-brand .gem { font-size: 26px; display: inline-block; margin-bottom: 10px; }

.login-brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-indent: 0.22em; /* 抵消末字间距，保持视觉居中 */
}

.login-brand p {
  margin: 6px 0 0;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
}

.login-card form::before {
  content: "";
  display: block;
  height: 1px;
  margin: 0 4px 22px;
  background: linear-gradient(90deg, transparent, var(--amber-line), transparent);
  opacity: 0.7;
}

.login-foot {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.08em;
}

/* ---------------- 表单元素 ---------------- */

.field { display: block; margin-bottom: 14px; }

.field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-s);
  color: var(--text);
  font: inherit;
  padding: 8px 11px;
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}

.input::placeholder { color: var(--faint); }

.input:focus {
  outline: none;
  border-color: var(--amber-line);
  box-shadow: 0 0 0 3px var(--amber-dim);
}

.input.invalid { border-color: var(--danger); }

select.input { appearance: auto; }

.input-date { color-scheme: dark; width: auto; }

textarea.input { resize: vertical; min-height: 72px; font-family: var(--mono); font-size: 12.5px; }

.form-error {
  background: var(--danger-dim);
  border: 1px solid rgba(255, 128, 128, 0.35);
  color: var(--danger);
  border-radius: var(--radius-s);
  padding: 8px 11px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

.hint { color: var(--faint); font-size: 12px; margin: 12px 0 0; }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  padding: 8px 15px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--speed) ease, border-color var(--speed) ease,
    color var(--speed) ease, filter var(--speed) ease;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--amber); color: var(--amber-ink); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--amber-strong); }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--amber-line); }

.btn-danger { background: transparent; border-color: rgba(255, 128, 128, 0.4); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-dim); }

.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--amber-strong); text-decoration: underline; }

/* ---------------- 应用骨架 ---------------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: none;
  background: var(--bg-raise);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.brand .gem { font-size: 18px; }

.brand-name { font-weight: 700; letter-spacing: 0.14em; font-size: 15px; }
.brand-sub { color: var(--faint); font-size: 11px; letter-spacing: 0.3em; margin-top: 1px; }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-s);
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  cursor: pointer;
  transition: color var(--speed) ease, background var(--speed) ease;
}

.nav-item:hover { color: var(--text); background: var(--surface); }

.nav-item.active {
  color: var(--amber);
  background: var(--amber-dim);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--amber);
}

.sidebar-foot { padding: 14px; border-top: 1px solid var(--line-soft); }

/* 签名元素：侧栏底部的矿脉 */
.vein {
  height: 46px;
  margin: 0 1px 1px;
  background:
    radial-gradient(3px 3px at 18% 62%, rgba(255, 200, 92, 0.75), transparent 100%),
    radial-gradient(2px 2px at 44% 34%, rgba(255, 221, 154, 0.6), transparent 100%),
    radial-gradient(2.5px 2.5px at 71% 70%, rgba(255, 200, 92, 0.55), transparent 100%),
    radial-gradient(2px 2px at 88% 40%, rgba(255, 221, 154, 0.45), transparent 100%),
    linear-gradient(100deg, transparent 12%, rgba(255, 200, 92, 0.16) 38%, rgba(255, 200, 92, 0.05) 62%, transparent 88%);
  background-color: var(--bg-raise);
  border-top: 1px solid var(--line-soft);
  border-radius: 0 0 var(--radius) var(--radius);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 26px 30px 48px;
  max-width: 1240px;
}

.section { animation: section-in 180ms ease; }

@keyframes section-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: 0.02em; }

.page-desc { margin: 5px 0 0; color: var(--faint); font-size: 12.5px; }

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

/* ---------------- 卡片与工具条 ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.card-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-toolbar .input { width: auto; min-width: 150px; }
.card-toolbar .input.grow { flex: 1; min-width: 160px; }

/* ---------------- 数据看板 ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
}

.stat-label { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }

.stat-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--amber);
}

.stat-value .unit { font-size: 13px; font-weight: 400; color: var(--faint); margin-left: 4px; }

.stat-sub { color: var(--faint); font-size: 12px; margin-top: 8px; }

.stat-sub b { color: var(--muted); font-weight: 600; }

.stat-grid-4 + .card { margin-top: 2px; }

/* 次级指标收敛视觉权重 */
.stat-secondary .stat-value { font-size: 20px; color: var(--text); font-weight: 600; }

.pool-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.pool-mini {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  background: var(--bg-raise);
}

.pool-mini-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.pool-mini-tier { font-weight: 700; font-size: 13px; color: var(--amber); letter-spacing: 0.05em; }

.pool-mini-count { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text); font-size: 14px; }

.pool-mini-count .cap { color: var(--faint); }

.pool-mini-meta { color: var(--faint); font-size: 11.5px; margin-top: 7px; }

.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }

.bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #E0A83E, var(--amber)); transition: width 240ms ease; }

/* ---------------- 表格 ---------------- */

.table-wrap { overflow-x: auto; }

table.tbl { width: 100%; border-collapse: collapse; }

.tbl th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: 0.06em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.tbl td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.tbl tbody tr { transition: background var(--speed) ease; }
.tbl tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.tbl .num, .mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.tbl .num { font-size: 13px; }

.cell-strong { font-weight: 600; }

.cell-dim { color: var(--faint); font-size: 12.5px; }

.cell-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.cell-trunc {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.prize-thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--surface-2);
  display: block;
}

.prize-thumb-none {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  border: 1px dashed var(--line);
  color: var(--faint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.table-loading, .empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}

.empty-error { color: var(--danger); }

/* ---------------- 徽章 ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}

.badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge-ok { color: var(--ok); background: var(--ok-dim); border-color: rgba(124, 217, 146, 0.3); }
.badge-info { color: var(--info); background: var(--info-dim); border-color: rgba(143, 184, 246, 0.3); }
.badge-warn { color: var(--warn); background: var(--warn-dim); border-color: rgba(255, 179, 92, 0.32); }
.badge-amber { color: var(--amber); background: var(--amber-dim); border-color: var(--amber-line); }
.badge-danger { color: var(--danger); background: var(--danger-dim); border-color: rgba(255, 128, 128, 0.3); }
.badge-muted { color: var(--faint); }

.tier-chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid var(--amber-line);
  border-radius: 6px;
  padding: 1px 8px;
}

/* ---------------- 分页 ---------------- */

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 14px;
}

.pager:empty { display: none; }

.pager-info { color: var(--faint); font-size: 12.5px; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------- 月卡页 ---------------- */

.monthly-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.mc-form-card { position: sticky; top: 24px; }

.mc-target {
  background: var(--bg-raise);
  border: 1px dashed var(--line);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.mc-target.picked { border-style: solid; border-color: var(--amber-line); color: var(--text); }

.mc-target .mono { color: var(--amber); }

/* ---------------- 开奖记录展开行 ---------------- */

.draw-detail td { background: var(--bg-raise); padding: 16px 18px; }

.dd-grid { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px 14px; font-size: 13px; margin-bottom: 14px; }

.dd-label { color: var(--faint); }

.dd-value { min-width: 0; word-break: break-all; }

.dd-hash { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.dd-section { margin-top: 14px; }

.dd-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.verify-line { font-size: 12.5px; font-weight: 600; }
.verify-line.v-ok { color: var(--ok); }
.verify-line.v-bad { color: var(--danger); }
.verify-line.v-none { color: var(--faint); font-weight: 400; }

.snapshot-tbl td { padding: 7px 12px; }
.snapshot-tbl .winner-mark { color: var(--amber); font-weight: 700; }

.copy-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--faint);
  border-radius: 5px;
  font-size: 11px;
  padding: 1px 7px;
  cursor: pointer;
  font-family: var(--mono);
}

.copy-btn:hover { color: var(--amber); border-color: var(--amber-line); }

.row-toggle {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.row-toggle:hover, .row-toggle.open { color: var(--amber); border-color: var(--amber-line); }

/* ---------------- 弹层 ---------------- */

#modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 8, 16, 0.68);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 16px 16px;
  overflow-y: auto;
}

.modal {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
  animation: modal-in 160ms ease;
}

.modal-wide { width: min(720px, 100%); }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }

.modal-sub { color: var(--faint); font-size: 12.5px; margin: 0 0 16px; }

.modal-body { font-size: 13.5px; color: var(--muted); }

.modal-body pre {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-s);
  padding: 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  max-height: 50vh;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.modal .form-error { margin-top: 12px; margin-bottom: 0; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 领奖字段编辑器 */

.cf-list { border: 1px solid var(--line-soft); border-radius: var(--radius-s); padding: 12px; background: var(--bg-raise); }

.cf-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.cf-row:last-child { margin-bottom: 0; }

.cf-req {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
}

.cf-empty { color: var(--faint); font-size: 12.5px; }

/* ---------------- 提示条 ---------------- */

#toast-box {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  animation: toast-in 180ms ease;
}

.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }

.toast-out { opacity: 0; transform: translateX(8px); transition: all 220ms ease; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .pool-strip { grid-template-columns: 1fr; }
  .monthly-layout { grid-template-columns: 1fr; }
  .mc-form-card { position: static; }
}

@media (max-width: 760px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .nav { flex-direction: row; overflow-x: auto; padding: 8px 10px; }
  .nav-item { white-space: nowrap; width: auto; }
  .nav-item.active::before { left: 8px; right: 8px; top: auto; bottom: 0; width: auto; height: 3px; }
  .sidebar-foot { display: none; }
  .vein { display: none; }

  .main { padding: 18px 14px 40px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .field-row { grid-template-columns: 1fr; }
  .cf-row { grid-template-columns: 1fr 1fr; }
  .cf-req { justify-self: start; }
  .cf-row .cf-del { justify-self: end; }
}

/* Template reference columns need a readable gap beside the independent cap. */
#template-table .template-tbl { margin-top: 14px; min-width: 880px; }
#template-table .template-tbl th,
#template-table .template-tbl td { padding: 14px 20px; vertical-align: middle; }
#template-table .template-tbl th:nth-child(2),
#template-table .template-tbl td:nth-child(2) { min-width: 100px; white-space: nowrap; }
#template-table .template-tbl th:nth-child(3),
#template-table .template-tbl td:nth-child(3) { min-width: 250px; white-space: nowrap; }
#template-table .template-tbl small { display: inline-block; margin-top: 5px; }
