/* --- Reset & Base --- */

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

:root {
    --color-bg: #f0f2f5;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;
    --color-border-light: #f1f3f5;
    --color-text: #1a1a2e;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: #eef2ff;
    --color-success: #059669;
    --color-success-bg: #ecfdf5;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-danger: #dc2626;
    --color-danger-bg: #fef2f2;
    --color-info: #2563eb;
    --color-info-bg: #eff6ff;
    --color-nav: #111827;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
    --transition: 150ms ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    color: var(--color-primary-hover);
}

code {
    font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 0.85em;
    background: var(--color-bg);
    padding: 2px 6px;
    border-radius: 4px;
}

/* --- Layout --- */

.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 24px;
}

main.container {
    padding-top: 36px;
    padding-bottom: 72px;
}

/* --- Navbar --- */

.navbar {
    background: var(--color-nav);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.nav-brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.nav-brand:hover {
    text-decoration: none;
    color: #c7d2fe;
}

.brand-icon {
    width: 30px;
    height: 30px;
    background: var(--color-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    color: #fff;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    color: #9ca3af;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 7px;
    transition: all var(--transition);
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    text-decoration: none;
}

.nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
}

/* --- Page Header --- */

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* --- Stats Row --- */

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--color-surface);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.stat-value.text-success { color: var(--color-success); }
.stat-value.text-primary { color: var(--color-primary); }
.stat-value.text-warning { color: var(--color-warning); }

/* --- Table --- */

.table-wrapper {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

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

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 0.875rem;
}

.table th {
    background: #fafbfc;
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom-color: var(--color-border);
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: #f9fafb;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table td.domain-name {
    font-weight: 600;
    color: var(--color-text);
}

.table td.url-cell {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table td.num {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.table .empty-row td {
    text-align: center;
    padding: 48px 16px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* --- Badges --- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-muted { background: #f3f4f6; color: #6b7280; }
.badge-news { background: var(--color-info-bg); color: var(--color-info); }
.badge-article { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-other { background: #f3f4f6; color: #6b7280; }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-category { background: #ede9fe; color: #6d28d9; }
.badge-subcategory { background: #e0f2fe; color: #0369a1; }

.card-tags, .detail-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.detail-tags { margin-bottom: 12px; }

/* --- Filters --- */

.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.filters select,
.filters input[type="text"] {
    padding: 9px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
    min-width: 160px;
}

.filters select:focus,
.filters input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.filters input[type="text"] {
    min-width: 220px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

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

.btn-primary:hover {
    background: var(--color-primary-hover);
    color: #fff;
    text-decoration: none;
}

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

.btn-ghost:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
}

/* --- Content Grid --- */

.content-grid {
    display: grid;
    gap: 12px;
}

.content-card {
    background: var(--color-surface);
    padding: 20px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: box-shadow var(--transition), border-color var(--transition);
}

.content-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #d1d5db;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-source {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.card-abstract {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 7;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-date {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.content-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.content-card h3 a {
    color: var(--color-text);
}

.content-card h3 a:hover {
    color: var(--color-primary);
}

.card-meta {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.card-meta .separator {
    color: var(--color-text-muted);
}

.content-grid .empty-state {
    text-align: center;
    padding: 48px 24px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.empty-state svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.9rem;
}

/* --- Detail Layout --- */

.detail-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    align-items: start;
}

.detail-main {
    background: var(--color-surface);
    padding: 32px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.detail-main h1 {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.detail-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.detail-meta .separator {
    color: var(--color-text-muted);
}

.detail-content {
    line-height: 1.8;
    font-size: 0.95rem;
    color: #374151;
}

.detail-content h2,
.detail-content h3 {
    margin-top: 28px;
    margin-bottom: 10px;
    color: var(--color-text);
}

.detail-content p {
    margin-bottom: 14px;
}

.detail-content ul,
.detail-content ol {
    margin-bottom: 14px;
    padding-left: 24px;
}

.detail-content a {
    text-decoration: underline;
    text-decoration-color: rgba(79, 70, 229, 0.3);
    text-underline-offset: 2px;
}

.detail-source {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border-light);
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.detail-source strong {
    color: var(--color-text);
}

.detail-sidebar {
    background: var(--color-surface);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.detail-sidebar h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 12px;
    margin-top: 24px;
}

.detail-sidebar h3:first-child {
    margin-top: 0;
}

.detail-sidebar dl {
    font-size: 0.85rem;
}

.detail-sidebar dt {
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-top: 10px;
}

.detail-sidebar dd {
    margin-bottom: 4px;
    color: var(--color-text);
}

.version-list {
    list-style: none;
    font-size: 0.85rem;
}

.version-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.version-list li:last-child {
    border-bottom: none;
}

.version-current {
    font-weight: 600;
}

/* --- Pagination --- */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 32px;
    font-size: 0.875rem;
}

.pagination a {
    padding: 8px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-weight: 500;
    transition: all var(--transition);
}

.pagination a:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    text-decoration: none;
}

.pagination .page-info {
    padding: 8px 4px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.pagination .disabled {
    padding: 8px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    opacity: 0.4;
    cursor: default;
    font-weight: 500;
}

.pagination-jump {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-input {
    width: 56px;
    padding: 7px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-surface);
    text-align: center;
}

.pagination-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* --- Back Link --- */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 24px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-weight: 500;
    transition: color var(--transition);
}

.back-link:hover {
    color: var(--color-primary);
    text-decoration: none;
}

/* --- Footer --- */

.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--color-border);
}

/* --- Responsive --- */

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--color-nav);
        flex-direction: column;
        padding: 8px 16px 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .nav-links.nav-open {
        display: flex;
    }

    .mobile-toggle {
        display: block;
    }

    .navbar {
        position: relative;
    }

    .detail-layout {
        grid-template-columns: 1fr;
    }

    .detail-main {
        padding: 20px;
    }

    .filters {
        flex-direction: column;
    }

    .filters select,
    .filters input[type="text"] {
        width: 100%;
        min-width: unset;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

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