/* Modern Design System with CSS Variables */
:root {
    /* Dark Theme Colors */
    --background-color: #0a0a0a;
    --surface-color: #1a1a1a;
    --surface-variant: #2a2a2a;
    --primary-color: #7c3aed;
    --primary-variant: #8b5cf6;
    --secondary-color: #06b6d4;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --on-surface-color: #f8fafc;
    --on-background-color: #f1f5f9;
    --border-color: #374151;
    --border-light: #4b5563;
    --text-muted: #9ca3af;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --blur-backdrop: blur(8px);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 20px;
}

:root[data-theme="light"] {
    /* Light Theme Colors */
    --background-color: #ffffff;
    --surface-color: #f8fafc;
    --surface-variant: #f1f5f9;
    --primary-color: #7c3aed;
    --primary-variant: #8b5cf6;
    --secondary-color: #0891b2;
    --accent-color: #d97706;
    --success-color: #059669;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --on-surface-color: #1e293b;
    --on-background-color: #0f172a;
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    --text-muted: #64748b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.data-table th {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--surface-color) !important;
    color: var(--on-surface-color) !important;
    font-weight: bold;
}

.data-table tr:nth-child(even) {
    background-color: var(--background-color);
}

.data-table tr:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

:root[data-theme="light"] .data-table tr:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Modern Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: linear-gradient(135deg, var(--background-color) 0%, var(--surface-color) 100%);
    color: var(--on-background-color);
    margin: 0;
    padding: 24px;
    min-height: 100vh;
    line-height: 1.6;
    font-size: 16px;
    font-weight: 400;
    transition: var(--transition);
}

/* Modern Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 32px 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 32px;
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-variant));
    border-radius: 2px;
}

header h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-variant));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

/* Modern Auth Container */
#auth-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

#auth-container button {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-variant));
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#auth-container button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

#auth-container button:hover::before {
    left: 100%;
}

#auth-container button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

#auth-container button:active {
    transform: translateY(0);
}

/* Modern Theme Toggle */
#theme-toggle {
    background: var(--surface-variant);
    border: 2px solid var(--border-color);
    font-size: 20px;
    cursor: pointer;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    position: relative;
}

#theme-toggle:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

#user-info {
    font-size: 14px;
}

.hidden {
    display: none !important;
}

/* Modern Widget Design */
.widget {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--accent-color));
}

.widget:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

/* Modern Widget Header */
.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.widget-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--on-surface-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.auth-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.auth-btn:hover {
    background-color: #9c5dfc;
}

.auth-btn.authorized {
    background-color: #4CAF50;
}

.auth-btn.authorized:hover {
    background-color: #45a049;
}

.categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-tag {
    background-color: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: bold;
}

.widget-header h2 {
    margin: 0;
}

/* Modern Action Buttons */
.toggle-btn {
    background: var(--surface-variant);
    border: 1px solid var(--border-color);
    color: var(--on-surface-color);
    font-size: 16px;
    cursor: pointer;
    padding: 10px;
    transition: var(--transition);
    border-radius: var(--border-radius);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
    transform: scale(1.1);
}

.refresh-btn {
    background: var(--surface-variant);
    border: 1px solid var(--border-color);
    color: var(--on-surface-color);
    font-size: 18px;
    cursor: pointer;
    padding: 10px;
    transition: var(--transition);
    border-radius: var(--border-radius);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.refresh-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: rotate(180deg) scale(1.1);
    border-color: var(--primary-color);
}

.refresh-btn:active {
    transform: rotate(360deg) scale(0.95);
}

.content {
    transition: max-height 0.3s ease;
}

.content.collapsed {
    display: none;
}

/* Modern Dashboard Layout */
#dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-top: 32px;
}

@media (min-width: 768px) {
    #dashboard {
        grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
    }
}

@media (min-width: 1200px) {
    #dashboard {
        grid-template-columns: repeat(auto-fit, minmax(700px, 1fr));
    }
}

@media (min-width: 1600px) {
    #dashboard {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding: 16px;
        font-size: 15px;
    }

    #dashboard {
        grid-template-columns: 1fr;
        gap: 20px;
        margin-top: 24px;
    }

    header {
        flex-direction: column;
        gap: 20px;
        padding-bottom: 24px;
        margin-bottom: 24px;
    }

    header h1 {
        font-size: 2rem;
        text-align: center;
    }

    #auth-container {
        justify-content: center;
        flex-wrap: wrap;
    }

    .header-buttons {
        justify-content: center;
        flex-wrap: wrap;
    }

    .widget {
        padding: 15px;
    }

    .widget-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .widget-header h2 {
        font-size: 18px;
        margin: 0;
    }

    .widget-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 0;
    }

    .widget-controls label {
        font-size: 14px;
    }

    .widget-controls select {
        font-size: 14px;
        padding: 8px;
    }

    /* Responsywne tabele - Card Layout dla mobile */
    .data-table {
        font-size: 12px;
        display: block;
        width: 100%;
        border: none;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody {
        display: block;
    }

    .data-table tr {
        display: block;
        background-color: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 15px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .data-table td {
        display: block;
        border: none;
        padding: 6px 0;
        text-align: left;
        position: relative;
        padding-left: 0;
    }

    .data-table td:before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--primary-color);
        display: block;
        font-size: 11px;
        text-transform: uppercase;
        margin-bottom: 4px;
        letter-spacing: 0.5px;
    }

    /* Przyciski akcji w mobilnym card layout */
    .data-table button {
        font-size: 12px;
        padding: 8px 12px;
        margin: 2px 4px 2px 0;
        border-radius: 6px;
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile-friendly action buttons container */
    .data-table td:last-child {
        margin-top: 8px;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
        margin-bottom: 0;
    }

    .data-table td:last-child:before {
        content: "Akcje";
        margin-bottom: 8px;
    }

    /* Override previous mobile styles conflicts */
    .data-table td:first-child {
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 12px;
        margin-bottom: 12px;
        font-weight: 500;
    }

    /* Special handling for app icons and complex content */
    .data-table td:first-child div {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-top: 8px;
    }

    .data-table td:first-child img {
        width: 48px !important;
        height: 48px !important;
        border-radius: 12px !important;
        flex-shrink: 0;
    }

    /* Links and interactive elements in mobile cards */
    .data-table a {
        color: var(--primary-color);
        text-decoration: none;
        font-weight: 500;
    }

    .data-table a:hover {
        text-decoration: underline;
    }

    /* Auth container na mobile */
    #auth-container {
        flex-direction: column;
        gap: 10px;
    }

    #auth-container button {
        font-size: 14px;
        padding: 12px 16px;
    }

    /* Theme toggle na mobile */
    #theme-toggle {
        font-size: 18px;
        padding: 12px;
    }

    /* Widget controls na mobile */
    .widget-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 0;
    }

    .widget-controls select {
        width: 100%;
        max-width: 200px;
    }

    /* Modalne okna na mobile */
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        margin: 10px !important;
        padding: 15px !important;
    }
}

/* Dodatkowe style dla bardzo małych ekranów (telefony) */
@media (max-width: 480px) {
    body {
        padding: 5px;
        font-size: 13px;
    }

    header h1 {
        font-size: 20px;
    }

    .widget {
        padding: 10px;
    }

    .widget-header h2 {
        font-size: 16px;
    }

    /* Header na bardzo małych ekranach */
    header h1 svg {
        width: 24px !important;
        height: 24px !important;
        margin-right: 8px !important;
    }

    #auth-container {
        width: 100%;
    }

    #auth-container button,
    #theme-toggle {
        width: 100%;
        justify-content: center;
        min-height: 44px; /* iOS touch target minimum */
    }

    /* Widget header buttons na małych ekranach */
    .header-buttons {
        gap: 6px;
    }

    .refresh-btn,
    .toggle-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    /* Enhanced mobile card layout */
    .data-table {
        font-size: 13px;
        display: block;
        width: 100%;
        border: none;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody {
        display: block;
    }

    .data-table tr {
        display: block;
        background-color: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        margin-bottom: 16px;
        padding: 16px;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .data-table tr:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    }

    .data-table td {
        display: flex;
        flex-direction: column;
        border: none;
        padding: 8px 0;
        text-align: left;
        margin-bottom: 8px;
    }

    .data-table td:last-child {
        margin-bottom: 0;
    }

    .data-table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--primary-color);
        font-size: 12px;
        text-transform: uppercase;
        margin-bottom: 4px;
        letter-spacing: 0.5px;
        opacity: 0.9;
    }

    /* Special styling for first column (usually app name) */
    .data-table td:first-child {
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 12px;
        margin-bottom: 12px;
        font-weight: 500;
    }

    .data-table td:first-child:before {
        font-size: 13px;
        color: var(--on-surface-color);
        font-weight: 700;
    }

    /* Fallback labels when data-label is not set */
    .data-table td:nth-child(1):not([data-label]):before { content: "Element"; }
    .data-table td:nth-child(2):not([data-label]):before { content: "Wartość 1"; }
    .data-table td:nth-child(3):not([data-label]):before { content: "Wartość 2"; }
    .data-table td:nth-child(4):not([data-label]):before { content: "Wartość 3"; }
    .data-table td:nth-child(5):not([data-label]):before { content: "Wartość 4"; }
    .data-table td:nth-child(6):not([data-label]):before { content: "Wartość 5"; }
    .data-table td:nth-child(7):not([data-label]):before { content: "Wartość 6"; }

    /* Wszystkie modalne okna na bardzo małych ekranach */
    div[id$="-modal"] > div {
        width: 98% !important;
        max-width: none !important;
        margin: 5px !important;
        padding: 10px !important;
        top: 5% !important;
        transform: translate(-50%, 0) !important;
    }

    /* Przyciski refresh i toggle mniejsze */
    .refresh-btn,
    .toggle-btn {
        font-size: 14px;
        min-width: 30px;
        min-height: 30px;
        padding: 6px;
    }
}

.widget {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.widget h2 {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    color: var(--primary-color);
}

/* Modern Widget Controls */
.widget-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.widget-controls label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.widget-controls select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-variant);
    color: var(--on-surface-color);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    min-width: 140px;
}

.widget-controls select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.widget-controls select:hover {
    border-color: var(--primary-color);
    background: var(--surface-color);
}


.widget .content {
    flex-grow: 1;
    font-size: 14px;
    color: var(--on-surface-color);
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
}

/* Modern Data Table Styles */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    background: var(--surface-color);
}

.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.data-table th {
    background: linear-gradient(135deg, var(--surface-variant), var(--surface-color));
    font-weight: 600;
    color: var(--primary-color);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th:nth-child(3),
.data-table th:nth-child(4),
.data-table th:nth-child(5),
.data-table th:nth-child(6),
.data-table th:nth-child(7) {
    text-align: right;
}

.data-table tbody tr {
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.data-table tbody tr:hover {
    background: linear-gradient(135deg, var(--surface-variant), var(--surface-color));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

/* Disable general hover for summary rows */
.data-table tbody tr.summary-row:hover {
    background: var(--primary-variant) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3) !important;
}

.data-table td:nth-child(3),
.data-table td:nth-child(4),
.data-table td:nth-child(5),
.data-table td:nth-child(6),
.data-table td:nth-child(7) {
    text-align: right;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-weight: 500;
}

.app-id {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

/* Sort indicators */
th[data-direction="asc"]:after {
    content: " ↑";
    font-weight: bold;
    color: var(--primary-color);
    font-size: 14px;
}

th[data-direction="desc"]:after {
    content: " ↓";
    font-weight: bold;
    color: var(--primary-color);
    font-size: 14px;
}

/* Style specyficzne dla tabeli App Store */
#app-store .data-table th:nth-child(1) { width: 40%; } /* Aplikacja - najszersza */
#app-store .data-table th:nth-child(2) { width: 10%; } /* Wersja */
#app-store .data-table th:nth-child(3) { width: 15%; } /* Data wydania */
#app-store .data-table th:nth-child(4) { width: 10%; } /* Min. iOS */
#app-store .data-table th:nth-child(5) { width: 10%; } /* Cena */
#app-store .data-table th:nth-child(6) { width: 10%; } /* Ocena */
#app-store .data-table th:nth-child(7) { width: 5%; }  /* Stan */

/* Zastosuj te same szerokości dla komórek danych */
#app-store .data-table td:nth-child(1) { width: 40%; overflow: hidden; text-overflow: ellipsis; }
#app-store .data-table td:nth-child(2) { width: 10%; }
#app-store .data-table td:nth-child(3) { width: 15%; }
#app-store .data-table td:nth-child(4) { width: 10%; }
#app-store .data-table td:nth-child(5) { width: 10%; }
#app-store .data-table td:nth-child(6) { width: 10%; }
#app-store .data-table td:nth-child(7) { width: 5%; }

/* Popraw white-space dla App Store tabeli - pozwalaj na zawijanie w pierwszej kolumnie */
#app-store .data-table td:nth-child(1) {
    white-space: normal;
    word-wrap: break-word;
}

/* Sortable table headers */
.data-table th {
    cursor: pointer;
}

#google-admob {
    grid-column: 1 / -1;
}

#google-analytics {
    grid-column: 1 / -1;
}

#app-store {
    grid-column: 1 / -1;
}

#google-ads {
    grid-column: 1 / -1;
}

/* Modern Chart Button Styles */
.chart-button,
button[title*="wykres"],
button[title*="Pokaż wykres"] {
    background: linear-gradient(135deg, var(--accent-color), var(--warning-color));
    border: none;
    color: white;
    padding: 8px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    margin: 0 4px;
    box-shadow: var(--shadow);
}

.chart-button:hover,
button[title*="wykres"]:hover,
button[title*="Pokaż wykres"]:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--warning-color), var(--accent-color));
}

.chart-button svg,
button[title*="wykres"] svg,
button[title*="Pokaż wykres"] svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
}

/* Info Button Styles */
button[title*="Szczegóły"],
button[onclick*="showChart"] {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    border: none;
    color: white;
    padding: 8px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    margin: 0 4px;
    box-shadow: var(--shadow);
}

button[title*="Szczegóły"]:hover,
button[onclick*="showChart"]:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

/* Modern Modal Styles */
div[id$="-modal"] {
    backdrop-filter: var(--blur-backdrop);
    background: rgba(0, 0, 0, 0.8) !important;
}

div[id$="-modal"] > div {
    background: var(--surface-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius-lg) !important;
    box-shadow: var(--shadow-xl) !important;
    color: var(--on-surface-color) !important;
}

div[id$="-modal"] h3 {
    color: var(--on-surface-color) !important;
    font-weight: 600 !important;
    margin-bottom: 16px !important;
    border-bottom: 2px solid var(--primary-color) !important;
    padding-bottom: 12px !important;
}

div[id$="-modal"] input[type="text"] {
    background: var(--surface-variant) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--on-surface-color) !important;
    border-radius: var(--border-radius) !important;
    transition: var(--transition) !important;
}

div[id$="-modal"] input[type="text"]:focus {
    border-color: var(--primary-color) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1) !important;
}

/* Modern Loading Modal */
#loading-modal {
    backdrop-filter: var(--blur-backdrop) !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
}

#loading-modal > div {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius-xl) !important;
    box-shadow: var(--shadow-xl) !important;
    padding: 30px;
    text-align: center;
    min-width: 300px;
}

.loading-spinner {
    margin: 0 auto 20px;
    width: 60px;
    height: 60px;
    border: 5px solid rgba(124, 58, 237, 0.2);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-title {
    color: var(--on-surface-color);
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

/* Mobile optimizations for loading modal */
@media (max-width: 768px) {
    #loading-modal > div {
        min-width: 280px !important;
        padding: 20px !important;
        width: 90% !important;
        max-width: 320px;
    }

    .loading-spinner {
        width: 50px !important;
        height: 50px !important;
        border-width: 4px !important;
        margin-bottom: 16px !important;
    }

    #loading-title {
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    #loading-modal > div {
        min-width: 250px !important;
        padding: 16px !important;
        width: 95% !important;
        max-width: 280px;
    }

    .loading-spinner {
        width: 40px !important;
        height: 40px !important;
        border-width: 3px !important;
        margin-bottom: 12px !important;
    }

    #loading-title {
        font-size: 15px !important;
        line-height: 1.4;
    }
}

/* Success and Status Indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-success {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
}

.status-warning {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: white;
}

.status-error {
    background: linear-gradient(135deg, var(--error-color), #dc2626);
    color: white;
}

/* Animation for hover effects */
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Improved button group styling */
.button-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.button-group button {
    flex-shrink: 0;
}

/* Focus states for accessibility */
button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.refresh-btn:focus-visible,
.toggle-btn:focus-visible,
.chart-button:focus-visible,
.info-button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Improve button hover performance */
.refresh-btn,
.toggle-btn,
.chart-button,
.info-button,
button[title*="wykres"],
button[title*="Szczegóły"] {
    will-change: transform, background-color;
    backface-visibility: hidden;
}

/* Summary row styling - maintain readability on hover */
.data-table tbody tr.summary-row {
    background-color: var(--primary-color) !important;
    color: white !important;
    font-weight: 600 !important;
}

.data-table tbody tr.summary-row:hover {
    background-color: var(--primary-variant) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3) !important;
}

.data-table tbody tr.summary-row a {
    color: white !important;
    text-decoration: underline;
}

.data-table tbody tr.summary-row:hover a {
    color: white !important;
    opacity: 0.9;
}

/* Light theme specific styles for summary row */
:root[data-theme="light"] .data-table tbody tr.summary-row {
    background-color: var(--primary-color) !important;
    color: white !important;
}

:root[data-theme="light"] .data-table tbody tr.summary-row:hover {
    background: #5b21b6 !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(91, 33, 182, 0.5) !important;
}

:root[data-theme="light"] .data-table tbody tr.summary-row a {
    color: white !important;
    text-decoration: underline;
}

:root[data-theme="light"] .data-table tbody tr.summary-row:hover a {
    color: white !important;
    opacity: 1;
}

:root[data-theme="light"] .data-table tbody tr.summary-row:hover * {
    color: white !important;
}

/* Ultra-specific override for light theme summary row hover */
:root[data-theme="light"] .data-table tbody tr.summary-row:hover {
    background-color: #5b21b6 !important;
    background-image: none !important;
    background: #5b21b6 !important;
}

:root[data-theme="light"] .data-table tbody tr.summary-row:hover td {
    color: white !important;
    background: transparent !important;
}

:root[data-theme="light"] .data-table tbody tr.summary-row:hover a,
:root[data-theme="light"] .data-table tbody tr.summary-row:hover span {
    color: white !important;
    background: transparent !important;
}

/* Force white text color for all content in summary row hover state */
:root[data-theme="light"] .data-table tbody tr.summary-row:hover,
:root[data-theme="light"] .data-table tbody tr.summary-row:hover *,
:root[data-theme="light"] .data-table tbody tr.summary-row:hover::before,
:root[data-theme="light"] .data-table tbody tr.summary-row:hover::after {
    color: white !important;
    background-color: #5b21b6 !important;
    background-image: none !important;
    background: #5b21b6 !important;
}

:root[data-theme="light"] .data-table tbody tr.summary-row:hover td,
:root[data-theme="light"] .data-table tbody tr.summary-row:hover th {
    background-color: transparent !important;
    background-image: none !important;
    background: transparent !important;
}