/* ========================================
   9999 Gold — Premium Mini Dashboard
   ======================================== */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('lib/fonts/inter-400.ttf') format('truetype');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('lib/fonts/inter-500.ttf') format('truetype');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('lib/fonts/inter-600.ttf') format('truetype');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('lib/fonts/inter-700.ttf') format('truetype');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('lib/fonts/jetbrains-700.ttf') format('truetype');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('lib/fonts/jetbrains-800.ttf') format('truetype');
}

:root {
  --bg-primary:   #0d1117;
  --bg-secondary: #161b22;
  --card-bg:      rgba(22, 27, 34, 0.7);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-primary: #f0f6fc;
  --text-muted:   #8b949e;
  
  --gold-glow:    rgba(212, 175, 55, 0.4);
  --green:        #3fb950;
  --red:          #f85149;
  
  --radius-lg:    16px;
  --radius-sm:    8px;
}

/* --- 单图标极简主题切换器 --- */
.theme-icon-btn {
  font-size: 18px;
  cursor: pointer;
  margin-right: 12px;
  user-select: none;
  transition: transform 0.2s, filter 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  line-height: 1; /* 防止 Emoji 被行高裁剪 */
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
}

.theme-icon-btn:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.15);
}

.theme-icon-btn:active {
  transform: scale(0.9);
}

body.theme-light .theme-icon-btn {
  background: rgba(0, 0, 0, 0.05);
}

body.theme-light .theme-icon-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}

/* ── Apple 风格明亮模式覆盖 ── */
body.theme-light {
  --bg-primary:   #f5f5f7; /* Apple 银灰面板 */
  --bg-secondary: #ffffff;
  --card-bg:      rgba(255, 255, 255, 0.85); /* 高透毛玻璃感 */
  --border-color: rgba(0, 0, 0, 0.05); /* 几乎不可见的极微细线边界 */
  --text-primary: #1d1d1f; /* 墨黑 */
  --text-muted:   #86868b;
  
  --gold-glow:    rgba(0, 0, 0, 0); /* 苹果风摒弃土豪金发光，讲究扎实 */
  --green:        #34c759;
  --red:          #ff3b30;

  background-image: none; /* 去掉极客风大光斑 */
}

/* 明亮模式高质感组件打磨 */
body.theme-light .mini-dashboard {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02); /* 超大发散的淡光雾阴影 */
  border: 1px solid rgba(255,255,255,0.6); /* 高光描边刻画立体感 */
}

body.theme-light .top-bar {
  border-bottom-color: rgba(0, 0, 0, 0.05);
  background: rgba(255, 255, 255, 0.5);
  font-weight: 500;
  color: #1d1d1f;
}

body.theme-light .vertical-label {
  color: #1d1d1f;
  font-weight: 600;
}

body.theme-light .logout-link:hover {
  color: #000;
}

body.theme-light .box-info-container {
  background: #f5f5f7;
}

body.theme-light .info-tag {
  color: #1d1d1f;
}

body.theme-light .info-time {
  color: #86868b;
}

body.theme-light .basis-value {
  text-shadow: none;
}

body.theme-light .compact-card__prices {
  background: #ffffff;
  border-color: rgba(0,0,0,0.05);
}

body.theme-light .price-item {
  color: #86868b;
}

body.theme-light .price-item b {
  color: #1d1d1f;
}

body.theme-light .compact-card__basis-box {
  background: #ffffff;
  border-color: rgba(0,0,0,0.05);
  box-shadow: 0 2px 8px rgba(0,0,0,0.02); /* 内卡片微浮雕 */
}

body.theme-light #authShield {
  background: rgba(255, 255, 255, 0.8);
}

body.theme-light .auth-box {
  background: #ffffff;
  box-shadow: 0 20px 50px rgba(0,0,0,0.1);
}

body.theme-light .auth-form input {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #0f172a !important;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(31, 38, 52, 0.5) 0, transparent 50%),
    radial-gradient(at 50% 0%, rgba(13, 17, 23, 1) 0, transparent 80%);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 10px;
}

.mini-dashboard {
  width: 100%;
  max-width: 500px; /* 适度拉宽，缓解长数字溢出 */
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 10px 16px 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 12px;

  /* 支持拖动悬浮的新增属性 */
  position: absolute;
  top: 15%; /* 改为固定顶部距离 */
  left: 50%;
  z-index: 1000;
  flex-shrink: 0; /* 整个面板不参与压缩 */
}

.top-bar:active {
  cursor: grabbing;
}

/* 激活或拖动中禁用过渡，防止“飞走”效应 */
.draggable-window:active,
.draggable-window.dragging {
  transition: none !important;
}

/* 顶部工具栏（兼拖动手柄） */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-color);
  cursor: grab;
  user-select: none;
  min-height: 0;
}

.top-bar-left {
  display: flex;
  gap: 6px;
  align-items: center;
}

.top-btn {
  font-size: 14px;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s;
  padding: 2px;
}

.top-btn:hover {
  opacity: 0.8;
}

.top-btn.active {
  opacity: 1;
}

.top-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* 区域隐藏动画 */
.section-hidden {
  display: none !important;
}




.logout-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  transition: all 0.2s;
}

.logout-link:hover {
  color: #fff;
}

.top-bar span {
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  margin-left: 4px;
}

/* 双面板联动容器 */
.dual-panel-wrapper {
  display: flex;
  gap: 16px;
  width: 100%;
  flex-wrap: wrap; /* 跨设备自适应 */
}

/* 紧凑内容区 */
.compact-card {
  display: flex;
  flex: 1;
  min-width: 420px;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.card-header-inner {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.8;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.compact-card__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.dual-title {
  text-align: center;
  font-size: 16px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.dual-body {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  flex-shrink: 0; /* 禁止整体压缩 */
}

.basis-half {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
}

.vertical-label {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  font-weight: 500;
  text-align: center;
  min-width: 13px; /* 防止文字宽度在弹性伸缩时被扭曲 */
}

.compact-card__prices {
  display: flex;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.price-item {
  font-size: 12px;
  color: var(--text-muted);
}

.price-item b {
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  margin-left: 4px;
}

/* 联合信息展示区样式 */
.box-info-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  flex-shrink: 0; /* 禁止压缩 */
  min-height: 52px; /* 锁定最小高度 */
  font-size: 14px;
  font-weight: normal;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  padding: 8px;
  border-radius: var(--radius-sm);
  margin-top: 0;
  margin-bottom: 0;
  width: 100%;
  box-sizing: border-box;
}

.info-row {
  display: grid;
  grid-template-columns: 90px 85px 1fr; /* 压缩标签与时间，保障数据位 */
  gap: 8px; /* 缩小间隙 */
  font-size: 13px;
  align-items: center;
  width: 100%;
  white-space: nowrap;
}

.info-tag {
  font-weight: 600;
  text-align: right;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-time {
  color: var(--text-muted);
  opacity: 0.6;
  font-size: 11px;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}

.info-num {
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.2px; /* 微调间距 */
}

/* 基差视觉核心 */
.compact-card__basis-box {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-lg);
  padding: 18px 5px;
  display: flex;
  flex: 1; /* 虽然占满，但禁止缩水 */
  flex-shrink: 0; 
  min-height: 80px; /* 固定最小体感高度 */
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: visible;
  transition: all 0.4s ease;
}

.compact-card__basis-box::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, var(--glow-color, transparent) 0%, transparent 70%);
  opacity: 0.15;
  pointer-events: none;
}

.basis-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 38px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
  text-shadow: 0 0 20px var(--glow-color, transparent);
  transition: color 0.3s ease;
}

/* 状态色 - 兼容多路独立窗口 ID */
[id^="basisExpand"] { 
  color: var(--red);
  --glow-color: var(--red);
}

[id^="basisShrink"] { 
  color: var(--green);
  --glow-color: var(--green);
}

/* 动画反馈 */
@keyframes flash-green { 0% { color: #fff; text-shadow: 0 0 15px var(--green); } 100% { color: var(--text-primary); } }
@keyframes flash-red { 0% { color: #fff; text-shadow: 0 0 15px var(--red); } 100% { color: var(--text-primary); } }

.price-up { animation: flash-green 0.8s ease-out; }
.price-down { animation: flash-red 0.8s ease-out; }

/* 响应式：如果不满足 100vh，允许滚动 */
@media (max-height: 500px) {
  body { height: auto; padding: 20px 10px; }
  /* .mini-dashboard { margin: 0 auto; } */
}

.error-msg {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 10px;
  display: none;
}

/* ========================================
   访客通行鉴权盾 (Auth Shield)
   ======================================== */
#authShield {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(13, 17, 23, 0.85); /* 深色背景 */
  backdrop-filter: blur(25px); /* 极强的磨砂玻璃效果 */
  -webkit-backdrop-filter: blur(25px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#authShield.active {
  opacity: 1;
  pointer-events: auto;
}

.auth-box {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  width: 90%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0,0,0,0.6);
  transform: translateY(20px) scale(0.95);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#authShield.active .auth-box {
  transform: translateY(0) scale(1);
}

.auth-box h2 {
  font-size: 18px;
  margin-bottom: 20px;
  font-weight: 600;
  letter-spacing: 1px;
}

.auth-box input[type="password"] {
  width: 100%;
  padding: 12px 15px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 16px;
  margin-bottom: 15px;
  outline: none;
  transition: border-color 0.3s;
  box-sizing: border-box;
}

.auth-box input[type="password"]:focus {
  border-color: var(--primary, #3b82f6);
}

.auth-box button {
  width: 100%;
  padding: 12px;
  background: var(--primary, #3b82f6);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.auth-box button:hover {
  opacity: 0.9;
}

.auth-error {
  color: var(--red);
  font-size: 13px;
  margin-bottom: 10px;
  min-height: 18px;
  display: none;
}

/* ========================================
   登录/注册 切换面板样式
   ======================================== */
.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 2px solid rgba(255,255,255,0.1);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
  transition: all 0.3s;
  font-size: 15px;
}

.auth-tab.active {
  color: #fff;
  border-bottom: 2px solid var(--primary, #3b82f6);
  margin-bottom: -2px; /* 覆盖底层边框 */
}

.auth-form {
  display: none;
  animation: fadeIn 0.4s;
}

.auth-form.active {
  display: block;
}

.auth-form input[type="text"] {
  width: 100%;
  padding: 12px 15px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  margin-bottom: 15px;
  outline: none;
  transition: border-color 0.3s;
  box-sizing: border-box;
}

.auth-form input[type="text"]:focus {
  border-color: var(--primary, #3b82f6);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
/* ===================== 【监控管理中心：总控条】 ===================== */
#controlCenter {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  padding: 8px 15px;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  z-index: 10000; /* 绝对置顶 */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.control-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 20px;
  transition: all 0.3s ease;
}

.control-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4b5563; /* 初始灰色（关闭） */
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

/* 激活状态（开启中） */
.control-item.active {
  color: var(--text-primary);
}

.control-item.active .status-dot {
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}

/* 窗口隐藏动画 */
.window-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: scale(0.95) translate(-50%, -50%) !important;
  pointer-events: none !important;
}

.draggable-window {
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   基差报警系统样式
   ======================================== */

/* 报警触发时基差盒子的脉冲效果 */
@keyframes alert-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0); }
  50% { box-shadow: 0 0 20px 4px rgba(248, 81, 73, 0.5); }
}

.compact-card__basis-box.alert-triggered {
  border-color: var(--red) !important;
  animation: alert-pulse 1s ease-in-out infinite;
}

.compact-card__basis-box.alert-triggered .basis-value {
  animation: alert-flash 0.8s ease-in-out infinite alternate;
}

@keyframes alert-flash {
  from { opacity: 1; }
  to { opacity: 0.5; }
}

/* 输入框独立行（dual-body 下方） */
.alert-inputs-row {
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.alert-input-group {
  flex: 1;
  display: flex;
  gap: 4px;
  justify-content: center;
  padding-left: 23px;
}

.alert-input {
  width: 55px;
  padding: 3px 5px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, color 0.2s;
  -moz-appearance: textfield;
  appearance: textfield;
}

.alert-input::-webkit-outer-spin-button,
.alert-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.alert-input:focus {
  border-color: var(--red);
  color: var(--text-primary);
}

.alert-input::placeholder {
  color: var(--text-muted);
  opacity: 0.4;
}

/* 输入框有值时高亮 */
.alert-input.has-value {
  color: var(--text-primary);
  border-color: rgba(248, 81, 73, 0.3);
  background: rgba(248, 81, 73, 0.06);
}

/* 铃铛开关 */
.alert-bell {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 20px;
  transition: all 0.3s ease;
  font-size: 16px;
  user-select: none;
  opacity: 0.5;
}

.alert-bell:hover {
  background: rgba(255, 255, 255, 0.05);
  opacity: 0.8;
}

.alert-bell.active {
  opacity: 1;
}

.alert-bell.ringing {
  animation: bell-shake 0.4s ease-in-out infinite;
  color: var(--red) !important;
}

@keyframes bell-shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(12deg); }
  75% { transform: rotate(-12deg); }
}

/* 亮色主题适配 */
body.theme-light .alert-input {
  background: rgba(0, 0, 0, 0.04);
  border-color: #e2e8f0;
  color: #64748b;
}

body.theme-light .alert-input.has-value {
  color: #0f172a;
  background: rgba(220, 38, 38, 0.05);
  border-color: rgba(220, 38, 38, 0.2);
}
