* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
	text-decoration: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #1a1d2e;
    color: #e2e8f0;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 250px;
    height: 100vh;
    background: #151827;
    padding: 20px 0;
    border-right: 1px solid #2d3548;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #151827;
    border-bottom: 1px solid #2d3548;
    align-items: center;
    padding: 0 20px;
    z-index: 999;
}

.menu-toggle {
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 1.5em;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
    font-weight: 700;
    color: #fff;
    margin-left: 15px;
}

.mobile-logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

.overlay.active {
    display: block;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 30px;
    font-size: 1.3em;
    font-weight: 700;
    color: #fff;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #8b92b0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95em;
}

.nav-item a {
    text-decoration: none;
    color: inherit;
    display: block;
    width: 100%;
}

.nav-item:hover {
    background: #1a1d2e;
    color: #e2e8f0;
}

.nav-item.active {
    background: #1a1d2e;
    color: #fff;
    border-left: 3px solid #667eea;
}

.nav-icon {
    font-size: 1.2em;
    width: 20px;
}

.main-content {
    margin-left: 240px;
    padding: 20px 40px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.8em;
    font-weight: 700;
    color: #fff;
}

.title-icon {
    font-size: 1.2em;
}

.top-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary {
    background: #2d3548;
    color: #e2e8f0;
}

.btn-secondary:hover {
    background: #3d4558;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #2d3548;
    border-radius: 8px;
    cursor: pointer;
}

.avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #22283a;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #2d3548;
    position: relative;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.stat-title {
    color: #8b92b0;
    font-size: 0.9em;
    font-weight: 500;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
}

.icon-purple { background: rgba(102, 126, 234, 0.15); color: #667eea; }
.icon-cyan { background: rgba(34, 211, 238, 0.15); color: #22d3ee; }
.icon-yellow { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.icon-green { background: rgba(34, 197, 94, 0.15); color: #22c55e; }

.stat-value {
    font-size: 2.2em;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
}

.stat-change {
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive { color: #22c55e; }
.stat-change.negative { color: #ef4444; }

.filters-section {
    background: #22283a;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #2d3548;
    margin-bottom: 24px;
}

.filters-grid {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr 2fr;
    gap: 16px;
    align-items: end;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    color: #8b92b0;
    font-size: 0.85em;
    font-weight: 600;
}

select, input[type="text"], input[type="date"], input[type="password"], input[type="search"] {
    width: 100%;
    padding: 10px 14px;
    background: #1a1d2e;
    border: 1px solid #2d3548;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

select:focus, input:focus {
    outline: none;
    border-color: #667eea;
}

.search-input {
    position: relative;
}

.search-input input {
    padding-left: 40px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #8b92b0;
}

.table-section {
    background: #22283a;
    border-radius: 12px;
    border: 1px solid #2d3548;
    overflow: hidden;
}

.table-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2d3548;
}

.table-title {
    font-size: 1.2em;
    font-weight: 700;
    color: #fff;
}

.table-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    padding: 8px 16px;
    background: #2d3548;
    border: 1px solid #3d4558;
    border-radius: 8px;
    color: #8b92b0;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-icon:hover {
    background: #3d4558;
    color: #e2e8f0;
}

.btn-filter {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #1a1d2e;
}

th {
    padding: 16px 24px;
    text-align: left;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b92b0;
}

td {
    padding: 18px 24px;
    border-bottom: 1px solid #2d3548;
    font-size: 0.9em;
    color: #e2e8f0;
}

tbody tr {
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: #1a1d2e;
}

.keyword-cell {
    font-weight: 600;
    color: #fff;
}

.position-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 6px 12px;
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.1em;
}

.change-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85em;
}

.change-badge.up {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.change-badge.down {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.change-badge.neutral {
    background: rgba(139, 146, 176, 0.15);
    color: #8b92b0;
}

.trend-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trend-progress {
    flex: 1;
    height: 6px;
    background: #2d3548;
    border-radius: 3px;
    overflow: hidden;
}

.trend-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
    border-radius: 3px;
}

.intent-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8em;
    font-weight: 600;
}

.intent-commercial {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.intent-info {
    background: rgba(34, 211, 238, 0.15);
    color: #22d3ee;
}

.intent-nav {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.difficulty-badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.8em;
    text-align: center;
}

.diff-high { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.diff-medium { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.diff-low { background: rgba(34, 197, 94, 0.15); color: #22c55e; }

.action-buttons {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.btn-action {
    width: 32px;
    height: 32px;
    border: 1px solid #3d4558;
    background: transparent;
    border-radius: 6px;
    color: #8b92b0;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-action:hover {
    transform: translateY(-1px);
}

.btn-action.refresh:hover {
    background: rgba(34, 211, 238, 0.15);
    color: #22d3ee;
    border-color: #22d3ee;
}

.btn-action.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: #ef4444;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-top: 1px solid #2d3548;
}

.pagination-info {
    color: #8b92b0;
    font-size: 0.85em;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid #2d3548;
    border-radius: 6px;
    color: #8b92b0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85em;
    transition: all 0.2s ease;
}

.page-btn:hover {
    background: #2d3548;
    color: #e2e8f0;
}

.page-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

@media (max-width: 1200px) {
    .filters-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Zapewnia to, że domyślne style są nadpisane przez style inline */

/* position-badge */
.position-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    text-align: center;
    min-width: 40px;
    transition: background 0.3s, color 0.3s;
}

/* change-badge (Style inline będą miały priorytet, ale to jest bezpieczna baza) */
.change-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
    transition: background 0.3s, color 0.3s;
}

/* Domyślne kolory, jeśli nie nadpisane przez PHP */
.change-badge.up {
    color: #10b981;
    background-color: rgba(16, 185, 129, 0.1);
}
.change-badge.down {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}
.change-badge.neutral {
    color: #94a3b8;
    background-color: #2d3548;
}

/* Nowy CSS dla Nakładki Ładowania */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Lekko przezroczyste tło */
    display: none; /* Domyślnie ukryte */
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Nad wszystkim innym */
    flex-direction: column;
    color: #e2e8f0;
}

.spinner {
    border: 5px solid #2d3548; /* Kolor tła spinnera */
    border-top: 5px solid #3b82f6; /* Kolor elementu obracającego się (niebieski) */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay.active {
    display: flex; /* Pokaż nakładkę, gdy aktywna */
}

@media (max-width: 968px) {
    .sidebar {
        width: 240px; /* Przywrócenie pełnej szerokości dla mobilnej */
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .logo span {
        display: inline;
    }

    .nav-item span:nth-child(2) {
        display: inline;
    }
    
    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding-top: 70px; /* Dodatkowe padding, aby treść nie chowała się pod mobilnym nagłówkiem */
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .top-actions {
        width: 100%;
        justify-content: space-between;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .table-section {
        overflow-x: auto;
    }

    table {
        min-width: 900px;
    }
}