/* ==========================================================================
   LuckyDesk · 抽奖工作台
   浅纸色 + 墨绿 + 赭石，侧栏布局，表格/面板式排版
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --paper:      #f3f0e7;
  --paper-2:    #ebe6d9;
  --card:       #fffdf7;
  --ink:        #211f1a;
  --ink-2:      #4a463d;
  --muted:      #7d7668;
  --faint:      #a49c8c;
  --line:       #e3dccb;
  --line-2:     #d3cab5;
  --green:      #0f6b5c;
  --green-soft: #e4f0eb;
  --ochre:      #b8791f;
  --ochre-soft: #f8eeda;
  --red:        #a83a2c;
  --red-soft:   #f8e7e2;
  --blue:       #2a5674;
  --blue-soft:  #e6eef4;
  --shadow:     0 1px 2px rgba(63, 54, 32, .05), 0 10px 26px -18px rgba(63, 54, 32, .35);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
  --serif: "Songti SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
}

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ------------------------------------------------------------------ 框架 */
.app { display: grid; grid-template-columns: 214px minmax(0, 1fr); min-height: 100vh; }

.rail {
  background: #fbf8f1;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 4px; }
.brand .glyph {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 9px;
  background: var(--green); color: #f7f4ea;
  display: grid; place-items: center;
  font: 700 17px/1 var(--serif); letter-spacing: .04em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .16);
}
.brand .name { font-family: var(--serif); font-size: 17px; font-weight: 700; }
.brand .sub { font-size: 10.5px; color: var(--faint); letter-spacing: .1em; text-transform: uppercase; margin-top: -1px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--paper-2); text-decoration: none; }
.nav a[aria-current="page"] {
  background: var(--green-soft); color: var(--green);
  font-weight: 600; border-left-color: var(--green);
}
.nav .k {
  width: 20px; height: 20px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 5px;
  font: 600 10.5px/1 var(--mono);
  background: rgba(33, 31, 26, .06); color: var(--muted);
}
.nav a[aria-current="page"] .k { background: rgba(15, 107, 92, .14); color: var(--green); }

.rail-foot { margin-top: auto; font-size: 10.5px; line-height: 1.8; color: var(--faint); padding: 0 4px; }
.rail-foot b { display: block; color: var(--muted); font-weight: 600; font-family: var(--mono); font-size: 10px; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 26px; border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 247, .75);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 700; }
.topbar .desc { margin: 0; font-size: 11.5px; color: var(--muted); }
.topbar .spacer { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--card);
  font-size: 11.5px; color: var(--muted); white-space: nowrap;
}
.chip b { font-family: var(--mono); font-size: 11px; color: var(--ink-2); font-weight: 600; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.dot.live { background: var(--green); box-shadow: 0 0 0 3px rgba(15, 107, 92, .16); }
.dot.busy { background: var(--ochre); box-shadow: 0 0 0 3px rgba(184, 121, 31, .18); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.wrap { padding: 22px 26px 46px; display: flex; flex-direction: column; gap: 18px; max-width: 1180px; }
/* 参数页把多个 panel 装在一个 form 里，这里补上同样的间距 */
.wrap > form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.checkline {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}

/* ------------------------------------------------------------------ 面板 */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 11px; box-shadow: var(--shadow); overflow: hidden;
}
.panel > header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(243, 240, 231, .55), transparent);
}
.panel > header h2 { margin: 0; font-size: 13.5px; font-weight: 700; letter-spacing: .02em; }
.panel > header .hint { font-size: 11.5px; color: var(--muted); }
.panel > header .spacer { flex: 1; }
.panel .body { padding: 16px; }
.panel .body.tight { padding: 0; }

/* ------------------------------------------------------------------ 指标 */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: 12px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 14px; box-shadow: var(--shadow);
}
.tile .lbl { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.tile .num {
  font-family: var(--mono); font-size: 24px; font-weight: 600; line-height: 1.15;
  letter-spacing: -.02em; margin-top: 4px; color: var(--ink);
}
.tile.accent { border-color: rgba(15, 107, 92, .3); background: linear-gradient(180deg, #f4faf7, var(--card)); }
.tile.warm { border-color: rgba(184, 121, 31, .3); background: linear-gradient(180deg, #fdf7ea, var(--card)); }

/* ------------------------------------------------------------------ 表单 */
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1 1 220px; }
.field label { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }
.field .note { font-size: 10.5px; color: var(--faint); }
/* 独立使用的标签（登录页等） */
.lbl { display: block; font-size: 11.5px; color: var(--muted); letter-spacing: .02em; margin: 0 0 6px; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; font: inherit; font-size: 13px; color: var(--ink);
  background: #fffefb; border: 1px solid var(--line-2); border-radius: 7px;
  padding: 8px 10px; outline: 0; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 104px; font-family: var(--mono); font-size: 12px; line-height: 1.65; }
input:focus, select:focus, textarea:focus {
  border-color: var(--green); box-shadow: 0 0 0 3px rgba(15, 107, 92, .12);
}
input::placeholder, textarea::placeholder { color: #b9b1a1; }
input[type="checkbox"] { accent-color: var(--green); width: 14px; height: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 15px; font: inherit; font-size: 13px; font-weight: 600;
  border-radius: 7px; border: 1px solid transparent; cursor: pointer;
  transition: transform .1s, filter .15s, background .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--green); color: #f6f3e9; box-shadow: 0 6px 14px -10px rgba(15, 107, 92, .9); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: #fffefb; border-color: var(--line-2); color: var(--ink-2); }
.btn.ghost:hover:not(:disabled) { background: var(--paper-2); }
.btn.danger { background: #fffaf8; border-color: rgba(168, 58, 44, .35); color: var(--red); }
.btn.danger:hover:not(:disabled) { background: var(--red-soft); }
.btn.sm { height: 29px; padding: 0 10px; font-size: 12px; border-radius: 6px; }

.actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ 分段 */
.seg { display: inline-flex; background: var(--paper-2); border-radius: 8px; padding: 3px; gap: 2px; }
.seg label {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
  font-size: 12.5px; color: var(--ink-2); font-weight: 500;
}
.seg input { display: none; }
.seg label.on { background: var(--card); box-shadow: 0 1px 3px rgba(63, 54, 32, .18); color: var(--green); font-weight: 600; }

/* ------------------------------------------------------------------ 选择器 */
.picker {
  border: 1px solid var(--line-2); border-radius: 8px; background: #fffefb;
  max-height: 236px; overflow: auto;
}
.picker .none { padding: 22px; text-align: center; color: var(--faint); font-size: 12.5px; }
.picker .rowline {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); font-size: 12.5px; cursor: pointer;
}
.picker .rowline:last-child { border-bottom: 0; }
.picker .rowline:hover { background: #faf7ee; }
.picker .rowline .rk { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .rowline .rm { color: var(--muted); font-family: var(--mono); font-size: 11px; }

/* ------------------------------------------------------------------ 进度 */
.bar { height: 6px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--green); transition: width .4s ease; }
.metrics { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.metrics b { font-family: var(--mono); color: var(--ink); font-size: 13px; font-weight: 600; }

/* ------------------------------------------------------------------ 日志 */
.log {
  margin: 0; padding: 12px 14px; background: #f7f4ec; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.75;
  height: auto; min-height: 52px; max-height: 236px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.log .l { display: block; color: var(--ink-2); }
.log .l .t { color: var(--faint); margin-right: 8px; }
.log .ok { color: var(--green); }
.log .err { color: var(--red); }
.log .warn { color: var(--ochre); }
.log .empty { color: var(--faint); }

/* ------------------------------------------------------------------ 表格 */
table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th, table.grid td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle;
}
table.grid th {
  font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .05em;
  background: #faf7ee;
}
/* 只有真正滚动容器的表头才吸顶，避免整页滚动时表头被顶栏盖住 */
.scroll-x table.grid th, .table-wrap table.grid th { position: sticky; top: 0; z-index: 1; }
table.grid tbody tr:hover { background: #faf8f1; }
table.grid td.mono { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
table.grid td.remark { font-weight: 600; }
table.grid .empty-row td { text-align: center; color: var(--faint); padding: 26px 12px; }
.scroll-x { overflow-x: auto; }

.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 21px;
  padding: 0 8px; border-radius: 5px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.tag.ok    { background: var(--green-soft); color: var(--green); }
.tag.warn  { background: var(--ochre-soft); color: var(--ochre); }
.tag.bad   { background: var(--red-soft);   color: var(--red); }
.tag.info  { background: var(--blue-soft);  color: var(--blue); }
.tag.plain { background: #ece5d4;          color: #5f594b; }

/* ------------------------------------------------------------------ 导入 */
.drop {
  border: 1.5px dashed var(--line-2); border-radius: 9px; padding: 18px;
  text-align: center; color: var(--muted); font-size: 12.5px;
  background: #fdfbf4; cursor: pointer; transition: .15s;
}
.drop:hover, .drop.over { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.drop b { display: block; font-size: 13px; color: var(--ink); margin-bottom: 3px; }
.drop.over b { color: var(--green); }

.fmt {
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
  background: #f7f4ec; border: 1px solid var(--line); border-radius: 7px;
  padding: 10px 12px; line-height: 1.8; overflow-x: auto;
}
.fmt em { color: var(--green); font-style: normal; }

.result-line { font-size: 12px; color: var(--muted); margin-top: 10px; }
.result-line b { color: var(--ink); }
.problems { margin: 8px 0 0; padding-left: 18px; font-size: 11.5px; color: var(--red); max-height: 96px; overflow: auto; }

/* ------------------------------------------------------------------ 提示 */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  z-index: 90; padding: 10px 18px; border-radius: 8px;
  background: var(--ink); color: #f8f5ec; font-size: 12.5px;
  box-shadow: 0 14px 34px -16px rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); }

footer.foot { padding: 0 26px 30px; font-size: 11px; color: var(--faint); }
footer.foot code { font-family: var(--mono); font-size: 10.5px; }

/* ------------------------------------------------------------------ 响应式 */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto; flex-direction: row; align-items: center;
    gap: 14px; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .rail .brand .sub { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav a { border-left: 0; border-bottom: 2px solid transparent; padding: 7px 10px; }
  .nav a[aria-current="page"] { border-left-color: transparent; border-bottom-color: var(--green); }
  .rail-foot { display: none; }
  .wrap, .topbar { padding-left: 15px; padding-right: 15px; }
  .topbar { position: static; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ==========================================================================
   客户端页面（客户只看到这一套）
   ========================================================================== */

body.site { background: var(--paper); }

.page {
  max-width: 780px; margin: 0 auto; padding: 34px 18px 52px;
  display: flex; flex-direction: column; gap: 16px;
}

.site-head { padding: 4px 2px 0; }
.site-brand { display: flex; align-items: center; gap: 13px; }
.site-brand .glyph {
  width: 42px; height: 42px; flex: 0 0 auto; border-radius: 11px;
  background: var(--green); color: #f7f4ea;
  display: grid; place-items: center;
  font: 700 18px/1 var(--serif); letter-spacing: .04em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .16);
}
.site-brand h1 { margin: 0; font-family: var(--serif); font-size: 21px; font-weight: 700; letter-spacing: .01em; }
.site-brand p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }

.site-notice {
  margin: 0; font-size: 12.5px; line-height: 1.7; color: var(--ink-2);
  background: #fbf7ea; border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 13px;
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.card.pad { padding: 16px; }

.tabs {
  display: flex; gap: 6px; background: var(--paper-2);
  padding: 4px; border-radius: 9px; margin-bottom: 16px;
}
.tabs .tab {
  flex: 1; height: 34px; border: 0; border-radius: 7px; background: transparent;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: .15s;
}
.tabs .tab:hover { color: var(--ink-2); }
.tabs .tab.on { background: var(--card); color: var(--green); box-shadow: 0 1px 3px rgba(63, 54, 32, .16); }

.pane .lbl { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.pane .hint { font-size: 11px; color: var(--faint); margin: 9px 0 0; line-height: 1.75; }
.pane .hint code, .drop code { font-family: var(--mono); font-size: 10.5px; color: var(--ink-2); background: rgba(33,31,26,.05); padding: 1px 4px; border-radius: 4px; }

#token-single { height: 44px; font-family: var(--mono); font-size: 12.5px; }
#token-batch { min-height: 124px; }

.drop { margin-top: 12px; }

.btn.block { width: 100%; height: 42px; margin-top: 14px; font-size: 14px; }

.run-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.run-head h2 { margin: 0; font-family: var(--serif); font-size: 15px; font-weight: 700; }
.run-state { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.run-state.live { color: var(--green); font-weight: 600; }
.run-state.done { color: var(--muted); }

.run-body { padding: 14px 16px 16px; }
.run-body .metrics { margin-top: 10px; }
.run-actions { display: flex; gap: 9px; margin-top: 14px; align-items: center; }
.run-actions a.btn { text-decoration: none; }

.site .log { height: auto; min-height: 0; max-height: 200px; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; }

.table-wrap { max-height: 360px; overflow: auto; border-top: 1px solid var(--line); }
.table-wrap table.grid th { top: 0; }

.site-foot {
  font-size: 11px; color: var(--faint); text-align: center; line-height: 1.9; padding-top: 4px;
}

.site .toast { z-index: 90; }

@media (max-width: 560px) {
  .page { padding: 22px 13px 40px; }
  .site-brand h1 { font-size: 18px; }
  .card.pad { padding: 13px; }
  .run-body { padding: 12px 13px 14px; }
}
