/* ============================================================
 * NetworkPanel 页面框架样式（工具页 / 文档页）
 *
 * 视觉参考 https://net.arsn.cn：白底卡片、1px 细边框、大圆角、弱阴影、
 * 高对比标题 + 次级说明文字；主色沿用本站品牌色 #5668EE。
 * ============================================================ */

:root {
    --np-primary: #5668EE;
    --np-primary-dark: #4557d6;
    --np-primary-soft: rgba(86, 104, 238, 0.08);
    --np-success: #16a34a;
    --np-warning: #f59e0b;
    --np-danger: #ef4444;

    --np-bg: #fafafa;
    --np-card: #ffffff;
    --np-subtle: #f5f6f8;
    --np-border: #e8eaee;
    --np-border-strong: #d9dde5;

    --np-text: #16181d;
    --np-text-secondary: #5b6270;
    --np-text-muted: #8b91a0;

    --np-radius-sm: 8px;
    --np-radius: 12px;
    --np-radius-lg: 16px;
    --np-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --np-shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --np-shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);

    --np-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
        'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    --np-font-mono: 'Geist Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --np-primary: #7b8bff;
        --np-primary-dark: #6a7bf0;
        --np-primary-soft: rgba(123, 139, 255, 0.14);
        --np-bg: #0d0e11;
        --np-card: #14161a;
        --np-subtle: #1b1e24;
        --np-border: #262a32;
        --np-border-strong: #333844;
        --np-text: #ededf1;
        --np-text-secondary: #a5acbb;
        --np-text-muted: #7b8291;
        --np-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
        --np-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
        --np-shadow-md: 0 12px 32px rgba(0, 0, 0, 0.55);
    }
}

* { box-sizing: border-box; }

body.np-body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--np-font);
    font-size: 15px;
    line-height: 1.7;
    color: var(--np-text);
    background: var(--np-bg);
    -webkit-font-smoothing: antialiased;
}

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

.np-container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 clamp(16px, 2vw, 24px);
}

.np-container-wide {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 clamp(16px, 2vw, 24px);
}

/* ============ 顶部导航 ============ */
.np-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--np-card) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--np-border);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
    .np-header { background: var(--np-card); }
}

.np-header-inner {
    display: flex;
    align-items: center;
    gap: 18px;
    height: 60px;
}

.np-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--np-text);
    font-weight: 650;
    flex-shrink: 0;
}
.np-brand:hover { text-decoration: none; }

.np-brand-mark {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--np-primary);
    color: #fff;
}
.np-brand-mark svg { width: 20px; height: 20px; }

.np-brand-name { font-size: 16px; letter-spacing: 0.2px; }

.np-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.np-nav::-webkit-scrollbar { display: none; }

.np-nav-link {
    padding: 7px 12px;
    border-radius: var(--np-radius-sm);
    color: var(--np-text-secondary);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .15s, color .15s;
}
.np-nav-link:hover { background: var(--np-subtle); color: var(--np-text); text-decoration: none; }
.np-nav-link.is-active { background: var(--np-primary-soft); color: var(--np-primary); }

.np-nav-extra { display: inline-flex; gap: 2px; }

.np-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ============ 按钮 / 表单 ============ */
.np-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border: 1px solid var(--np-border-strong);
    border-radius: var(--np-radius-sm);
    background: var(--np-card);
    color: var(--np-text);
    font-size: 14px;
    font-weight: 550;
    font-family: inherit;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s, opacity .15s;
}
.np-btn:hover { background: var(--np-subtle); text-decoration: none; }
.np-btn:disabled { opacity: .55; cursor: not-allowed; }

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

.np-btn-ghost { background: transparent; }

.np-btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }

.np-input,
.np-select {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--np-border-strong);
    border-radius: var(--np-radius-sm);
    background: var(--np-card);
    color: var(--np-text);
    font-size: 15px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.np-input:focus,
.np-select:focus {
    outline: none;
    border-color: var(--np-primary);
    box-shadow: 0 0 0 3px var(--np-primary-soft);
}
.np-input[readonly] { background: var(--np-subtle); color: var(--np-text-secondary); }

.np-select { cursor: pointer; }

.np-field { margin-bottom: 16px; }
.np-field:last-child { margin-bottom: 0; }

.np-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--np-text-secondary);
}

.np-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--np-text-muted);
}

.np-input-group { display: flex; gap: 10px; flex-wrap: wrap; }
.np-input-group > .np-input { flex: 1 1 200px; }
.np-input-group > .np-select { flex: 0 0 auto; width: auto; min-width: 120px; }

.np-stepper { display: flex; gap: 6px; }
.np-stepper .np-btn { width: 42px; padding: 0; font-size: 18px; }

/* ============ 页面主体 ============ */
.np-main { flex: 1; padding-top: 28px; padding-bottom: 48px; }

.np-page-head { margin-bottom: 22px; }

.np-page-title {
    margin: 0;
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.np-page-subtitle {
    margin: 8px 0 0;
    color: var(--np-text-secondary);
    font-size: 15px;
}

.np-card {
    background: var(--np-card);
    border: 1px solid var(--np-border);
    border-radius: var(--np-radius-lg);
    box-shadow: var(--np-shadow);
    padding: 22px;
    margin-bottom: 18px;
}

.np-card:last-child { margin-bottom: 0; }

.np-card-title {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 650;
    display: flex;
    align-items: center;
    gap: 8px;
}

.np-card-desc {
    margin: 0 0 18px;
    font-size: 13px;
    color: var(--np-text-muted);
}

.np-section-title {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 650;
    color: var(--np-text);
}

/* 网格 */
.np-grid { display: grid; gap: 14px; }
.np-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.np-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.np-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (max-width: 900px) {
    .np-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .np-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .np-grid-2, .np-grid-3 { grid-template-columns: 1fr; }
    .np-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .np-card { padding: 18px 16px; }
}

/* 数据块 */
.np-stat {
    border: 1px solid var(--np-border);
    border-radius: var(--np-radius);
    background: var(--np-subtle);
    padding: 14px 16px;
}

.np-stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--np-text-muted);
    margin-bottom: 6px;
}

.np-stat-value {
    font-family: var(--np-font-mono);
    font-size: 18px;
    font-weight: 650;
    color: var(--np-text);
    word-break: break-all;
}

.np-stat-value.is-primary { color: var(--np-primary); }
.np-stat-value.is-success { color: var(--np-success); }

/* 表格 */
.np-table-wrap { overflow-x: auto; }

.np-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.np-table th,
.np-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--np-border);
    white-space: nowrap;
}

.np-table th {
    font-size: 12px;
    font-weight: 650;
    color: var(--np-text-muted);
    background: var(--np-subtle);
}

.np-table tbody tr:last-child td { border-bottom: none; }
.np-table tbody tr:hover { background: var(--np-primary-soft); }

.np-table td.np-num { font-family: var(--np-font-mono); }

/* 键值信息表 */
.np-kv { width: 100%; border-collapse: collapse; }
.np-kv th,
.np-kv td {
    padding: 11px 12px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--np-border);
    vertical-align: top;
}
.np-kv th {
    width: 132px;
    font-weight: 500;
    color: var(--np-text-muted);
    background: var(--np-subtle);
}
.np-kv tr:last-child th,
.np-kv tr:last-child td { border-bottom: none; }
.np-kv td { word-break: break-all; }

@media (max-width: 560px) {
    .np-kv th { width: 96px; }
}

/* 状态提示 */
.np-alert {
    padding: 12px 14px;
    border-radius: var(--np-radius);
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid transparent;
}
.np-alert-info { background: var(--np-primary-soft); border-color: var(--np-primary); color: var(--np-text); }
.np-alert-danger { background: rgba(239, 68, 68, .08); border-color: rgba(239, 68, 68, .45); color: var(--np-danger); }
.np-alert-warning { background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .45); color: #b45309; }
.np-alert[hidden] { display: none; }

/* 标签 */
.np-tag {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background: var(--np-primary-soft);
    color: var(--np-primary);
}
.np-tag-muted { background: var(--np-subtle); color: var(--np-text-muted); }
.np-tag-success { background: rgba(22, 163, 74, .12); color: var(--np-success); }

/* 加载动画 */
.np-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid var(--np-border);
    border-top-color: var(--np-primary);
    border-radius: 50%;
    animation: np-spin .8s linear infinite;
}

@keyframes np-spin { to { transform: rotate(360deg); } }

.np-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 26px 0;
    color: var(--np-text-muted);
    font-size: 14px;
}

/* 工具卡片（工具箱首页） */
.np-tool-card {
    display: block;
    padding: 20px;
    border: 1px solid var(--np-border);
    border-radius: var(--np-radius-lg);
    background: var(--np-card);
    color: var(--np-text);
    box-shadow: var(--np-shadow);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.np-tool-card:hover {
    text-decoration: none;
    transform: translateY(-2px);
    border-color: var(--np-primary);
    box-shadow: var(--np-shadow-md);
}
.np-tool-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--np-primary-soft);
    color: var(--np-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}
.np-tool-name { font-size: 16px; font-weight: 650; margin-bottom: 4px; }
.np-tool-desc { font-size: 13px; color: var(--np-text-muted); line-height: 1.6; }

/* ============ 文档页（用户协议 / 隐私政策） ============ */
.np-doc-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

@media (max-width: 900px) {
    .np-doc-layout { grid-template-columns: 1fr; gap: 18px; }
}

.np-toc {
    position: sticky;
    top: 84px;
    border: 1px solid var(--np-border);
    border-radius: var(--np-radius);
    background: var(--np-card);
    padding: 16px;
    font-size: 13px;
}

.np-toc-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--np-text-muted);
    margin-bottom: 10px;
}

.np-toc-list { list-style: none; margin: 0; padding: 0; }
.np-toc-list li { margin-bottom: 2px; }
.np-toc-list a {
    display: block;
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--np-text-secondary);
    line-height: 1.5;
}
.np-toc-list a:hover { background: var(--np-subtle); text-decoration: none; }
.np-toc-list a.is-active { background: var(--np-primary-soft); color: var(--np-primary); font-weight: 600; }

@media (max-width: 900px) {
    .np-toc { position: static; }
}

.np-doc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px dashed var(--np-border-strong);
    border-radius: var(--np-radius);
    font-size: 13px;
    color: var(--np-text-muted);
}

.np-doc-body { font-size: 15px; line-height: 1.85; color: var(--np-text); }
.np-doc-body h2 {
    margin: 30px 0 12px;
    padding-top: 6px;
    font-size: 19px;
    font-weight: 680;
    scroll-margin-top: 84px;
}
.np-doc-body h2:first-child { margin-top: 0; }
.np-doc-body h3 {
    margin: 20px 0 8px;
    font-size: 16px;
    font-weight: 650;
    scroll-margin-top: 84px;
}
.np-doc-body p { margin: 0 0 14px; }
.np-doc-body ul,
.np-doc-body ol { margin: 0 0 16px; padding-left: 24px; }
.np-doc-body li { margin-bottom: 6px; }
.np-doc-body strong { font-weight: 650; }
.np-doc-body hr { border: none; border-top: 1px solid var(--np-border); margin: 24px 0; }
.np-doc-body blockquote {
    margin: 0 0 16px;
    padding: 10px 16px;
    border-left: 3px solid var(--np-primary);
    background: var(--np-primary-soft);
    border-radius: 0 var(--np-radius-sm) var(--np-radius-sm) 0;
}
.np-doc-body code {
    font-family: var(--np-font-mono);
    font-size: 13px;
    background: var(--np-subtle);
    padding: 2px 6px;
    border-radius: 5px;
}
.np-doc-body table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.np-doc-body th,
.np-doc-body td { border: 1px solid var(--np-border); padding: 8px 10px; font-size: 14px; }
.np-doc-body th { background: var(--np-subtle); }

.np-doc-empty {
    padding: 40px 0;
    text-align: center;
    color: var(--np-text-muted);
}

.np-doc-updated { font-family: var(--np-font-mono); }

/* ============ 页脚 ============ */
.np-footer {
    border-top: 1px solid var(--np-border);
    background: var(--np-card);
    padding: 24px 0 32px;
    font-size: 13px;
    color: var(--np-text-muted);
    text-align: center;
}

.np-footer-links {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.np-dot { color: var(--np-border-strong); }
.np-footer-text { margin-bottom: 8px; white-space: pre-wrap; text-align: center; }
.np-footer-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}
.np-footer-html { margin-top: 10px; text-align: center; }

/* 移动端：页脚链接在小屏下自动换行并保持居中 */
@media (max-width: 480px) {
    .np-footer { padding: 18px 0 24px; }
    .np-footer-links { gap: 8px; }
    .np-footer-meta { gap: 8px; }
}

/* ============ 返回顶部 ============ */
.np-backtop {
    position: fixed;
    right: 20px;
    bottom: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--np-border-strong);
    background: var(--np-card);
    color: var(--np-text-secondary);
    cursor: pointer;
    box-shadow: var(--np-shadow-md);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 60;
}
.np-backtop.is-visible { display: flex; }

/* ============================================================
 * IP 进阶工具页（ip-tools.php）专用组件
 * ============================================================ */

.np-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 768px) { .np-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 结果展示区 */
.np-result { margin-top: 16px; }
.np-result[hidden] { display: none; }

/* 徽标 */
.np-badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.np-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
    line-height: 1.6;
}
.np-badge-ok { background: rgba(22, 163, 74, 0.12); color: var(--np-success); }
.np-badge-warn { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.np-badge-muted {
    background: var(--np-subtle); color: var(--np-text-secondary);
    font-weight: 500; font-family: var(--np-font-mono); font-size: 12.5px;
}

/* 说明文字 */
.np-note { margin: 12px 0 0; font-size: 13.5px; color: var(--np-text-secondary); line-height: 1.7; }
.np-note:first-child { margin-top: 0; }
.np-note-warn { color: #b45309; }
.np-note-muted { color: var(--np-text-muted); font-size: 12.5px; }

/* 小型输入框（端口等） */
.np-input-sm {
    flex: 0 0 auto; width: 150px;
    height: 42px; padding: 0 12px;
    border: 1px solid var(--np-border-strong); border-radius: var(--np-radius-sm);
    font-size: 14px; color: var(--np-text); background: var(--np-card);
    font-family: var(--np-font-mono);
}
.np-input-sm:focus { outline: none; border-color: var(--np-primary); box-shadow: 0 0 0 3px var(--np-primary-soft); }

/* 统计卡补充 */
.np-stat-sub { margin-top: 4px; font-size: 12px; color: var(--np-text-muted); font-family: var(--np-font-mono); }
.np-unit { font-size: 13px; font-weight: 500; color: var(--np-text-muted); margin-left: 2px; }
.np-stat-value.is-danger { color: var(--np-danger); font-size: 22px; }

/* 状态点 */
.np-dot-ok { color: var(--np-success); font-weight: 600; }

/* ============================================================
 * 主题切换按钮
 * ============================================================ */
.np-theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--np-border-strong);
    border-radius: 999px;
    background: var(--np-card);
    color: var(--np-text-secondary);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.np-theme-switch:hover {
    background: var(--np-subtle);
    border-color: var(--np-primary);
    color: var(--np-primary);
    text-decoration: none;
}
.np-theme-switch-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--np-primary);
    box-shadow: 0 0 0 3px var(--np-primary-soft);
    flex-shrink: 0;
}
.np-theme-switch-text { line-height: 1; }

@media (max-width: 768px) {
    .np-theme-switch { padding: 0 8px; }
    .np-theme-switch-text { display: none; }
    .np-theme-switch-dot { margin: 0 1px; }
}

/* ============================================================
 * 首页重要合规提示 / 公告提示模块（抗插件拦截）
 * 不使用 ad/notice/promo/banner/announcement 等敏感类名
 * 关键文本通过 JS base64 解码注入，减少静态匹配
 * ============================================================ */
.h-m { margin: 14px 0 0; }
.h-m:first-child { margin-top: 0; }

.h-m-i {
    padding: 14px 18px;
    border-radius: var(--np-radius);
    border: 1px solid var(--np-border);
    background: var(--np-card);
    font-size: 14px;
    line-height: 1.7;
}
.h-m-i p { margin: 0; }
.h-m-i p + p { margin-top: 8px; }
.h-m-i a { color: var(--np-primary); text-decoration: underline; }
.h-m-i a:hover { color: var(--np-primary-dark); }

.h-m-cs .h-m-i {
    background: var(--hm-bg, #fff9e6);
    border-color: var(--hm-border, #f0d99e);
    color: #5c4a15;
}

.h-m-nt .h-m-i {
    background: var(--hm-bg, #f0f5ff);
    border-color: var(--hm-border, #c7d2f5);
    color: #24326b;
}

@media (prefers-color-scheme: dark) {
    .h-m-cs .h-m-i { background: #2e2818; border-color: #5c4f2a; color: #efe3c3; }
    .h-m-nt .h-m-i { background: #161b30; border-color: #2c355c; color: #d4dbfa; }
}
.np-dot-bad { color: var(--np-danger); font-weight: 600; }
