:root {
    --bg-color: #0a0a0a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --primary: #00ff88;
    --secondary: #00d4ff;
    --text-main: #ffffff;
    --text-dim: #a0a0a0;
    --accent-gradient: linear-gradient(135deg, #00ff88 0%, #00d4ff 100%);
    --error: #ff4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 30px;
}

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

.login-mini-btn {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 15px;
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-mini-btn i {
    font-size: 1.1rem;
    color: var(--primary);
}

.logout-mini-btn {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.2);
    color: #ff4444;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.logo span {
    color: var(--primary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ff4444;
    box-shadow: 0 0 10px #ff4444;
}

.status-dot.active {
    background-color: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.main-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 20px 0;
}

.steps-circle {
    position: relative;
    width: 280px;
    height: 280px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.progress-ring {
    position: absolute;
    transform: rotate(-90deg);
}

.progress-ring__circle {
    transition: stroke-dashoffset 0.35s;
    transform-origin: 50% 50%;
}

.steps-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.steps-content .label {
    font-size: 0.9rem;
    color: var(--text-dim);
    letter-spacing: 2px;
}

.steps-content .value {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
    margin: 10px 0;
}

.steps-content .goal {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s;
}

.stat-card i {
    font-size: 1.2rem;
    margin-bottom: 5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-card .label {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.stat-card .value {
    font-size: 1.4rem;
    font-weight: 600;
}

.stat-card .value small {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-dim);
}

.controls {
    margin-top: auto;
    padding-bottom: 20px;
}

.primary-btn {
    width: 100%;
    padding: 20px;
    border-radius: 20px;
    border: none;
    background: var(--accent-gradient);
    color: #000;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 255, 136, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    width: 100%;
    padding: 18px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #ff4444;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}

.hidden {
    display: none !important;
}

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

.modal-content {
    background: #1a1a1a;
    padding: 30px;
    border-radius: 30px;
    text-align: center;
    max-width: 400px;
}

.modal-content h2 {
    margin-bottom: 15px;
}

.modal-content p {
    color: var(--text-dim);
    margin-bottom: 25px;
    line-height: 1.5;
}

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

.active-tracking .steps-circle {
    animation: pulse 2s infinite ease-in-out;
}

.history-section {
    margin-top: 20px;
    padding-bottom: 30px;
}

.history-section h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-dim);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.history-main {
    flex: 1;
}

.delete-workout-btn {
    background: transparent;
    border: none;
    color: var(--error);
    opacity: 0.5;
    padding: 10px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.delete-workout-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.history-item .date {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.history-item .stats {
    display: flex;
    gap: 15px;
}

.history-item .stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.history-item .stat .val {
    font-weight: 600;
}

.history-item .stat .lbl {
    font-size: 0.7rem;
    color: var(--text-dim);
}

.empty-msg {
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
    padding: 20px;
}

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: opacity 0.5s, visibility 0.5s;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    text-align: center;
    position: relative;
    background: var(--bg-color);
    padding: 40px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
}

.auth-card .logo {
    font-size: 2.5rem;
    margin-bottom: 30px;
}

.auth-card h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.auth-card p {
    color: var(--text-dim);
    margin-bottom: 30px;
}

.input-group {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.input-group i {
    color: var(--text-dim);
    margin-right: 15px;
}

.input-group input {
    background: transparent;
    border: none;
    color: white;
    padding: 18px 0;
    width: 100%;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
}

.auth-toggle {
    margin-top: 25px;
    font-size: 0.9rem;
}

.auth-toggle span {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
}

.auth-mode .app-container {
    filter: blur(10px);
    pointer-events: none;
}

#auth-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.profile-scroll-area {
    overflow-y: auto;
    flex: 1;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    margin-top: 10px;
}

.input-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-field label {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.input-field input, .input-field select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    color: white;
    font-family: inherit;
    outline: none;
    width: 100%;
}

.chart-container {
    width: 100%;
    height: 200px;
    margin-top: 10px;
}

.history-list.compact .history-item {
    padding: 10px 15px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 8px;
}

.history-list.compact .stat {
    font-size: 0.8rem;
}

/* --- NEW UI OVERHAUL --- */

.view-section {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 80px;
    overflow-y: auto;
    padding: 20px;
}

.main-stats {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.steps-circle {
    position: relative;
    width: 280px;
    height: 280px;
}

.steps-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.steps-info .label {
    font-size: 0.9rem;
    color: var(--text-dim);
    letter-spacing: 2px;
}

.steps-info .value {
    font-size: 4rem;
    font-weight: 900;
    margin: 5px 0;
    line-height: 1;
}

.steps-info .goal {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-card i {
    font-size: 1.5rem;
    color: var(--primary);
}

.stat-card .label {
    font-size: 0.8rem;
    color: var(--text-dim);
}

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

.view-section.hidden {
    display: none !important;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #111;
    display: flex;
    justify-content: space-around;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: 0.3s;
}

.nav-item i {
    font-size: 1.3rem;
}

.nav-item.active {
    color: var(--primary);
}

/* Training View */
#view-training {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    padding: 0;
    background: #000;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.training-top-bar {
    position: absolute;
    top: env(safe-area-inset-top);
    left: 0;
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
}

.training-top-bar h2 {
    font-weight: 800;
    letter-spacing: 1px;
    font-size: 1.2rem;
}

.top-actions {
    display: flex;
    gap: 15px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.training-target-card {
    position: absolute;
    top: 100px;
    left: 20px;
    right: 20px;
    background: white;
    border-radius: 24px;
    padding: 20px;
    color: #333;
    z-index: 10;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.target-selector, .activity-selector {
    width: 100%;
    background: #f0f0f0;
    padding: 12px 20px;
    border-radius: 15px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    cursor: pointer;
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    list-style: none;
    margin-top: 5px;
    z-index: 100;
    overflow: hidden;
}

.dropdown-list li {
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
}

.dropdown-list li:last-child {
    border-bottom: none;
}

.dropdown-list li:active {
    background: #f0f0f0;
}

.target-value-row {
    display: flex;
    align-items: center;
    gap: 30px;
    margin: 10px 0;
}

.circle-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    cursor: pointer;
}

.target-value {
    text-align: center;
}

.target-value #target-number {
    font-size: 3.5rem;
    font-weight: 800;
    display: block;
}

.target-value #target-unit {
    color: #888;
    font-weight: 600;
}

.training-bottom-bar, .active-bottom-bar {
    position: absolute;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.map-action-btn {
    position: absolute;
    right: 20px;
    top: 200px;
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background: white;
    border: none;
    color: #444;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10;
    cursor: pointer;
}

.start-training-btn, .pause-training-btn {
    flex: 1;
    margin: 0 20px;
    padding: 18px;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, #4488ff 0%, #0044ff 100%);
    color: white;
    font-size: 1.4rem;
    font-weight: 800;
    box-shadow: 0 8px 20px rgba(0, 68, 255, 0.3);
    cursor: pointer;
}

.floating-icon-btn {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: white;
    border: none;
    color: #444;
    font-size: 1.3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    cursor: pointer;
}

/* Active Stats Overlay */
.active-stats-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 45%;
    background: white;
    color: #1a1a1a;
    z-index: 20;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.huge-stat {
    margin-bottom: 5px;
}

.huge-stat span {
    font-size: 5rem;
    font-weight: 800;
}

.huge-stat small {
    font-size: 1.2rem;
    font-weight: 600;
    color: #666;
    margin-left: 5px;
}

.sub-stat {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 30px;
}

.sub-stat i {
    color: #4488ff;
    margin-right: 5px;
}

.stats-row {
    width: 100%;
    display: flex;
    justify-content: space-around;
}

.stat-col {
    display: flex;
    flex-direction: column;
}

.stat-col .val {
    font-size: 1.8rem;
    font-weight: 800;
}

.stat-col .lbl {
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
}

/* Settings Modal */
.fullscreen-modal {
    padding: 0 !important;
}

.modal-content.full {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    color: #333;
    text-align: left;
}

.modal-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    background: white;
    border-bottom: 1px solid #f0f0f0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.modal-header .icon-btn {
    background: #f0f0f0;
    border: none;
    color: #333;
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: none;
    cursor: pointer;
}

.modal-header h2 {
    flex: 1;
    text-align: center;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a1a;
}

.settings-tabs {
    display: flex;
    padding: 15px 20px; gap: 10px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    background: white;
    color: #666;
    font-weight: 600;
    cursor: pointer;
}

.tab-btn.active {
    background: #007bff;
    color: white;
}

.settings-section {
    padding: 20px;
}

.settings-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.setting-row {
    background: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
}

.setting-row:first-child { border-top-left-radius: 18px; border-top-right-radius: 18px; }
.setting-row:last-child { border-bottom-left-radius: 18px; border-bottom-right-radius: 18px; border-bottom: none; }

.value-dropdown {
    color: #007bff;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px; width: 20px;
    left: 4px; bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider { background-color: #2196F3; }
input:checked + .slider:before { transform: translateX(22px); }

.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Profile View */
#view-profile {
    padding: 20px;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.settings-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-card h3 {
    margin-bottom: 20px;
}

.settings-card .setting-row {
    background: transparent;
    padding: 15px 0;
    color: white;
}

/* Map fix */
.leaflet-control-container {
    display: none !important;
}


/* NEW UI STYLES */

/* HISTORY V2 STYLES */
.history-list-v2 {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 30px;
}

.history-group-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #8e9aaf;
    margin: 25px 0 10px 5px;
}

.workout-card-v2 {
    background: #fff;
    border-radius: 25px;
    padding: 18px;
    display: flex;
    gap: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.02);
    cursor: pointer;
    transition: transform 0.2s;
    margin-bottom: 10px;
}

.workout-card-v2:active {
    transform: scale(0.98);
}

.workout-thumb {
    width: 85px;
    height: 85px;
    background: #f0f4ff;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.workout-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.workout-header-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}

.workout-type {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1a2b48;
}

.workout-time-small {
    font-size: 0.85rem;
    color: #aaa;
}

.workout-main-val {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1a1a1a;
    margin: 2px 0 8px 0;
}

.workout-main-val small {
    font-size: 1rem;
    color: #1a1a1a;
}

.workout-stats-row {
    display: flex;
    gap: 12px;
    font-size: 0.85rem;
    color: #999;
}

.detail-container {
    animation: slideUp 0.4s ease;
}

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

/* Map Action Buttons */
.map-action-btn {
    position: absolute;
    right: 20px;
    bottom: 320px;
    width: 50px;
    height: 50px;
    background: white;
    border: none;
    border-radius: 50%;
    color: #007bff;
    font-size: 1.2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
}

.map-action-btn:active {
    transform: scale(0.9);
}

.spinning i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
#target-number {
    background: transparent;
    border: none;
    font-size: 3rem;
    font-weight: 800;
    color: #1a1a1a;
    width: 140px;
    text-align: center;
    outline: none;
    font-family: inherit;
}
#target-number::-webkit-inner-spin-button, 
#target-number::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}
