/* 极简风格 */
:root {
    --bg: #f5f5f5;
    --card: #fff;
    --text: #333;
    --sub: #666;
    --muted: #999;
    --accent: #2563eb;
    --border: #e5e5e5;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Noto Sans SC', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }

/* Header */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo { font-size: 18px; font-weight: 700; }

.search { flex: 1; }

.search input {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg);
}

.search input:focus {
    outline: none;
    border-color: var(--accent);
}

.header-actions { display: flex; gap: 8px; }

.btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
}

.btn:hover { background: #1d4ed8; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { background: var(--bg); }

/* 分类列表 */
.cat-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cat-item {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    background: var(--bg);
    color: var(--sub);
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cat-item:hover { background: var(--border); }

.cat-item.active {
    background: var(--accent);
    color: #fff;
}

/* 网站卡片 */
.site-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.site-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

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

.site-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.site-fav {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.4;
}

.site-fav:hover, .site-fav.active { opacity: 1; }

/* 空状态 */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 20px;
}

.page-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    color: var(--sub);
    cursor: pointer;
    font-size: 13px;
}

.page-btn:hover, .page-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--muted);
    font-size: 13px;
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background: var(--card);
    border-left: 1px solid var(--border);
    z-index: 200;
    transition: right 0.2s;
    display: flex;
    flex-direction: column;
}

.sidebar.active { right: 0; }

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

.sidebar-header h3 { font-size: 15px; }

.close {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg);
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
}

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

.fav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
}

.fav-item:hover { background: var(--bg); }

/* 弹窗 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--card);
    border-radius: 12px;
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    padding: 24px;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg);
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
}

/* 管理后台 */
.admin {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: none;
}

.admin.active { display: block; }

.admin-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.admin-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.admin-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header h2 { font-size: 16px; }

.admin-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 左侧分类栏 */
.admin-sidebar {
    width: 180px;
    border-right: 1px solid var(--border);
    padding: 12px;
    overflow-y: auto;
}

.admin-sidebar .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0;
    border: none;
}

.admin-sidebar h3 { font-size: 13px; color: var(--sub); }

.btn-sm {
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}

.admin-cat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin-bottom: 4px;
}

.admin-cat-item:hover { background: var(--bg); }

.admin-cat-item.active {
    background: var(--accent);
    color: #fff;
}

.admin-cat-item .cat-count {
    font-size: 11px;
    opacity: 0.7;
}

.admin-cat-item .cat-actions {
    display: none;
    gap: 4px;
    margin-left: 8px;
}

.admin-cat-item:hover .cat-actions {
    display: flex;
}

.cat-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0.6;
}

.cat-actions button:hover {
    opacity: 1;
    background: rgba(0,0,0,0.1);
}

/* 右侧主内容 */
.admin-main {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

/* 内嵌表单 */
.inline-form {
    display: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.inline-form.active { display: block; }

.inline-form h4 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text);
}

.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-group { margin-bottom: 14px; }

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

.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

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

.table th, .table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--bg);
    color: var(--sub);
    font-weight: 500;
}

.table tr:hover td { background: var(--bg); }

.table-actions { display: flex; gap: 6px; }

.table-actions button {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: none;
    font-size: 12px;
    cursor: pointer;
}

.table-actions button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.table-actions .del:hover {
    border-color: #dc2626;
    color: #dc2626;
}

/* 主容器：左侧分类 + 右侧网站 */
.main-container {
    display: flex;
    max-width: 1000px;
    margin: 0 auto;
    min-height: calc(100vh - 200px);
}

/* 左侧分类栏 */
.home-sidebar {
    width: 160px;
    padding: 20px 12px;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
    padding-left: 8px;
}

.home-sidebar .cat-list {
    flex-direction: column;
    gap: 4px;
}

.home-sidebar .cat-item {
    width: 100%;
    padding: 10px 12px;
    justify-content: flex-start;
}

/* 右侧网站 */
.main {
    flex: 1;
    padding: 20px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* 响应式 */
@media (max-width: 768px) {
    .header-inner { flex-wrap: wrap; }
    .search { order: 3; width: 100%; }
    .tool-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-panel { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
    .main-container { flex-direction: column; }
    .home-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
    .home-sidebar .cat-list { flex-direction: row; flex-wrap: wrap; }
    .home-sidebar .cat-item { width: auto; }
}

@media (max-width: 480px) {
    .tool-grid { grid-template-columns: 1fr; }
}