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

:root {
    --strava-orange: #fc4c02;
    --strava-orange-hover: #e04400;
    --text-primary: #242428;
    --text-secondary: #6d6d78;
    --text-link: #fc4c02;
    --border-color: #dfdfe8;
    --background: #fff;
    --white: #fff;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

.main-header {
    background: var(--white);
    border-bottom: 1px solid rgba(223, 223, 232, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--strava-orange);
    letter-spacing: -0.5px;
}

.logo-short {
    display: none;
}

.powered-by-header {
    display: flex;
    align-items: center;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.powered-by-header:hover {
    opacity: 1;
}

.powered-by-header img {
    display: block;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: opacity 0.2s;
}

.user-profile-link:hover {
    opacity: 0.8;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-logout:hover {
    color: var(--strava-orange);
    background: rgba(252, 76, 2, 0.08);
}

.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.login-section {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    padding: 20px;
}

body:has(.login-section:not(.hidden)) {
    background: linear-gradient(
        135deg,
        var(--white) 0%,
        rgba(252, 76, 2, 0.03) 25%,
        var(--white) 50%,
        rgba(252, 76, 2, 0.06) 75%,
        var(--white) 100%
    );
    background-size: 400% 400%;
    animation: gradientMove 15s ease infinite;
    height: 100vh;
    overflow: hidden;
}

@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

body:has(.login-section:not(.hidden)) .main-footer {
    margin-top: 0;
    flex-shrink: 0;
}

body:has(.login-section:not(.hidden)) .main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    max-width: 600px;
    text-align: center;
}

.hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.hero-title {
    font-size: 42px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.hero-title span {
    color: var(--strava-orange);
}

.hero-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
}

.btn-strava-official {
    display: inline-block;
    transition: transform 0.2s, opacity 0.2s;
}

.btn-strava-official img {
    display: block;
    height: 48px;
    width: auto;
}

.btn-strava-official:hover {
    transform: scale(1.02);
}

.hero-features {
    display: flex;
    gap: 32px;
}

.feature {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
    max-width: 180px;
}

.feature-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(252, 76, 2, 0.08);
    border-radius: 8px;
    color: var(--strava-orange);
}

.feature-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.feature-text strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.feature-text span {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.hero-powered {
    display: inline-block;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.hero-powered:hover {
    opacity: 1;
}

.hero-powered img {
    display: block;
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 32px;
    }

    .hero-subtitle {
        font-size: 16px;
    }

    .hero-features {
        flex-direction: column;
        gap: 24px;
        align-items: center;
    }

    .feature {
        max-width: 280px;
    }

    body:has(.login-section:not(.hidden)) {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    body:has(.login-section:not(.hidden)) .main-content {
        overflow: visible;
    }
}

.page-header {
    margin-bottom: 20px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.filters-box {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.filter-group input[type="date"],
.filter-group input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    min-width: 160px;
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--text-primary);
}

.filter-group input[type="date"] {
    cursor: pointer;
}

.filter-group input[type="text"] {
    min-width: 200px;
}

.filter-group input[type="date"]:hover,
.filter-group input[type="text"]:hover {
    border-color: var(--strava-orange);
}

.filter-group input[type="date"]:focus,
.filter-group input[type="text"]:focus {
    outline: none;
    border-color: var(--strava-orange);
    box-shadow: 0 0 0 3px rgba(252, 76, 2, 0.1);
}

.filter-group input[type="text"]::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.filter-group input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.filter-group input[type="date"]:hover::-webkit-calendar-picker-indicator,
.filter-group input[type="date"]:focus::-webkit-calendar-picker-indicator {
    opacity: 1;
}

.custom-dropdown {
    position: relative;
    min-width: 160px;
}

.custom-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: var(--white);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    user-select: none;
}

.custom-dropdown-trigger:hover,
.custom-dropdown.open .custom-dropdown-trigger {
    border-color: var(--strava-orange);
}

.custom-dropdown.open .custom-dropdown-trigger {
    box-shadow: 0 0 0 3px rgba(252, 76, 2, 0.1);
    border-radius: 4px 4px 0 0;
}

.custom-dropdown-arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-secondary);
    transition: transform 0.2s;
}

.custom-dropdown.open .custom-dropdown-arrow {
    transform: rotate(180deg);
    border-top-color: var(--strava-orange);
}

.custom-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--strava-orange);
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 240px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.custom-dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.custom-dropdown-menu::-webkit-scrollbar-track {
    background: #f7f7fa;
    border-radius: 3px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.custom-dropdown.open .custom-dropdown-menu {
    display: block;
}

.custom-dropdown-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    font-size: 14px;
}

.custom-dropdown-option:hover {
    background: rgba(252, 76, 2, 0.08);
    color: var(--strava-orange);
}

.custom-dropdown-option.selected {
    background: rgba(252, 76, 2, 0.12);
    color: var(--strava-orange);
    font-weight: 500;
}

.custom-dropdown-option:last-child {
    border-radius: 0 0 4px 4px;
}

select.hidden-select {
    display: none !important;
}

.btn-search {
    padding: 8px 20px;
    background: var(--strava-orange);
    border: 1px solid var(--strava-orange);
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--white);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-search:hover {
    background: var(--strava-orange-hover);
    border-color: var(--strava-orange-hover);
}

.btn-clear {
    padding: 8px 20px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: #f7f7fa;
    border-color: #b0b0b8;
    color: var(--text-primary);
}

.activities-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.activities-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
}

.loading-indicator {
    display: flex;
    align-items: center;
}

.spinner-small {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--strava-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.export-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
}

.selected-count {
    color: var(--text-secondary);
    font-size: 14px;
}

.export-controls .custom-dropdown {
    min-width: 120px;
}

.btn-download {
    padding: 8px 16px;
    background: var(--strava-orange);
    color: var(--white);
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-download:hover:not(:disabled) {
    background: var(--strava-orange-hover);
}

.btn-download:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.progress-section {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 16px;
    margin-bottom: 16px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--strava-orange);
    transition: width 0.3s;
    width: 0;
}

.activities-table-container {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

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

.activities-table thead {
    background: #f7f7fa;
    border-bottom: 1px solid var(--border-color);
}

.activities-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    white-space: nowrap;
}

.activities-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.activities-table th.sortable:hover {
    color: var(--strava-orange);
}

.activities-table th.sortable .sort-icon {
    display: inline-block;
    width: 12px;
    margin-left: 4px;
    opacity: 0.3;
}

.activities-table th.sortable .sort-icon::after {
    content: "⇅";
    font-size: 10px;
}

.activities-table th.sortable.sort-asc .sort-icon,
.activities-table th.sortable.sort-desc .sort-icon {
    opacity: 1;
    color: var(--strava-orange);
}

.activities-table th.sortable.sort-asc .sort-icon::after {
    content: "↑";
}

.activities-table th.sortable.sort-desc .sort-icon::after {
    content: "↓";
}

.activities-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.activities-table tbody tr:last-child td {
    border-bottom: none;
}

.activities-table tbody tr:hover {
    background: #fafafa;
}

.col-checkbox {
    width: 40px;
    text-align: center;
}

.col-sport {
    width: 120px;
}

.col-date {
    width: 130px;
}

.col-title {
    min-width: 200px;
}

.col-time,
.col-distance,
.col-elevation {
    width: 100px;
    text-align: right;
}

.col-actions {
    width: 150px;
    text-align: right;
}

input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    background: var(--white);
}

input[type="checkbox"]:hover {
    border-color: var(--strava-orange);
}

input[type="checkbox"]:checked {
    background: var(--strava-orange);
    border-color: var(--strava-orange);
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="checkbox"]:indeterminate {
    background: var(--strava-orange);
    border-color: var(--strava-orange);
}

input[type="checkbox"]:indeterminate::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 6px;
    width: 8px;
    height: 2px;
    background: white;
}

.activity-sport,
.activity-date {
    font-size: 14px;
    color: var(--text-primary);
}

.activity-link {
    color: #FC5200;
    text-decoration: none;
    font-weight: 500;
}

.activity-link:hover {
    text-decoration: underline;
}

.title-hint {
    font-weight: 400;
    font-size: 10px;
    text-transform: none;
    color: var(--text-secondary);
    opacity: 0.8;
}

.activity-stat {
    font-size: 14px;
    text-align: right;
}

.activity-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-export {
    padding: 4px 10px;
    font-size: 12px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-export:hover {
    border-color: var(--strava-orange);
    color: var(--strava-orange);
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--strava-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    padding: 48px;
    text-align: center;
    color: var(--text-secondary);
}

.pagination-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 20px;
}

.btn-page {
    padding: 8px 16px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-page:hover:not(:disabled) {
    background: #f7f7fa;
    border-color: var(--strava-orange);
    color: var(--strava-orange);
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 14px;
    color: var(--text-secondary);
}

.main-footer {
    background: #f7f7fa;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

.footer-left,
.footer-right {
    flex: 1;
}

.footer-right {
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
}

.footer-center {
    flex: 1;
    text-align: center;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--strava-orange);
}

.footer-note {
    font-size: 12px;
    opacity: 0.8;
}

.footer-separator {
    margin: 0 8px;
    opacity: 0.5;
}

.footer-link-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
}

.footer-link-btn:hover {
    color: var(--strava-orange);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--white);
    border-radius: 8px;
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(to right, rgba(252, 76, 2, 0.05), transparent);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--strava-orange);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--strava-orange);
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    margin: 0 0 20px;
    line-height: 1.7;
    color: var(--text-primary);
    font-size: 14px;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-body p strong {
    color: var(--strava-orange);
}

.modal-body a {
    color: var(--strava-orange);
    text-decoration: none;
    font-weight: 500;
}

.modal-body a:hover {
    text-decoration: underline;
}

.btn-settings {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-settings:hover {
    color: var(--strava-orange);
    border-color: var(--strava-orange);
    background: rgba(252, 76, 2, 0.06);
}

.filename-settings {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filename-setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filename-label,
.filename-vars-label,
.filename-preview-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.filename-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: var(--white);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.filename-input:focus {
    outline: none;
    border-color: var(--strava-orange);
    box-shadow: 0 0 0 3px rgba(252, 76, 2, 0.1);
}

.filename-setting-group .custom-dropdown {
    width: 100%;
}

.filename-vars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filename-var-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filename-var-chip {
    padding: 4px 10px;
    background: rgba(252, 76, 2, 0.07);
    border: 1px solid rgba(252, 76, 2, 0.2);
    border-radius: 99px;
    font-size: 13px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    color: var(--strava-orange);
    cursor: pointer;
    transition: all 0.15s;
}

.filename-var-chip:hover {
    background: rgba(252, 76, 2, 0.15);
    border-color: var(--strava-orange);
}

.filename-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filename-preview-code {
    display: block;
    padding: 10px 14px;
    background: #f7f7fa;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    color: var(--text-primary);
    word-break: break-all;
    min-height: 38px;
}

.filename-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 4px;
}

@media (max-width: 768px) {
    .header-content {
        padding: 0 16px;
    }

    .main-content {
        padding: 16px;
    }

    .filters-row {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group input,
    .custom-dropdown {
        width: 100%;
    }

    .activities-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .export-controls {
        flex-wrap: wrap;
    }

    .activities-table-container {
        overflow-x: auto;
    }

    .activities-table {
        min-width: 700px;
    }

    .col-elevation {
        display: none;
    }

    .footer-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .footer-left,
    .footer-center,
    .footer-right {
        text-align: center;
        justify-content: center;
    }
}

@media (max-width: 580px) {
    #user-name {
        display: none;
    }
}

@media (max-width: 425px) {
    .logo-full {
        display: none;
    }

    .logo-short {
        display: inline;
    }
}