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

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #e6e6e6;
    --text-secondary: #a0a0b0;
    --accent: #00c853;
    --accent-hover: #00e676;
    --danger: #ff5252;
    --warning: #ffc107;
    --info: #448aff;
    --status-new: #ff5252;
    --status-to-process: #ff9800;
    --status-in-progress: #ffc107;
    --status-completed: #00c853;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

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

.header-back {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Sync bar */
.sync-bar {
    display: none;
    background: var(--warning);
    color: #000;
    padding: 8px 16px;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
}

.sync-bar.visible {
    display: block;
}

/* Main content */
.content {
    padding: 16px;
    padding-bottom: 80px;
}

/* Login */
.login-container {
    max-width: 360px;
    margin: 60px auto;
    padding: 24px;
}

.login-logo {
    text-align: center;
    font-size: 48px;
    margin-bottom: 8px;
}

.login-title {
    text-align: center;
    font-size: 22px;
    margin-bottom: 24px;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

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

.btn-primary {
    background: var(--accent);
    color: #000;
}

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

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

.btn-secondary {
    background: rgba(255,255,255,0.1);
}

.btn-block {
    width: 100%;
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s;
}

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

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

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

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-new { background: var(--status-new); color: #fff; }
.status-to_process { background: var(--status-to-process); color: #000; }
.status-in_progress { background: var(--status-in-progress); color: #000; }
.status-completed { background: var(--status-completed); color: #000; }

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}

/* Deadline */
.deadline {
    font-size: 13px;
    margin-top: 6px;
}

.deadline-ok { color: var(--text-secondary); }
.deadline-warning { color: var(--warning); font-weight: 600; }
.deadline-overdue { color: var(--danger); font-weight: 600; }

/* Photo grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.photo-thumb {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-thumb .photo-type {
    position: absolute;
    bottom: 4px;
    left: 4px;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0,0,0,0.7);
}

.photo-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    border: none;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    z-index: 2;
}

/* GPS info */
.gps-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.distance-ok { color: var(--accent); }
.distance-warning { color: var(--warning); }

/* Span list item */
.span-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
}

.span-item:active {
    background: rgba(255,255,255,0.05);
}

.span-status-icon {
    font-size: 20px;
    margin-left: 8px;
}

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

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

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Photo lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.95);
    z-index: 300;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 95%;
    max-height: 90vh;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 28px;
    color: #fff;
    background: none;
    border: none;
    cursor: pointer;
}

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

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

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    z-index: 400;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
}

.toast-success { background: var(--accent); color: #000; }
.toast-error { background: var(--danger); color: #fff; }
.toast-warning { background: var(--warning); color: #000; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

/* Footer nav */
.footer-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 12px;
    color: var(--text-secondary);
    font-size: 11px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: none;
}

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

.nav-item-icon {
    font-size: 22px;
}

/* Map */
.locality-map {
    height: 280px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    z-index: 1;
}

.map-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.map-actions .btn {
    flex: 1;
    font-size: 14px;
    padding: 10px 8px;
}

/* Point cards */
.point-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

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

.point-photos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.point-photo-wrap {
    min-width: 0;
}

.point-placeholder {
    aspect-ratio: 4/3;
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Responsive */
@media (min-width: 768px) {
    .content {
        max-width: 600px;
        margin: 0 auto;
    }
}
