/* ===== EasyTrace 基础样式（蓝紫渐变卡片风） ===== */
:root {
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1f2333;
  --muted: #8a8fa3;
  --line: #e6e8f2;
  --warn: #d97706;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(79, 70, 229, .10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- 顶栏 ---- */
.topbar {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 2px 10px rgba(79, 70, 229, .25);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { font-size: 22px; font-weight: 800; letter-spacing: .5px; }
.tagline { font-size: 13px; color: rgba(255, 255, 255, .82); }
.status-box { display: flex; align-items: center; gap: 10px; }
.status-text { font-size: 14px; padding: 5px 12px; border-radius: 999px; background: rgba(255,255,255,.16); }
.status-text.ok { background: rgba(34,197,94,.28); }
.status-text.warn { background: rgba(251,191,36,.3); color: #fff; }

/* ---- 布局 ---- */
.container {
  max-width: 1180px;
  margin: 24px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 24px;
  align-items: start;
}
.container-narrow { grid-template-columns: 1fr; max-width: 760px; }

/* ---- 卡片 ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card-title { margin: 0 0 18px; font-size: 18px; font-weight: 700; }

/* ---- 类别按钮 ---- */
.cat-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.cat-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 14px; color: var(--text); transition: all .15s;
}
.cat-btn:hover { border-color: var(--primary); }
.cat-btn.active { background: var(--grad); color: #fff; border-color: transparent; }
.cat-icon { font-size: 16px; }
.cat-name { font-weight: 600; }

/* ---- 表单 ---- */
.form-fields { display: flex; flex-direction: column; gap: 16px; }
.fixed-fields, .dynamic-fields { display: flex; flex-direction: column; gap: 14px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--text); }
.req { color: var(--danger); }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; background: #fff; color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.input-file { font-size: 14px; }

/* ---- 按钮 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: #fff; border-color: transparent; }
.btn-primary:hover { color: #fff; filter: brightness(1.05); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; padding: 12px; margin-top: 4px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---- 资产列表 ---- */
.asset-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 12px; background: #fff; transition: box-shadow .15s;
}
.asset-item:hover { box-shadow: var(--shadow); }
.asset-icon { font-size: 26px; flex-shrink: 0; }
.asset-main { flex: 1; min-width: 0; }
.asset-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.asset-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.pill {
  background: var(--grad); color: #fff; font-size: 12px;
  padding: 2px 10px; border-radius: 999px; font-weight: 600;
}
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.asset-time { font-size: 12px; }
.asset-actions { display: flex; gap: 8px; flex-shrink: 0; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.muted { color: var(--muted); }

/* ---- 详情页（扫码） ---- */
.detail-head { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
.detail-icon { font-size: 40px; }
.sub-title { font-size: 16px; font-weight: 700; margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv { display: flex; justify-content: space-between; gap: 20px; padding: 8px 12px; background: #fafbff; border-radius: 8px; }
.kv-label { color: var(--muted); font-size: 14px; }
.kv-value { font-size: 14px; font-weight: 600; text-align: right; word-break: break-all; }
.attach-list { display: flex; flex-direction: column; gap: 8px; }
.attach-link { color: var(--primary); text-decoration: none; font-size: 14px; }
.attach-link:hover { text-decoration: underline; }

/* ---- 模态框 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 18, 40, .55);
  display: none; align-items: center; justify-content: center; z-index: 100;
  padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 26px;
  width: 100%; max-width: 420px; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close {
  position: absolute; top: 12px; right: 14px; border: none; background: none;
  font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted);
}
.modal-close:hover { color: var(--text); }
.modal-title { margin: 0 0 12px; font-size: 18px; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }

/* 登录/注册面板（最高层级，强制使用） */
#authModal { z-index: 200; }
#authModal .modal { max-width: 400px; }
.auth-error { min-height: 18px; font-size: 13px; color: #dc2626; margin: 2px 0 8px; }
.auth-switch { margin-top: 10px; }
.auth-switch .btn-ghost { color: var(--primary); }

/* 二维码模态 */
.qr-body { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.qr-body img { width: 240px; height: 240px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.qr-info .qr-title { font-size: 16px; font-weight: 700; }
.qr-info .qr-code { font-family: ui-monospace, monospace; color: var(--primary); font-weight: 700; margin: 3px 0; }
.qr-info .qr-cat { color: var(--muted); font-size: 13px; }

/* 付费墙 */
.paywall-badge {
  display: inline-block; background: #fef3c7; color: #b45309;
  font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px; margin-bottom: 10px;
}
.paywall-text { font-size: 14px; color: var(--text); margin: 0 0 12px; }
.trial-info { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.trial-row { margin: 2px 0; }
.paywall-hint { font-size: 12px; color: var(--muted); text-align: center; margin: 12px 0 0; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #1f2333; color: #fff; padding: 12px 22px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 200;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ---- 底部注脚 ---- */
.footer {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 30px 16px 34px;
}

/* 打印区域默认隐藏（屏幕） */
#printArea { display: none; }

/* ---- 响应式：窄屏单栏 ---- */
@media (max-width: 860px) {
  .container { grid-template-columns: 1fr; }
  .status-box .status-text { font-size: 12px; }
  .asset-item { flex-wrap: wrap; }
  .asset-actions { width: 100%; justify-content: flex-end; }
}

/* ---- 打印专用 ---- */
@media print {
  body { background: #fff; }
  .topbar, .footer, .modal-mask, .toast, #detailSection, .status-box, #scanPrintBtn {
    display: none !important;
  }
  .container, .container-narrow { max-width: none; margin: 0; padding: 0; border: none; }
  #printArea { display: block !important; }
  .print-head { text-align: center; font-family: inherit; }
  .print-head h2 {
    font-size: 30px; margin: 6px 0; font-weight: 800;
    text-transform: uppercase; letter-spacing: 1px;
  }
  .print-meta { color: #444; font-size: 16px; margin: 6px 0 18px; }
  .print-meta span { margin: 0 8px; }
  #printQr { width: 220px; height: 220px; }
  .lang-switch { display: none !important; }
}

/* ============================================================
   多语言：语言切换器
   ============================================================ */
.lang-switch { position: relative; display: inline-block; }

.lang-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; font-size: 13px; line-height: 1;
  font-family: inherit; color: var(--primary, #4f46e5); font-weight: 600;
  background: rgba(255, 255, 255, .96);
  border: 1.5px solid rgba(255, 255, 255, .55);
  border-radius: 8px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .16);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.lang-btn:hover { background: #fff; box-shadow: 0 2px 8px rgba(15, 23, 42, .22); }
.lang-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lang-globe { font-size: 14px; }
.lang-cur { letter-spacing: .2px; }
.lang-caret { font-size: 10px; opacity: .55; transition: transform .18s; }
.lang-btn[aria-expanded="true"] .lang-caret { transform: rotate(180deg); }

.lang-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 500;
  min-width: 184px; padding: 6px;
  background: #fff; border: 1px solid var(--line, #e3e6eb); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .14);
  display: none; max-height: min(70vh, 420px); overflow-y: auto;
}
.lang-menu.open { display: block; }

.lang-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
  color: var(--text, #1f2937); background: none; border: none;
  border-radius: 7px; cursor: pointer; text-align: left;
}
.lang-item:hover { background: #f2f5f9; }
.lang-item.active { background: #eef5ff; color: #1d4ed8; font-weight: 600; }
/* 语言徽标：用区域缩写替代国旗 emoji（Windows 无国旗字形，会渲染成「CN」字母） */
.lang-badge {
  flex: none; width: 24px; height: 18px; line-height: 18px;
  font-size: 10px; font-weight: 700; text-align: center; letter-spacing: .3px;
  color: #475569; background: #eef1f5; border-radius: 4px;
}
.lang-item.active .lang-badge { color: #1d4ed8; background: #dbeafe; }
.lang-name { flex: 1; }
.lang-tick { color: #1d4ed8; font-size: 12px; }

/* 顶栏里的切换器（放在状态区左侧） */
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* 页面主体顶部的语言条：解决顶栏切换器被登录弹窗遮住的问题
   注意：main.container 是 CSS Grid（5fr 7fr）。
   .lang-bar 作为第一个 grid item 会只占第 1 列并把卡片挤到下一行，
   必须 grid-column: 1 / -1 让它横跨整行，否则布局会被破坏。 */
.lang-bar {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  margin: 0; padding: 9px 16px;
  background: #fff; border: 1px solid var(--line, #e3e6eb); border-radius: 11px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.lang-bar-label {
  font-size: 13px; color: var(--muted, #6b7280); letter-spacing: .2px;
}
/* 语言条里的按钮走浅色风格（不在深色顶栏上，不需要白底反色） */
.lang-bar .lang-btn {
  color: var(--primary, #4f46e5); font-weight: 600;
  background: #f6f7ff; border-color: #dfe3f5; box-shadow: none;
}
.lang-bar .lang-btn:hover { background: #eef1ff; border-color: #c7cff0; }
.lang-bar .lang-btn:focus-visible { outline-color: var(--primary, #4f46e5); }
/* 窄屏：语言条标签与按钮靠两端 */
@media (max-width: 640px) {
  .lang-bar { justify-content: space-between; padding: 8px 12px; }
  .lang-bar-label { font-size: 12.5px; }
}

/* ============================================================
   多语言：RTL（阿拉伯语）基础适配
   html[dir=rtl] 时翻转文本方向与阴影方向
   ============================================================ */
html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] .toast { left: auto; right: 50%; transform: translateX(50%) translateY(20px); }
html[dir="rtl"] .toast.show { transform: translateX(50%) translateY(0); }
html[dir="rtl"] .lang-menu { right: auto; left: 0; }
html[dir="rtl"] .lang-item { text-align: right; }

/* 阿拉伯语字体栈（优先系统阿拉伯字体，中文/日文/韩文回退保持不变） */
html[lang="ar"] body,
html[lang="ar"] input,
html[lang="ar"] button,
html[lang="ar"] textarea,
html[lang="ar"] select {
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Geeza Pro", "Arial", sans-serif;
}
/* 俄语用西里尔字母，字体栈无需特殊处理，保留默认 */