/* CSS Variables */
:root {
    --primary: #007AFF;
    --primary-dark: #0056CC;
    --success: #34C759;
    --warning: #FF9500;
    --danger: #FF3B30;
    --bg-primary: #F2F2F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #E5E5EA;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --border-color: #C6C6C8;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --nav-height: 50px;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: var(--safe-area-top);
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
}

#app {
    max-width: 600px;
    margin: 0 auto;
}

/* Navigation */
nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}

nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 10px;
    padding: 8px 16px;
    transition: color 0.2s;
}

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

nav a svg {
    width: 24px;
    height: 24px;
}

/* Main Content */
main {
    padding: 16px;
    padding-top: calc(16px + var(--safe-area-top));
}

/* Headers */
h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
}

h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 12px;
}

h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

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

.card-title {
    font-size: 17px;
    font-weight: 600;
}

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

/* Project Color Indicator */
.color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

/* Lists */
.list {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.list-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.2s;
}

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

.list-item:active {
    background: var(--bg-tertiary);
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.list-item-meta {
    text-align: right;
    font-size: 14px;
    color: var(--text-secondary);
}

.list-item-chevron {
    color: var(--text-secondary);
    margin-left: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform 0.2s, box-shadow 0.2s;
}

.fab:active {
    transform: scale(0.95);
}

.fab svg {
    width: 24px;
    height: 24px;
}

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

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

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

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

.form-input::placeholder {
    color: var(--text-secondary);
}

textarea.form-input {
    min-height: 100px;
    resize: vertical;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238E8E93' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
}

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

.color-option.selected {
    border-color: var(--text-primary);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

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

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Budget Indicator */
.budget-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.budget-progress {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.budget-green {
    background: var(--success);
}

.budget-yellow {
    background: var(--warning);
}

.budget-red {
    background: var(--danger);
}

/* Time Display */
.time-range {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 14px;
}

.hours-display {
    font-weight: 600;
    color: var(--primary);
}

/* Duration Controls */
.duration-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 8px 0 16px;
}

.duration-display {
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: calc(var(--safe-area-top) + 16px);
    left: 16px;
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--text-primary);
    color: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    box-shadow: var(--shadow);
    animation: toast-in 0.3s ease;
    pointer-events: auto;
}

.toast.toast-success {
    background: var(--success);
}

.toast.toast-error {
    background: var(--danger);
}

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

/* Category Badge */
.category-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Date Group */
.date-group {
    margin-bottom: 24px;
}

.date-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 4px;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.filter-btn {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 150;
    animation: fade-in 0.2s;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px;
    padding-bottom: calc(24px + var(--safe-area-bottom));
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slide-up 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.modal-title {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

/* Action Buttons Row */
.action-row {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.action-row .btn {
    flex: 1;
}

/* Utility Classes */
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }

/* Responsive */
@media (min-width: 600px) {
    main {
        padding: 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
