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

html, body {
    height: 100%;
    width: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
}

body {
    overflow-y: scroll;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.sticky-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-compact {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 0.4rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.header-compact h1 {
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    margin: 0;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.3rem;
    flex: 1;
}

.stat {
    text-align: center;
    background: rgba(255,255,255,0.15);
    padding: 0.25rem;
    border-radius: 0.3rem;
    backdrop-filter: blur(10px);
}

.stat-number {
    font-size: 1rem;
    font-weight: bold;
    display: block;
    line-height: 1;
}

.stat-label {
    font-size: 0.6rem;
    opacity: 0.9;
    line-height: 1;
    margin-top: 0.1rem;
}

.controls {
    padding: 0.4rem 0.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.add-truck-form {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.input-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
}

.add-truck-form input {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid #e9ecef;
    border-radius: 0.3rem;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

.add-truck-form input:focus {
    outline: none;
    border-color: #3498db;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #3498db;
    border-top: none;
    border-radius: 0 0 0.3rem 0.3rem;
    max-height: 150px;
    overflow-y: auto;
    z-index: 1001;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    display: none;
}

.autocomplete-list.show {
    display: block;
}

.autocomplete-item {
    padding: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #e3f2fd;
}

.btn {
    padding: 0.5rem 0.7rem;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 0.3rem;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    touch-action: manipulation;
}

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

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #229954);
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.btn-small {
    padding: 0.35rem 0.5rem;
    font-size: 0.7rem;
}

.btn-file-label {
    margin: 0;
    cursor: pointer;
}

input[type="file"] {
    display: none;
}

.scroll-container {
    background: white;
}

.board {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    padding: 0.5rem;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.column {
    background: #f8f9fa;
    border-radius: 0.5rem;
    padding: 0.4rem;
    min-height: 80px;
    border: 2px dashed #e9ecef;
    transition: all 0.2s;
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.column.drag-over {
    border-color: #3498db;
    background: #e3f2fd;
}

.column-header {
    text-align: center;
    margin-bottom: 0.4rem;
    padding: 0.4rem;
    background: white;
    border-radius: 0.3rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.column-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.1;
}

.column-capacity {
    font-size: 0.65rem;
    color: #7f8c8d;
    margin-top: 0.1rem;
    line-height: 1;
}

.truck-card {
    background: white;
    border-radius: 0.3rem;
    padding: 0.35rem 0.4rem;
    margin-bottom: 0.3rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    cursor: move;
    transition: box-shadow 0.2s;
    border-left: 3px solid #3498db;
}

.truck-card:active {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.truck-card.dragging {
    opacity: 0.5;
}

.truck-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.2rem;
}

.truck-id {
    font-weight: bold;
    color: #2c3e50;
    font-size: 0.85rem;
    flex: 1;
    line-height: 1;
    word-break: break-word;
    min-width: 0;
}

.truck-id input {
    font-weight: bold;
    color: #2c3e50;
    font-size: 0.85rem;
    border: 1px solid #3498db;
    padding: 0.2rem 0.3rem;
    border-radius: 0.2rem;
    width: 100%;
}

.truck-actions {
    display: flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.truck-actions button {
    min-width: 44px;
    min-height: 32px;
}

.truck-time {
    color: #7f8c8d;
    font-size: 0.7rem;
    margin-bottom: 0.15rem;
    line-height: 1;
}

.truck-duration {
    color: #27ae60;
    font-weight: 600;
    font-size: 0.75rem;
    line-height: 1;
}

.truck-move {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.truck-move .btn {
    flex: 1;
    min-height: 36px;
    font-size: 0.8rem;
    font-weight: 600;
}

.completed-list {
    background: #f8f9fa;
    border-radius: 0.5rem;
    padding: 0.5rem;
    margin: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
}

.completed-header {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.4rem;
    text-align: center;
}

.completed-truck {
    background: white;
    padding: 0.5rem;
    margin-bottom: 0.3rem;
    border-radius: 0.3rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-left: 3px solid #27ae60;
    font-size: 0.75rem;
}

.completed-truck small {
    font-size: 0.65rem;
}

.data-controls {
    padding: 0.5rem;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    justify-content: center;
}

.data-controls .btn {
    flex: 1;
    min-width: 60px;
}

.auto-save-status {
    position: fixed;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(39, 174, 96, 0.9);
    color: white;
    padding: 0.3rem 0.5rem;
    border-radius: 0.3rem;
    font-size: 0.65rem;
    z-index: 999;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Tablet landscape and larger */
@media (min-width: 768px) and (orientation: landscape),
       (min-width: 1024px) {
    .board {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.75rem;
        padding: 1rem;
    }

    .header-compact {
        padding: 0.6rem 1rem;
    }

    .header-compact h1 {
        font-size: 1.3rem;
    }

    .stat-number {
        font-size: 1.2rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .controls {
        padding: 0.6rem 1rem;
    }

    .add-truck-form input {
        font-size: 0.9rem;
        padding: 0.6rem;
    }

    .btn {
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }

    .column {
        padding: 0.75rem;
    }

    .truck-card {
        padding: 0.6rem;
    }

    .column-title {
        font-size: 1rem;
    }

    .column-capacity {
        font-size: 0.75rem;
    }

    .truck-id {
        font-size: 0.95rem;
    }

    .truck-time {
        font-size: 0.8rem;
    }

    .truck-duration {
        font-size: 0.85rem;
    }
}

/* Tablet portrait */
@media (min-width: 600px) and (max-width: 767px) {
    .board {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large phones landscape */
@media (max-width: 767px) and (orientation: landscape) {
    .board {
        grid-template-columns: repeat(3, 1fr);
    }

    .stats {
        gap: 0.4rem;
    }

    .stat {
        padding: 0.3rem;
    }
}

/* Very small phones */
@media (max-width: 374px) {
    .header-compact h1 {
        font-size: 0.85rem;
    }

    .stat-number {
        font-size: 0.9rem;
    }

    .stat-label {
        font-size: 0.55rem;
    }

    .add-truck-form input {
        font-size: 0.8rem;
    }

    .btn {
        font-size: 0.7rem;
        padding: 0.45rem 0.5rem;
    }

    .column-title {
        font-size: 0.75rem;
    }

    .truck-id {
        font-size: 0.75rem;
    }
}
