* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif; background: #F5F7FA; color: #333; line-height: 1.6; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
a { text-decoration: none; color: inherit; }

/* App Layout */
.app-container { display: flex; min-height: 100vh; }
.logo { font-size: 22px; font-weight: 700; color: #2563EB; }

/* Sidebar */
.side-nav { width: 240px; height: 100vh; background: #fff; border-right: 1px solid #E8E8E8; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; z-index: 1000; }
.side-nav-header { padding: 20px 24px; border-bottom: 1px solid #E8E8E8; }
.menu-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.menu-item { display: block; padding: 10px 24px; font-size: 14px; color: #333; transition: all 0.2s; cursor: pointer; }
.menu-item:hover { background: #F5F5F5; color: #1890FF; }
.menu-item.active { color: #1890FF; background: #E6F7FF; font-weight: 500; border-right: 3px solid #1890FF; }
.menu-title { }
.side-nav-footer { border-top: 1px solid #E8E8E8; padding: 8px 0; }
.side-nav-footer .menu-item { color: #666; }

/* Mobile toggle */
.mobile-toggle { display: none; position: fixed; top: 12px; left: 12px; width: 36px; height: 36px; background: #fff; border: 1px solid #E8E8E8; border-radius: 6px; cursor: pointer; z-index: 1001; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.mobile-toggle span { display: block; width: 18px; height: 2px; background: #333; position: relative; transition: background 0.3s; }
.mobile-toggle span::before, .mobile-toggle span::after { content: ''; position: absolute; left: 0; width: 18px; height: 2px; background: #333; transition: all 0.3s; }
.mobile-toggle span::before { top: -6px; }
.mobile-toggle span::after { bottom: -6px; }
.mobile-toggle.open span { background: transparent; }
.mobile-toggle.open span::before { top: 0; transform: rotate(45deg); }
.mobile-toggle.open span::after { top: 0; transform: rotate(-45deg); }

/* Sidebar overlay */
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.3); z-index: 999; }

/* Main Area */
.main-area { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-height: 100vh; background: #F5F5F5; }

/* App Header */
.app-header { background: #fff; padding: 16px 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100; }
.app-header h1 { margin: 0; font-size: 22px; color: #333; font-weight: 600; }
.header-search { width: 280px; }
.header-search input { width: 100%; padding: 8px 16px; border: 1px solid #E8E8E8; border-radius: 6px; font-size: 14px; outline: none; transition: border-color 0.2s; }
.header-search input:focus { border-color: #1890FF; box-shadow: 0 0 0 2px rgba(24,144,255,0.15); }

/* Cards Area */
.cards-area { flex: 1; padding: 20px; }
.home-ad { display: flex; align-items: center; gap: 14px; min-height: 72px; margin-bottom: 20px; padding: 14px 16px; background: #fff; border: 1px solid #E2E8F0; border-radius: 8px; color: #0F172A; }
.home-ad-js { margin-bottom: 20px; }
.home-ad:hover { border-color: #93C5FD; box-shadow: 0 4px 14px rgba(37,99,235,0.08); }
.home-ad img { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: #F1F5F9; flex-shrink: 0; }
.home-ad-body { display: flex; flex-direction: column; min-width: 0; }
.home-ad-body strong { font-size: 15px; margin-bottom: 3px; }
.home-ad-body span { font-size: 13px; color: #64748B; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-info { font-size: 14px; color: #666; margin-bottom: 16px; }
.cat-section { margin-bottom: 32px; }
.cat-section-title { font-size: 18px; font-weight: 600; margin-bottom: 12px; padding-left: 12px; border-left: 3px solid #1890FF; color: #333; }

/* Card Grid */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { display: flex; align-items: flex-start; gap: 14px; padding: 16px; background: #fff; border: 1px solid #E8E8E8; border-radius: 8px; transition: all 0.3s; cursor: pointer; }
.card:hover { transform: translateY(-4px); box-shadow: 0 5px 15px rgba(0,0,0,0.08); }
.card-icon { flex-shrink: 0; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: #F1F5F9; display: flex; align-items: center; justify-content: center; }
.card-icon img { width: 28px; height: 28px; object-fit: contain; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: #1A1A1A; }
.card-desc { font-size: 12px; color: #666; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; }

/* Navbar (for submit/login pages) */
.navbar { background: #fff; border-bottom: 1px solid #E2E8F0; padding: 16px 0; }
.navbar .container { display: flex; justify-content: space-between; align-items: center; }
.nav-links { display: flex; gap: 24px; }
.nav-links a { color: #475569; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: #2563EB; }

/* Submit Form */
.submit-section { padding: 40px 0; }
.submit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; align-items: start; }
.submit-main { min-width: 0; }
.submit-section h1 { margin-bottom: 24px; }
.submit-form .form-group { margin-bottom: 20px; }
.donation-box { background: #fff; border: 1px solid #E2E8F0; border-radius: 8px; padding: 18px; text-align: center; }
.donation-box h2 { font-size: 16px; margin-bottom: 8px; color: #0F172A; }
.donation-box p { font-size: 13px; color: #64748B; margin-bottom: 12px; }
.donation-box img { width: 180px; max-width: 100%; border-radius: 8px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; color: #374151; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px; border: 1px solid #D1D5DB; border-radius: 8px; font-size: 14px; font-family: inherit; transition: border-color 0.2s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #2563EB; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.btn-primary { padding: 12px 28px; background: #2563EB; color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.btn-primary:hover { background: #1D4ED8; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; }
.alert.success { background: #DCFCE7; color: #166534; border: 1px solid #86EFAC; }
.alert.error { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }

/* Login Page */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #F1F5F9; }
.login-box { background: #fff; padding: 40px; border-radius: 16px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); width: 100%; max-width: 400px; }
.login-box h1 { text-align: center; margin-bottom: 24px; }

/* Admin */
.admin-nav { background: #1E293B; color: #fff; padding: 16px 0; }
.admin-nav .container { display: flex; justify-content: space-between; align-items: center; }
.admin-nav .logo { color: #fff; }
.admin-nav .nav-links a { color: #94A3B8; }
.admin-nav .nav-links a:hover { color: #fff; }
.admin-main { padding: 32px 0; min-height: calc(100vh - 60px); }

/* Stats Cards */
.stats-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card { background: #fff; padding: 24px; border-radius: 12px; border: 1px solid #E2E8F0; }
.stat-card h3 { font-size: 14px; color: #64748B; margin-bottom: 8px; }
.stat-number { font-size: 32px; font-weight: 700; color: #2563EB; }

/* Charts */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-card { background: #fff; padding: 20px; border-radius: 12px; border: 1px solid #E2E8F0; }
.chart-card h3 { font-size: 14px; color: #475569; margin-bottom: 12px; }

/* Data Table */
.data-table { width: 100%; background: #fff; border-radius: 12px; border: 1px solid #E2E8F0; border-collapse: collapse; margin-bottom: 16px; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #F1F5F9; }
.data-table th { background: #F8FAFC; font-weight: 600; color: #475569; font-size: 13px; text-transform: uppercase; }
.data-table tr:hover { background: #F8FAFC; }
.data-table .actions { display: flex; gap: 4px; }

.toolbar { margin-bottom: 16px; }
.url-link { color: #2563EB; max-width: 100%; display: inline-block; overflow-wrap: anywhere; word-break: break-word; line-height: 1.45; }

/* Admin links page */
.admin-page { display: flex; flex-direction: column; gap: 16px; }
.admin-page-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 4px; }
.admin-page-header h1 { font-size: 26px; line-height: 1.2; color: #0F172A; }
.admin-page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-form-panel { max-width: 520px; background: #fff; border: 1px solid #E2E8F0; border-radius: 8px; padding: 24px; }
.wide-form-panel { max-width: none; }
.form-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; margin-bottom: 0; }
.checkbox-group input { width: auto; }
.dashboard-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 0; }
.dashboard-table { margin-bottom: 0; table-layout: fixed; font-size: 13px; }
.dashboard-table th, .dashboard-table td { padding: 10px 8px; overflow-wrap: anywhere; word-break: break-word; }
.dashboard-table th:nth-child(1) { width: 12%; }
.dashboard-table th:nth-child(2) { width: 16%; }
.dashboard-table th:nth-child(3) { width: 11%; }
.dashboard-table th:nth-child(4) { width: 10%; }
.dashboard-table th:nth-child(5) { width: 10%; }
.dashboard-table th:nth-child(6) { width: 8%; }
.dashboard-table th:nth-child(7) { width: 11%; }
.dashboard-table th:nth-child(8) { width: 12%; }
.dashboard-table th:nth-child(9) { width: 10%; }
.dashboard-table td:nth-child(7), .dashboard-table td:nth-child(8) { color: #2563EB; }
.links-stats { grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 0; }
.links-stats .stat-card { padding: 16px 18px; border-radius: 8px; }
.links-stats .stat-number { font-size: 28px; line-height: 1.15; }
.table-panel { background: #fff; border: 1px solid #E2E8F0; border-radius: 8px; overflow: hidden; }
.table-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #E2E8F0; background: #fff; }
.table-panel-header h2 { font-size: 16px; font-weight: 600; color: #0F172A; }
.table-scroll { width: 100%; overflow-x: visible; }
.links-table { width: 100%; margin-bottom: 0; border: 0; border-radius: 0; table-layout: fixed; }
.links-table th, .links-table td { vertical-align: middle; }
.links-table tbody tr:last-child td { border-bottom: 0; }
.links-table .col-id { width: 5%; }
.links-table .col-icon { width: 6%; }
.links-table .col-title { width: 15%; }
.links-table .col-url { width: 21%; }
.links-table .col-category { width: 10%; }
.links-table .col-visits { width: 7%; }
.links-table .col-visitors { width: 7%; }
.links-table .col-status { width: 8%; }
.links-table .col-date { width: 10%; }
.links-table .col-actions { width: 11%; }
.link-icon-cell { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #E2E8F0; border-radius: 8px; background: #F8FAFC; }
.link-icon-cell img { width: 24px; height: 24px; border-radius: 4px; object-fit: contain; }
.empty-icon { color: #94A3B8; font-weight: 600; }
.link-title-cell { color: #0F172A; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-pill { display: inline-flex; max-width: 100%; align-items: center; padding: 4px 8px; border-radius: 999px; background: #F1F5F9; color: #475569; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-active { color: #166534; background: #DCFCE7; }
.status-pending { color: #92400E; background: #FEF3C7; }
.status-success { color: #166534; background: #DCFCE7; }
.status-warning { color: #92400E; background: #FEF3C7; }
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-actions form { display: inline-flex; }
.btn-file { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.btn-file input { display: none; }
.muted { color: #64748B; }
.empty-table { text-align: center !important; color: #94A3B8; padding: 40px 16px !important; }
.progress-modal { max-width: 600px; }
.progress-modal h3 { margin-bottom: 12px; }
.progress-track { height: 6px; background: #E8E8E8; border-radius: 3px; margin-bottom: 8px; overflow: hidden; }
.progress-bar { height: 6px; width: 0%; background: #1890FF; border-radius: 3px; transition: width 0.3s; }
.progress-text { font-size: 13px; color: #666; max-height: 300px; overflow-y: auto; font-family: monospace; white-space: pre-wrap; line-height: 1.6; }

/* Buttons */
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; border: 1px solid #D1D5DB; background: #fff; cursor: pointer; font-weight: 500; transition: all 0.2s; }
.btn-sm:hover { background: #F1F5F9; }
.btn-danger { color: #DC2626; border-color: #FCA5A5; }
.btn-danger:hover { background: #FEE2E2; }
.btn-success { color: #16A34A; border-color: #86EFAC; }
.btn-success:hover { background: #DCFCE7; }
.btn-warning { color: #D97706; border-color: #FDE68A; }
.btn-warning:hover { background: #FEF3C7; }

/* Modal */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 1000; }
.modal-content { background: #fff; margin: 10% auto; padding: 32px; border-radius: 16px; max-width: 500px; position: relative; }
.modal-content .close { position: absolute; top: 16px; right: 20px; font-size: 24px; cursor: pointer; color: #94A3B8; }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 16px 0; }
.pagination a { padding: 8px 16px; background: #fff; border: 1px solid #E2E8F0; border-radius: 8px; color: #2563EB; font-weight: 500; transition: all 0.2s; }
.pagination a:hover { background: #2563EB; color: #fff; }
.pagination span { color: #64748B; }

/* Duplicate row */
.duplicate { background: #FEF2F2 !important; }

/* Footer */
.footer { text-align: center; padding: 32px 0; color: #94A3B8; font-size: 14px; border-top: 1px solid #E2E8F0; margin-top: 40px; }
.footer-line { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* No results */
.no-results { text-align: center; padding: 60px 0; color: #94A3B8; font-size: 16px; }

@media (max-width: 768px) {
    .mobile-toggle { display: flex; }
    .side-nav { transform: translateX(-100%); transition: transform 0.3s ease; }
    .side-nav.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .app-header { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 16px 12px 56px; }
    .app-header h1 { font-size: 18px; text-align: center; }
    .header-search { width: 100%; }
    .charts-row { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: 1fr; }
    .card { padding: 12px; }
    .cards-area { padding: 12px; }
    .submit-layout { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .home-ad { align-items: flex-start; }
    .home-ad img { width: 72px; height: 48px; }
    .admin-main { padding: 20px 0; }
    .admin-page-header { align-items: stretch; flex-direction: column; }
    .admin-page-actions { width: 100%; }
    .admin-page-actions .btn-primary, .admin-page-actions .btn-sm { flex: 1; text-align: center; }
    .links-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .links-stats .stat-card { padding: 14px; }
    .dashboard-stats .stat-card { padding: 14px; }
    .links-stats .stat-number { font-size: 24px; }
    .dashboard-stats .stat-number { font-size: 24px; }
    .table-panel-header { padding: 12px; }
    .links-table, .links-table thead, .links-table tbody, .links-table tr, .links-table th, .links-table td,
    .dashboard-table, .dashboard-table thead, .dashboard-table tbody, .dashboard-table tr, .dashboard-table th, .dashboard-table td { display: block; }
    .links-table thead, .dashboard-table thead { display: none; }
    .links-table tr, .dashboard-table tr { padding: 12px; border-bottom: 1px solid #E2E8F0; }
    .links-table tbody tr:last-child, .dashboard-table tbody tr:last-child { border-bottom: 0; }
    .links-table td, .dashboard-table td { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 0; text-align: right; }
    .links-table td::before, .dashboard-table td::before { content: attr(data-label); flex: 0 0 72px; color: #64748B; font-weight: 600; text-align: left; }
    .links-table td:first-child, .dashboard-table td:first-child { padding-top: 0; }
    .links-table td:last-child, .dashboard-table td:last-child { padding-bottom: 0; }
    .link-title-cell { white-space: normal; text-align: right; }
    .row-actions { justify-content: flex-end; }
    .empty-table { display: block !important; text-align: center !important; }
    .empty-table::before { display: none; }
}
