* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    color: #333;
}

/* Login Modal Specific Styles */
#loginModal.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

#loginModal .modal-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* Settings Modal */
#settingsModal.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

#settingsModal .modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* Edit Link Modal */
#editLinkModal.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    overflow-y: auto;
}

#editLinkModal .modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    margin: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Header */
.dashboard-header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo h1 {
    font-size: 1.5rem;
    color: #667eea;
    font-weight: 600;
}

.main-nav {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: #6b7280;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.3s;
}

.nav-link:hover {
    background: #f3f4f6;
    color: #667eea;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn-primary {
    background: #10b981;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    border-color: #667eea;
    color: #667eea;
}

/* Filters Bar */
.filters-bar {
    background: white;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.btn-refresh {
    background: white;
    border: 1px solid #e5e7eb;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s;
}

.btn-refresh:hover {
    background: #f9fafb;
    transform: rotate(180deg);
}

.date-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #e5e7eb;
    padding: 8px 15px;
    border-radius: 8px;
    background: white;
}

.date-picker input[type="date"] {
    border: none;
    outline: none;
    font-size: 0.9rem;
}

.btn-prev, .btn-next {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
}

.btn-prev:hover, .btn-next:hover {
    color: #667eea;
}

.filter-select, .search-input {
    padding: 10px 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
}

.filter-select:focus, .search-input:focus {
    border-color: #667eea;
}

.search-input {
    flex: 1;
    max-width: 300px;
}

/* Stats Table */
.stats-section {
    background: white;
    margin: 20px 30px;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
}

.stats-table thead {
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

.stats-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s;
}

.stats-table tbody tr:hover {
    background: #f9fafb;
}

.stats-table td {
    padding: 15px;
    color: #6b7280;
}

.link-name {
    color: #10b981;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.link-name:hover {
    text-decoration: underline;
}

.totals-row {
    background: #e0f2fe !important;
    font-weight: 600;
}

.totals-row td {
    color: #0369a1 !important;
}

.actions-menu {
    position: relative;
    display: inline-block;
}

.btn-actions {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 5px 10px;
    font-size: 1.2rem;
}

.btn-actions:hover {
    color: #667eea;
}

.actions-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    z-index: 9999;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}

.actions-dropdown.show {
    display: block;
}

.actions-dropdown.open-upward {
    top: auto;
    bottom: 100%;
}

.action-item {
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #374151;
    transition: background 0.2s;
}

.action-item:hover {
    background: #f9fafb;
}

.action-item:first-child {
    border-radius: 8px 8px 0 0;
}

.action-item:last-child {
    border-radius: 0 0 8px 8px;
}

/* Info Alert */
.info-alert {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 15px 20px;
    margin: 0 30px 30px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.alert-icon {
    font-size: 1.5rem;
}

.info-alert strong {
    color: #1e40af;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    overflow-y: auto;
    padding: 20px;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.large {
    max-width: 1000px;
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: #1f2937;
}

.modal-header span {
    color: #10b981;
}

.btn-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.btn-close:hover {
    color: #374151;
}

.modal-body {
    padding: 30px;
}

/* Blocked Clicks */
.blocked-summary {
    text-align: center;
    margin-bottom: 30px;
}

.blocked-count {
    font-size: 2rem;
    color: #10b981;
    margin-bottom: 10px;
}

.blocked-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.blocked-table thead {
    background: #f9fafb;
}

.blocked-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 0.85rem;
}

.blocked-table td {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #6b7280;
    font-size: 0.9rem;
}

.blocked-table tbody tr:hover {
    background: #f9fafb;
}

.type-badge {
    background: #fee2e2;
    color: #991b1b;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.country-flag {
    font-size: 1.2rem;
    margin-right: 5px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.btn-page {
    background: white;
    border: 1px solid #e5e7eb;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-page:hover {
    border-color: #667eea;
    color: #667eea;
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Breakdown Stats */
.breakdown-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: #f9fafb;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
}

.info-note {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #92400e;
    font-size: 0.9rem;
}

/* Daily Table */
.daily-table {
    width: 100%;
    border-collapse: collapse;
}

.daily-table thead {
    background: #f9fafb;
}

.daily-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 0.85rem;
}

.daily-table td {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #6b7280;
}

.daily-table tbody tr:hover {
    background: #f9fafb;
}

/* Traffic Analysis */
.analysis-filter {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.analysis-filter label {
    font-weight: 600;
    color: #374151;
}

.analysis-filter select {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    outline: none;
}

.analysis-table {
    width: 100%;
    border-collapse: collapse;
}

.analysis-table thead {
    background: #f9fafb;
}

.analysis-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 0.85rem;
}

.analysis-table td {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #6b7280;
}

.analysis-table tbody tr:hover {
    background: #f9fafb;
}

/* Traffic Quality */
.quality-score {
    text-align: center;
    margin-bottom: 30px;
}

.quality-score h3 {
    color: #1f2937;
    margin-bottom: 20px;
}

.quality-score h3 span {
    color: #10b981;
}

.gauge {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.quality-metrics {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.metric-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.metric-item {
    background: #f9fafb;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-label {
    font-weight: 600;
    color: #6b7280;
    font-size: 0.9rem;
}

.metric-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1f2937;
}

/* Loading */
.loading-row {
    text-align: center;
    padding: 40px !important;
    color: #9ca3af;
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-header {
        flex-wrap: wrap;
        gap: 15px;
    }

    .filters-bar {
        flex-wrap: wrap;
    }

    .stats-table {
        font-size: 0.85rem;
    }

    .modal-content {
        margin: 20px;
    }
}

@media (max-width: 768px) {
    .main-nav {
        display: none;
    }

    .breakdown-stats {
        grid-template-columns: 1fr;
    }

    .metric-row {
        grid-template-columns: 1fr;
    }

    .stats-table th, .stats-table td {
        padding: 10px 5px;
        font-size: 0.8rem;
    }
}

/* Edit Modal Tabs */
.edit-tabs {
    display: flex;
    gap: 5px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
}

.edit-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.3s;
}

.edit-tab:hover {
    color: #667eea;
    background: #f9fafb;
}

.edit-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.edit-tab-content {
    display: none;
}

/* Link name styling */
.link-name {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
}

.link-name:hover {
    color: #5568d3;
    text-decoration: underline;
}
