/* web/shared/base.css — 设计令牌 + 两端共用组件样式 */

:root {
  --bg: #0f1216;
  --bg-2: #161b22;
  --bg-3: #1c232c;
  --line: #2a323d;
  --line-2: #38414d;
  --fg: #e6edf3;
  --fg-2: #9aa7b4;
  --fg-3: #6b7785;
  --accent: #4c9aff;
  --accent-2: #2f7ae5;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --tmall: #ff0036;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

/*
 * 必须放在组件样式之前并且用 !important：
 * 组件类（如 .m-drawer{display:flex}）的优先级高于浏览器默认的
 * [hidden]{display:none}，会让 hidden 属性失效、元素照常显示。
 * 这是「抽屉盖住底部导航导致点不动」那类 bug 的根因。
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: .3px; white-space: nowrap; }
.brand .dot { color: var(--accent); }
.spacer { flex: 1; }

/* ---------- 徽标 ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--fg-2);
  white-space: nowrap;
}
.chip b { color: var(--fg); font-weight: 600; }
.chip.ok { border-color: rgba(63,185,80,.4); color: var(--ok); }
.chip.warn { border-color: rgba(210,153,34,.4); color: var(--warn); }
.chip.err { border-color: rgba(248,81,73,.4); color: var(--err); }
.chip.tmall { background: rgba(255,0,54,.12); border-color: rgba(255,0,54,.4); color: var(--tmall); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #232b35; border-color: #4a5665; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent-2); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent); }
.btn.danger { border-color: rgba(248,81,73,.5); color: var(--err); }
.btn.danger:hover:not(:disabled) { background: rgba(248,81,73,.12); }
.btn.sm { padding: 4px 9px; font-size: 12px; }

/* ---------- 输入 ---------- */
.input, .select {
  padding: 7px 10px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  min-width: 0;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--fg-3); }
/* 下拉框：沿用 .input 的观感，但要覆盖浏览器默认的 system 外观与高度 */
select.input, select.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-3) 50%),
    linear-gradient(135deg, var(--fg-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% + 1px), calc(100% - 10px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
  cursor: pointer;
}
select.input option, select.select option { background: var(--bg); color: var(--fg); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--fg-2); }

/* 字段说明文字。PC 端 style.css 里也有一份（更小一号）；这里给 H5 用，
   否则 H5 里所有 class="hint" 的说明文字都是正文大小，看不出是次要信息。 */
.hint { font-size: 12px; line-height: 1.6; color: var(--fg-3); margin-top: 4px; }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  position: sticky;
  /* 必须贴在顶栏**下面**，不能也是 top:0 ——
     两者都 top:0 时，顶栏(z-50)会整条盖住页签条(z-40)，
     页面一滚动所有页签就点不动了。实际高度由 app.js 的 syncStickyLayout() 写入。 */
  top: var(--topbar-h, 48px);
  z-index: 40;
}
.tab {
  padding: 10px 14px;
  color: var(--fg-2);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  font-family: inherit;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.tab .badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  background: var(--bg-3);
  border-radius: 999px;
  font-size: 11px;
  color: var(--fg-2);
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card h3 { margin: 0 0 10px; font-size: 13px; color: var(--fg-2); font-weight: 600; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); }
table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
  white-space: nowrap;
}
table.data th, table.data td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
table.data thead th {
  position: sticky;
  top: 0;
  background: var(--bg-3);
  color: var(--fg-2);
  font-weight: 600;
  z-index: 2;
  user-select: none;
}
table.data thead th.sortable { cursor: pointer; }
table.data thead th.sortable:hover { color: var(--fg); }
table.data tbody tr:hover { background: rgba(76,154,255,.06); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.wrap { white-space: normal; min-width: 220px; max-width: 420px; }
table.data td.mono { font-family: var(--mono); font-size: 11.5px; }

/* ---------- Markdown 报告 ---------- */
.md { max-width: 900px; font-size: 14px; }
.md h1 { font-size: 22px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.md h2 { font-size: 18px; margin-top: 28px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.md h3 { font-size: 15px; margin-top: 20px; color: var(--fg); }
.md blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent);
  background: rgba(76,154,255,.07);
  color: var(--fg-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.md code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12.5px; }
.md-table-wrap { overflow-x: auto; margin: 12px 0; }
.md-table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.md-table th { background: var(--bg-3); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.md-check { color: var(--fg-3); }

/* ---------- 图片库 ---------- */
.img-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.img-cell {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
}
.img-cell img { width: 100%; height: 100%; object-fit: contain; display: block; }
.img-cell .tag {
  position: absolute; left: 4px; bottom: 4px;
  padding: 1px 5px; font-size: 10px;
  background: rgba(0,0,0,.7); border-radius: 4px; color: #fff;
}

/* ---------- 日志 ---------- */
.log {
  background: #0b0e12;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #c9d4de;
}
.log .l-err { color: var(--err); }
.log .l-warn { color: var(--warn); }
.log .l-ok { color: var(--ok); }
.log .l-sys { color: var(--accent); }

/* ---------- 提示条 ---------- */
.notice {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  font-size: 13px;
  color: var(--fg-2);
}
.notice.warn { border-color: rgba(210,153,34,.45); background: rgba(210,153,34,.1); color: #e3b341; }
.notice.ok { border-color: rgba(63,185,80,.45); background: rgba(63,185,80,.1); color: #56d364; }
.notice.err { border-color: rgba(248,81,73,.45); background: rgba(248,81,73,.1); color: #ff7b72; }
.notice strong { color: inherit; }

/* ---------- 进度条 ---------- */
.progress { height: 6px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  padding: 9px 16px;
  background: #232b35;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 999;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-err { border-color: rgba(248,81,73,.6); color: #ff7b72; }
.toast-ok { border-color: rgba(63,185,80,.6); color: #56d364; }

/* ---------- 空状态 ---------- */
.empty { padding: 40px 20px; text-align: center; color: var(--fg-3); }
.empty .big { font-size: 30px; margin-bottom: 8px; }

.muted { color: var(--fg-3); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
