* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #ca1906;
    --primary-dark: #a81404;
    --primary-light: #fde8e5;
    --bg: #f5f5f5;
    --white: #ffffff;
    --gray: #718096;
    --light-gray: #e2e8f0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 12px;
    --font: 'Montserrat', sans-serif;
    --nav-height: 56px;
    --header-height: 56px;
    --bottom-nav-height: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: #1a202c;
    overflow: hidden;
    height: 100vh;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg);
    position: relative;
}

/* Header */
.app-header {
    background: var(--white);
    padding: 12px 16px;
    border-bottom: 1px solid var(--light-gray);
    flex-shrink: 0;
    height: var(--header-height);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.menu-btn, .notif-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    position: relative;
}

.header-logo {
    height: 32px;
    width: auto;
}

.notif-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    border: 2px solid var(--white);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: var(--white);
    z-index: 200;
    transition: left 0.3s ease;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 16px rgba(0,0,0,0.1);
}

.sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sidebar-logo {
    height: 36px;
    width: auto;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--light-gray);
    margin-bottom: 16px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 16px;
}

.user-email {
    font-size: 12px;
    color: var(--gray);
}

.sidebar-menu {
    list-style: none;
    flex: 1;
    padding: 0;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    text-decoration: none;
    color: #1a202c;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.2s;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: var(--primary-light);
    color: var(--primary);
}

.logout-btn {
    margin-top: auto;
    padding: 12px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    font-size: 14px;
}

/* Main Content */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 80px;
    padding-bottom: calc(80px + var(--safe-bottom));
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page h2 {
    font-size: 20px;
    margin-bottom: 16px;
}

/* Welcome Card */
.welcome-card {
    background: var(--primary);
    color: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.welcome-card h2 {
    font-size: 20px;
    margin: 0 0 4px 0;
}

.welcome-card p {
    opacity: 0.85;
    font-size: 14px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--white);
    padding: 12px 8px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-icon {
    display: block;
    font-size: 22px;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    display: block;
    font-size: 10px;
    color: var(--gray);
}

/* Section Card */
.section-card {
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.section-card h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--light-gray);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    font-size: 20px;
}

.activity-text {
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.activity-time {
    font-size: 11px;
    color: var(--gray);
}

/* Project Cards */
.project-card-mobile {
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.project-header h3 {
    font-size: 16px;
}

.project-status {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.status-progress {
    background: #dbeafe;
    color: #2563eb;
}

.status-completed {
    background: #d1fae5;
    color: #059669;
}

.progress-bar {
    height: 6px;
    background: var(--light-gray);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s;
}

.project-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--gray);
    margin: 8px 0;
}

.btn-view-project {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    font-family: var(--font);
}

/* Advance Cards */
.advance-card {
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.advance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.advance-week {
    font-weight: 600;
    font-size: 15px;
}

.advance-status {
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.advance-status.approved {
    background: #d1fae5;
    color: #059669;
}

.advance-status.pending {
    background: #fef3c7;
    color: #d97706;
}

.advance-desc {
    font-size: 13px;
    color: var(--gray);
}

.advance-progress {
    font-size: 14px;
    font-weight: 500;
    color: var(--primary);
    margin: 8px 0;
}

.btn-view-advance {
    background: var(--primary-light);
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
}

/* Document Cards */
.doc-list {
    margin-bottom: 16px;
}

.doc-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--white);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}

.doc-icon {
    font-size: 24px;
}

.doc-info {
    flex: 1;
}

.doc-name {
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.doc-date {
    font-size: 11px;
    color: var(--gray);
}

.doc-signed {
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.doc-signed.signed {
    background: #d1fae5;
    color: #059669;
}

.doc-signed.pending {
    background: #fef3c7;
    color: #d97706;
}

.btn-upload-doc {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: var(--font);
}

/* Messages */
.message-card {
    background: var(--white);
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}

.message-card.unread {
    border-left: 4px solid var(--primary);
}

.message-sender {
    font-weight: 600;
    font-size: 14px;
}

.message-preview {
    font-size: 13px;
    color: var(--gray);
    margin: 2px 0;
}

.message-time {
    font-size: 11px;
    color: var(--gray);
}

.message-input {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    background: var(--white);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-top: 8px;
    box-shadow: var(--shadow);
}

.message-input input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: var(--font);
    padding: 8px 0;
}

.message-input button {
    background: var(--primary);
    border: none;
    color: var(--white);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
}

/* Tokens */
.token-balance {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.token-amount {
    display: block;
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
}

.token-label {
    display: block;
    font-size: 14px;
    color: var(--gray);
}

.token-equivalent {
    display: block;
    font-size: 13px;
    color: var(--gray);
    margin-top: 4px;
}

.token-packages {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.package-card {
    background: var(--white);
    padding: 16px 8px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
}

.package-card.featured {
    border-color: var(--primary);
}

.package-tokens {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.package-price {
    display: block;
    font-size: 18px;
    font-weight: 600;
    margin: 4px 0;
}

.package-name {
    display: block;
    font-size: 12px;
    color: var(--gray);
}

.btn-buy {
    margin-top: 8px;
    padding: 6px 16px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font);
}

.token-history {
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.token-history h4 {
    font-size: 14px;
    margin-bottom: 8px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--light-gray);
    font-size: 13px;
}

.history-item:last-child {
    border-bottom: none;
}

.history-date {
    color: var(--gray);
    font-size: 12px;
}

/* Settings */
.settings-group {
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.settings-group h3 {
    font-size: 15px;
    margin-bottom: 12px;
}

.setting-item {
    margin-bottom: 12px;
}

.setting-item label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray);
    margin-bottom: 2px;
}

.setting-item input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font);
}

.btn-save-settings,
.btn-change-password,
.btn-mfa-setup {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: var(--font);
}

.btn-save-settings {
    background: var(--primary);
    color: var(--white);
}

.btn-change-password {
    background: var(--light-gray);
    color: #1a202c;
}

.btn-mfa-setup {
    background: #dbeafe;
    color: #2563eb;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-around;
    padding: 6px 0 calc(6px + var(--safe-bottom));
    z-index: 50;
    max-width: 480px;
    margin: 0 auto;
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 12px;
    cursor: pointer;
    position: relative;
    font-family: var(--font);
}

.nav-icon {
    font-size: 22px;
}

.nav-label {
    font-size: 10px;
    color: var(--gray);
    font-weight: 500;
}

.nav-item.active .nav-label {
    color: var(--primary);
}

.nav-item .badge {
    position: absolute;
    top: 0;
    right: 2px;
    background: var(--primary);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--white);
    padding: 30px 24px;
    border-radius: var(--radius);
    max-width: 360px;
    width: 90%;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 20px;
}

.modal-content .form-group {
    margin-bottom: 14px;
}

.modal-content input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font);
}

.form-footer {
    text-align: center;
    font-size: 13px;
    color: var(--gray);
    margin-top: 12px;
}

.form-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Utility */
.hidden {
    display: none !important;
}