:root {
    --primary-blue: #004a99;
    --accent-blue: #00aeef;
    --header-bg: #f8f9fa;
    --text-dark: #1a1a1a;
    --text-muted: #6c757d;
    --border-grey: #e0e0e0;
    --bg-main: #f0f2f5;
    --white: #ffffff;
    --success-green: #2ecc71;
    --error-red: #e74c3c;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Technical Grid Pattern */
.technical-grid-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(0, 74, 153, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 74, 153, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 0;
}

/* Main Layout & Background */
body {
    font-family: 'Inter', sans-serif;
    background: #f8f9fa;
    color: var(--text-dark);
    font-size: 13px;
    line-height: 1.5;
    min-height: 100vh;
}

/* Header Redesign */
.main-header {
    background: #ffffff;
    padding: 10px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #eee;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-logo {
    height: 65px;
    object-fit: contain;
}

.search-box {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-grow: 1;
    justify-content: center;
}

.eng-date-input {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fdfdfd;
    font-size: 0.9rem;
    color: #444;
}

.search-box input[type="text"] {
    width: 350px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    transition: box-shadow 0.2s;
}

.search-box input[type="text"]:focus {
    box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.1);
    border-color: var(--primary-blue);
    outline: none;
}

#search-btn {
    background: #004a99;
    color: white;
    padding: 10px 25px;
    border-radius: 8px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.2s;
}

#search-btn:hover {
    background: #003a7a;
}

/* Modern Welcome Screen */
.modern-welcome {
    position: relative;
    width: 100%;
    height: calc(100vh - 80px);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Circuit Background Pattern - High-Quality SVG */
.circuit-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f8f9fa;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%23004a99' stroke-width='0.5' stroke-opacity='0.1'%3E%3Cpath d='M10 10h80v80h-80zM50 10v80M10 50h80'/%3E%3Ccircle cx='10' cy='10' r='1.5' fill='%23004a99' fill-opacity='0.15'/%3E%3Ccircle cx='90' cy='10' r='1.5' fill='%23004a99' fill-opacity='0.15'/%3E%3Ccircle cx='10' cy='90' r='1.5' fill='%23004a99' fill-opacity='0.15'/%3E%3Ccircle cx='90' cy='90' r='1.5' fill='%23004a99' fill-opacity='0.15'/%3E%3Ccircle cx='50' cy='50' r='2' fill='%2328a745' fill-opacity='0.15'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 200px 200px;
    opacity: 1;
    pointer-events: none;
    z-index: 0;
}

.welcome-card {
    background: #ffffff;
    padding: 60px 50px;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
    text-align: center;
    width: 100%;
    max-width: 750px;
    z-index: 10;
    border: 1px solid #f0f0f0;
}

.welcome-logo-large img {
    height: 140px;
    margin-bottom: 30px;
}

.welcome-card h1 {
    font-size: 3.2rem;
    color: #004a99;
    margin-bottom: 20px;
    font-weight: 800;
    letter-spacing: -1px;
}

.welcome-subtitle {
    font-size: 1.4rem;
    color: #888;
    margin-bottom: 40px;
    font-weight: 500;
}

.status-badges {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 45px;
}

.badge {
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.badge-actiu {
    background: #34c759;
}

.badge-prod {
    background: #004a99;
}

.badge-user {
    background: #2c3e50;
}

.instruction-box {
    background: linear-gradient(135deg, #5c59ac 0%, #46438b 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 20px;
    text-align: left;
    margin-top: 20px;
    box-shadow: 0 10px 20px rgba(70, 67, 139, 0.2);
}

.info-icon svg {
    width: 32px;
    height: 32px;
}

.instruction-box p {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 500;
    opacity: 0.95;
    line-height: 1.4;
}

/* Hide route sheet by default */
.route-sheet {
    width: 1050px;
    max-width: 98vw;
    background: var(--white);
    padding: 15px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    display: none;
    margin: 20px auto;
}

/* 3-Column Top Header */
.sheet-top-header {
    display: grid;
    grid-template-columns: 220px 1fr 220px;
    border-bottom: 2px solid #000;
    padding-bottom: 15px;
    margin-bottom: 5px;
    align-items: center;
}

.logos {
    display: flex;
    gap: 15px;
    align-items: center;
}

.header-center {
    text-align: center;
}

.header-center h1 {
    font-size: 1.1rem;
    margin: 5px 0;
    color: #000;
}

.header-center h2 {
    font-size: 1.2rem;
    font-weight: bold;
}

.header-right-box {
    border: 1px solid var(--border-grey);
    display: grid;
    grid-template-columns: 80px 1fr;
}

.right-box-item {
    border: 0.5px solid var(--border-grey);
    padding: 5px;
    min-height: 25px;
    display: flex;
    align-items: center;
}

.right-box-label {
    background: var(--header-bg);
    font-size: 0.7rem;
    justify-content: flex-end;
    color: #555;
    font-weight: bold;
}

.right-box-value {
    font-weight: bold;
    font-size: 1rem;
    justify-content: flex-end;
    padding-right: 10px;
}

/* Field Groups (Servei, Centre, etc) */
.field-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 5px;
}

.field {
    border: 1px solid var(--border-grey);
    display: flex;
    flex-direction: column;
}

.field-label {
    background: var(--primary-blue);
    font-size: 0.7rem;
    padding: 2px 5px;
    font-weight: bold;
    color: #fff;
}

.field-value {
    padding: 5px;
    font-weight: 500;
    font-size: 0.95rem;
    min-height: 25px;
}

/* Vehicle Section */
.vehicle-container {
    margin-top: 5px;
    margin-bottom: 5px;
}

.vehicle-header-label {
    background: var(--primary-blue);
    border: 1px solid var(--border-grey);
    border-bottom: none;
    font-size: 0.7rem;
    padding: 2px 5px;
    font-weight: bold;
    color: #fff;
}

.vehicle-row {
    display: grid;
    grid-template-columns: 200px 120px 1fr;
    border: 1px solid var(--border-grey);
    background: #fff;
}

.veh-col {
    border-right: 1px solid var(--border-grey);
}

.veh-col:last-child {
    border-right: none;
}

/* Table Styles */
.sheet-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 5px;
}

.sheet-table th {
    background: var(--primary-blue);
    border: 1px solid var(--border-grey);
    padding: 4px 8px;
    font-size: 0.75rem;
    text-align: left;
    font-weight: bold;
    color: #fff;
}

.sheet-table td {
    border: 1px solid var(--border-grey);
    padding: 4px 8px;
    vertical-align: middle;
}

.row-header {
    background: var(--header-bg);
    font-weight: bold;
    font-size: 0.9rem;
}

/* Inputs */
.sheet-input {
    width: 100%;
    border: none;
    padding: 4px;
    font-family: inherit;
    font-size: 1.1rem;
    background: transparent;
    outline: none;
    color: #004a99;
    font-weight: bold;
}

textarea.sheet-input {
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
}

.sheet-input:focus {
    background: #fff9c4;
}

/* Checklist Section */
.checklist-container {
    margin-top: 10px;
    border: 1px solid var(--border-grey);
}

.checklist-header {
    background: #e8f5e9;
    /* Light green header */
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: bold;
    border-bottom: 1px solid var(--border-grey);
}

.checklist-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: #fff;
}

/* Sheet Inputs - Premium Editable Style */
.sheet-input {
    border: none;
    border-bottom: 2px dashed #ddd;
    background: transparent;
    padding: 2px 5px;
    font-family: inherit;
    color: #333;
    transition: all 0.2s ease;
    outline: none;
}

.sheet-input:focus {
    border-bottom: 2px solid var(--primary-blue);
    background: rgba(0, 74, 153, 0.03);
    color: #000;
}

.sheet-input::placeholder {
    color: #ccc;
    font-style: italic;
    font-size: 0.8rem;
}

.checklist-item {
    border-right: 1px solid var(--border-grey);
    border-bottom: 1px solid var(--border-grey);
    padding: 6px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 35px;
}

.checklist-item:nth-child(4n) {
    border-right: none;
}

.checklist-item label {
    font-size: 0.75rem;
    color: #444;
    font-weight: 500;
}

.checklist-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.fuel-input-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

.fuel-liters {
    width: 50px;
    padding: 2px;
    border: 1px solid var(--border-grey);
    border-radius: 3px;
    font-size: 0.8rem;
    text-align: right;
    display: none;
    /* Shown when fuel checkbox is checked */
}

/* Reporting Buttons */
.report-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    padding: 5px 0;
}

.report-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-grey);
    border-radius: 20px;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.report-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.report-btn.fraction-btn {
    color: #004a99;
    border-color: #a3c1e0;
}

.report-btn.fraction-btn:active {
    background: #e3f2fd;
}

.report-btn.breakdown-btn {
    color: #c62828;
    border-color: #ffccbc;
}

.report-btn.breakdown-btn:active {
    background: #ffebee;
}

/* Engineering Buttons */
.eng-btn-primary,
.eng-btn-secondary {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.eng-btn-primary {
    background: var(--primary-blue);
    color: white;
    border: 1px solid var(--primary-blue);
    box-shadow: 0 4px 6px rgba(0, 74, 153, 0.2);
}

.eng-btn-primary:hover {
    background: #003a7a;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 74, 153, 0.3);
}

.eng-btn-secondary {
    background: white;
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
}

.eng-btn-secondary:hover {
    background: #f0f7ff;
    transform: translateY(-1px);
}

/* History Table Styles */
.history-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.history-table tr:hover {
    background-color: #e3f2fd;
}

.history-table td {
    font-size: 0.9rem;
    color: #444;
}

.history-table .action-btn {
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin: 0 2px;
}

.history-table .view-btn {
    background: #e3f2fd;
    color: var(--primary-blue);
    border: 1px solid var(--primary-blue);
}

.history-table .delete-btn {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.history-table .delete-btn:hover {
    background: #ef5350;
    color: white;
}

/* Desktop/Print adjustments */
@media print {
    header {
        display: none;
    }

    body {
        background: white;
        padding: 0;
    }

    .route-sheet {
        box-shadow: none;
        border: none;
        width: 100%;
        max-width: 100%;
        padding: 0;
    }
}