:root {
    --primary-color: #1a3a5a;
    --secondary-color: #f4f4f9;
    --accent-color: #4a90e2;
    --text-color: #333;
    --light-gray: #f9f9f9;
    --medium-gray: #e0e0e0;
    --dark-gray: #666;
    --error-color: #d9534f;
    --success-color: #5cb85c;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--secondary-color);
    color: var(--text-color);
    line-height: 1.6;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
    padding: 0.8rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.logo-img {
    height: 40px;
    margin-right: 10px;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.nav-menu {
    display: flex;
    list-style: none;
}

.nav-item {
    margin-left: 20px;
}

.nav-link {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
}

.nav-link:hover, .nav-link.active {
    background-color: var(--accent-color);
    color: #fff;
}

.hamburger {
    display: none;
    cursor: pointer;
}

.bar {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px auto;
    background-color: var(--primary-color);
    transition: all 0.3s ease-in-out;
}

main {
    padding: 2rem;
}

section {
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
}

h1 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.card {
    background-color: var(--light-gray);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid var(--medium-gray);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card i {
    font-size: 2.5rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
}

.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--dark-gray);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--medium-gray);
    border-radius: 5px;
    font-size: 1rem;
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    background-color: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: background-color 0.3s;
    text-align: center;
}

.btn:hover {
    background-color: #3a7ac8;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}

thead {
    background-color: var(--primary-color);
    color: #fff;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--medium-gray);
}

tbody tr:nth-child(even) {
    background-color: var(--light-gray);
}

tbody tr:hover {
    background-color: #e9eff5;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 1.5rem;
}

.pagination button {
    margin: 0 10px;
    width: auto;
}

.pagination span {
    font-weight: bold;
}

.template-details {
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: var(--light-gray);
    border-radius: 5px;
}

.template-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--medium-gray);
}

.template-row:last-child {
    border-bottom: none;
}

.template-label {
    font-weight: bold;
}

.template-total {
    margin-top: 1.5rem;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: right;
}

#costos-container .costo-muestra {
    width: auto;
    text-align: right;
}

footer {
    text-align: center;
    padding: 1.5rem;
    background-color: #fff;
    margin-top: 2rem;
    border-top: 1px solid var(--medium-gray);
}

/* --- ESTILOS PARA MÓVILES --- */
@media (max-width: 768px) {
    .navbar {
        padding: 0.8rem 1rem;
    }

    .nav-menu {
        position: fixed;
        left: -100%;
        top: 60px; /* Altura del navbar */
        flex-direction: column;
        background-color: #fff;
        width: 100%;
        height: calc(100vh - 60px);
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
        padding-top: 2rem;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-item {
        margin: 1.5rem 0;
    }

    .hamburger {
        display: block;
    }

    .hamburger.active .bar:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .hamburger.active .bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    main {
        padding: 1rem;
    }

    section {
        padding: 1.5rem 1rem;
    }

    /* Tablas Responsivas */
    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 1px solid var(--medium-gray);
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    tbody tr:nth-child(even) {
        background-color: #fff; /* Reset even row color for card view */
    }

    td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
        text-align: right;
        min-height: 38px; /* Ensure consistent height */
        display: flex; /* Align items better */
        align-items: center;
        justify-content: flex-end;
    }

    td:before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        color: var(--primary-color);
    }

    td:last-child {
        border-bottom: 0;
    }
    
    .action-buttons {
        justify-content: flex-start; /* Align buttons to the left in card view */
        padding-left: 10px;
    }

    .action-buttons button {
        width: auto; /* Allow buttons to size to content */
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .pagination button {
        padding: 8px 12px;
    }
}
