/* Dshy 控制台 v4 · 纸感工作台
   中性底 + 单一玫瑰强调色 + Outfit(拉丁) / 系统(中文)
   亮暗双模式，跟随系统 */

@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/outfit-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+20AC, U+2122;
}

:root {
  --paper: #f4f4f6;
  --surface: #ffffff;
  --surface-soft: #fafafb;
  --ink: #23252f;
  --ink-2: #4d5160;
  --muted: #878c9c;
  --hairline: #e6e7ec;
  --accent: #b8486b;
  --accent-ink: #a03d5d;
  --accent-soft: #f9edf1;
  --ok: #35795c;
  --ok-soft: #e9f4ee;
  --warn: #a06b1f;
  --danger: #b8486b;
  --danger-soft: #f9edf1;
  --shadow: 0 1px 2px rgba(35, 37, 47, .05), 0 4px 16px rgba(35, 37, 47, .06);
  --r-card: 14px;
  --r-btn: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16171c;
    --surface: #1e2027;
    --surface-soft: #21232b;
    --ink: #e8eaf1;
    --ink-2: #c2c5d1;
    --muted: #8b90a0;
    --hairline: #2c2f39;
    --accent: #e0809f;
    --accent-ink: #e89bb4;
    --accent-soft: #322229;
    --ok: #5cb389;
    --ok-soft: #1e2c25;
    --warn: #d1a05a;
    --danger: #e0809f;
    --danger-soft: #322229;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "Outfit", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- 通用控件 ---------- */
input, select {
  width: 100%; padding: 11px 14px; font: inherit; font-size: 15px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-btn);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-btn);
  cursor: pointer; transition: transform .1s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-danger { color: var(--danger); border-color: var(--hairline); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }

/* 图标默认尺寸 */
.ic { width: 20px; height: 20px; flex-shrink: 0; }
.ic-s { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 340px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 36px 28px 30px;
}
.login-mark {
  width: 46px; height: 46px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; background: var(--accent); border-radius: 12px;
}
.login-mark svg { width: 24px; height: 24px; }
.login-card h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; text-align: center; }
.login-sub { color: var(--muted); font-size: 13px; text-align: center; margin: 4px 0 26px; }
.login-err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 13px) 18px 13px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.status-pill {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  color: var(--muted); background: var(--surface); border: 1px solid var(--hairline);
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.status-pill.ok::before { background: var(--ok); }
.status-pill.bad { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.status-pill.bad::before { background: var(--danger); }
@media (prefers-reduced-motion: no-preference) {
  .status-pill.ok::before { animation: breathe 2.4s ease-in-out infinite; }
}
@keyframes breathe { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- 浮动导航 ---------- */
.dock {
  position: fixed; z-index: 30;
  left: 14px; right: 14px; bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; padding: 5px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 11px; font-weight: 600;
  border-radius: 14px; transition: color .15s, background .15s;
}
.tab .ic { width: 21px; height: 21px; }
.tab.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- 内容区 ---------- */
.view { padding: 18px 16px 106px; max-width: 560px; margin: 0 auto; }

/* ---------- 区块标题（朴素语言，不搞大写眉标） ---------- */
.sec {
  display: flex; align-items: center; justify-content: space-between;
  margin: 26px 2px 10px;
}
.sec:first-child { margin-top: 2px; }
.sec h2 { font-size: 16.5px; font-weight: 700; letter-spacing: -0.01em; }
.sec .more { font-size: 13px; color: var(--muted); }

/* ---------- 卡片（留给真正需要容器感的内容） ---------- */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
@media (prefers-reduced-motion: no-preference) {
  .card { animation: rise .3s ease both; }
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------- 状态首卡 ---------- */
.hero { display: flex; align-items: center; gap: 14px; padding: 18px 16px; }
.hero-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ok); background: var(--ok-soft);
}
.hero-icon .ic { width: 22px; height: 22px; }
.hero-icon.off { color: var(--muted); background: var(--paper); }
.hero-body { flex: 1; min-width: 0; }
.hero-state { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.hero-who { font-size: 13px; color: var(--muted); margin-top: 1px; }
.hero-err { font-size: 12.5px; color: var(--danger); margin-top: 2px; }

/* ---------- 指标行（开放式，不做卡片套卡片） ---------- */
.metrics {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-card); box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr 1fr;
  padding: 4px 0; margin-bottom: 12px; overflow: hidden;
}
.metric { padding: 13px 16px; min-width: 0; }
.metric:nth-child(odd) { border-right: 1px solid var(--hairline); }
.metric:nth-child(n+3) { border-top: 1px solid var(--hairline); }
.metric .k { font-size: 12.5px; color: var(--muted); }
.metric .v {
  margin-top: 2px; font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
  word-break: break-all;
}
.metric .v.small { font-size: 13.5px; font-weight: 600; line-height: 1.4; }
.metric .v.num { font-size: 19px; color: var(--accent); }

/* ---------- 键值行 ---------- */
.kv { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; gap: 12px; }
.kv .k { color: var(--muted); font-size: 13px; flex-shrink: 0; }
.kv .v { text-align: right; word-break: break-all; font-weight: 600; }
.v.ok { color: var(--ok); }
.v.err { color: var(--danger); }
.v.warn { color: var(--warn); }

/* ---------- 二维码 ---------- */
.qr-card { display: flex; flex-direction: column; align-items: center; }
.qr-box {
  width: 210px; height: 210px; border-radius: 12px; margin: 4px 0 2px;
  background: #fff; border: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
@media (prefers-color-scheme: dark) { .qr-box { background: #fff; } }
.qr-box svg, .qr-box img { width: 100%; height: 100%; }
.qr-tip { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }

/* ---------- 列表行（只在行间放一条发丝线，不做上下夹边） ---------- */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 2px;
}
.rows .row + .row { border-top: 1px solid var(--hairline); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; word-break: break-all; }
.row-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; word-break: break-all; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.row-actions .btn-sm { padding: 6px 8px; }

/* ---------- 开关 ---------- */
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; cursor: pointer; inset: 0;
  background: #d5d7e0; border-radius: 999px; transition: background .18s;
}
@media (prefers-color-scheme: dark) { .switch .track { background: #3a3d49; } }
.switch .track::before {
  content: ""; position: absolute; height: 22px; width: 22px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(20px); }
.switch input:disabled + .track { opacity: .5; }
@media (prefers-reduced-motion: reduce) { .switch .track::before { transition: none; } }

/* ---------- 单选 ---------- */
.model-radio {
  appearance: none; -webkit-appearance: none;
  width: 21px; height: 21px; margin: 0; flex-shrink: 0; cursor: pointer;
  border: 2px solid var(--hairline); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); transition: border .15s, box-shadow .15s;
}
.model-radio:checked { border: 6.5px solid var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); vertical-align: 2px;
}
.badge.off { color: var(--muted); background: var(--paper); border: 1px solid var(--hairline); }

/* ---------- 日志 ---------- */
.log-box {
  background: #202229; color: #c9cdd9;
  border-radius: var(--r-card); padding: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.6;
  max-height: 58dvh; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}
@media (prefers-color-scheme: dark) { .log-box { background: #101116; border: 1px solid var(--hairline); } }
.log-line { margin-bottom: 3px; }
.lv-INFO { color: #8ab6e0; }
.lv-WARNING { color: #d8b46f; }
.lv-ERROR, .lv-CRITICAL { color: #e08a9d; }
.lv-DEBUG { color: #6f7484; }
.log-t { color: #6f7484; }

/* ---------- 搜索行 ---------- */
.search-row { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.search-row input { margin-bottom: 0; flex: 1; }
.section-gap { margin-top: 14px; }

/* ---------- 骨架屏（替代转圈） ---------- */
.sk {
  border-radius: 7px;
  background: var(--hairline);
  color: transparent !important;
  user-select: none;
}
@media (prefers-color-scheme: no-preference) { /* no-op，占位 */ }
@media (prefers-reduced-motion: no-preference) {
  .sk { animation: shimmer 1.4s ease-in-out infinite; }
}
@keyframes shimmer { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.sk-line { height: 13px; margin: 9px 0; }
.sk-line.w60 { width: 60%; } .sk-line.w80 { width: 80%; } .sk-line.w40 { width: 40%; }

/* ---------- 空状态 ---------- */
.empty {
  border: 1.5px dashed var(--hairline); border-radius: var(--r-card);
  padding: 22px 14px; text-align: center; color: var(--muted);
  font-size: 13px; line-height: 1.8;
}

.toast {
  position: fixed; left: 50%; bottom: calc(94px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; z-index: 99;
  max-width: 86vw; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
