 :root {
            --ts-green: #009640;
            --ts-bg: #e0f2f1;
            --label-color: #009640;
            --border-color: #ced4da;
            --focus-glow: rgba(0, 150, 64, 0.25);
        }

        * {
            box-sizing: border-box;
        }

        body {
            background-color: var(--ts-bg);
        }

        .container {
            width: 100%;
            max-width: 500px;
            margin:0 auto;
        }

        .main-card {
            background: white;
            border-radius: 10px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            width: 100%;
        }

        /* HEADER COMPACTO */
        .card-header-custom {
            background-color: var(--ts-green);
            padding: 5px 12px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-radius: 10px 10px 0 0;
            color: white;
            gap: 8px;
        }

        .emblem-container {
            /*! background: white; */
            border-radius: 50%;
            padding: 4px;
            width: 65px;
            height: 65px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .emblem-img {
            width: 100%;
            height: auto;
            object-fit: contain;
        }

        .header-content {
            text-align: right;
            flex-grow: 1;
        }

        .header-title {
            font-size: 1.1rem;
            font-weight: 700;
            margin: 0;
            line-height: 1;
        }

        .header-subtitle {
            font-size: 0.85rem !important;
            margin: 0;
        }

        .card-body-custom {
            padding: 10px;
        }

        /* FILAS DEL FORMULARIO - FUERZA EL LAYOUT HORIZONTAL */
        .form-row {
            display: flex;
            align-items: center;
            margin-bottom: 6px;
            gap: 5px;
            /* Espacio mínimo entre columnas */
        }

        .col-label {
            width: 70px;
            /* Ancho fijo para etiquetas */
            text-align: right;
            flex-shrink: 0;
        }

.col-input {
    flex-grow: 1;
    min-width: 0;
    width: 20%;
}

        /* Etiquetas pequeñas pero legibles */
.main-card label {
    color: #00471e;
    text-transform: uppercase;
    font-weight: 700;
    font-size: 0.7rem;
    line-height: 1;
    display: block;
}

        input[type="text"],
        input[type="date"],
        select {
            width: 100%;
            padding: 6px 4px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            font-size: 0.9rem;
            outline: none;
            height: 35px;
        }

        /* Ajustes específicos para 320px */
        @media (max-width: 325px) {
            .col-label {
                width: 62px;
            }

            .main-card label {
                font-size: 0.65rem;
            }

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

            input,
            select {
                font-size: 0.8rem;
            }

            .card-header-custom {
                padding: 5px 10px;
            }
        }

        input:focus,
        select:focus {
            border-color: var(--ts-green);
            box-shadow: 0 0 0 0.15rem var(--focus-glow);
        }

        .btn-calc {
            background-color: var(--ts-green);
            color: white;
            font-weight: 700;
            font-size: 1rem;
            padding: 10px;
            border-radius: 6px;
            border: none;
            cursor: pointer;
            width: 100%;
            margin-top: 8px;
            transition: background 0.2s;
            text-transform: uppercase;
        }

        .btn-calc:hover {
            background-color: #007a33;
        }

        /* Modal MÁS BONITO */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(4px);
            /* Efecto moderno */
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .modal-overlay.open {
            display: flex;
            opacity: 1;
        }

        .modal-content {
            background: white;
            border-radius: 12px;
            width: 90%;
            max-width: 340px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
            overflow: hidden;
            text-align: center;
            transform: scale(0.9);
            transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        .modal-overlay.open .modal-content {
            transform: scale(1);
        }

        .modal-header {
            background-color: var(--ts-green);
            color: white;
            padding: 15px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-title {
            margin: 0;
            font-size: 1.1rem;
            font-weight: 700;
            letter-spacing: 0.5px;
        }

        .btn-close {
            background: transparent;
            border: none;
            color: white;
            font-size: 1.5rem;
            cursor: pointer;
            line-height: 1;
            padding: 0;
            opacity: 0.8;
            transition: opacity 0.2s;
        }

        .btn-close:hover {
            opacity: 1;
            transform: scale(1.1);
        }

        .modal-body {
            padding: 25px 0px;
        }

        .text-muted {
            color: #6c757d;
            font-size: 0.85rem;
            margin: 0 0 10px 0;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .cf-result {
            font-family: 'Courier New', Courier, monospace;
            background-color: #f1fcf5;
            color: var(--ts-green);
            border: 2px dashed #a5d6a7;
            border-radius: 6px;
            padding: 10px;
            font-weight: bold;
            font-size: 1.4rem;
            margin: 0 0 20px 0;
            word-break: break-all;
            letter-spacing: 2px;
        }

        /* TS CARD MODAL STYLES */
        .ts-card {
            border-radius: 15px;
            border: none;
            width: 100%;
            max-width: 500px;
            font-family: Arial, Helvetica, sans-serif;
            text-align: left;
            position: relative;
            background: #f0fcfc;
        }

        .ts-header {
            background-color: #009640;
            color: white;
            padding: 10px 15px;
            display: flex;
            align-items: center;
            gap: 15px;
            border-bottom: 2px solid white;
        }

        .ts-emblem {
            width: 50px;
            height: 50px;
            flex-shrink: 0;
        }

        .ts-emblem img {
            width: 100%;
            height: auto;
        }

        .ts-title-box {
            text-align: right;
            margin-left: auto;
        }

        .h_1 {
            margin: 0;
            font-size: 1.4rem;
            font-weight: normal;
            display:block;
        }

        .h_2 {
            margin: 0;
            font-size: 0.9rem;
            font-weight: normal;
            display:block;
            opacity: 0.9;
        }

        .ts-body {
            padding: 15px;
            background: linear-gradient(180deg, #ffffff 0%, #e0fbfb 100%);
            min-height: 200px;
        }

        .ts-row {
            display: flex;
            align-items: center;
            margin-bottom: 8px;
            font-size: 1rem;
        }

        .ts-label {
            color: #009640;
            font-weight: bold;
            font-size: 0.75rem;
            line-height: 1.1;
            width: 80px;
            text-align: right;
            margin-right: 15px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            height: 100%;
        }

        .ts-label-right {
            color: #009640;
            font-weight: bold;
            font-size: 0.85rem;
            margin-left: auto;
        }

        .ts-value {
            font-family: Arial, sans-serif;
            font-size: 1.1rem;
            color: black;
            text-transform: uppercase;
            /*! flex-grow: 1; */
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .ts-cf-row {
            margin-bottom: 15px;
            align-items: center;
        }

        .ts-cf-value {
            font-size: 1.6rem;
            letter-spacing: 1px;
            font-family: sans-serif;
        }

        .modal-footer {
            padding: 10px;
            text-align: center;
            background: #e0f2f1;
            display: flex;
            justify-content: center;
            gap: 15px;
        }

        .btn-copy {
            background: transparent;
            border: 2px solid var(--ts-green);
            color: var(--ts-green);
            padding: 8px 20px;
            border-radius: 50px;
            cursor: pointer;
            font-weight: 600;
            font-size: 0.9rem;
            transition: all 0.2s;
            background: #e0f2f1;
            display: flex;
            justify-content: center;
            gap: 15px;
        }

        .btn-close-text {
            background: none;
            border: none;
            color: #666;
            cursor: pointer;
            font-weight: bold;
            font-size: 0.9rem;
        }

        .btn-close-text:hover {
            color: black;
        }

        /* AUTOCOMPLETE STYLES */
        .search-wrapper {
            position: relative;
            width: 100%;
        }

        .loading-spinner {
            display: none;
            position: absolute;
            right: 10px;
            top: 50%;
           transform: translateY(-50%);
            width: 16px;
            height: 16px;
            border: 2px solid #e0e0e0;
            border-top-color: var(--ts-green);
            border-radius: 50%;
            animation: spin 0.6s linear infinite;
        }

        .loading-spinner2 {
            display: none;
            position: absolute;
            left: 10px;
            top: 50%;
           transform: translateY(-50%);
            width: 16px;
            height: 16px;
            border: 2px solid #e0e0e0;
            border-top-color: var(--ts-green);
            border-radius: 50%;
            animation: spin 0.6s linear infinite;
        }

        @keyframes spin {
            to { transform: translateY(-50%) rotate(360deg); }
        }

        .loading-spinner.active, .loading-spinner2.active {
            display: block;
        }

        .results-container {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            background: white;
            border: 1px solid var(--border-color);
            border-top: none;
            border-radius: 0 0 8px 8px;
            max-height: 250px;
            overflow-y: auto;
            display: none;
            z-index: 1000;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
        }

        .results-container.active {
            display: block;
        }

        .result-item {
            padding: 10px 12px;
            border-bottom: 1px solid #f0f0f0;
            cursor: pointer;
            transition: background-color 0.2s ease;
            text-align: left;
        }

        .result-item:last-child {
            border-bottom: none;
        }

        .result-item:hover, .result-item.selected {
            background-color: #f0fcf5; /* Light green tint */
        }

        .result-name {
            font-weight: 600;
            color: #333;
            font-size: 0.9rem;
            margin-bottom: 2px;
        }

        .result-info {
            font-size: 0.75rem;
            color: #888;
            display: flex;
            gap: 10px;
        }

        @media (max-width: 450px) {
            .ts-title-box h1 {
                font-size: 1.1rem;
            }

            .ts-title-box h2 {
                font-size: 0.7rem;
            }

            .ts-cf-value {
                font-size: 1.3rem;
            }

            .ts-label {
                width: 65px;
                font-size: 0.7rem;
            }

            .ts-value {
                font-size: 1rem;
            }
        }

        .ts-min {
            font-size: 0.8rem;
            margin-left: auto;
            text-align: right;
            color: var(--ts-green);
            font-weight: bold;
            /*! margin-right: 5px; */
            width: fit-content;
        }

        /* Button Loading State */
        .btn-calc {
            position: relative;
            transition: all 0.3s ease;
        }

        .btn-calc.loading {
            color: transparent; /* Hide text */
            pointer-events: none;
        }

        .btn-calc.loading::after {
            content: "";
            position: absolute;
            left: 50%;
            top: 50%;
            width: 20px;
            height: 20px;
            margin-left: -10px;
            margin-top: -10px;
            border: 2px solid rgba(255,255,255,0.3);
            border-top-color: white;
            border-radius: 50%;
            animation: spin 0.6s linear infinite;
        }
        
                /* History Button (Rectangular) */
.btn-history {
	background-color: #40028a;
	color: white;
	font-weight: 700;
	font-size: 1rem;
	padding: 8px;
	border-radius: 6px;
	border: none;
	cursor: pointer;
	width: 45px;
	margin-bottom: 5px;
	margin-left: auto;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	text-transform: uppercase;
	box-shadow: 0 4px 6px rgba(0,0,0,0.1);
	transition: background 0.2s, transform 0.1s;
}

        .btn-history:hover {
            background-color: #2c0061ff;
            transform: translateY(-1px);
        }
        
        /* History List */
        .history-list {
            max-height: 400px;
            overflow-y: auto;
            padding: 10px;
        }
        .history-item {
            background: #f8f9fa;
            border: 1px solid #eee;
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: box-shadow 0.2s;
        }
        .history-item:hover {
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        .history-info {
            flex-grow: 1;
        }
        .history-name {
            font-weight: bold;
            color: #333;
            margin-bottom: 4px;
        }
        .history-cf {
            font-family: monospace;
            color: var(--ts-green);
            font-weight: bold;
            font-size: 1.1em;
        }
        .history-actions {
            display: flex;
            gap: 10px;
            margin-left: 15px;
        }
        .btn-restore, .btn-delete {
            border: none;
            background: none;
            cursor: pointer;
            padding: 5px;
            border-radius: 4px;
            transition: background 0.2s;
        }
        .btn-restore {
            color: var(--ts-green);
        }
        .btn-restore:hover {
            background: rgba(0, 150, 64, 0.1);
        }
        .btn-delete {
            color: #dc3545;
        }
        .btn-delete:hover {
            background: rgba(220, 53, 69, 0.1);
        }
        .empty-history {
            text-align: center;
            color: #999;
            padding: 20px;
            font-style: italic;
        }
        .close-modal {
    background: transparent;
    border: none;
    font-size: 30px;
    cursor: pointer;
}