/* ============================================================
   核纪元 · 通用组件层
   ============================================================ */

/* ---------- 面板 ---------- */
.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(160deg, rgba(13, 29, 52, 0.72), rgba(6, 14, 26, 0.78));
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.panel-pad {
  padding: 22px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-head h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
}

.panel-head h3 svg {
  width: 17px;
  height: 17px;
  color: var(--cyan);
}

.panel-note {
  font-size: 12px;
  color: var(--text-3);
}

.panel-topline {
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.65;
}

/* ---------- 按钮 ---------- */
.btn {
  --btn-bg: linear-gradient(135deg, rgba(56, 225, 255, 0.16), rgba(56, 225, 255, 0.06));
  --btn-border: rgba(56, 225, 255, 0.38);
  --btn-color: #dff8ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 12px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-color);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s var(--ease-out), box-shadow 0.22s, border-color 0.22s, background 0.22s, color 0.22s;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(56, 225, 255, 0.16);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0) scale(0.985);
}

.btn-primary {
  --btn-bg: linear-gradient(135deg, #38e1ff, #19b8d8);
  --btn-border: transparent;
  --btn-color: #02141c;
  box-shadow: 0 10px 30px rgba(56, 225, 255, 0.24);
}

.btn-primary:hover {
  box-shadow: 0 14px 40px rgba(56, 225, 255, 0.36);
}

.btn-green {
  --btn-bg: linear-gradient(135deg, #3ef0a2, #16c47f);
  --btn-border: transparent;
  --btn-color: #02140d;
  box-shadow: 0 10px 30px rgba(62, 240, 162, 0.2);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-border: var(--line-2);
  --btn-color: var(--text);
}

.btn-quiet {
  --btn-bg: rgba(120, 190, 255, 0.06);
  --btn-border: transparent;
  --btn-color: var(--text-2);
}

.btn-quiet:hover {
  --btn-color: var(--text);
}

.btn-danger {
  --btn-bg: rgba(255, 107, 107, 0.14);
  --btn-border: rgba(255, 107, 107, 0.45);
  --btn-color: #ffd9d9;
}

.btn-danger:hover {
  --btn-bg: rgba(255, 107, 107, 0.22);
}

.btn-sm {
  padding: 7px 13px;
  font-size: 12.5px;
  border-radius: 9px;
  gap: 6px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15.5px;
  border-radius: 14px;
}

.btn-block {
  width: 100%;
}

.btn[disabled],
.btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ---------- 标签 / 徽章 ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(120, 190, 255, 0.045);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover {
  color: var(--text);
  border-color: var(--line-2);
}

.chip.is-active {
  color: #02141f;
  background: linear-gradient(135deg, #38e1ff, #20c9ea);
  border-color: transparent;
  box-shadow: 0 4px 18px rgba(56, 225, 255, 0.25);
}

.chip .chip-count {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.7;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-cyan { color: var(--cyan); background: rgba(56, 225, 255, 0.1); border-color: rgba(56, 225, 255, 0.25); }
.badge-green { color: var(--green); background: rgba(62, 240, 162, 0.1); border-color: rgba(62, 240, 162, 0.25); }
.badge-amber { color: var(--amber); background: rgba(255, 200, 87, 0.1); border-color: rgba(255, 200, 87, 0.25); }
.badge-red { color: var(--red); background: rgba(255, 107, 107, 0.1); border-color: rgba(255, 107, 107, 0.25); }
.badge-violet { color: var(--violet); background: rgba(167, 139, 250, 0.1); border-color: rgba(167, 139, 250, 0.25); }
.badge-line { color: var(--text-2); background: rgba(120, 190, 255, 0.05); border-color: var(--line); }

/* ---------- 进度 ---------- */
.progress {
  height: 6px;
  border-radius: 99px;
  background: rgba(120, 190, 255, 0.1);
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  transition: width 0.5s var(--ease-out);
  box-shadow: 0 0 12px rgba(56, 225, 255, 0.5);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-3);
  font-family: var(--font-mono);
  margin-top: 7px;
}

/* ---------- 分段控件 ---------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 11px;
  background: rgba(120, 190, 255, 0.06);
  border: 1px solid var(--line);
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: all 0.18s;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.is-active {
  background: rgba(56, 225, 255, 0.13);
  color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(56, 225, 255, 0.24);
}

/* ---------- KPI ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.kpi {
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(120, 190, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.kpi b {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}

.kpi b .kpi-unit {
  font-size: 11px;
  color: var(--text-3);
  margin-left: 3px;
  font-family: var(--font-sans);
  font-weight: 500;
}

.kpi span {
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.22s ease both;
}

.modal {
  position: relative;
  width: min(680px, 100%);
  max-height: min(86dvh, 860px);
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl);
  border: 1px solid var(--line-2);
  background:
    radial-gradient(600px 260px at 85% 0%, rgba(56, 225, 255, 0.1), transparent 70%),
    linear-gradient(160deg, #0c1c33, #071120 70%);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  animation: popIn 0.32s var(--ease-spring) both;
  overflow: hidden;
}

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

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px 26px 0;
}

.modal-head-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cyan);
}

.modal-title {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(120, 190, 255, 0.05);
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.3);
}

.modal-close svg {
  width: 16px;
  height: 16px;
}

.modal-body {
  padding: 18px 26px 6px;
  overflow-y: auto;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.7;
}

.modal-body h3 {
  color: var(--text);
  margin: 18px 0 8px;
  font-size: 15px;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body p + p {
  margin-top: 10px;
}

.modal-body strong {
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 16px 26px 24px;
}

.modal-actions .spacer {
  flex: 1;
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  right: 20px;
  top: calc(var(--header-h) + 14px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 40px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: rgba(9, 20, 36, 0.94);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  animation: toastIn 0.35s var(--ease-spring) both;
  pointer-events: auto;
}

.toast.is-out {
  animation: toastOut 0.25s ease forwards;
}

.toast .toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  margin-top: 1px;
}

.toast .toast-icon svg {
  width: 17px;
  height: 17px;
}

.toast.success { border-color: rgba(62, 240, 162, 0.4); }
.toast.success .toast-icon { color: var(--green); }
.toast.error { border-color: rgba(255, 107, 107, 0.4); }
.toast.error .toast-icon { color: var(--red); }
.toast.info .toast-icon { color: var(--cyan); }
.toast.achievement {
  border-color: rgba(255, 200, 87, 0.45);
  background: linear-gradient(135deg, rgba(45, 34, 8, 0.96), rgba(20, 16, 6, 0.96));
}
.toast.achievement .toast-icon { color: var(--amber); }
.toast.achievement b { color: var(--amber); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(28px) scale(0.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px) scale(0.97); }
}

/* ---------- 拖拽 ---------- */
.drag-ghost {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  opacity: 0.92;
  transform: translate(-50%, -50%) rotate(-1.5deg) scale(0.97);
  filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.5));
  transition: none;
}

.is-dragging {
  user-select: none !important;
  cursor: grabbing !important;
}

.is-dragging * {
  cursor: grabbing !important;
}

.dropzone {
  position: relative;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-lg);
  background: rgba(120, 190, 255, 0.03);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.dropzone.is-over {
  border-color: var(--cyan);
  background: rgba(56, 225, 255, 0.08);
  box-shadow: 0 0 0 4px rgba(56, 225, 255, 0.08), 0 0 34px rgba(56, 225, 255, 0.16);
}

.dropzone.is-over::after {
  border-color: var(--cyan);
}

/* ---------- 分隔/提示 ---------- */
.hint-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-3);
}

.hint-line svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
  border: 0;
}

.sources {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.sources .source-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.sources .source-item::before {
  content: "§";
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* 数据来源说明 */
.data-note {
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  border-left: 2px solid var(--line-2);
  background: rgba(120, 190, 255, 0.03);
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.6;
}

/* 空状态 */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* 键盘提示 */
kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  background: rgba(120, 190, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}

@media (max-width: 560px) {
  .overlay { padding: 12px; }
  .modal { max-height: 90dvh; border-radius: var(--r-lg); }
  .modal-head { padding: 20px 18px 0; }
  .modal-body { padding: 14px 18px 4px; }
  .modal-actions { padding: 14px 18px 20px; }
  .toast-root { right: 12px; top: auto; bottom: 14px; left: 12px; max-width: none; }
  .toast { animation: fadeUp 0.3s var(--ease-spring) both; }
}

/* ---------- 启动自检提示 ---------- */
.boot-guard {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 180;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 200, 87, 0.42);
  border-radius: 13px;
  background: rgba(24, 18, 6, 0.96);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  max-width: min(580px, calc(100vw - 36px));
  animation: fadeUp 0.3s var(--ease-out) both;
}

.boot-guard[hidden] {
  display: none !important;
}

.boot-guard .boot-guard-text {
  display: flex;
  align-items: center;
  gap: 9px;
  line-height: 1.5;
}

.boot-guard .boot-guard-text svg {
  color: var(--amber);
  flex-shrink: 0;
}

.boot-guard-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .boot-guard {
    left: 10px;
    right: 10px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    max-width: none;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .boot-guard-actions {
    justify-content: flex-end;
  }
}


@media (max-width: 640px) {
  .toast-root {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
}
