/* LDFRP 控制台样式。
 *
 * 刻意不引入任何 CSS 框架：为这点界面加载 200 KB 的 Bootstrap 不划算，
 * 而且弱网下多一个失败点。整套约 6 KB，走 gzip 后不到 2 KB。 */

:root {
    --bg: #f6f5fa;
    --surface: #ffffff;
    --border: #e6e3ef;
    --text: #1f1b2e;
    --muted: #6b6480;
    --primary: #6b4ee6;
    --primary-dark: #5a3fd4;
    --ok: #157347;
    --warn: #b26a00;
    --err: #b42318;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(31, 27, 46, .06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14121c;
        --surface: #1d1a29;
        --border: #2e2940;
        --text: #ece9f5;
        --muted: #a19ab8;
        --primary: #8b73f0;
        --primary-dark: #7a62e0;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Noto Sans SC", sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

.skip {
    position: absolute;
    left: -9999px;
}
.skip:focus {
    left: 12px; top: 12px;
    padding: 8px 14px;
    background: var(--surface);
    border-radius: var(--radius);
    z-index: 100;
}

/* ---- 顶栏 ---- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 58px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
    width: 22px; height: 22px;
    border-radius: 6px;
    background: var(--primary);
    position: relative;
}
.brand-mark::after {
    content: "";
    position: absolute;
    inset: 6px 8px 6px 7px;
    background: var(--surface);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
    padding: 6px 11px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 14px;
}
.nav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.nav a.on { background: var(--bg); color: var(--text); font-weight: 600; }

.who {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--muted);
}
.who a { color: var(--muted); }
.inline { display: inline; margin: 0; }

button.link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}
button.link:hover { color: var(--err); text-decoration: underline; }

/* ---- 主体 ---- */
main { padding: 26px 0 60px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 18px;
}
.card.narrow { max-width: 420px; margin: 40px auto; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.card-title {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 650;
}
.card-head .card-title { margin: 0; }

.hint { color: var(--muted); font-size: 13.5px; margin: 4px 0 16px; }
.hint.center { text-align: center; margin-top: 18px; }
.opt { color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 22px 0; text-align: center; }

/* ---- 统计卡片 ---- */
.grid.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.grid.stats .card { margin: 0; padding: 16px 18px; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.stat-sub { color: var(--muted); font-size: 12.5px; }

/* ---- 表单 ---- */
.form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13.5px; font-weight: 550; }
.field .hint { margin: 0; font-size: 12.5px; }

input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(107, 78, 230, .14);
}

/* ---- 按钮 ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font: inherit;
    font-weight: 550;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 5px 11px; font-size: 13px; }

.btn.danger { color: var(--err); border-color: var(--err); }
.btn.danger:hover { background: rgba(180, 35, 24, .07); }

/* ---- 表格 ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.table tr:last-child td { border-bottom: 0; }

.mono {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
}

/* ---- 徽章 ---- */
.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--border);
}
.pill.ok { color: var(--ok); border-color: currentColor; background: transparent; }
.pill.warn { color: var(--warn); border-color: currentColor; background: transparent; }
.pill.off { color: var(--err); border-color: currentColor; background: transparent; }

/* ---- 提示条 ---- */
.flash {
    padding: 11px 15px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid;
}
.flash.ok { color: var(--ok); border-color: rgba(21, 115, 71, .3); background: rgba(21, 115, 71, .07); }
.flash.err { color: var(--err); border-color: rgba(180, 35, 24, .3); background: rgba(180, 35, 24, .07); }
.flash.warn { color: var(--warn); border-color: rgba(178, 106, 0, .3); background: rgba(178, 106, 0, .07); }

/* ---- 键值列表 ---- */
.kv {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 9px 16px;
    margin: 14px 0 0;
    font-size: 14px;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---- 页脚 ---- */
.footer {
    border-top: 1px solid var(--border);
    padding: 20px 0;
    color: var(--muted);
    font-size: 13px;
}

/* ---- 移动端 ---- */
@media (max-width: 640px) {
    .wrap { padding: 0 14px; }
    .topbar-inner { height: auto; flex-wrap: wrap; padding: 12px 0; gap: 10px; }
    .nav { order: 3; width: 100%; margin-left: 0; }
    .who { margin-left: auto; }
    .card { padding: 16px 14px; }
    .card.narrow { margin: 20px auto; }
    main { padding: 18px 0 40px; }
    .grid.stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-value { font-size: 19px; }
    .kv { grid-template-columns: 92px 1fr; gap: 7px 12px; }
    .table th, .table td { padding: 9px 6px; font-size: 13px; }
}

/* 表单里的多列布局 */
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.row3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.checks { display: flex; gap: 18px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.check input { width: auto; }
td.right { text-align: right; white-space: nowrap; }
td.right .inline + .inline { margin-left: 6px; }
select.mini { width: auto; padding: 4px 8px; font-size: 13px; }

/* 部署命令 */
pre.cmd {
  background: var(--bg-soft, #f5f5f7);
  border: 1px solid var(--line, #e3e3e8);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  cursor: pointer;
}
pre.cmd:hover { border-color: var(--accent, #3b82f6); }

/* 流量柱状图 */
.chart {
  display: flex; align-items: flex-end; gap: 6px;
  height: 140px; padding: 8px 0 24px;
  border-bottom: 1px solid var(--line, #e3e3e8);
}
.bar {
  flex: 1; display: flex; flex-direction: column;
  justify-content: flex-end; align-items: center;
  height: 100%; position: relative; cursor: default;
}
.bar-fill {
  width: 100%; min-height: 2px;
  background: linear-gradient(180deg, var(--accent, #3b82f6), var(--accent-soft, #93c5fd));
  border-radius: 3px 3px 0 0;
  transition: opacity .15s;
}
.bar:hover .bar-fill { opacity: .75; }
.bar-label {
  position: absolute; bottom: -20px;
  font-size: 10px; color: var(--muted, #8a8a93);
  white-space: nowrap;
}

/* 自检 */
.diag { border-left: 3px solid var(--line, #e3e3e8); }
.diag-ok   { border-left-color: var(--ok, #16a34a); }
.diag-warn { border-left-color: #d97706; }
.diag-fail { border-left-color: var(--danger, #dc2626); }

.diag-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.diag-title { font-size: 15px; font-weight: 600; margin: 0; }

.diag-badge {
  font-size: 11px; padding: 2px 7px; border-radius: 10px;
  background: var(--line, #e3e3e8); color: var(--muted, #6b7280);
  white-space: nowrap;
}
.diag-ok .diag-badge   { background: #dcfce7; color: #15803d; }
.diag-warn .diag-badge { background: #fef3c7; color: #b45309; }
.diag-fail .diag-badge { background: #fee2e2; color: #b91c1c; }

.diag-detail { margin: 0 0 6px; font-size: 14px; }
.diag-cause { margin: 0 0 8px; font-size: 13px; color: var(--muted, #6b7280); }
.diag-fix { font-size: 13px; }
.diag-fix ul { margin: 4px 0 0; padding-left: 20px; }
.diag-fix li { margin: 2px 0; line-height: 1.6; }
.diag-fix code, .diag-detail code { 
  background: var(--code-bg, #f3f4f6); padding: 1px 5px; border-radius: 3px;
  font-size: 12px; word-break: break-all;
}

/* 引导步骤 */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.step { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line, #eee); }
.step:last-child { border-bottom: none; }

.step-num {
  flex: 0 0 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  background: var(--line, #eee); color: var(--muted, #888);
}
.step.current .step-num { background: var(--accent, #3b82f6); color: #fff; }
.step.done .step-num { background: var(--ok, #16a34a); color: #fff; }

.step-body { flex: 1; min-width: 0; }
.step-title { font-size: 15px; font-weight: 600; }
.step.done .step-title { color: var(--muted, #888); }
.step-why { font-size: 13px; color: var(--muted, #6b7280); margin-top: 3px; line-height: 1.6; }
.step-body-inner { margin-top: 10px; }

/* 可选完善项 */
.opt-list { display: flex; flex-direction: column; gap: 2px; }
.opt {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line, #f0f0f0);
}
.opt:last-child { border-bottom: none; }
.opt-main { flex: 1; min-width: 0; }
.opt-title { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.opt-detail { font-size: 13px; color: var(--muted, #6b7280); margin-top: 3px; line-height: 1.6; }
.btn-ghost {
  background: transparent; border: 1px solid var(--line, #ddd);
  color: inherit; white-space: nowrap; font-size: 13px;
}
.btn-ghost:hover { border-color: var(--accent, #3b82f6); }

/* ---- 自检页 ---- */

/* 概览：三个数字比一行文字更容易一眼扫到 */
.diag-stats {
  display: flex;
  gap: 10px;
  margin: 14px 0 0;
}

.diag-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid var(--line, #e3e3e8);
  background: var(--bg-soft, #fafafa);
}

.diag-stat-num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.diag-stat-label {
  font-size: 12px;
  color: var(--muted, #6b7280);
  margin-top: 2px;
}

.diag-stat-ok   .diag-stat-num { color: var(--ok, #16a34a); }
.diag-stat-warn .diag-stat-num { color: #d97706; }
.diag-stat-fail .diag-stat-num { color: var(--danger, #dc2626); }

/* 问题项之间留白，块本身也要能立住 */
.diag + .diag {
  margin-top: 10px;
}

.diag {
  padding: 10px 12px;
  margin: 0;
  background: var(--bg, #fff);
}

/* 通过的项压成一行，不占版面 */
.diag-passed {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}

.diag-passed-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.diag-passed-item:nth-child(odd) {
  background: var(--bg-soft, #fafafa);
}

.diag-passed-mark {
  color: var(--ok, #16a34a);
  font-weight: 700;
  flex: none;
}

.diag-passed-title {
  font-weight: 500;
  flex: none;
  min-width: 140px;
}

.diag-passed-detail {
  color: var(--muted, #6b7280);
  word-break: break-word;
}

@media (max-width: 720px) {
  .diag-stats { flex-direction: column; }
  .diag-passed-item { flex-wrap: wrap; }
  .diag-passed-title { min-width: 0; }
}
/* ---- 首页「下一步」 ---- */

.next-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.next-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line, #e3e3e8);
  border-radius: 8px;
  background: var(--bg-soft, #fafafa);
}

.next-step-body {
  flex: 1;
  min-width: 0;
}

.next-step-title {
  font-weight: 600;
  font-size: 14px;
}

.next-step-why {
  font-size: 13px;
  color: var(--muted, #6b7280);
  margin-top: 2px;
  line-height: 1.55;
}

.next-step .btn {
  flex: none;
  text-decoration: none;
}

@media (max-width: 640px) {
  .next-step {
    flex-direction: column;
    align-items: stretch;
  }
}
/* ---- 管理侧概览 ---- */

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.quick-links .btn {
  text-decoration: none;
}

/* 导航里切换面板的入口，和普通菜单拉开距离 */
.nav .switch {
  margin-left: auto;
  opacity: .75;
}

.nav .switch:hover {
  opacity: 1;
}
/* ---- 二次确认弹窗 ---- */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.confirm-overlay[hidden] {
  display: none;
}

.confirm-box {
  background: var(--bg, #fff);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
  padding: 22px 24px 18px;
  width: 100%;
  max-width: 420px;
}

.confirm-text {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text, #1f2328);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.confirm-actions .btn {
  min-width: 76px;
}
