/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --purple: #8b5cf6;
    --blue: #3b82f6;
    --green: #22c55e;
    --red: #ef4444;
    --orange: #f97316;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ===== Header ===== */
.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.logo-icon { font-size: 24px; }

.search-box {
    flex: 1;
    max-width: 500px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

#searchInput {
    width: 100%;
    padding: 10px 40px 10px 44px;
    border: 2px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    background: var(--bg);
    transition: all 0.2s;
    outline: none;
}

#searchInput:focus {
    border-color: var(--primary);
    background: var(--card);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.clear-btn {
    position: absolute;
    right: 12px;
    background: var(--border);
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-link {
    white-space: nowrap;
    padding: 8px 16px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.admin-link:hover { background: var(--primary); color: #fff; }

/* ===== Layout: 左侧侧栏 + 主内容 ===== */
.layout-wrapper {
    display: flex;
    align-items: stretch;
}

.site-sidebar {
    flex: 0 0 240px;
    width: 240px;
    background: var(--card);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: flex-basis 0.25s ease, width 0.25s ease;
    z-index: 90;
}

body.sidebar-collapsed .site-sidebar {
    flex-basis: 0;
    width: 0;
}

.site-main-col {
    flex: 1;
    min-width: 0;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--bg); color: var(--primary); }

.sidebar-cats {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
    color: var(--text-muted);
}

.category-tab:hover { background: var(--bg); color: var(--text); }
.category-tab.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

.cat-icon { font-size: 16px; flex-shrink: 0; }

.cat-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cat-count {
    font-size: 12px;
    background: var(--bg);
    color: var(--text-muted);
    padding: 1px 9px;
    border-radius: 10px;
    flex-shrink: 0;
}

.category-tab.active .cat-count { background: #fff; color: var(--primary-dark); }

.sidebar-foot {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-stat { font-size: 12px; color: var(--text-muted); }
.sidebar-stat b { color: var(--text); }

.sidebar-admin {
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.sidebar-admin:hover { text-decoration: underline; }

/* 浮动展开按钮 + 遮罩 */
.sidebar-floating-btn {
    position: fixed;
    top: 76px;
    left: 14px;
    z-index: 190;
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    font-size: 18px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.15s;
}

.sidebar-floating-btn:hover { background: var(--primary-dark); }

body.sidebar-collapsed .sidebar-floating-btn { display: flex; }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 180;
    display: none;
}

/* ===== Main Content ===== */
.main-content { padding: 32px 0; min-height: calc(100vh - 200px); }

.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

/* ===== Category Section ===== */
.category-section { margin-bottom: 40px; }

.category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.category-title {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cat-icon-large { font-size: 24px; }

.category-desc {
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Links Grid ===== */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.25s;
    cursor: pointer;
}

.link-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.link-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.link-icon img { width: 40px; height: 40px; border-radius: 10px; }

.fallback-letter {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    border-radius: 10px;
}

.link-info { min-width: 0; flex: 1; }

.link-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-desc {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Notes ===== */
.notes-section { margin-top: 40px; }

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.note-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.25s;
}

.note-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary); }

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

.note-title { font-size: 16px; font-weight: 600; }

.note-tag {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
}

.note-content {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 12px;
}

.note-footer { font-size: 12px; color: #94a3b8; }

/* ===== Search Results ===== */
.search-results { padding: 24px 0; }
.search-results .section-title { margin-bottom: 16px; }

.no-results { text-align: center; padding: 60px 0; color: var(--text-muted); }
.no-results-icon { font-size: 48px; margin-bottom: 12px; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; margin-bottom: 8px; color: var(--text); }
.empty-state p { margin-bottom: 20px; }

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

/* ===== Buttons ===== */
.btn-primary {
    display: inline-block;
    padding: 10px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    display: inline-block;
    padding: 10px 24px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-secondary:hover { background: var(--border); }

.btn-block { width: 100%; text-align: center; }

.btn-link {
    color: var(--primary);
    font-size: 13px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}

.btn-link:hover { text-decoration: underline; }
.btn-danger { color: var(--red); }
.inline-form { display: inline; }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* ===== Admin Login ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    text-align: center;
}

.login-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 24px; }
.back-link { display: inline-block; margin-top: 16px; color: var(--text-muted); font-size: 13px; }
.back-link:hover { color: var(--primary); }

/* ===== Admin Layout ===== */
.admin-body { background: var(--bg); }

.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: 220px;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
}

.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
.sidebar-logo { font-size: 18px; font-weight: 700; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    color: var(--text-muted);
    transition: all 0.15s;
}

.sidebar-link:hover { background: var(--bg); color: var(--text); }
.sidebar-link.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.sidebar-link.logout { color: var(--red); }
.sidebar-link.logout:hover { background: #fef2f2; }

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.admin-main {
    flex: 1;
    margin-left: 220px;
    padding: 32px;
    min-width: 0;
}

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 700; }

/* ===== Stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid;
}

.stat-purple { border-left-color: var(--purple); }
.stat-blue { border-left-color: var(--blue); }
.stat-green { border-left-color: var(--green); }

.stat-icon { font-size: 32px; }
.stat-number { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ===== Admin Actions ===== */
.admin-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.action-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.action-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.action-icon { font-size: 28px; }

/* ===== Forms ===== */
.form-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.form-card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

.form-row { display: flex; gap: 12px; margin-bottom: 0; }
.form-row .form-group { flex: 1; }
.form-row .form-large { flex: 2; }
.form-row .form-small { flex: 0 0 140px; }

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

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border 0.2s;
    outline: none;
}

.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border 0.2s;
}

.form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ===== Tables ===== */
.table-card {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

.td-icon { font-size: 20px; text-align: center; }
.td-desc { color: var(--text-muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-url a { color: var(--primary); }
.td-url a:hover { text-decoration: underline; }
.td-actions { white-space: nowrap; }
.table-empty { text-align: center; padding: 32px; color: var(--text-muted); }

/* ===== Notes List ===== */
.notes-list { display: flex; flex-direction: column; gap: 12px; }

.note-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
}

.note-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.note-item-header h4 { font-size: 16px; font-weight: 600; }
.note-item-content { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.6; }

.note-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ===== 徽章 ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}
.badge-green { background: #f0fdf4; color: #15803d; }
.badge-red { background: #fef2f2; color: #dc2626; }
.badge-blue { background: #eff6ff; color: #1d4ed8; }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* ===== 安全概览 ===== */
.security-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.sec-card {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    border-left: 3px solid var(--border);
}
.sec-total { border-left-color: var(--primary); }
.sec-broken { border-left-color: var(--red); }
.sec-overseas { border-left-color: var(--orange); }
.sec-domestic { border-left-color: var(--green); }
.sec-unchecked { border-left-color: var(--text-muted); }
.sec-num { font-size: 22px; font-weight: 700; line-height: 1; }
.sec-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== 检测工具栏 ===== */
.check-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.check-toolbar .btn-primary { white-space: nowrap; }
.check-toolbar .btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.check-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 200px;
}
.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--purple));
    transition: width 0.3s;
}
.check-progress span { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.check-hint { font-size: 12px; color: var(--text-muted); flex-basis: 100%; }

/* ===== 筛选条 ===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.filter-chip {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 13px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-divider { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }

/* ===== 表格新列 ===== */
.td-status { white-space: nowrap; }
.td-location { white-space: nowrap; }
.td-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-inner { flex-wrap: wrap; height: auto; padding: 12px 0; gap: 10px; }
    .logo { font-size: 18px; }
    .search-box { order: 3; flex: 1 1 100%; max-width: none; }
    .admin-link { padding: 6px 12px; font-size: 13px; }

    .admin-sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 200;
    }
    .admin-sidebar.show { transform: translateX(0); }

    .admin-main { margin-left: 0; padding: 16px; }

    /* 移动端：左侧侧栏变为抽屉式滑出 */
    .layout-wrapper { display: block; }

    .site-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        width: 260px;
        flex-basis: 260px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }
    body.sidebar-open .site-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-overlay { display: block; }

    .sidebar-floating-btn { display: flex; }
    .sidebar-head { padding-top: 22px; }

    .links-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .link-card { padding: 12px; }
    .link-title { font-size: 13px; }
    .link-desc { font-size: 11px; }

    .form-row { flex-direction: column; gap: 0; }
    .form-row .form-small { flex: 1; }

    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px; }
    .td-desc { display: none; }

    .stats-grid { grid-template-columns: 1fr; }
}
