* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    font-size: 16px;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 16px 32px;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 28px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #ffffff;
    font-size: 28px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#auth-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

#signOut {
    padding: 8px 16px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#signOut:hover {
    background: #c0392b;
}

main {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Color Legend */
.color-legend {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
}

.color-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #495057;
}

.color-legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.color-legend-color.cleared {
    background: #27ae60;
}

.color-legend-color.not-cleared {
    background: #ff6b6b;
}

.form-section {
    margin-bottom: 40px;
}

.form-section h2,
.records-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 28px;
    font-weight: 700;
}

.form-group {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.form-group label {
    flex: 0 0 200px;
    font-weight: 500;
    color: #555;
    text-align: right;
}

.form-group input,
.form-group select,
.form-group textarea {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
}

.form-group textarea {
    resize: vertical;
}

.btn-primary {
    background: #3498db;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    font-weight: 500;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-primary:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.records-section {
    margin-top: 40px;
}

/* Modal layout for detailed form */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e1e4e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #2c3e50;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #7f8c8d;
}

.modal-close:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 16px 20px 20px;
    overflow-y: auto;
}

.cards-pocket {
    margin-bottom: 24px;
}

.cards-pocket-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
}

.cards-pocket-header h3 {
    font-size: 22px;
    font-weight: 700;
    color: #2c3e50;
}

.cards-count {
    font-size: 13px;
    color: #777;
}

.cards-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: stretch;
}

.cards-row-scroll {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
}

.cards-row-scroll {
    scrollbar-width: thin;
    scrollbar-color: #667eea #f1f3f5;
}

.cards-row-scroll::-webkit-scrollbar {
    height: 4px;
}

.cards-row-scroll::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 2px;
}

.cards-row-scroll::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 2px;
    transition: background 0.2s ease;
}

.cards-row-scroll::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

.road-card {
    flex: 1 1 360px;
    max-width: 520px;
    min-width: 320px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e1e4e8;
    padding: 12px;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.road-card-status-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 20;
    font-size: 14px;
    color: #16a085;
}

.road-card-status-indicator.visible {
    opacity: 1;
    transform: scale(1);
}

.road-card-status-indicator.saving::before {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(22, 160, 133, 0.25);
    border-top-color: #16a085;
    animation: road-card-spin 0.7s linear infinite;
}

.road-card-status-indicator.saved::before {
    content: '✓';
    font-weight: 700;
    color: #16a085;
}

@keyframes road-card-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.road-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, rgba(22, 160, 133, 0.6) 0%, rgba(22, 160, 133, 0.2) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.road-card-required::before {
    opacity: 1;
}

.road-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 20px rgba(22, 160, 133, 0.1);
    transform: translateY(-2px);
    border-color: #3498db66;
}

.road-card-required {
    min-height: 300px;
    max-height: 300px;
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: stretch;
}

.road-card-not-required {
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.road-card-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.road-card-header-with-badge {
    display: none; /* Hidden in new horizontal design */
}

.road-card-title-row {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 0;
    min-height: 0;
    flex: 1;
}

.road-card-title-full-width {
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.4;
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    min-height: 0;
}

.road-card-length-badge-inline {
    background: #ff6b6b;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.road-card-length-badge {
    background: #ff6b6b;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.road-card-title {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.3;
    flex: 1;
}

.road-card-badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #eef6ff;
    color: #0062cc;
    white-space: nowrap;
}

.road-card-meta {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.road-card-meta span + span {
    margin-left: 8px;
}

.road-card-progress {
    margin-top: 4px;
}

.road-card-progress-bar {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: #e9ecef;
    overflow: hidden;
    margin-bottom: 2px;
}

.road-card-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #27ae60, #2ecc71);
}

.road-card-progress-label {
    font-size: 11px;
    color: #555;
}

.road-card-content {
    display: flex;
    flex-direction: row;
    gap: 12px;
    flex: 1;
    align-items: stretch;
    height: 100%;
}

.road-card-left-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: 90px;
    flex-shrink: 0;
    padding-top: 0;
}

.road-card-snowflake-icon {
    font-size: 24px;
    color: #3498db;
    line-height: 1;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
}

.road-card-right-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    justify-content: space-between;
}

/* Progress bar instead of pie chart */
.road-card-progress-container {
    width: 100%;
    margin-top: 12px;
    margin-bottom: 2px;
    position: relative;
    padding: 4px 0;
}

.road-card-progress-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(180deg, rgba(22, 160, 133, 0.08) 0%, rgba(22, 160, 133, 0.02) 100%);
    border-radius: 16px;
    z-index: 0;
    pointer-events: none;
}

.road-card-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    margin-top: 0;
    font-size: 14px;
}

.road-card-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.road-card-stat-label {
    font-size: 11px;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.road-card-stat-label.cleared-label {
    color: #16a085;
    font-weight: 600;
}

.road-card-stat-label.remaining-label {
    color: #ff6b6b;
}

.road-card-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 4px;
}

.road-card-stat-value.cleared {
    color: #16a085;
    font-size: 20px;
}

.road-card-stat-value.remaining {
    color: #ff6b6b;
    font-size: 16px;
}

.road-card-stat-icon {
    font-size: 16px;
    line-height: 1;
}

.road-card-stat-icon.cleared-icon {
    font-size: 18px;
}

.road-card-stat-icon.remaining-icon {
    font-size: 14px;
}

.road-card-progress-bar-wrapper {
    width: 100%;
    height: 32px;
    background: #ff6b6b;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 3px,
        rgba(255, 255, 255, 0.9) 3px,
        rgba(255, 255, 255, 0.9) 12px
    );
    border-radius: 16px;
    overflow: visible;
    position: relative;
    box-shadow: 0 2px 8px rgba(22, 160, 133, 0.15), inset 0 1px 2px rgba(0,0,0,0.05);
    cursor: pointer;
    user-select: none;
    touch-action: none;
    z-index: 1;
}

.road-card-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #16a085 0%, #1abc9c 100%);
    border-radius: 16px;
    transition: width 0.2s ease;
    position: relative;
    min-width: 0;
    box-shadow: 0 0 12px rgba(22, 160, 133, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3);
    z-index: 2;
}

.road-card-progress-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: #ffffff;
    border: 3px solid #16a085;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(22, 160, 133, 0.6), inset 0 2px 4px rgba(0,0,0,0.1), 0 2px 6px rgba(0,0,0,0.2);
    cursor: grab;
    z-index: 15;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.road-card-progress-marker::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #16a085;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.road-card-progress-marker.has-checkmark::after {
    content: '✓';
    width: auto;
    height: auto;
    background: transparent;
    color: #16a085;
    font-size: 12px;
    font-weight: bold;
    opacity: 1;
}

.road-card-progress-marker:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 0 12px rgba(22, 160, 133, 0.8), inset 0 2px 4px rgba(0,0,0,0.1), 0 3px 8px rgba(0,0,0,0.3);
}

.road-card-progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.road-card-progress-label-left {
    color: #27ae60;
    font-weight: 600;
}

.road-card-progress-label-right {
    color: #ff6b6b;
    font-weight: 600;
}


/* Snow Depth Slider (Vertical, Left Side) */
.road-card-snow-depth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
    flex: 1;
    min-height: 0;
    padding: 2px 0;
}

.road-card-snow-depth-label {
    font-size: 10px;
    font-weight: 600;
    color: #555;
    text-align: center;
    margin-bottom: 0;
    line-height: 1.2;
    height: 14px;
    flex-shrink: 0;
}

.road-card-snow-depth-slider-wrapper {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex: 1;
    min-height: 0;
    margin: 4px 0;
}

.road-card-snow-depth-slider {
    width: 140px;
    height: 6px;
    transform: rotate(-90deg);
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #e9ecef 0%, #e9ecef 100%);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    position: absolute;
}

.road-card-snow-depth-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border: 2px solid white;
}

.road-card-snow-depth-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border: 2px solid white;
}

.road-card-snow-depth-value {
    text-align: center;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    align-items: center;
    flex-shrink: 0;
    height: 40px;
}

.road-card-snow-depth-metric {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0;
    line-height: 1.2;
}

.road-card-snow-depth-imperial {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    line-height: 1.2;
}

.road-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding-top: 2px;
    margin-top: 0;
}

.road-card-footer-label {
    font-size: 14px;
    color: #555;
    font-weight: 600;
    margin-right: 8px;
}

.card-clearance-select {
    font-size: 15px;
    padding: 10px 18px 10px 36px;
    border-radius: 8px;
    border: 2px solid #d0d7de;
    background-color: #ffffff;
    color: #333;
    min-width: 180px;
    cursor: pointer;
    font-weight: 600;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.card-clearance-select.required-status {
    border-color: #16a085;
    box-shadow: 0 0 0 1px rgba(22, 160, 133, 0.1);
}

.card-clearance-select.required-status::before {
    content: '✓';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #16a085;
    font-weight: bold;
    font-size: 16px;
    z-index: 1;
    pointer-events: none;
}

.card-clearance-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
}

.clearance-card {
    margin-top: 10px;
    border-radius: 8px;
    border: 1px solid #e1e4e8;
    padding: 16px 20px;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.card-road-title {
    font-size: 14px;
    font-weight: 500;
    color: #666;
    font-family: 'Courier New', monospace;
}

.card-total-length {
    font-size: 14px;
    color: #555;
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef6ff;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.fall-detail-section {
    background: #f8f9fa;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.fall-detail-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e1e4e8;
}

.records-table-container {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.records-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: white;
}

.records-table thead {
    background: #667eea;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.records-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.records-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e1e4e8;
    color: #2c3e50;
}

.records-table tbody tr:hover {
    background: #f8f9fa;
}

.records-table tbody tr:last-child td {
    border-bottom: none;
}

.card-body-content {
    display: flex;
    gap: 24px;
    align-items: stretch;
}

.card-left {
    flex: 0 0 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.card-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-legend {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: #555;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.legend-dot.cleared {
    background: #27ae60;
}

.legend-dot.remaining {
    background: #e74c3c;
}

.card-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.inline-row {
    flex-direction: row;
    gap: 16px;
}

.inline-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inline-field label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.inline-field select,
.inline-field input,
.inline-field textarea {
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 14px;
}

.slider-label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider-row input[type="range"] {
    flex: 1;
}

.slider-row span {
    font-size: 12px;
    color: #666;
    min-width: 36px;
    text-align: center;
}

.slider-value {
    font-size: 13px;
    font-weight: 500;
    color: #2c3e50;
}

.card-actions {
    margin-top: 4px;
    display: flex;
    justify-content: flex-end;
}

.record-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    border-left: 4px solid #3498db;
}

.record-item h3 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 16px;
}

.record-item p {
    color: #666;
    font-size: 14px;
    margin: 4px 0;
}

.message {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

#firebaseui-auth-container {
    margin: 0;
}

