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

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg: #f8fafc;
    --card-bg: #fff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

.header {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: #fff;
    padding: 48px 0;
    text-align: center;
}

.site-title { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.5px; }
.site-desc { font-size: 1rem; opacity: .85; margin-top: 8px; }

main { flex: 1; padding: 32px 0; }

.category { margin-bottom: 36px; }

.category-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    padding-left: 14px;
    border-left: 4px solid var(--primary);
    line-height: 1.3;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card-bg);
    padding: 16px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    transition: transform .15s, box-shadow .15s;
    border: 1px solid var(--border);
}

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

.link-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.link-icon img { width: 20px; height: 20px; object-fit: contain; }
.link-favicon-fallback { font-size: 18px; }

.link-info { min-width: 0; }
.link-title-text { display: block; font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-desc { display: block; font-size: .8rem; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.footer {
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 24px 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: .875rem;
}

.footer-text { margin-bottom: 8px; }
.contact-info { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; }

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ── Admin Styles ── */
.admin-wrapper { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: 240px;
    background: #1e293b;
    color: #f1f5f9;
    padding: 20px 0;
    flex-shrink: 0;
}
.admin-sidebar h2 {
    padding: 0 20px 20px;
    font-size: 1.1rem;
    border-bottom: 1px solid #334155;
    margin-bottom: 12px;
}
.admin-sidebar nav a {
    display: block;
    padding: 10px 20px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: .925rem;
    transition: background .15s;
}
.admin-sidebar nav a:hover,
.admin-sidebar nav a.active { background: #334155; color: #fff; }

.admin-main { flex: 1; background: #f8fafc; padding: 30px; }

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.admin-header h1 { font-size: 1.5rem; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
    line-height: 1.5;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 4px 10px; font-size: .8rem; border-radius: 6px; }
.btn-gray { background: #e2e8f0; color: #475569; }
.btn-gray:hover { background: #cbd5e1; }

.table-wrapper { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--border); }

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

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

th { background: #f8fafc; font-weight: 600; color: var(--text-secondary); font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; }

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

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--text); font-size: .875rem; }
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    transition: border-color .15s;
    background: #fff;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.form-group textarea { min-height: 100px; resize: vertical; }

.status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: .75rem; font-weight: 600; }
.status-show { background: #dcfce7; color: #166534; }
.status-hide { background: #fef2f2; color: #991b1b; }

.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

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

.login-box {
    background: #fff;
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-box h2 { text-align: center; margin-bottom: 24px; color: var(--text); }

.login-box .btn { width: 100%; padding: 12px; font-size: 1rem; margin-top: 8px; }

.alert {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: .9rem;
}

.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

.inline-form { display: inline; }

/* Mobile */
@media (max-width: 768px) {
    .header { padding: 32px 0; }
    .site-title { font-size: 1.6rem; }
    .links-grid { grid-template-columns: 1fr; }
    .admin-sidebar { width: 180px; }
    .admin-main { padding: 20px; }
}
