/*
 * BT Universal Console 主样式
 * 说明：全部界面样式集中在本文件，避免内联样式，方便二次开发和统一换肤。
 */

:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #172033;
  --muted: #708098;
  --line: #e5eaf2;
  --primary: #20b57a;
  --primary-dark: #159766;
  --primary-soft: #e9f9f2;
  --danger: #e55665;
  --danger-soft: #fff0f2;
  --warning: #e5a42d;
  --warning-soft: #fff7e4;
  --info: #3979e8;
  --info-soft: #edf4ff;
  --shadow: 0 14px 45px rgba(25, 42, 70, .09);
  --shadow-soft: 0 5px 22px rgba(25, 42, 70, .07);
  --sidebar: #121b2c;
  --sidebar-2: #18253b;
  --sidebar-text: #b9c5d8;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-width: 244px;
}

html[data-theme="dark"] {
  --bg: #0d1420;
  --panel: #121d2c;
  --panel-2: #172435;
  --text: #edf4ff;
  --muted: #98a8bf;
  --line: #26354a;
  --primary-soft: rgba(32, 181, 122, .14);
  --danger-soft: rgba(229, 86, 101, .12);
  --warning-soft: rgba(229, 164, 45, .12);
  --info-soft: rgba(57, 121, 232, .14);
  --shadow: 0 14px 45px rgba(0, 0, 0, .25);
  --shadow-soft: 0 5px 22px rgba(0, 0, 0, .2);
  --sidebar: #09111d;
  --sidebar-2: #101c2e;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
code, pre, .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(57, 121, 232, .18);
  outline-offset: 2px;
}
.is-hidden { display: none !important; }
.noscript { padding: 16px; background: #9f1d2a; color: #fff; text-align: center; }

/* ---------- 连接页 ---------- */
.connect-view {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 34px 18px;
  background:
    radial-gradient(circle at 20% 10%, rgba(32, 181, 122, .15), transparent 32%),
    radial-gradient(circle at 90% 85%, rgba(57, 121, 232, .14), transparent 35%),
    linear-gradient(145deg, #eff8f5, #f7f9fc 56%, #eef4ff);
}
html[data-theme="dark"] .connect-view {
  background:
    radial-gradient(circle at 20% 10%, rgba(32, 181, 122, .12), transparent 32%),
    radial-gradient(circle at 90% 85%, rgba(57, 121, 232, .11), transparent 35%),
    linear-gradient(145deg, #09111b, #0e1623 56%, #0a1320);
}
.connect-bg { position: absolute; border-radius: 999px; filter: blur(1px); pointer-events: none; }
.connect-bg-a { width: 300px; height: 300px; top: -100px; right: 8%; background: rgba(32, 181, 122, .08); }
.connect-bg-b { width: 260px; height: 260px; bottom: -90px; left: 10%; background: rgba(57, 121, 232, .07); }
.connect-card {
  position: relative;
  width: min(520px, 100%);
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(255, 255, 255, .8);
  box-shadow: 0 28px 80px rgba(31, 50, 82, .15);
  border-radius: 24px;
  padding: 30px;
  backdrop-filter: blur(16px);
}
html[data-theme="dark"] .connect-card {
  background: rgba(18, 29, 44, .94);
  border-color: rgba(255, 255, 255, .06);
}
.brand-block { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.brand-logo {
  width: 52px; height: 52px; border-radius: 15px;
  display: grid; place-items: center;
  color: #fff; font-size: 20px; font-weight: 800; letter-spacing: -.5px;
  background: linear-gradient(135deg, #20b57a, #2dcd91);
  box-shadow: 0 12px 26px rgba(32, 181, 122, .25);
}
.brand-logo-small { width: 38px; height: 38px; border-radius: 11px; font-size: 15px; box-shadow: none; }
.brand-block h1 { margin: 0; font-size: 22px; letter-spacing: -.4px; }
.brand-block p { margin: 3px 0 0; color: var(--muted); }
.field-label { display: block; font-weight: 700; margin: 15px 0 7px; }
.input-wrap { position: relative; }
.input-wrap input, .form-control, .form-select, .form-textarea {
  width: 100%; min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.input-wrap input { min-height: 46px; padding: 11px 13px; }
.password-wrap input { padding-right: 68px; }
.password-wrap .icon-btn { position: absolute; right: 6px; top: 6px; min-width: 52px; height: 34px; font-size: 12px; }
.input-wrap input:focus, .form-control:focus, .form-select:focus, .form-textarea:focus {
  border-color: rgba(32, 181, 122, .75);
  box-shadow: 0 0 0 4px rgba(32, 181, 122, .10);
  outline: none;
}
.field-help { margin-top: 6px; color: var(--muted); font-size: 12px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 16px 0; color: var(--muted); user-select: none; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.connect-help { margin-top: 16px; color: var(--muted); }
.connect-help summary { cursor: pointer; color: var(--text); font-weight: 700; }
.help-copy { padding: 4px 4px 0 17px; font-size: 12.5px; }
.help-copy p { margin: 8px 0; }
.connect-foot { text-align: center; margin-top: 22px; color: var(--muted); font-size: 12px; }

/* ---------- 通用控件 ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  min-height: 36px;
  padding: 8px 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-weight: 650;
  transition: transform .12s ease, background .16s ease, border-color .16s ease, opacity .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn-light:hover { background: var(--panel-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); background: transparent; border-color: rgba(229, 86, 101, .25); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-sm { min-height: 30px; padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; min-height: 46px; }
.btn-loader { display: none; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.is-loading .btn-loader { display: inline-block; }
.btn.is-loading .btn-text { opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 9px; min-width: 36px; height: 36px; padding: 0 9px;
  display: inline-grid; place-items: center;
}
.icon-btn:hover { background: var(--panel-2); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-success { background: var(--primary-soft); color: var(--primary-dark); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: #ad7417; }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.notice { border-radius: 12px; padding: 12px 14px; display: flex; gap: 5px; flex-direction: column; border: 1px solid transparent; margin-bottom: 14px; }
.notice strong { font-size: 13px; }
.notice span, .notice p { color: var(--muted); margin: 0; }
.notice-info { background: var(--info-soft); border-color: rgba(57, 121, 232, .13); }
.notice-warning { background: var(--warning-soft); border-color: rgba(229, 164, 45, .17); }
.notice-danger { background: var(--danger-soft); border-color: rgba(229, 86, 101, .17); }
.notice-success { background: var(--primary-soft); border-color: rgba(32, 181, 122, .16); }

/* ---------- 应用布局 ---------- */
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
  width: var(--sidebar-width); color: var(--sidebar-text);
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  border-right: 1px solid rgba(255,255,255,.04);
  display: flex; flex-direction: column;
}
.sidebar-brand { height: 68px; padding: 0 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-brand-text strong { color: #fff; font-size: 14px; }
.sidebar-brand-text span { color: #74869f; font-size: 11px; }
.sidebar-close { display: none; margin-left: auto; background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.08); color: #fff; }
.main-nav { flex: 1; padding: 12px 9px; overflow-y: auto; }
.nav-item {
  width: 100%; border: 0; background: transparent; color: var(--sidebar-text);
  padding: 9px 11px; margin: 2px 0; border-radius: 9px;
  display: flex; align-items: center; gap: 11px; text-align: left;
  transition: background .15s ease, color .15s ease;
}
.nav-item span { width: 21px; text-align: center; font-size: 16px; color: #7f92ad; }
.nav-item b { font-weight: 600; font-size: 13px; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: rgba(32, 181, 122, .15); color: #fff; }
.nav-item.active span { color: #45dda5; }
.sidebar-bottom { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.connection-mini { display: flex; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 10px; background: rgba(255,255,255,.04); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 4px rgba(52,211,153,.08); flex: 0 0 auto; }
.connection-mini div { min-width: 0; display: flex; flex-direction: column; }
.connection-mini b { color: #fff; font-size: 11px; }
.connection-mini small { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8294ae; font-size: 10px; }
.main-area { width: 100%; min-width: 0; margin-left: var(--sidebar-width); }
.topbar {
  height: 68px; position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 0 22px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar h2 { margin: 0; font-size: 18px; }
.topbar p { margin: 1px 0 0; color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.mobile-menu { display: none; }
.page-container { padding: 22px; max-width: 1680px; margin: 0 auto; }
.sidebar-mask { display: none; }

/* ---------- 页面组件 ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.page-head h3 { margin: 0; font-size: 18px; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; max-width: 740px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.card-head { padding: 15px 17px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h4 { margin: 0; font-size: 14px; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.card-body { padding: 16px 17px; }
.stat-card { padding: 16px 17px; display: flex; flex-direction: column; gap: 6px; min-height: 116px; }
.stat-top { display: flex; justify-content: space-between; align-items: center; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary-dark); font-weight: 800; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.6px; }
.stat-sub { color: var(--muted); font-size: 11px; }
.progress { height: 7px; background: var(--panel-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #56d6a8); border-radius: inherit; }
.progress.is-warning > i { background: linear-gradient(90deg, #e5a42d, #f2c461); }
.progress.is-danger > i { background: linear-gradient(90deg, #e55665, #ef8d97); }
.kv-list { display: grid; gap: 10px; }
.kv-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding-bottom: 9px; border-bottom: 1px dashed var(--line); }
.kv-row:last-child { border-bottom: 0; padding-bottom: 0; }
.kv-row span { color: var(--muted); }
.kv-row b { text-align: right; word-break: break-word; }

.table-card { overflow: hidden; }
.table-toolbar { padding: 13px 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.search-input { position: relative; flex: 1; max-width: 340px; }
.search-input input { width: 100%; height: 36px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 9px; padding: 7px 11px 7px 32px; }
.search-input span { position: absolute; left: 11px; top: 8px; color: var(--muted); }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.data-table th, .data-table td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { background: var(--panel-2); color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.data-table td { font-size: 12px; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.data-table tr:last-child td { border-bottom: 0; }
.cell-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.cell-main { font-weight: 700; }
.cell-sub { color: var(--muted); font-size: 10px; margin-top: 2px; }
.empty-state { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 5px; }
.loading-state { padding: 34px 20px; text-align: center; color: var(--muted); }
.loading-ring { width: 24px; height: 24px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 9px; }

/* 文件管理 */
.file-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; min-height: 36px; padding: 7px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; }
.breadcrumb button { border: 0; background: transparent; color: var(--info); padding: 0 3px; }
.file-name { display: flex; align-items: center; gap: 7px; }
.file-icon { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); }
.file-row-dir .file-icon { background: var(--warning-soft); color: #b27817; }
.editor-area { min-height: 52vh; resize: vertical; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; line-height: 1.55; tab-size: 2; }

/* 服务中心 */
.service-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.service-card { padding: 15px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.service-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); border-color: rgba(32,181,122,.32); }
.service-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.service-card h4 { margin: 0; font-size: 14px; }
.service-card p { margin: 5px 0 11px; color: var(--muted); font-size: 11px; min-height: 34px; }
.service-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.action-chip { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 7px; padding: 4px 7px; font-size: 10px; }
.action-chip:hover { border-color: rgba(32,181,122,.4); color: var(--primary-dark); }

/* API 调试台 */
.console-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-group { min-width: 0; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 700; }
.form-group .help { color: var(--muted); font-size: 10px; margin-top: 5px; }
.form-textarea { min-height: 110px; resize: vertical; }
.code-box { background: #0b1320; color: #d8e4f3; border-radius: 10px; padding: 13px; overflow: auto; min-height: 180px; max-height: 520px; white-space: pre-wrap; word-break: break-word; font-size: 11px; line-height: 1.55; }
.code-box .json-key { color: #7dd3fc; }
.response-meta { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 9px; }

/* 请求日志 */
.log-method { font-weight: 800; font-size: 10px; }
.log-ok { color: var(--primary-dark); }
.log-fail { color: var(--danger); }

/* 帮助 */
.help-section { padding: 17px; }
.help-section h4 { margin: 0 0 8px; }
.help-section p, .help-section li { color: var(--muted); font-size: 12px; }
.help-section ul, .help-section ol { padding-left: 20px; }
.inline-code { background: var(--panel-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 18px; }
.modal.open { display: flex; }
.modal-mask { position: absolute; inset: 0; background: rgba(4, 10, 18, .58); backdrop-filter: blur(3px); }
.modal-card { position: relative; z-index: 1; width: min(720px, 100%); max-height: calc(100vh - 36px); overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 24px 70px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.modal-head { padding: 16px 18px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.modal-wide .modal-card { width: min(980px, 100%); }

/* ---------- Toast ---------- */
.toast-container { position: fixed; top: 82px; right: 18px; z-index: 130; width: min(360px, calc(100vw - 36px)); display: grid; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 10px; box-shadow: var(--shadow); padding: 11px 13px; animation: toastIn .18s ease both; }
.toast.success { border-left-color: var(--primary); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast strong { display: block; margin-bottom: 2px; font-size: 12px; }
.toast p { margin: 0; color: var(--muted); font-size: 11px; word-break: break-word; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.16); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-grid; }
  .sidebar-mask { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.42); }
  .sidebar-mask.open { display: block; }
  .main-area { margin-left: 0; }
  .mobile-menu { display: inline-grid; }
  .console-layout { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
  .page-container { padding: 15px; }
  .topbar-actions .badge { display: none; }
}

@media (max-width: 680px) {
  .connect-card { padding: 22px 18px; border-radius: 18px; }
  .grid-4, .grid-3, .grid-2, .service-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .page-actions { justify-content: flex-start; width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: auto; }
  .topbar { height: auto; min-height: 64px; padding-top: 8px; padding-bottom: 8px; }
  .topbar p { display: none; }
  .topbar-actions { gap: 5px; }
  .topbar-actions .btn { padding: 7px 9px; min-height: 34px; font-size: 11px; }
  .topbar-actions #disconnectBtn { display: none; }
  .page-container { padding: 12px; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .search-input { max-width: none; }
  .modal { padding: 8px; align-items: flex-end; }
  .modal-card { max-height: calc(100vh - 16px); border-radius: 16px 16px 8px 8px; }
}

/* ---------- 通用布局辅助类（避免在业务模板中重复写静态内联样式） ---------- */
.page-gap { margin-top: 14px; }
.compact-actions { margin-top: 12px; justify-content: flex-start; }
.code-box-short { min-height: 120px; max-height: 360px; }
.full-span { grid-column: 1 / -1; }

/* 资源进度条按 5% 分档，保持 CSS 与 HTML/JS 结构分离。 */
.progress-w-0 { width: 0%; }
.progress-w-5 { width: 5%; }
.progress-w-10 { width: 10%; }
.progress-w-15 { width: 15%; }
.progress-w-20 { width: 20%; }
.progress-w-25 { width: 25%; }
.progress-w-30 { width: 30%; }
.progress-w-35 { width: 35%; }
.progress-w-40 { width: 40%; }
.progress-w-45 { width: 45%; }
.progress-w-50 { width: 50%; }
.progress-w-55 { width: 55%; }
.progress-w-60 { width: 60%; }
.progress-w-65 { width: 65%; }
.progress-w-70 { width: 70%; }
.progress-w-75 { width: 75%; }
.progress-w-80 { width: 80%; }
.progress-w-85 { width: 85%; }
.progress-w-90 { width: 90%; }
.progress-w-95 { width: 95%; }
.progress-w-100 { width: 100%; }

/* ---------- v7.0：登录帮助与全局居中提示 ---------- */
.help-nested {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  overflow: hidden;
}
.help-nested > summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--text);
  font-weight: 700;
  list-style-position: inside;
}
.help-nested-body {
  padding: 0 12px 10px;
  border-top: 1px solid var(--line);
}
.help-nested-body p { margin: 9px 0; line-height: 1.65; }

/* 所有 Toast 改成屏幕正中央，不再显示在右上角。 */
.toast-container {
  position: fixed;
  inset: 0;
  z-index: 130;
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  pointer-events: none;
}
.toast {
  width: min(460px, calc(100vw - 36px));
  pointer-events: auto;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid var(--info);
  border-left: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.24);
  padding: 16px 18px;
  animation: toastCenterIn .18s ease both;
}
.toast.success { border-top-color: var(--primary); border-left-color: var(--line); }
.toast.error { border-top-color: var(--danger); border-left-color: var(--line); }
.toast.warning { border-top-color: var(--warning); border-left-color: var(--line); }
.toast strong { display: block; margin-bottom: 6px; font-size: 14px; }
.toast p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; word-break: break-word; }
@keyframes toastCenterIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* v7.2：所有提示统一使用屏幕正中央“模态提示”，并带背景遮罩。 */
.toast-container {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  pointer-events: none;
}
.toast-container.has-toast { display: flex !important; }
.toast-container.has-toast::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(8, 15, 28, .42);
  backdrop-filter: blur(2px);
}
.toast-container .toast {
  position: relative;
  z-index: 1;
  width: min(500px, calc(100vw - 40px));
  margin: 0 !important;
  text-align: center;
  border-radius: 16px;
  padding: 22px 44px 20px 22px;
  box-shadow: 0 28px 90px rgba(0,0,0,.30);
}
.toast-close {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 30px;
  cursor: pointer;
}
.toast-close:hover { background: var(--soft); color: var(--text); }
.check-row-warning { margin-top: 8px; }


/* v7.2：概览自动刷新控件与已安装服务管理。 */
.dashboard-actions { align-items: center; }
.auto-refresh-toggle { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--text); font-size: 12px; cursor: pointer; }
.auto-refresh-toggle input { width: 15px; height: 15px; accent-color: var(--primary); }
.compact-select { width: auto; min-width: 82px; height: 34px; padding-top: 0; padding-bottom: 0; }
.installed-service-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.installed-service-item { border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: var(--soft); }
.installed-service-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.installed-service-main strong { display:block; font-size: 13px; }
.installed-service-main span:not(.badge) { display:block; margin-top:4px; color:var(--muted); font-size:11px; }
.service-note { margin-top: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.service-note strong { display:block; margin-bottom:4px; font-size:12px; }
.service-note span { display:block; color:var(--muted); font-size:11px; line-height:1.65; }
@media (max-width: 860px) { .installed-service-grid { grid-template-columns:1fr; } .dashboard-actions { width:100%; } }

/* ---------- v7.2.1：本地连接历史与服务操作遮罩 ---------- */
.connection-history-field { position: relative; }
.connection-history {
  position: absolute;
  z-index: 45;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(5, 14, 26, .18);
}
.connection-history.is-hidden { display: none; }
.connection-history-empty { padding: 16px 12px; text-align: center; color: var(--muted); font-size: 12px; }
.connection-history-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 11px;
  border-radius: 9px;
  cursor: pointer;
  display: grid;
  gap: 3px;
}
.connection-history-item:hover,
.connection-history-item:focus { outline: none; background: var(--primary-soft); }
.connection-history-item strong { font-size: 12px; word-break: break-all; }
.connection-history-item span { color: var(--muted); font-size: 10px; }

.php-service-control { margin-top: 12px; }
.php-service-select-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 10px; }
.php-service-select-row .form-select { min-width: 180px; width: auto; }
.php-service-status { margin-left: auto; }

.operation-overlay {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.operation-overlay.open { display: flex; }
.operation-overlay-mask {
  position: absolute;
  inset: 0;
  background: rgba(4, 10, 18, .68);
  backdrop-filter: blur(5px);
}
.operation-overlay-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  padding: 28px 28px 24px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 19px;
  box-shadow: 0 32px 100px rgba(0,0,0,.34);
}
.operation-overlay-icon {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid rgba(32,181,122,.22);
  font-size: 30px;
  font-weight: 800;
  animation: operationSpin 1.15s linear infinite;
}
.operation-overlay-card h3 { margin: 0; font-size: 18px; }
.operation-overlay-card p { margin: 7px 0 15px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.operation-overlay-card strong { display: block; margin-top: 11px; font-size: 13px; }
.operation-overlay-card small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.55; }
.operation-progress { height: 9px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.operation-progress i { display: block; height: 100%; width: 8%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #56d6a8); transition: width .28s ease; }
.operation-overlay.is-success .operation-overlay-icon { animation: none; color: var(--primary-dark); }
.operation-overlay.is-danger .operation-overlay-icon { animation: none; color: var(--danger); background: var(--danger-soft); }
@keyframes operationSpin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  .connection-history { max-height: 220px; }
  .php-service-select-row { align-items: stretch; }
  .php-service-select-row .form-select { width: 100%; }
  .php-service-status { margin-left: 0; }
  .operation-overlay-card { padding: 24px 18px 21px; }
}

/* v7.2.2：API JSON 默认转换为可读信息，原始返回仅作为可展开的排查信息。 */
.readable-response { display: grid; gap: 14px; }
.readable-response-host { min-height: 150px; }
.readable-kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 14px; }
.readable-kv-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(248,250,252,.72); }
.readable-kv-key { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.readable-kv-row strong { text-align: right; font-size: 13px; font-weight: 650; min-width: 0; }
.readable-wrap { word-break: break-word; overflow-wrap: anywhere; }
.readable-empty { color: var(--muted); font-weight: 500; }
.readable-number { font-variant-numeric: tabular-nums; }
.readable-bool { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.readable-bool.is-true { background: rgba(16,185,129,.12); color: #047857; }
.readable-bool.is-false { background: rgba(100,116,139,.12); color: #475569; }
.readable-stack { display: grid; gap: 12px; }
.readable-section { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.readable-section > h5, .readable-section-head h5 { margin: 0; font-size: 13px; }
.readable-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.readable-section-head span { color: var(--muted); font-size: 11px; }
.readable-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.readable-table { min-width: 560px; margin: 0; }
.readable-table th, .readable-table td { vertical-align: top; }
.readable-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.readable-tag { padding: 5px 9px; border-radius: 999px; background: #f1f5f9; border: 1px solid var(--line); font-size: 12px; }
.readable-single, .readable-empty-state { padding: 14px; border: 1px dashed var(--line); border-radius: 10px; background: #f8fafc; color: var(--muted); }
.raw-details { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.raw-details summary { cursor: pointer; user-select: none; color: var(--muted); font-size: 12px; font-weight: 650; }
.raw-details[open] summary { margin-bottom: 9px; }
.service-runtime-note { display: inline-flex; margin-left: 7px; padding: 2px 6px; border-radius: 999px; background: rgba(16,185,129,.1); color: #047857; font-size: 10px; font-weight: 700; vertical-align: 1px; }
@media (max-width: 760px) {
  .readable-kv { grid-template-columns: 1fr; }
  .readable-kv-row { flex-direction: column; gap: 5px; }
  .readable-kv-row strong { text-align: left; }
}
