:root {
    --primary: #FF6B35;
    --primary-light: #FFF0EB;
    --dark: #1F2937;
    --gray: #64748B;
    --light-gray: #E2E8F0;
    --bg: #F8FAFC;
    --white: #FFFFFF;
    --gold: #FBBF24;
    --silver: #CBD5E1;
    --bronze: #D97706;
    --red: #EF4444;
    --green: #10B981;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--dark);
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    position: relative;
    padding-bottom: 90px;
}

/* Header */
.page-header {
    background: var(--white);
    padding: 16px 20px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.page-header.with-back {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.back-btn {
    position: absolute;
    left: 16px;
    font-size: 20px;
    color: var(--dark);
    text-decoration: none;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 16px;
    padding: 16px;
    margin: 12px 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--gray);
}

.form-input {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    border: 1px solid var(--light-gray);
    border-radius: 12px;
    font-size: 15px;
    background: var(--white);
    color: var(--dark);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--primary);
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    height: 50px;
    line-height: 50px;
    border: none;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
}

.btn:active {
    opacity: 0.85;
}

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

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

.btn-gray {
    background: var(--light-gray);
    color: var(--dark);
}

.btn-small {
    display: inline-block;
    width: auto;
    height: 32px;
    line-height: 32px;
    padding: 0 14px;
    font-size: 13px;
}

/* Links */
.text-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

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

.text-muted {
    color: var(--gray);
    font-size: 13px;
}

.text-danger {
    color: var(--red);
}

.hint-text {
    font-size: 12px;
    color: var(--gray);
    text-align: center;
    margin-top: 12px;
}

/* Auth pages */
.auth-page {
    padding: 40px 24px;
}

.auth-icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
}

.auth-title {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--gray);
    text-align: center;
    margin-bottom: 32px;
}

.auth-form {
    margin-bottom: 16px;
}

.auth-footer {
    text-align: center;
    margin-top: 16px;
}

/* Tab bar */
.tab-bar {
    display: flex;
    background: var(--light-gray);
    border-radius: 20px;
    padding: 3px;
    margin: 12px 16px;
}

.tab-item {
    flex: 1;
    height: 36px;
    line-height: 36px;
    text-align: center;
    border-radius: 18px;
    font-size: 14px;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-item.active {
    background: var(--white);
    color: var(--primary);
    font-weight: 600;
}

/* Podium */
.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin: 24px 16px 16px;
    min-height: 170px;
}

.podium-item {
    text-align: center;
    margin: 0 18px;
}

.podium-avatar-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
}

.podium-item.first .podium-avatar-wrapper {
    width: 90px;
    height: 90px;
}

.podium-item.second .podium-avatar-wrapper,
.podium-item.third .podium-avatar-wrapper {
    width: 72px;
    height: 72px;
}

.podium-border {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    object-fit: contain;
    z-index: 3;
    pointer-events: none;
}

.podium-avatar {
    position: relative;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    z-index: 2;
}

.podium-item.first .podium-avatar {
    width: 90px;
    height: 90px;
    font-size: 28px;
}

.podium-item.second .podium-avatar {
    width: 70px;
    height: 70px;
    font-size: 20px;
}

.podium-item.third .podium-avatar {
    width: 70px;
    height: 70px;
    font-size: 20px;
}

.podium-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
}

.podium-steps {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

/* Rank list */
.rank-section-title {
    font-size: 15px;
    font-weight: 600;
    margin: 20px 16px 8px;
}

.rank-list {
    padding: 0 16px;
}

.rank-item {
    display: flex;
    align-items: center;
    background: var(--white);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.rank-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    margin-right: 12px;
    flex-shrink: 0;
}

.rank-badge.gold {
    background: var(--gold);
}

.rank-badge.silver {
    background: var(--silver);
}

.rank-badge.bronze {
    background: var(--bronze);
}

.rank-badge.normal {
    background: var(--light-gray);
    color: var(--dark);
}

.rank-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 600;
    margin-right: 12px;
    flex-shrink: 0;
}

.rank-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.rank-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-label {
    font-size: 12px;
    color: var(--gray);
}

.rank-steps {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

/* Self rank bar */
.self-rank-bar {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 398px;
    background: var(--primary);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    color: var(--white);
    box-shadow: 0 4px 16px rgba(255, 107, 53, 0.3);
    z-index: 90;
}

.self-rank-bar .rank-badge {
    background: rgba(255,255,255,0.25);
    color: var(--white);
    margin-right: 12px;
}

.self-rank-bar .rank-avatar {
    background: var(--white);
    color: var(--primary);
}

.self-rank-bar .rank-name {
    color: var(--white);
}

.self-rank-bar .rank-label {
    color: var(--primary-light);
}

.self-rank-bar .rank-steps {
    color: var(--white);
}

/* Bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    background: var(--white);
    border-top: 1px solid var(--light-gray);
    display: flex;
    z-index: 100;
}

.nav-item {
    flex: 1;
    text-align: center;
    padding: 8px 0 12px;
    text-decoration: none;
    color: var(--gray);
    font-size: 12px;
}

.nav-item .nav-icon {
    font-size: 20px;
    display: block;
    margin-bottom: 2px;
}

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

/* Profile */
.profile-card {
    text-align: center;
    padding: 24px 16px;
}

.profile-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 600;
    margin: 0 auto 12px;
}

.profile-name {
    font-size: 18px;
    font-weight: 600;
}

.profile-account {
    font-size: 13px;
    color: var(--gray);
    margin-top: 4px;
}

.stats-row {
    display: flex;
    margin: 0 16px 16px;
    gap: 10px;
}

.stat-card {
    flex: 1;
    background: var(--white);
    border-radius: 12px;
    padding: 16px 8px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--gray);
    margin-top: 4px;
}

.menu-list {
    margin: 0 16px;
}

.menu-item {
    display: flex;
    align-items: center;
    background: var(--white);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    text-decoration: none;
    color: var(--dark);
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.menu-tag {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    margin-right: 10px;
}

.menu-text {
    flex: 1;
    font-size: 15px;
}

.menu-arrow {
    color: var(--gray);
    font-size: 14px;
}

/* Admin */
.admin-page {
    padding: 16px;
}

.admin-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.date-picker {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 1px solid var(--light-gray);
    border-radius: 12px;
    font-size: 15px;
    margin-bottom: 16px;
    background: var(--white);
}

.steps-list {
    margin-bottom: 80px;
}

.steps-item {
    display: flex;
    align-items: center;
    background: var(--white);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.steps-item .rank-avatar {
    margin-right: 12px;
}

.steps-item .user-name {
    flex: 1;
    font-size: 15px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.steps-input {
    width: 100px;
    height: 40px;
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    padding: 0 10px;
    font-size: 15px;
    text-align: right;
    background: var(--bg);
}

.save-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    background: var(--white);
    border-top: 1px solid var(--light-gray);
    padding: 12px 16px;
    z-index: 100;
}

/* User management */
.user-item {
    display: flex;
    align-items: center;
    background: var(--white);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.user-main {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
    margin-left: 12px;
    overflow: hidden;
}

.user-name {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-account {
    font-size: 12px;
    color: var(--gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: 12px;
    margin-left: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}

.user-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 10px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    width: 80%;
    max-width: 320px;
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-body {
    font-size: 14px;
    color: var(--gray);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions .btn {
    flex: 1;
}

/* Toast */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.75);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 300;
    display: none;
}

.toast.active {
    display: block;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* Date display */
.date-display {
    text-align: center;
    font-size: 13px;
    color: var(--gray);
    margin-top: 4px;
}

.month-toggle {
    display: inline-block;
    margin: 6px auto 0;
    padding: 4px 12px;
    border: 1px solid var(--primary);
    border-radius: 999px;
    font-size: 12px;
    color: var(--primary);
    background: var(--primary-light);
    text-align: center;
    cursor: pointer;
}

/* Color picker */
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
}

.color-swatch.active {
    border-color: var(--dark);
    transform: scale(1.1);
}

.color-swatch:active {
    transform: scale(0.95);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray);
}

/* Admin nav */
.admin-nav {
    display: flex;
    gap: 10px;
    margin: 0 16px 16px;
}

.admin-nav .btn {
    flex: 1;
}

/* Responsive */
@media (min-width: 431px) {
    .app-container {
        box-shadow: 0 0 20px rgba(0,0,0,0.05);
    }
}
