/* ==========================================================================
   客户门户（报价目录）—— 样式
   --------------------------------------------------------------------------
   设计逻辑和后台（public/css/app.css）**保持一致**：
     同一套色彩令牌、同一套面板（.panel）/统计卡（.stat-row）/表单字段（.field）
     /表格（table.grid）/分页（.pager）/提示条（.toast）。
   后台只有夜间；门户多了个白天模式，用 :root[data-theme="light"] 覆盖同一批令牌，
   所以组件规则不用写两遍 —— 这也正是"令牌化"的意义。
   ========================================================================== */

:root {
  /* —— 和后台完全同名同值。改颜色请两边一起改，别在这里另起一套 —— */
  --bg: #0f1115;
  --bg-soft: #161923;
  --bg-panel: #1b1f2b;
  --bg-hover: #232838;
  --bg-input: #12151d;
  --line: #2a3041;
  --line-soft: #232838;
  --text: #e6e9f0;
  --text-dim: #98a1b5;
  --text-mute: #6d768c;
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, .15);
  --accent-2: #34d399;
  --warn: #f59e0b;
  --danger: #ef4444;
  /* 新史低用高饱和亮黄、新上架用绿 —— 和后台价格高亮同一套语义 */
  --low: #ffe100;
  --new: #4ade80;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .4);
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "SF Mono", Menlo, monospace;

  /* 门户自己的补充：表头底色、内容最大宽度、三种状态标签的配色 */
  --head: #171b25;
  --shell: 1260px;
  --tone-ok-bg: #1c3327;
  --tone-ok-fg: #6fdca8;
  --tone-ok-line: #2a4d3a;
  --tone-info-bg: #1b3540;
  --tone-info-fg: #7fd4e8;
  --tone-info-line: #27505e;
  --tone-mute-bg: #2a2a30;
  --tone-mute-fg: #8b93a5;
  --tone-mute-line: #3a3a44;
  --tone-zone-bg: #24304a;
  --tone-zone-fg: #9dbcf5;
  --tone-zone-line: #33436a;
  color-scheme: dark;
}

/* ---- 白天：只覆盖令牌，不动组件规则 ---- */
:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-soft: #eef1f6;
  --bg-panel: #ffffff;
  --bg-hover: #eef2f8;
  --bg-input: #ffffff;
  --line: #dbe2ec;
  --line-soft: #e7ecf3;
  --text: #0f172a;
  --text-dim: #475569;
  --text-mute: #64748b;
  --accent: #1d6fd0;
  --accent-soft: rgba(29, 111, 208, .12);
  --accent-2: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  /* 纯黄在浅底上对比度不够（1.4:1），换深琥珀；仍是"黄系"，语义不变 */
  --low: #a16207;
  --new: #15803d;
  --shadow: 0 8px 28px rgba(15, 23, 42, .12);
  --head: #f1f5f9;
  --tone-ok-bg: #e7f7ee;
  --tone-ok-fg: #15803d;
  --tone-ok-line: #bfe8d0;
  --tone-info-bg: #e6f2fb;
  --tone-info-fg: #1d6fd0;
  --tone-info-line: #c3ddf3;
  --tone-mute-bg: #eef1f6;
  --tone-mute-fg: #64748b;
  --tone-mute-line: #dbe2ec;
  --tone-zone-bg: #e8eefb;
  --tone-zone-fg: #1d4ed8;
  --tone-zone-line: #c7d6f5;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* 作者样式里的 display 会盖掉浏览器给 [hidden] 的 display:none（UA 优先级最低），
   所以「登录后藏起登录卡」这类事必须显式兜住。 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }

/* ------------------------------------------------------------------ 顶栏 */

.topbar {
  background: linear-gradient(180deg, #1a1e29, #14171f);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
:root[data-theme="light"] .topbar { background: linear-gradient(180deg, #ffffff, #f4f6fa); }

.topbar-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 24px; height: 24px; flex: 0 0 auto; color: var(--accent); }
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--text-mute); white-space: nowrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* 主题开关：长得像后台的 .btn.btn-ghost.btn-sm */
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.theme-btn:hover { background: var(--bg-hover); color: var(--text); }
.theme-btn .ico { width: 14px; height: 14px; }
/* 夜间模式显示「太阳」（点它变成白天），白天显示「月亮」 */
.ico-sun { display: none; }
:root[data-theme="light"] .ico-sun { display: inline-block; }
:root[data-theme="light"] .ico-moon { display: none; }

/* ------------------------------------------------------------------ 布局 */

.shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 16px 18px 40px;
}

/* ------------------------------------------------------------- 统计卡片 */

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
/* 门户只有 4 张卡，铺满整行才不至于右边空一大块 */
.stat {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 13px;
  flex: 1 1 0;
  min-width: 132px;
}
.stat-label { font-size: 11px; color: var(--text-mute); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { font-size: 19px; font-weight: 700; font-family: var(--mono); letter-spacing: -.5px; white-space: nowrap; }
.stat-value.accent { color: var(--accent); }
.stat-value.good { color: var(--accent-2); }
.stat-value.low { color: var(--low); }
.stat-value.new { color: var(--new); }

/* ------------------------------------------------------------------ 面板 */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: clip;              /* 收掉表格直角，别顶破圆角 */
}
/* 筛选面板要漏出来（里面可能有下拉面板），别被 clip 切掉 */
.panel-filter { overflow: visible; position: relative; z-index: 5; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.panel-title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.count-inline { font-size: 12px; font-weight: 400; color: var(--text-mute); }
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.result-note { font-size: 11.5px; color: var(--text-mute); }

/* ---------------------------------------------------------------- 表单 */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 14px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 11px; color: var(--text-mute); }
.field.grow { flex: 1 1 220px; }
.field.f-wide { flex: 1 1 180px; max-width: 260px; }
.field.f-sm { flex: 0 1 110px; max-width: 130px; }
.field-flags { flex: 0 0 auto; }

input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
  min-width: 0;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--text-mute); }
select { cursor: pointer; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: #2b3145; border-color: #3a4256; }
:root[data-theme="light"] .btn:hover:not(:disabled) { background: #e3e9f2; border-color: #c8d2e0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: #4c7fe0; border-color: #4c7fe0; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn .ico { width: 14px; height: 14px; flex: 0 0 auto; }

/* --------------------------------------------------- 新史低 / 新上架开关 */

.toggles { display: flex; align-items: center; gap: 6px; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.toggle:hover { border-color: #3a4256; color: var(--text); }
/* 选中：反色，用语义色描边 —— 颜色本身就是"这是史低/新上架"的提示 */
.toggle[aria-pressed="true"] { color: var(--text); font-weight: 600; }
.toggle#flagLow[aria-pressed="true"] { background: rgba(255, 225, 0, .14); border-color: rgba(255, 225, 0, .5); }
.toggle#flagNew[aria-pressed="true"] { background: rgba(74, 222, 128, .13); border-color: rgba(74, 222, 128, .45); }
:root[data-theme="light"] .toggle#flagLow[aria-pressed="true"] { background: rgba(161, 98, 7, .12); border-color: rgba(161, 98, 7, .45); }
:root[data-theme="light"] .toggle#flagNew[aria-pressed="true"] { background: rgba(21, 128, 61, .1); border-color: rgba(21, 128, 61, .4); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.dot-low { background: var(--low); }
.dot-new { background: var(--new); }
.toggle-count { font-family: var(--mono); font-size: 11px; color: var(--text-mute); }

/* --------------------------------------------------------- 勾选复制条 */

.pick-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick-count { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.pick-count b { font-family: var(--mono); color: var(--accent); font-size: 13px; }

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

.table-wrap { overflow: auto; }

table.grid {
  width: 100%;
  table-layout: fixed;          /* 两列游戏名等宽靠它（都不写宽度就会平分） */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--head);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
table.grid tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
/* 整行可点：指针暗示可以点，点哪儿都算勾选 */
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: var(--bg-hover); }
table.grid tbody tr.is-picked { background: var(--accent-soft); }
table.grid tbody tr:last-child td { border-bottom: none; }

/* 列宽：和后台一个思路 —— 固定的给死数，两列游戏名都不写宽度 = 平分 */
.c-check { width: 34px; }
.c-id { width: 74px; text-align: right; }
.c-zone { width: 96px; }
.c-pub { width: 150px; }
.c-act { width: 176px; }
.c-price { width: 132px; }
.c-game, .c-game-zh { overflow-wrap: anywhere; }
td.c-id { font-family: var(--mono); font-size: 11.5px; color: var(--text-mute); }
/* 价格居中。要带 table.grid 前缀，否则压不过 table.grid thead th 的 text-align:left */
table.grid th.c-price, table.grid td.c-price { text-align: center; }
.c-check input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

/* 游戏名两列：中文名比英文名重一点，客户先看中文 */
.game-zh { font-size: 13px; color: var(--text); }
.game-zh.none { color: var(--text-mute); opacity: .55; }
.game-title { color: var(--text-dim); }

/* 标签 / 状态 */
.tag, .status, .zone-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.zone-tag, .tag-zone { background: var(--tone-zone-bg); color: var(--tone-zone-fg); border: 1px solid var(--tone-zone-line); }
.status-active { background: var(--tone-ok-bg); color: var(--tone-ok-fg); border: 1px solid var(--tone-ok-line); }
.status-upcoming { background: var(--tone-info-bg); color: var(--tone-info-fg); border: 1px solid var(--tone-info-line); }
.status-ended { background: var(--tone-mute-bg); color: var(--tone-mute-fg); border: 1px solid var(--tone-mute-line); }
/* 没登记档期的：一个短横就够，别做成徽标（那是"没有信息"，不是一种状态） */
.act-none { color: var(--text-mute); }
.act-period { display: block; margin-top: 3px; font-family: var(--mono); font-size: 10.5px; color: var(--text-mute); }

/* 徽标：新史低 / 新上架 */
.badge {
  display: inline-block;
  margin-top: 3px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.6;
}
.badge-low { color: var(--low); background: rgba(255, 225, 0, .17); box-shadow: inset 0 0 0 1px rgba(255, 225, 0, .42); }
.badge-new { color: var(--new); background: rgba(74, 222, 128, .13); box-shadow: inset 0 0 0 1px rgba(74, 222, 128, .32); }
:root[data-theme="light"] .badge-low { background: rgba(161, 98, 7, .12); box-shadow: inset 0 0 0 1px rgba(161, 98, 7, .4); }
:root[data-theme="light"] .badge-new { background: rgba(21, 128, 61, .1); box-shadow: inset 0 0 0 1px rgba(21, 128, 61, .35); }

/* 价格：等宽字体，双币时第二行小一号 */
.price { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.price-2 { display: block; font-size: 11px; font-weight: 400; color: var(--text-mute); }
.price-none { color: var(--text-mute); font-weight: 400; }
.id-num { font-family: var(--mono); font-size: 11.5px; color: var(--text-mute); }
.pub-name { font-size: 12.5px; color: var(--text-dim); }

/* --------------------------------------------------------------- 空状态 */

.empty { text-align: center; padding: 40px 20px 46px; color: var(--text-mute); }
.empty-ico { width: 32px; height: 32px; opacity: .55; margin-bottom: 10px; }
.empty p { margin: 0; font-size: 13px; }

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

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.pager-info { font-size: 12px; color: var(--text-mute); }

.legal { margin: 14px 2px 0; font-size: 11.5px; color: var(--text-mute); }

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 400px;
  animation: toastIn .18s ease-out;
}
.toast.ok { border-color: var(--tone-ok-line); color: var(--tone-ok-fg); }
.toast.err { border-color: #5a2a2a; color: #ffc4c4; }
:root[data-theme="light"] .toast.err { border-color: #f3c4c4; color: #b91c1c; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

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

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 18px;
}
.login-theme { position: fixed; top: 14px; right: 16px; }
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
}
.login-card .brand { margin-bottom: 18px; }
.login-title { font-size: 19px; margin: 0 0 18px; letter-spacing: -.2px; }
.login-card .field { margin-bottom: 12px; }
.form-error {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .4);
  color: #ffc4c4;
  font-size: 12.5px;
}
:root[data-theme="light"] .form-error { background: #fdecec; border-color: #f3c4c4; color: #b91c1c; }

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

/* 窗口变窄时先收掉次要列，别让表格横向溢出 */
@media (max-width: 980px) {
  .c-pub { display: none; }
  .field.f-wide, .field.f-sm { max-width: none; flex: 1 1 140px; }
}
@media (max-width: 760px) {
  .shell { padding: 12px 12px 32px; }
  .topbar-inner { padding: 10px 12px; gap: 10px; }
  .brand-sub { display: none; }
  .c-act { width: 132px; }
  .c-id { width: 58px; }
  .result-note { display: none; }
  .stat { flex: 1 1 120px; min-width: 110px; }
  .stat-value { font-size: 17px; }
}
@media (max-width: 560px) {
  .c-zone { width: 78px; }
  .field-flags { flex: 1 1 100%; }
  .toggles { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media print {
  .topbar-right, .panel-filter, .pager, .toast, .c-check, .legal { display: none !important; }
  :root, :root[data-theme="light"] {
    --bg: #fff; --bg-panel: #fff; --bg-input: #fff; --text: #000; --text-dim: #333;
    --text-mute: #555; --line: #ccc; --line-soft: #ddd; --head: #f2f2f2;
  }
  .panel { break-inside: auto; }
}
