:root {
    --primary: #a8b5ff;
    --primary-dark: #8b9bff;
    --primary-light: #c4cdff;
    --secondary: #ffb5d9;
    --success: #a8e6cf;
    --warning: #ffd9a8;
    --danger: #ffb3b3;
    --dark: #4a5568;
    --dark-light: #718096;
    --light: #fef5ff;
    --gray: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #fef5ff;
    --bg-gradient: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    --text-primary: #4a5568;
    --text-secondary: #718096;
    --border-color: #e9d5ff;
    --gradient-1: linear-gradient(135deg, #a8b5ff 0%, #c4cdff 100%);
    --gradient-2: linear-gradient(135deg, #ffb5d9 0%, #ffd9e8 100%);
    --gradient-3: linear-gradient(135deg, #a8e6cf 0%, #c4f5e0 100%);
    --shadow-sm: 0 1px 2px 0 rgba(139, 92, 246, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(139, 92, 246, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(139, 92, 246, 0.15);
    --shadow-xl: 0 20px 25px -5px rgba(139, 92, 246, 0.2);
}

body.dark-mode {
    --primary: #a8b5ff;
    --primary-dark: #8b9bff;
    --primary-light: #c4cdff;
    --secondary: #ffb5d9;
    --success: #a8e6cf;
    --warning: #ffd9a8;
    --danger: #ffb3b3;
    --dark: #e9d5ff;
    --dark-light: #d8b4fe;
    --light: #1a1a2e;
    --gray: #a8a29e;
    --bg-primary: #1a1a2e;
    --bg-secondary: #252538;
    --bg-gradient: linear-gradient(135deg, #2d2d44 0%, #1a1a2e 100%);
    --text-primary: #e9d5ff;
    --text-secondary: #c4b5fd;
    --border-color: #3f3f5e;
    --gradient-1: linear-gradient(135deg, #6b7aff 0%, #8b9bff 100%);
    --gradient-2: linear-gradient(135deg, #ff8fc7 0%, #ffb5d9 100%);
    --gradient-3: linear-gradient(135deg, #7dd3c0 0%, #a8e6cf 100%);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

.page {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

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

.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.logo-container {
    text-align: center;
    margin-bottom: 3rem;
    animation: slideInUp 0.6s ease-out;
}

.logo-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

.app-title {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.tagline {
    font-size: 1.125rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
}

.auth-form-container {
    background: white;
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 400px;
    animation: scaleIn 0.5s ease-out 0.2s backwards;
}

.contact-admin {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--gray);
    font-size: 0.875rem;
}

.contact-admin a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.contact-admin a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
    width: 100%;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-warning:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-warning:active {
    transform: translateY(0);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.navbar {
    background: var(--bg-primary);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background 0.3s ease;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-logo {
    font-size: 1.5rem;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-link {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray);
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: var(--light);
    color: var(--primary);
}

.nav-link.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.logout-btn {
    color: var(--danger);
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

#user-dashboard, #admin-dashboard {
    background: var(--bg-secondary);
    min-height: 100vh;
    transition: background 0.3s ease;
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.4s ease-in-out;
}

.dashboard-container, .history-container, .admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.welcome-section {
    margin-bottom: 2rem;
}

.welcome-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.welcome-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.presets-section {
    margin-bottom: 2rem;
}

.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.5rem;
}

.preset-card {
    background: var(--bg-primary);
    border-radius: 1.25rem;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.preset-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-1);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.preset-card:hover::before {
    transform: scaleX(1);
}

.preset-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.preset-card.popular {
    border: 2px solid var(--primary);
}

.badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--gradient-1);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.preset-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.preset-card h4 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.preset-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.preset-duration {
    display: inline-block;
    background: var(--bg-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
}

.preset-benefits {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
    text-align: left;
}

.active-fast-section {
    animation: slideInUp 0.5s ease-out;
}

.timer-card {
    background: var(--bg-primary);
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    transition: background 0.3s ease;
}

.timer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.fast-times {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 1rem;
}

.fast-time-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fast-time-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fast-time-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.fast-date-value {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.timer-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
}

.timer-actions {
    display: flex;
    gap: 0.5rem;
}

.timer-circle-container {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 2rem;
}

.timer-circle {
    width: 100%;
    height: auto;
    transform: rotate(-90deg);
}

.timer-circle-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 8;
}

.timer-circle-progress {
    fill: none;
    stroke: url(#gradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 1s linear;
}

.timer-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.timer-display {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.timer-percentage {
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 600;
}

.stage-info {
    background: var(--gradient-1);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

.stage-info h4 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.stage-info p {
    opacity: 0.95;
    line-height: 1.6;
}

.timeline {
    margin-top: 2rem;
}

.timeline h4 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
}

.timeline-list {
    position: relative;
    display: flex;
    justify-content: space-between;
    padding: 3rem 1rem 1rem;
    overflow-x: auto;
    gap: 0.5rem;
}

.timeline-list::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 2.5rem;
    height: 3px;
    background: linear-gradient(90deg, var(--border-color) 0%, var(--primary-light) 100%);
    border-radius: 2px;
}

.timeline-item {
    position: relative;
    flex: 1;
    min-width: 120px;
    text-align: center;
    transition: all 0.3s ease;
    padding-top: 2rem;
}

.timeline-item.active {
    animation: pulse 2s ease-in-out infinite;
}

.timeline-item.completed .timeline-marker {
    background: var(--success);
    box-shadow: 0 0 0 6px rgba(168, 230, 207, 0.3);
    transform: scale(1.2);
}

.timeline-item.active .timeline-marker {
    background: var(--primary);
    box-shadow: 0 0 0 6px rgba(168, 181, 255, 0.3);
    animation: pulse 2s ease-in-out infinite;
    transform: scale(1.3);
}

.timeline-marker {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 4px solid var(--border-color);
    transition: all 0.3s ease;
    z-index: 2;
}

.timeline-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 1rem;
    transition: all 0.3s ease;
}

.timeline-item.active .timeline-content {
    background: linear-gradient(135deg, rgba(168, 181, 255, 0.2) 0%, rgba(196, 205, 255, 0.2) 100%);
    transform: translateY(-5px);
}

.timeline-item.completed .timeline-content {
    background: linear-gradient(135deg, rgba(168, 230, 207, 0.15) 0%, rgba(196, 245, 224, 0.15) 100%);
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timeline-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.timeline-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: none;
}

.timeline-item.active .timeline-desc,
.timeline-item.completed .timeline-desc {
    display: block;
}

.stage-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 1rem;
    margin-top: 1rem;
    overflow: hidden;
}

.stage-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 1rem;
    transition: width 1s ease;
    width: 0%;
}

.stage-progress-text {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    opacity: 0.9;
    text-align: center;
}

.history-container {
    animation: slideInUp 0.5s ease-out;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-primary);
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.history-list {
    background: var(--bg-primary);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: background 0.3s ease;
}

.history-list h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.history-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    transition: all 0.3s ease;
}

.history-item:hover {
    background: rgba(99, 102, 241, 0.05);
    transform: translateX(5px);
}

.history-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.history-icon {
    font-size: 1.5rem;
}

.history-details h4 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.history-details p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.history-duration {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.history-item.broken {
    border-left: 3px solid var(--warning);
}

.history-item.broken .history-duration {
    color: var(--warning);
}

.break-reason {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--warning);
    font-style: italic;
}

.admin-container {
    animation: slideInUp 0.5s ease-out;
}

.admin-actions {
    margin-bottom: 1.5rem;
}

.users-table-container {
    background: var(--bg-primary);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    transition: background 0.3s ease;
}

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

.users-table th {
    text-align: left;
    padding: 1rem;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
}

.users-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.users-table tbody tr {
    transition: all 0.2s ease;
}

.users-table tbody tr:hover {
    background: var(--bg-secondary);
}

.action-btns {
    display: flex;
    gap: 0.5rem;
}

.btn-edit, .btn-delete {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
}

.btn-edit {
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-edit:hover {
    background: var(--primary-dark);
}

.btn-delete {
    background: var(--danger);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-delete:hover {
    background: #dc2626;
}

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

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: scaleIn 0.3s ease-out;
    transition: background 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

#modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.theme-toggle {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    transform: rotate(15deg);
}

.theme-icon {
    display: block;
    transition: transform 0.3s ease;
}

body.dark-mode .theme-icon {
    content: '☀️';
}

@media (max-width: 768px) {
    .navbar {
        padding: 1rem;
        flex-wrap: wrap;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
        margin-top: 1rem;
    }

    .nav-link {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    .dashboard-container, .history-container, .admin-container {
        padding: 1rem;
    }

    .welcome-title {
        font-size: 1.5rem;
    }

    .presets-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 1rem;
    }

    .preset-card {
        padding: 1rem;
    }

    .preset-icon {
        font-size: 2rem;
    }

    .timer-display {
        font-size: 2rem;
    }

    .fast-times {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .fast-time-value {
        font-size: 1.25rem;
    }

    .timeline-list {
        flex-wrap: nowrap;
        overflow-x: scroll;
        scrollbar-width: thin;
    }

    .timeline-item {
        min-width: 100px;
    }

    .timeline-label {
        font-size: 0.75rem;
    }

    .timeline-desc {
        font-size: 0.7rem;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .auth-form-container {
        padding: 1.5rem;
    }

    .app-title {
        font-size: 2.5rem;
    }

    .users-table {
        font-size: 0.875rem;
    }

    .users-table th, .users-table td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .logo-icon {
        font-size: 3rem;
    }

    .app-title {
        font-size: 2rem;
    }

    .presets-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}
