/* ========================================
   TheMindFlayer Design System v2.0
   现代科技感 · 深色优先 · 高信息密度
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');

/* ========================================
   CSS Variables - Design Tokens
   ======================================== */

:root {
  color-scheme: dark;
  --bg: #0a0e1a;
  --bg-secondary: #0f1419;
  --surface: #1e293b;
  --surface-hover: #293548;
  --surface-secondary: #162236;
  --surface-subtle: #1a2332;
  --surface-strong: #334155;
  --brand: #14b8a6;
  --brand-hover: #0d9488;
  --brand-light: #2dd4bf;
  --brand-soft: rgba(20, 184, 166, 0.1);
  --brand-glow: rgba(20, 184, 166, 0.2);
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.1);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-soft: rgba(239, 68, 68, 0.1);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.1);
  --info: #06b6d4;
  --info-soft: rgba(6, 182, 212, 0.1);
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-soft: #94a3b8;
  --text-faint: #64748b;
  --text-muted: #475569;
  --line: rgba(148, 163, 184, 0.1);
  --line-strong: rgba(148, 163, 184, 0.2);
  --line-emphasis: rgba(148, 163, 184, 0.3);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-brand: 0 0 20px rgba(20, 184, 166, 0.3);
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(148, 163, 184, 0.1);
  --glass-blur: blur(12px);
  --radius-sm: 4px;
  --radius: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  --content: 1280px;
  --sidebar-width: 260px;
  --on-brand: #ffffff;
  --on-danger: #ffffff;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-secondary: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --surface-secondary: #f1f5f9;
  --surface-subtle: #e2e8f0;
  --surface-strong: #cbd5e1;
  --brand: #0d9488;
  --brand-hover: #0f766e;
  --brand-light: #14b8a6;
  --brand-soft: rgba(13, 148, 136, 0.1);
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-soft: #64748b;
  --text-faint: #94a3b8;
  --text-muted: #cbd5e1;
  --line: rgba(51, 65, 85, 0.1);
  --line-strong: rgba(51, 65, 85, 0.15);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-brand: 0 0 20px rgba(13, 148, 136, 0.2);
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(51, 65, 85, 0.1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

/* 上面的 * { margin: 0 } 是作者样式，会盖掉浏览器默认的 dialog { margin: auto }，
   于是所有 showModal() 弹窗都被钉在左上角。这里把居中还回来。 */
dialog {
  margin: auto;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

::selection {
  background: var(--brand-soft);
  color: var(--text);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 16px;
}

h1 { font-size: 40px; font-weight: 900; }
h2 { font-size: 32px; }
h3 { font-size: 24px; }
h4 { font-size: 20px; }
h5 { font-size: 18px; }
h6 { font-size: 16px; }

p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color 150ms ease;
}

a:hover { color: var(--brand-light); }
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

code, kbd {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
  font-feature-settings: "tnum";
}

strong { font-weight: 600; color: var(--text); }
small { font-size: 13px; color: var(--text-soft); }

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand);
  margin-bottom: 12px;
  display: block;
}

.eyebrow--light { color: var(--brand-light); }

.text-link {
  color: var(--brand);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.text-link:hover { color: var(--brand-light); }

.muted {
  color: var(--text-faint);
  font-style: italic;
}

/* Layout */
.container {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 24px;
}

.grid {
  display: grid;
  gap: 16px;
}

.span-2 { grid-column: span 2; }

/* Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--brand);
  color: white;
  padding: 8px 16px;
  z-index: 100;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  top: 0;
}

/* Buttons */
.button, button[type="button"], button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-hover) 100%);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 200ms ease;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.button:hover, button[type="button"]:hover, button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--shadow-brand);
}

.button:active, button:active { transform: scale(0.98); }

.button:disabled, button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* 下面每个变体都是单类选择器（0,1,0），比基础样式里的 `button[type="button"]`
   （0,1,1）少一分特指度，所以写在 <button type="button"|"submit"> 上时会被基础
   样式整条压回主色按钮——背景、文字色、内边距全都白写。每条变体补一个 `button.`
   前缀的版本凑到同分，靠写在后面赢；`.button` 用在 <a> 上时仍走单类那条。
   没写 type 属性的裸 <button> 不匹配属性选择器，本来就没这个问题。 */
.button--secondary, .secondary-button,
button.button--secondary, button.secondary-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.button--secondary:hover, .secondary-button:hover,
button.button--secondary:hover, button.secondary-button:hover {
  background: var(--surface-hover);
  border-color: var(--brand);
  color: var(--brand);
}

.button--danger, .danger,
button.button--danger, button.danger {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-hover) 100%);
  color: var(--on-danger);
}

/* Explicit primary — same as the default button, kept for templates that
   spell the modifier out alongside .button */
.button--primary,
button.button--primary {
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-hover) 100%);
  border: none;
}

.button--large,
button.button--large {
  min-height: 52px;
  padding: 0 32px;
  font-size: 15px;
}

.button--small,
button.button--small {
  min-height: 36px;
  padding: 0 16px;
  font-size: 13px;
}

.button--quiet,
button.button--quiet {
  background: transparent;
  color: var(--text-soft);
  box-shadow: none;
  padding: 0 12px;
}

/* 幽灵按钮不跟基础样式一起上浮、发主色光：透明底上浮出一片青绿投影很怪。 */
.button--quiet:hover,
button.button--quiet:hover {
  color: var(--text);
  background: var(--surface-hover);
  box-shadow: none;
  transform: none;
}

/* Cards & Panels */
.card, .glass-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: all 200ms ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-color: var(--glass-border);
}

.card--compact {
  padding: 16px;
}

.card--highlight {
  border-color: var(--brand);
  box-shadow: var(--shadow), 0 0 0 1px var(--brand-soft);
}

/* Badges & Pills */
.badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1;
  white-space: nowrap;
}

.badge {
  background: var(--surface-secondary);
  color: var(--text-secondary);
}

.pill {
  background: var(--success-soft);
  color: var(--success);
}

.pill.disabled, .pill.inactive {
  background: var(--text-muted);
  color: var(--text-faint);
}

.pill.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.pill.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.user-level {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.user-level--none { color: var(--text-soft); background: var(--surface-secondary); border-color: var(--line-strong); }
.user-level--day { color: #0c4a6e; background: #e0f2fe; border-color: #7dd3fc; }
.user-level--week { color: #065f46; background: #d1fae5; border-color: #6ee7b7; }
.user-level--month { color: #5b21b6; background: #ede9fe; border-color: #c4b5fd; }
.user-level--quarter { color: #92400e; background: #fef3c7; border-color: #fcd34d; }
.user-level--year { color: #9f1239; background: #ffe4e6; border-color: #fda4af; }

:root[data-theme="dark"] .user-level--day { color: #bae6fd; background: rgba(14, 116, 144, .24); border-color: #0e7490; }
:root[data-theme="dark"] .user-level--week { color: #a7f3d0; background: rgba(4, 120, 87, .24); border-color: #047857; }
:root[data-theme="dark"] .user-level--month { color: #ddd6fe; background: rgba(109, 40, 217, .24); border-color: #6d28d9; }
:root[data-theme="dark"] .user-level--quarter { color: #fde68a; background: rgba(180, 83, 9, .24); border-color: #b45309; }
:root[data-theme="dark"] .user-level--year { color: #fecdd3; background: rgba(190, 24, 93, .24); border-color: #be185d; }

.campaign-card {
  margin: 20px 0;
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-secondary);
}

.campaign-card h3 { margin-bottom: 6px; }
.campaign-card p { margin-bottom: 0; }
.campaign-grid { margin-top: 16px; }
.campaign-level-checks { display: grid; gap: 4px; margin-top: 4px; }
.campaign-level-checks .check-row { margin-top: 0; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.check-row input { width: 18px; min-height: 18px; }
.campaign-preview { margin-top: 16px; padding: 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.campaign-user-list { display: grid; gap: 6px; margin-top: 10px; color: var(--text-secondary); }

.protocol-recipe-table table { min-width: 940px; }
.protocol-recipe-levels { display: grid; gap: 4px; }
.protocol-recipe-levels .check-row { margin-top: 0; }
.protocol-recipe-users-cell { min-width: 170px; }
.protocol-recipe-users-open {
  min-height: 36px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface-secondary);
  border: 1px solid var(--line-strong);
}
.protocol-recipe-users-open:hover:not(:disabled) { background: var(--surface-hover); }
.protocol-recipe-users-summary { display: block; margin-top: 6px; color: var(--text-soft); }
#protocolRecipesStatus { margin-top: 12px; }
.positive-duration { color: var(--success); }
.negative-duration { color: var(--danger); }
/* 详情弹窗设备表里的强制解绑按钮：比默认表格按钮矮一点，免得把行高撑开。 */
.admin-panel #tmfDetailMachineRows .tmf-machine-unbind-btn {
  min-height: 34px;
  padding: 0 10px;
}

.history-dialog {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  margin: auto;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
}

.history-dialog::backdrop { background: rgba(2, 6, 23, .72); backdrop-filter: blur(4px); }
.history-dialog__surface { padding: 24px; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xl); overflow: auto; }

.password-dialog {
  width: min(520px, calc(100vw - 32px));
  margin: auto;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
}

.password-dialog::backdrop { background: rgba(2, 6, 23, .72); backdrop-filter: blur(4px); }
.password-dialog__surface { display: grid; gap: 16px; padding: 24px; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xl); }
.password-dialog__surface .section-head { margin-bottom: 0; }
.password-dialog__surface .toolbar { justify-content: flex-end; }

.protocol-user-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background: transparent;
  border: 0;
}

.protocol-user-dialog::backdrop { background: rgba(2, 6, 23, .72); backdrop-filter: blur(4px); }
.protocol-user-dialog__surface {
  display: grid;
  grid-template-rows: auto auto auto minmax(240px, 1fr) auto;
  gap: 16px;
  max-height: calc(100vh - 32px);
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
}
.protocol-user-dialog__surface .section-head { margin-bottom: 0; }
.protocol-user-dialog__filters {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(4, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}
.protocol-user-dialog__filters .field { margin: 0; }
.protocol-user-dialog__actions,
.protocol-user-dialog__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.protocol-user-dialog__table { min-height: 240px; overflow: auto; }
.protocol-user-dialog__table table { min-width: 760px; }
.protocol-user-dialog__checkbox { width: 18px; min-height: 18px; }
.protocol-user-dialog__footer > div:first-child { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

@media (max-width: 820px) {
  .protocol-user-dialog__surface {
    grid-template-rows: auto auto auto minmax(180px, 1fr) auto;
    padding: 16px;
  }
  .protocol-user-dialog__filters { grid-template-columns: 1fr 1fr; }
  .protocol-user-dialog__search { grid-column: 1 / -1; }
  .protocol-user-dialog__actions,
  .protocol-user-dialog__footer { align-items: stretch; }
}

@media (max-width: 560px) {
  .protocol-user-dialog__surface { overflow-y: auto; }
  .protocol-user-dialog__filters { grid-template-columns: 1fr; }
  .protocol-user-dialog__search { grid-column: auto; }
  .protocol-user-dialog__table { min-height: 0; }
  .protocol-user-dialog__table table { min-width: 0; }
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-soft);
}

.status::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.status.inactive::before {
  background: var(--text-muted);
}

/* Forms */
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface-secondary);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: all 150ms ease;
}

textarea {
  padding: 12px 16px;
  min-height: 88px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

input:disabled, select:disabled, textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input[type="search"] {
  padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 18px;
}

select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 12px) center;
  background-size: 18px;
  appearance: none;
  cursor: pointer;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.hint {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 4px;
}

.duration-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.duration-grid label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.duration-grid label input {
  flex: 1;
  min-width: 0;
}

.duration-grid span {
  flex: 0 0 auto;
  min-width: 30px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Progress */
.progress {
  height: 12px;
  background: var(--surface-secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent) 100%);
  border-radius: var(--radius-full);
  transition: width 300ms ease;
}

.progress-bar.indeterminate {
  width: 40%;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--surface-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--line-strong);
}

td {
  padding: 12px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}

tbody tr:hover {
  background: var(--surface-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

td code {
  font-size: 12px;
  padding: 2px 6px;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.list-toolbar {
  padding: 16px 0;
}

/* 只对直接摆在工具条里的搜索框生效。包在 .field（纵向 flex）里时主轴是竖的，
   flex-basis: 240px 会变成 240px 高，把输入框撑成一个方块。 */
.list-toolbar > input[type="search"] {
  flex: 1 1 240px;
  width: auto;
  min-width: 0;
}

/* 带 label 的搜索框，让外层 .field 去抢宽度，输入框自己保持 width: 100%。 */
.list-toolbar > .field:has(> input[type="search"]) {
  flex: 1 1 240px;
  min-width: 0;
}

.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 16px 0;
}

/* 批量操作条：没选东西时保持在页面上但压低存在感，
   避免出现/消失把下面的表格顶来顶去。 */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-secondary);
  opacity: 0.65;
}

.batch-bar--active {
  opacity: 1;
  border-color: var(--line-strong);
}

.batch-bar__count {
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

.batch-bar--active .batch-bar__count {
  color: var(--text);
  font-weight: 600;
}

/* 复选框列：按内容收窄，别让它跟着表格平分宽度。 */
th.select-col,
td.select-col {
  width: 36px;
  padding-right: 0;
  text-align: center;
}

.select-col input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  cursor: pointer;
}

/* Modal/Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Segmented Control */
.segmented-control {
  display: inline-flex;
  background: var(--surface-secondary);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}

.segmented-control button {
  min-height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: all 150ms ease;
}

.segmented-control button:hover {
  color: var(--text);
}

.segmented-control button[aria-pressed="true"],
.segmented-control button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Tabs */
.tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 150ms ease;
  text-align: left;
  width: 100%;
}

.tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.tab.active {
  background: var(--brand);
  color: var(--on-brand);
}

/* Navigation */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
  max-width: var(--content);
  margin: 0 auto;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.navbar-nav a {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 150ms ease;
}

.navbar-nav a:hover {
  color: var(--text);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  font-weight: 900;
}

/* Hero Section */
.hero {
  position: relative;
  padding: 120px 24px 80px;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -25%;
  width: 150%;
  height: 150%;
  background: radial-gradient(circle at 30% 40%, rgba(56, 189, 248, 0.15) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(20, 184, 166, 0.12) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero-content {
  max-width: var(--content);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  align-items: center;
}

.hero-text h1 {
  font-size: 64px;
  font-weight: 900;
  line-height: 1.05;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-text p {
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-visual {
  position: relative;
}

.hero-visual img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--line);
}

/* Feature Grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  padding: 80px 24px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: all 200ms ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand);
}

.feature-icon {
  width: 48px;
  height: 48px;
  background: var(--brand-soft);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--brand);
}

.feature-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 14px;
  color: var(--text-soft);
  margin: 0;
}

/* Showcase Cards */
.showcase-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 80px 24px;
  max-width: var(--content);
  margin: 0 auto;
}

.showcase-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px;
  overflow: hidden;
}

.showcase-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--brand-glow) 0%, transparent 70%);
  pointer-events: none;
}

.showcase-card h2 {
  font-size: 32px;
  margin-bottom: 16px;
}

.showcase-card p {
  font-size: 16px;
  margin-bottom: 24px;
}

.showcase-features {
  list-style: none;
  margin-bottom: 32px;
}

.showcase-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.showcase-features li::before {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 50%;
  font-weight: 700;
  flex-shrink: 0;
}

/* Workflow Steps */
.workflow {
  padding: 80px 24px;
  background: var(--surface-subtle);
}

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 32px;
  max-width: var(--content);
  margin: 0 auto;
  position: relative;
}

.workflow-step {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 32px 24px;
  text-align: center;
}

.workflow-number {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  border-radius: 50%;
  color: white;
  font-size: 24px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.workflow-step h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.workflow-step p {
  font-size: 14px;
  color: var(--text-soft);
  margin: 0;
}

/* Admin Layout */
.admin-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-sidebar .brand {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.admin-nav {
  padding: 16px;
  flex: 1;
}

.admin-sidebar__footer {
  padding: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-logout {
  width: 100%;
  justify-content: center;
}

.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-topbar__title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-topbar h1 {
  font-size: 24px;
  margin: 0;
}

button.admin-mobile-toggle {
  display: none;
}

.admin-content {
  flex: 1;
  min-width: 0;
  padding: 24px;
  background: var(--bg-secondary);
}

.admin-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.admin-panel h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

.admin-panel form {
  margin-bottom: 24px;
}

.admin-panel form .grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 24px;
}

.admin-panel.active {
  display: block;
}

/* Screenshot Gallery */
.screenshot-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.screenshot-card {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm, 0 10px 30px rgba(0, 0, 0, 0.18));
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.screenshot-card:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong, var(--line));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.screenshot-card img {
  display: block;
  width: 100%;
  height: auto;
  border-bottom: 1px solid var(--line);
}

.screenshot-card figcaption {
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
}

@media (max-width: 1023px) {
  .screenshot-gallery {
    grid-template-columns: 1fr;
    max-width: 640px;
    margin: 0 auto;
  }
}

/* World Scan Layout */
.world-scan-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  padding: 24px;
  max-width: var(--content);
  margin: 0 auto;
}

.scan-form-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
}

.scan-form-panel h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

.scan-form-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.scan-status-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
}

.scan-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.metric-card {
  background: var(--surface-secondary);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--brand);
  font-feature-settings: "tnum";
  margin-bottom: 4px;
}

.metric-label {
  font-size: 13px;
  color: var(--text-soft);
}

.scan-history-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
}

/* Player Detail */
.player-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.player-metric {
  background: var(--surface-secondary);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.player-metric dt {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.player-metric dd {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  font-feature-settings: "tnum";
}

/* Activation Entry */
.activation-entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  font-size: 13px;
}

.activation-entry:not(:last-child) {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 4px;
}

.activation-entry code {
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  padding: 0;
  color: var(--text);
}

.activation-meta {
  color: var(--text-soft);
  font-size: 12px;
}

.activation-live {
  color: var(--success);
  font-weight: 600;
}

.activation-expired {
  color: var(--danger);
  font-weight: 600;
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  top: -30%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle at 40% 30%, rgba(56, 189, 248, 0.12) 0%, transparent 50%),
              radial-gradient(circle at 60% 70%, rgba(20, 184, 166, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.login-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-xl);
}

.login-box h1 {
  text-align: center;
  margin-bottom: 32px;
  font-size: 32px;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-box button[type="submit"] {
  width: 100%;
  margin-top: 12px;
}

/* Responsive Design */

/* Desktop Large (1280px+) */
@media (min-width: 1280px) {
  .world-scan-layout {
    grid-template-columns: 2fr 3fr;
  }

  .scan-left {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }

  .admin-panel form .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) {
  .hero-content {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .hero-text h1 {
    font-size: 48px;
  }

  .showcase-dual {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 300ms ease;
    box-shadow: var(--shadow-xl);
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  button.admin-mobile-toggle {
    display: inline-flex;
  }

  .admin-topbar h1 {
    font-size: 20px;
  }

  .world-scan-layout {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 10px 12px;
  }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
  body {
    font-size: 13px;
  }

  .container {
    padding: 0 16px;
  }

  h1 { font-size: 32px; }
  h2 { font-size: 24px; }
  h3 { font-size: 20px; }

  .hero {
    padding: 80px 16px 60px;
  }

  .hero-text h1 {
    font-size: 36px;
  }

  .hero-text p {
    font-size: 16px;
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-actions .button {
    width: 100%;
  }

  .feature-grid {
    grid-template-columns: 1fr;
    padding: 60px 16px;
  }

  .showcase-dual {
    grid-template-columns: 1fr;
    padding: 60px 16px;
  }

  .showcase-card {
    padding: 24px;
  }

  .workflow {
    padding: 60px 16px;
  }

  .workflow-steps {
    grid-template-columns: 1fr;
  }

  .navbar-nav {
    display: none;
  }

  .admin-content {
    padding: 16px;
  }

  .admin-panel {
    padding: 16px;
  }

  .admin-panel form .grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    padding: 12px 16px;
  }

  .admin-topbar__title {
    flex: 1;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .button,
  .toolbar input {
    width: 100%;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar input,
  .filter-bar .button {
    width: 100%;
  }

  .table-wrap {
    border: none;
  }

  table {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: block;
  }

  tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 16px;
    padding: 16px;
  }

  td {
    display: block;
    padding: 8px 0;
    border: none;
    text-align: left;
  }

  td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-soft);
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
  }

  td:last-child {
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 8px;
  }

  td:last-child button {
    flex: 1;
  }

  /* 卡片布局把每个单元格摊成一行，复选框列如果还是 36px 居中，
     就是卡片顶上一个没有说明的孤零零方块。给它排在行首并补个标签。 */
  td.select-col {
    width: auto;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  td.select-col::before {
    content: "选择";
    margin-bottom: 0;
  }

  .modal {
    max-width: 100%;
    border-radius: var(--radius-md);
  }

  .modal-header,
  .modal-content,
  .modal-footer {
    padding: 16px;
  }

  .scan-status-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .player-detail {
    grid-template-columns: 1fr;
  }

  .duration-grid {
    grid-template-columns: 1fr;
  }

  .login-box {
    padding: 24px;
  }

  .login-box h1 {
    font-size: 24px;
  }
}

/* Print Styles */
@media print {
  .navbar,
  .admin-sidebar,
  .admin-topbar,
  .button,
  .toolbar {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

.w-full {
  width: 100%;
}

/* Loading States */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Focus Visible Enhancement */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

button:focus-visible,
.button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Smooth Scrolling */
html {
  scroll-padding-top: 80px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --line: rgba(148, 163, 184, 0.3);
    --line-strong: rgba(148, 163, 184, 0.5);
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ========================================
   Compatibility layer — rules for components still in use.
   Restored from v1 and re-pointed at v2 design tokens.
   ======================================== */

.form-grid,
.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.alert {
    display: none;
    margin-top: 14px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13px;
}

.alert.show,
.alert.is-visible {
    display: block;
}

.alert--error,
.error {
    border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
    background: var(--danger-soft);
    color: var(--danger);
}

.alert--success,
.result {
    border-color: color-mix(in srgb, var(--success) 36%, var(--line));
    background: var(--success-soft);
    color: var(--text);
}

.alert--warning {
    border-color: color-mix(in srgb, var(--warning) 40%, var(--line));
    background: var(--warning-soft);
    color: var(--warning);
}

.alert--info {
    border-color: color-mix(in srgb, var(--info) 40%, var(--line));
    background: var(--info-soft);
    color: var(--text);
}

.badge--info {
    background: var(--info-soft);
    color: var(--info);
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.section-heading h1,
.section-heading h2,
.section-heading h3 {
    margin-bottom: 4px;
}

.section-heading p {
    margin-bottom: 0;
    color: var(--text-soft);
}

.empty-state {
    padding: 32px 18px;
    color: var(--text-soft);
    text-align: center;
}

.segmented-control button.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.toast-region {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1200;
    width: min(360px, calc(100vw - 36px));
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.toast {
    transform: translateY(-8px);
    opacity: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--success);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    transition: transform 180ms ease, opacity 180ms ease;
}

.toast.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.confirm-dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-md);
}

.confirm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
}

.confirm-dialog__surface {
    display: grid;
    grid-template-columns: 38px 1fr;
    gap: 14px;
    padding: 22px;
}

.confirm-dialog__surface h2 {
    margin-bottom: 6px;
    font-size: 18px;
}

.confirm-dialog__surface p {
    margin-bottom: 0;
    color: var(--text-soft);
}

.confirm-dialog__icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--warning-soft);
    color: var(--warning);
    font-weight: 800;
}

.confirm-dialog__actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.public-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(16px);
}

.public-nav {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand--inverse {
    color: #edf3f4;
}

.brand-mark--inverse {
    background: #edf3f4;
    color: #172126;
}

.public-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.public-links > a:not(.button) {
    min-height: 44px;
    display: flex;
    align-items: center;
    color: var(--text-soft);
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
}

.public-links > a:not(.button):hover {
    color: var(--brand);
}

.site-footer {
    padding-block: 24px;
    border-top: 1px solid var(--line);
    background: var(--bg);
    color: var(--text-soft);
    font-size: 12px;
}

.auth-product__headline {
    max-width: 560px;
    margin-bottom: 16px;
    font-size: 36px;
    font-weight: 750;
    line-height: 1.2;
}

.auth-product__footer,
.auth-security,
.auth-loading {
    color: var(--text-faint);
    font-size: 12px;
}

.auth-security {
    margin: 20px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.auth-loading {
    margin-top: 12px;
}

.scan-page {
    padding: 34px 0 60px;
}

.scan-page__heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 28px;
}

.scan-page__heading h1 {
    margin-bottom: 8px;
    font-size: 36px;
    line-height: 1.15;
}

.scan-page__heading p {
    margin-bottom: 0;
    color: var(--text-soft);
}

/* 标题右侧的操作区：公告入口 + 购买次数。窄屏下 .scan-page__heading 会改成
 * 纵向排（见响应式那段），这里跟着换行就行。 */
.scan-page__heading-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* 标题旁边那个铃铛：点开翻历史公告。做成方形图标按钮，未读数挂右上角。 */
.scan-announcement-trigger,
button.scan-announcement-trigger {
    position: relative;
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border: 1px solid var(--line);
}

.scan-announcement-trigger--unread,
button.scan-announcement-trigger--unread {
    border-color: var(--brand);
    color: var(--brand);
}

/* 角标压在按钮边框外面，overflow 不能裁掉它，所以按钮自己不设 overflow。 */
.scan-announcement-trigger__badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.scan-balance {
    min-height: 32px;
    padding-inline: 11px;
}

/* 站点公告弹窗。开页时把没读过的公告直接弹出来，点「知道了」记在本地不再自动弹；
 * 标题右边那个「站点公告」按钮可以再翻出来看，包含已经关掉的。 */
.announcement-dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-md);
}

.announcement-dialog::backdrop {
    background: rgba(2, 6, 23, .72);
    backdrop-filter: blur(4px);
}

/* 公告多了让列表自己滚，头部和「知道了」不跟着滚出屏幕。max-height 用 vh
 * 写成确定值，里面的 flex 子项才算得出高度。 */
.announcement-dialog__surface {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 50px);
    padding: 20px 22px;
}

.announcement-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.announcement-dialog__head h2 {
    margin-bottom: 0;
    font-size: 20px;
}

.announcement-dialog .dialog-close {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-soft);
    font-size: 20px;
    line-height: 1;
    box-shadow: none;
}

.announcement-dialog .dialog-close:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
    transform: none;
    box-shadow: none;
}

.announcement-dialog__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    margin-top: 16px;
    overflow-y: auto;
}

.announcement-dialog__actions {
    display: flex;
    flex: none;
    justify-content: flex-end;
    margin-top: 18px;
}

/* `.alert.show` 是 display:block，选择器权重和 .site-announcement.show 相同，
 * 靠写在后面覆盖；不带 .show 的话公告整条会被 .alert 的 display:none 吞掉。 */
.site-announcement,
.site-announcement.show {
    display: block;
    margin-top: 0;
    padding: 13px 15px;
}

.site-announcement__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.site-announcement__title {
    display: block;
    font-size: 14px;
}

/* 历史公告里的已读/未读标记。未读用品牌色拉一下注意力，已读维持灰底。 */
.site-announcement__status {
    flex: none;
    padding: 2px 8px;
    font-size: 11px;
}

.site-announcement__status--unread {
    background: var(--brand-soft);
    color: var(--brand);
}

/* 正文跟着级别配色会变成一片红/黄，正文一律用正文色，只让标题带级别色。 */
.site-announcement__body {
    margin: 4px 0 0;
    color: var(--text-soft);
    /* 管理员在文本域里敲的换行要原样保留，正文是 textContent 落地的纯文本。 */
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.site-announcement__meta {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 12px;
}

.site-announcement--pinned {
    border-left-width: 3px;
}

/* 已经点过「知道了」的旧公告，从「站点公告」按钮翻出来时压暗一点。 */
.site-announcement--read {
    opacity: 0.72;
}

.scan-workspace {
    width: min(100% - 40px, var(--content));
    display: grid;
    grid-template-columns: minmax(420px, 0.9fr) minmax(420px, 1.1fr);
    grid-template-rows: min-content 1fr;
    align-items: start;
    gap: 18px;
    margin: 26px auto 0;
}

.scan-query-panel,
.scan-status-panel,
.scan-history {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.online-gather-workspace .scan-query-panel::before,
.online-gather-workspace .scan-status-panel::before {
    display: none;
    content: none;
}

.online-gather-layout {
    grid-template-columns: minmax(360px, 0.86fr) minmax(560px, 1.14fr);
    gap: 22px;
}

.online-gather-nav-links {
    display: flex;
}

.online-gather-card h1 {
    margin-bottom: 10px;
    font-size: 34px;
    line-height: 1.15;
}

.online-gather-auth-stack,
.online-gather-config-stack {
    display: grid;
    gap: 18px;
}

.online-gather-auth-stack {
    margin-top: 22px;
}

.online-gather-form {
    align-items: end;
}

.online-gather-form > h2,
.online-gather-form > .online-gather-field--span,
.online-gather-form > .online-gather-card--span,
.online-gather-form > button[type="submit"] {
    grid-column: 1 / -1;
}

.online-gather-form > h2 {
    margin-bottom: -4px;
    font-size: 20px;
    line-height: 1.2;
}

.online-gather-card--span {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-subtle);
}

.online-gather-card--span h3 {
    margin-bottom: 12px;
    font-size: 15px;
    line-height: 1.25;
}

.online-gather-inline-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.online-gather-workspace .panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.online-gather-workspace .panel-heading h2,
.online-gather-workspace .panel-heading h3,
.online-gather-workspace .panel-heading p {
    margin-bottom: 0;
}

.online-gather-workspace .history-list {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.online-gather-workspace .history-card {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr) minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-subtle);
}

.online-gather-workspace .history-card span,
.online-gather-workspace .history-card strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.online-gather-workspace .online-gather-account-card {
    grid-template-columns: minmax(220px, 1.25fr) minmax(180px, 1fr) minmax(100px, 0.55fr) auto;
    align-items: stretch;
}

.online-gather-account__identity,
.online-gather-account__profile,
.online-gather-account__status {
    min-width: 0;
    display: grid;
    align-content: center;
    gap: 4px;
}

.online-gather-account__identity span,
.online-gather-account__profile span,
.online-gather-account__status span {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.45;
}

.online-gather-account__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.online-row-list {
    display: grid;
    gap: 12px;
}

.online-config-row {
    min-width: 0;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.online-config-row__fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    align-items: end;
    gap: 12px;
}

.online-config-row__fields button {
    width: 100%;
}

/* 桌面端：左栏 查询+状态，右栏 历史记录 */
.scan-workspace > .scan-query-panel {
    grid-column: 1;
    grid-row: 1;
}

.scan-workspace > .scan-status-panel {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
}

.scan-workspace > .scan-history {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: start;
}

.scan-query-panel::before,
.scan-status-panel::before {
    display: block;
    margin-bottom: 18px;
    color: var(--text-faint);
    font-size: 12px;
    font-weight: 800;
}

.scan-query-panel::before {
    content: "查询条件";
}

.query-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
}

.scan-query-panel .field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
}

.scan-query-panel .field + .field {
    margin-top: 0;
}

.scan-query-panel .field.span-2,
.rescan-option {
    grid-column: span 2;
}

.rescan-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-subtle);
    cursor: pointer;
}

.rescan-option:hover {
    border-color: var(--warning);
}

.rescan-option input {
    flex: 0 0 auto;
    width: 18px;
    min-height: 18px;
    margin: 2px 0 0;
    accent-color: var(--warning);
}

.rescan-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.rescan-title {
    font-size: 13px;
    font-weight: 750;
}

.rescan-detail {
    margin-top: 2px;
    color: var(--text-soft);
    font-size: 12px;
}

.query-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
}

.query-actions button {
    flex: 0 0 auto;
    min-width: 92px;
    white-space: nowrap;
}

.scan-query-panel button,
.scan-status-panel button,
.scan-history button,
.result-dialog button {
    min-height: 44px;
    padding: 7px 13px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--brand);
    color: var(--on-brand);
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
}

.scan-query-panel button:hover,
.scan-status-panel button:hover,
.scan-history button:hover {
    background: var(--brand-hover);
}

.scan-query-panel button:disabled,
.scan-status-panel button:disabled,
.scan-history button:disabled,
.result-dialog button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.frequent-queries {
    display: grid;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.frequent-queries h2 {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
}

.frequent-query-group {
    min-width: 0;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
}

.frequent-query-label {
    padding-top: 8px;
    color: var(--text-faint);
    font-size: 12px;
}

.frequent-query-list {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.scan-query-panel .frequent-query-button {
    min-width: 0;
    min-height: 36px;
    max-width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 9px;
    border-color: var(--line);
    border-radius: 6px;
    background: var(--surface-subtle);
    color: var(--text);
    font-weight: 650;
}

.scan-query-panel .frequent-query-button:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}

.frequent-query-button__value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.frequent-query-button__meta {
    flex: none;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 500;
}

.billing-copy {
    color: var(--warning);
    font-size: 12px;
}

.status-row,
.result-heading,
.history-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.status-main,
.result-title {
    min-width: 0;
}

.status-title {
    font-size: 18px;
    font-weight: 750;
}

.status-detail,
.result-subtitle,
.history-status {
    margin-top: 4px;
    color: var(--text-soft);
    font-size: 12px;
}

.status-title.error {
    color: var(--danger);
}

.status-badge,
.source-badge {
    flex: 0 0 auto;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 12px;
    font-weight: 750;
}

.queue-facts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin-top: 20px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--line);
}

.queue-fact {
    min-width: 0;
    padding: 12px;
    background: var(--surface-subtle);
}

.queue-fact span {
    display: block;
    color: var(--text-faint);
    font-size: 11px;
}

.queue-fact strong {
    display: block;
    margin-top: 3px;
    overflow-wrap: anywhere;
    font-size: 13px;
}

.scan-history {
    margin-top: 2px;
}

.scan-history h2 {
    margin-bottom: 0;
    font-size: 20px;
}

.scan-history .table-wrap {
    margin-top: 16px;
}

.history-action {
    min-height: 44px !important;
    padding: 5px 10px !important;
    font-size: 12px !important;
}

.result-dialog {
    width: min(1160px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100vh - 32px);
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-md);
}

.result-dialog::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
}

.result-dialog-shell {
    max-height: calc(100vh - 34px);
    overflow-y: auto;
    padding: 24px;
}

.result-section {
    padding-bottom: 4px;
}

.result-heading {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.result-heading h2 {
    margin-bottom: 0;
    font-size: 22px;
}

.result-heading-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-dialog .dialog-close {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border-color: var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: 24px;
    line-height: 1;
}

.result-dialog .dialog-close:hover,
.result-dialog .secondary-button:hover,
.result-dialog .row-detail-button:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}

.result-dialog .secondary-button,
.result-dialog .row-detail-button {
    border-color: var(--line-strong);
    background: var(--surface);
    color: var(--text);
}

.player-back-button {
    margin: 16px 0 0;
}

.player-back-button::before {
    content: "←";
    margin-right: 6px;
    font-weight: 700;
}

.player-identity {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 0;
}

.player-name {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 24px;
}

.player-account,
.alliance-name {
    margin-top: 4px;
    color: var(--text-soft);
    font-size: 13px;
}

.coordinate {
    flex: 0 0 auto;
    padding: 8px 11px;
    border-radius: var(--radius);
    background: var(--info-soft);
    color: var(--info);
    font-weight: 750;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.metric {
    min-width: 0;
    min-height: 92px;
    padding: 18px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.metric-detail {
    margin-top: 6px;
    color: var(--text-faint);
    font-size: 12px;
}

.metric[data-state="active"] {
    border-color: color-mix(in srgb, var(--warning) 45%, var(--line));
    background: var(--warning-soft);
}

.metric[data-state="danger"] {
    border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
    background: var(--danger-soft);
}

.marches {
    margin-top: 24px;
}

.section-count,
.pagination-status {
    color: var(--text-soft);
    font-size: 12px;
}

.bulk-result {
    padding-top: 20px;
}

.bulk-result .section-heading > div:first-child {
    min-width: 0;
}

.bulk-result .section-heading .secondary-button,
.bulk-result__actions {
    flex: 0 0 auto;
}

.bulk-query-controls {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(105px, 1fr)) minmax(130px, 1fr) minmax(105px, 0.8fr);
    gap: 10px;
    align-items: end;
    margin-top: 16px;
}

.bulk-query-controls .field,
.bulk-query-controls .field + .field {
    margin-top: 0;
}

.bulk-result .table-wrap,
.marches .table-wrap {
    margin-top: 12px;
}

.bulk-result table,
.marches table,
.scan-history table {
    min-width: 0;
    table-layout: fixed;
    width: 100%;
}

.scan-history th,
.scan-history td {
    padding: 10px 8px;
    font-size: 12px;
    word-break: break-word;
}

.scan-history th:first-child,
.scan-history td:first-child,
.scan-history th:nth-child(7),
.scan-history td:nth-child(7) {
    white-space: normal;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}

.pagination-status {
    min-width: 110px;
    text-align: center;
}

button.nav-toggle {
    display: none;
}

/* Bare <button> elements inside admin panels/toolbars lack a type attribute,
   so they miss the global button[type=...] base styling. Give them the full
   geometry here so 复制/下载/刷新/禁用/删除 all render consistently. */
.admin-panel button,
.admin-topbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: var(--on-brand);
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-hover) 100%);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 200ms ease;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.admin-panel button:hover,
.admin-topbar button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), var(--shadow-brand);
}

.admin-panel button:disabled,
.admin-topbar button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.admin-panel button.secondary {
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.admin-panel button.secondary:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}

.admin-panel button.danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-hover) 100%);
    color: var(--on-danger);
}

.admin-panel button.warning {
    background: var(--surface);
    border: 1px solid var(--danger);
    color: var(--danger);
    box-shadow: var(--shadow-sm);
}

.admin-panel button.warning:hover {
    background: var(--danger);
    color: var(--on-danger);
}

.admin-panel button.warning:disabled {
    border-color: var(--line-strong);
    color: var(--text-muted);
    background: var(--surface);
}

/* Compact action buttons inside table rows */
.admin-panel td .toolbar,
.admin-panel table td {
    white-space: nowrap;
}

/* 表头跟着单元格一起不换行：扫描记录有 12 列，「账号」被折成上下两个字之后
 * 看起来像一列空的。 */
.admin-panel table th {
    white-space: nowrap;
}

/* 自由文本列（扫描记录的「查询目标」之类）会被塞进一整段广告文字，配上上面那条
 * nowrap 就把后面所有列挤出可视区域。这类单元格截断成一行，点一下（或回车）
 * 展开成多行，再点收回。上限写在单元格上，内层 span 跟着单元格实际宽度走，
 * 表格有富余宽度时省略号才不会停在一片空白前面。 */
.cell-clip {
    max-width: 240px;
    cursor: zoom-in;
}

.cell-clip__text {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-clip.is-expanded {
    max-width: 420px;
    cursor: zoom-out;
}

.cell-clip.is-expanded .cell-clip__text {
    overflow: visible;
    overflow-wrap: anywhere;
    white-space: normal;
}

/* 扫描记录有 12 列，默认的 16px 左右内边距光是留白就吃掉近 400px。收到 10px，
 * 省出来的宽度刚好让任务状态、计费状态、完成时间留在首屏里。 */
.world-scan-history-table th,
.world-scan-history-table td {
    padding-inline: 10px;
}

/* 站点公告：标题列走 .cell-clip 截断，正文列不在表里，别再放宽表格。 */
.announcement-table .cell-clip {
    max-width: 320px;
}

/* 「置顶 / 立即发布」两个勾选项和 select 同高，塞进 .grid 的一格里。 */
.announcement-flags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    min-height: 42px;
}

.admin-panel td button {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
    box-shadow: none;
}

.admin-panel td button + button {
    margin-left: 8px;
}

.admin-panel .error,
.admin-panel .result {
    display: none;
    margin-top: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.admin-panel .error.show,
.admin-panel .result.show {
    display: block;
}

.admin-panel .key-box {
    max-height: 220px;
    margin-top: 10px;
    overflow: auto;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-family: Consolas, monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 0.92fr) minmax(420px, 1.08fr);
    background: var(--surface);
}

.auth-product {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 44px;
    background: #172126;
    color: #edf3f4;
}

.auth-product p {
    max-width: 520px;
    color: #b7c5c9;
}

.auth-main {
    display: grid;
    place-items: center;
    padding: 32px;
    background: var(--bg);
}

.auth-form {
    width: min(100%, 420px);
}

.auth-form h1 {
    margin-bottom: 8px;
    font-size: 30px;
}

.auth-form__intro {
    margin-bottom: 28px;
    color: var(--text-soft);
}

.auth-form .button {
    width: 100%;
    margin-top: 20px;
}

.list-item-stacked {
    white-space: normal;
    word-break: break-word;
    color: var(--text-soft);
    font-size: 13px;
    padding-block: 2px;
}

.list-item-stacked:first-child {
    color: var(--text);
    font-weight: 500;
}


@media (max-width: 900px) {

  button.nav-toggle,
      button.admin-mobile-toggle {
          display: inline-flex;
      }

  .public-nav {
          flex-wrap: wrap;
          padding-block: 10px;
      }

  .public-links {
          width: 100%;
          display: none;
          align-items: stretch;
          flex-direction: column;
          gap: 4px;
          padding: 10px 0 4px;
      }

  .public-links.is-open {
          display: flex;
      }

  .public-links > a {
          min-height: 44px;
          display: flex;
          align-items: center;
          padding-inline: 8px;
      }

  .admin-sidebar.is-open {
          transform: translateX(0);
      }

  .auth-shell {
          grid-template-columns: 1fr;
      }

  .auth-product {
          min-height: auto;
          padding: 28px;
      }

  .auth-product__detail {
          display: none;
      }

  .scan-page__heading {
          align-items: flex-start;
          flex-direction: column;
      }

  .scan-workspace {
          width: min(100% - 32px, var(--content));
          grid-template-columns: 1fr;
      }

  .scan-workspace > .scan-query-panel,
      .scan-workspace > .scan-status-panel,
      .scan-workspace > .scan-history {
          grid-column: 1;
          grid-row: auto;
      }

  .online-gather-nav-links {
          width: auto;
          display: flex;
          align-items: center;
          flex-direction: row;
          gap: 10px;
          padding: 0;
      }

  .online-gather-inline-grid {
          grid-template-columns: repeat(2, minmax(0, 1fr));
      }

  .online-gather-workspace .history-card {
          grid-template-columns: repeat(2, minmax(0, 1fr));
      }

  .online-gather-workspace .online-gather-account-card {
          grid-template-columns: repeat(2, minmax(0, 1fr));
      }

  .online-gather-account__actions {
          justify-content: flex-start;
      }

  .metrics {
          grid-template-columns: repeat(2, minmax(0, 1fr));
      }

}


@media (max-width: 640px) {

  .form-grid {
          grid-template-columns: 1fr;
      }

  .section-heading {
          align-items: stretch;
          flex-direction: column;
          gap: 12px;
      }

  .admin-topbar,
      .admin-content,
      .auth-main {
          padding-inline: 14px;
      }

  .auth-main {
          place-items: start center;
          padding-top: 48px;
      }

  .auth-product {
          padding: 20px;
      }

  .toast-region {
          top: 12px;
          right: 12px;
          width: calc(100vw - 24px);
      }

  .scan-page {
          padding-top: 24px;
      }

  .scan-workspace {
          width: min(100% - 24px, var(--content));
      }

  .scan-page__heading h1 {
          font-size: 30px;
      }

  .query-grid,
      .queue-facts,
      .metrics {
          grid-template-columns: 1fr;
      }

  .scan-query-panel .field.span-2,
      .rescan-option {
          grid-column: span 1;
      }

  .frequent-query-group {
          grid-template-columns: 1fr;
          gap: 4px;
      }

  .frequent-query-label {
          padding-top: 0;
      }

  .scan-query-panel,
      .scan-status-panel,
      .scan-history {
          padding: 16px;
      }

  .online-gather-nav-links,
      .online-gather-workspace .history-card,
      .online-gather-inline-grid {
          grid-template-columns: 1fr;
      }

  .online-gather-workspace .online-gather-account-card {
          grid-template-columns: 1fr;
      }

  .online-gather-account__actions .button {
          flex: 1;
      }

  .online-gather-nav-links {
          width: 100%;
          align-items: stretch;
          flex-direction: column;
      }

  .online-gather-form > button[type="submit"] {
          width: 100%;
      }

  .query-actions,
      .status-row,
      .history-toolbar,
      .result-heading,
      .player-identity {
          align-items: stretch;
          flex-direction: column;
      }

  .query-actions button {
          width: 100%;
      }

  .coordinate,
      .source-badge {
          align-self: flex-start;
      }

  .result-dialog {
          width: calc(100vw - 16px);
          max-height: calc(100vh - 16px);
      }

  .result-dialog-shell {
          max-height: calc(100vh - 18px);
          padding: 16px;
      }

  .bulk-query-controls {
          grid-template-columns: repeat(2, minmax(0, 1fr));
      }

  .bulk-query-controls .bulk-search-field {
          grid-column: 1 / -1;
      }

  .pagination-bar {
          justify-content: space-between;
      }

}

/* ==========================================================================
   账号会话弹窗、账户中心与管理端返利面板
   ========================================================================== */

.auth-dialog {
    border: none;
    padding: 0;
    background: transparent;
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
}

.auth-dialog::backdrop {
    background: rgba(3, 10, 14, 0.62);
    backdrop-filter: blur(3px);
}

.auth-dialog__surface {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.auth-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.auth-dialog__head h2 {
    margin: 0;
    font-size: 18px;
}

.auth-dialog__tabs {
    width: 100%;
}

.auth-dialog__tabs button {
    flex: 1;
}

.auth-dialog__form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.captcha-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.captcha-row input {
    flex: 1;
    min-width: 0;
}

.captcha-row .button {
    flex-shrink: 0;
    white-space: nowrap;
}

.captcha-image {
    width: 120px;
    height: 44px;
    flex-shrink: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-secondary);
    cursor: pointer;
    object-fit: cover;
}

/* 横向留白交给 .container（模板里一起挂着），这样正文和顶栏在每个断点上都用同一个
 * 数值，不会出现顶栏 16px、正文 14px 差一点点的错位。这里只管上下留白。 */
.account-page {
    padding-block: 28px 56px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.account-page__heading {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.account-page__heading h1 {
    margin: 0;
}

.account-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.account-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.account-card__title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.account-card__title h2 {
    margin: 0;
    font-size: 16px;
}

.account-metrics {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.account-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-secondary);
}

.account-metric__label {
    font-size: 12px;
    color: var(--text-soft);
}

.account-metric__value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1.2;
}

.account-metric__value--money::before {
    content: "¥";
    margin-right: 2px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-soft);
}

.invite-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.invite-code-row code {
    flex: 1;
    min-width: 160px;
    padding: 10px 12px;
    font-size: 17px;
    letter-spacing: 0.08em;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface-secondary);
    text-align: center;
}

.account-login-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 56px 24px;
    text-align: center;
}

.account-login-gate h2 {
    margin: 0;
}

.account-session {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* 管理端账户页：紧凑列表 + 详情弹窗，替代原来 1430px 宽的九列大表。 */
.account-list-table th,
.account-list-table td {
    white-space: nowrap;
}

.account-list-table td:first-child {
    white-space: normal;
    overflow-wrap: anywhere;
}

.detail-dialog {
    border: none;
    padding: 0;
    background: transparent;
    width: min(920px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
}

.detail-dialog::backdrop {
    background: rgba(3, 10, 14, 0.62);
    backdrop-filter: blur(3px);
}

.detail-dialog__surface {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.detail-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.detail-dialog__head h2 {
    margin: 0;
    font-size: 18px;
}

.detail-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-secondary);
}

.detail-section > h3 {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.detail-facts {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.detail-fact {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-fact__label {
    font-size: 12px;
    color: var(--text-soft);
}

.detail-fact__value {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.detail-inline-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.detail-inline-form .field {
    min-width: 120px;
}

.withdrawal-qrcode {
    max-width: 220px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

/* 管理端审批弹窗里的收款码预览：居中并留出空图时的占位高度，
 * 免得图片加载失败时弹窗高度塌成一条。 */
.qrcode-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 160px;
    padding: 12px 0;
}

@media (max-width: 640px) {
    .account-page {
        padding-block: 20px 40px;
    }

    .account-grid {
        grid-template-columns: 1fr;
    }

    .auth-dialog,
    .detail-dialog {
        width: calc(100vw - 16px);
    }

    .auth-dialog__surface,
    .detail-dialog__surface {
        padding: 18px;
    }

    .captcha-row {
        flex-wrap: wrap;
    }
}


/* ========================================
   扫描 TXT 转 Excel 工具页
   ======================================== */

.tool-intake {
    margin-top: 24px;
}

.dropzone {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 26px 24px;
    border: 1px dashed color-mix(in srgb, var(--brand) 45%, var(--line-strong));
    border-radius: var(--radius-md);
    background: var(--surface-subtle);
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.dropzone:hover,
.dropzone:focus-visible {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.dropzone.is-active {
    border-color: var(--brand-light);
    background: var(--brand-soft);
    box-shadow: var(--shadow-brand);
}

.dropzone__icon {
    flex: none;
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--brand-soft);
    color: var(--brand-light);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.dropzone__text {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
}

.dropzone__text strong {
    font-size: 16px;
    color: var(--text);
}

.dropzone__text span {
    font-size: 13px;
    color: var(--text-soft);
}

.tool-result {
    margin-top: 20px;
}

.tool-result .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
}

/* button[type="button"] 的特指度压过单独一个 .secondary-button，这里照 .result-dialog
   的老办法再具体一层，别让「换一个文件」抢了「生成 Excel」的视觉重量。 */
.tool-result .secondary-button {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-sm);
}

.tool-result .secondary-button:hover {
    background: var(--surface-hover);
    border-color: var(--brand);
    color: var(--brand);
}

.tool-options {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 16px;
    margin-top: 20px;
}

.tool-fieldset {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding: 16px 18px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-secondary);
}

.tool-fieldset legend {
    padding: 0 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 14px;
}

.checkbox-grid .check-row,
.tool-fieldset > .check-row {
    margin-top: 0;
}

.tool-fieldset .check-row span {
    font-size: 13px;
    color: var(--text-secondary);
}

.tool-actions {
    align-items: center;
    gap: 14px;
    margin-top: 20px;
}

.tool-preview {
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.tool-preview .table-wrap {
    margin-top: 12px;
}

.tool-preview tbody td:nth-child(5) {
    font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
    .tool-result .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tool-options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .tool-result .metrics,
    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .dropzone {
        padding: 20px 16px;
    }
}
